package jfcraft.packet;

/** Packet with 5 Ints
 *
 * @author pquiring
 */

import jfcraft.client.Client;
import jfcraft.data.*;

public class PacketClearBlock2 extends Packet {
  public int i1, i2, i3, i4, i5;

  public PacketClearBlock2() {}

  public PacketClearBlock2(byte cmd) {
    super(cmd);
  }

  public PacketClearBlock2(byte cmd, int i1, int i2, int i3, int i4, int i5) {
    super(cmd);
    this.i1 = i1;
    this.i2 = i2;
    this.i3 = i3;
    this.i4 = i4;
    this.i5 = i5;
  }

  //process on client side
  public void process(Client client) {
    //i = cx,cz gx,gy,gz
    int cx = i1;
    int cz = i2;
    int gx = i3;
    int gy = i4;
    int gz = i5;
    Chunk chunk = client.world.chunks.getChunk(client.player.dim, cx,cz);
    if (chunk == null) return;
    chunk.clearBlock2(gx, gy, gz);
    chunk.delCrack(gx, gy, gz);
  }

  @Override
  public boolean write(SerialBuffer buffer, boolean file) {
    super.write(buffer, file);
    buffer.writeInt(i1);
    buffer.writeInt(i2);
    buffer.writeInt(i3);
    buffer.writeInt(i4);
    buffer.writeInt(i5);
    return true;
  }

  @Override
  public boolean read(SerialBuffer buffer, boolean file) {
    super.read(buffer, file);
    i1 = buffer.readInt();
    i2 = buffer.readInt();
    i3 = buffer.readInt();
    i4 = buffer.readInt();
    i5 = buffer.readInt();
    return true;
  }
}

@@ -88,50 +88,169 @@
 rt j
-fcraft.client.Client;%0D%0Aimport jfcraft.data
+ava.util.*;%0D%0A%0D%0Aimport jfcraft.block.*;%0D%0Aimport jfcraft.client.*;%0D%0Aimport jfcraft.data.*;%0D%0Aimport jfcraft.entity.*;%0D%0Aimport jfcraft.move.*;%0D%0Aimport jfcraft.opengl
 .*;%0D
@@ -334,16 +334,45 @@
 i4, i5;%0D
+%0A  public boolean particles;%0D
 %0A%0D%0A  pub
@@ -540,16 +540,35 @@
 , int i5
+, boolean particles
 ) %7B%0D%0A   
@@ -674,25 +674,103 @@
 i5 = i5;%0D%0A  
-%7D
+  this.particles = particles;%0D%0A  %7D%0D%0A%0D%0A  private static Random r = new Random();
 %0D%0A%0D%0A  //proc
@@ -1060,71 +1060,859 @@
     
-chunk.clearBlock2(gx, gy, gz);%0D%0A    chunk.delCrack(gx, gy, gz);
+int bits = chunk.getBits(gx, gy, gz);%0D%0A    int var = Chunk.getVar(bits);%0D%0A    char oldid = chunk.clearBlock2(gx, gy, gz);%0D%0A    chunk.delCrack(gx, gy, gz);%0D%0A    if (particles) %7B%0D%0A      //generate particles%0D%0A      float x = cx * 16f + gx;%0D%0A      float y = gy;%0D%0A      float z = cz * 16f + gz;%0D%0A      BlockBase block = Static.blocks.blocks%5Boldid%5D;%0D%0A      SubTexture st = block.getDestroyTexture(var);%0D%0A      if (st != null) %7B%0D%0A        for(int a=0;a%3C10;a++) %7B%0D%0A          Particle p = new Particle(x + r.nextFloat(), y + r.nextFloat(), z + r.nextFloat(), st, false);%0D%0A          p.init(chunk.world);%0D%0A          p.createVelocity();%0D%0A          p.maxAge = r.nextInt(20) + 20;%0D%0A          p.scale = r.nextFloat() / 20f + 0.1f;%0D%0A          p.isGreen = block.isGreen;%0D%0A          p.setMove(new MoveGravity());%0D%0A          chunk.addEntity(p);%0D%0A        %7D%0D%0A      %7D%0D%0A    %7D
 %0D%0A  
@@ -2148,24 +2148,61 @@
 teInt(i5);%0D%0A
+    buffer.writeBoolean(particles);%0D%0A
     return t
@@ -2454,24 +2454,63 @@
 readInt();%0D%0A
+    particles = buffer.readBoolean();%0D%0A
     return t

create particles for breaking blocks in blocks2