package ch.spacebase.mc.protocol.packet.ingame.server.world;

import java.io.IOException;

import ch.spacebase.packetlib.io.NetInput;
import ch.spacebase.packetlib.io.NetOutput;
import ch.spacebase.packetlib.packet.Packet;

public class ServerBlockBreakAnimPacket implements Packet {

	private int breakerEntityId;
	private int x;
	private int y;
	private int z;
	private Stage stage;
	
	public ServerBlockBreakAnimPacket() {
	}
	
	public ServerBlockBreakAnimPacket(int breakerEntityId, int x, int y, int z, Stage stage) {
		this.breakerEntityId = breakerEntityId;
		this.x = x;
		this.y = y;
		this.z = z;
		this.stage = stage;
	}
	
	public int getBreakerEntityId() {
		return this.breakerEntityId;
	}
	
	public int getX() {
		return this.x;
	}
	
	public int getY() {
		return this.y;
	}
	
	public int getZ() {
		return this.z;
	}
	
	public Stage getStage() {
		return this.stage;
	}

	@Override
	public void read(NetInput in) throws IOException {
		this.breakerEntityId = in.readVarInt();
		this.x = in.readInt();
		this.y = in.readInt();
		this.z = in.readInt();
		this.stage = Stage.values()[in.readByte()];
	}

	@Override
	public void write(NetOutput out) throws IOException {
		out.writeVarInt(this.breakerEntityId);
		out.writeInt(this.x);
		out.writeInt(this.y);
		out.writeInt(this.z);
		out.writeByte(this.stage.ordinal());
	}
	
	@Override
	public boolean isPriority() {
		return false;
	}

	public static enum Stage {
		STAGE_1,
		STAGE_2,
		STAGE_3,
		STAGE_4,
		STAGE_5,
		STAGE_6,
		STAGE_7,
		STAGE_8,
		STAGE_9,
		STAGE_10;
	}
	
}

@@ -1061,28 +1061,86 @@
 nt();%0A%09%09
-this.stage =
+byte stage = in.readByte();%0A%09%09this.stage = stage == -1 ? Stage.RESET :
  Stage.v
@@ -1147,29 +1147,21 @@
 alues()%5B
-in.readByte()
+stage
 %5D;%0A%09%7D%0A%0A%09
@@ -1364,16 +1364,49 @@
 is.stage
+ == Stage.RESET ? -1 : this.stage
 .ordinal
@@ -1604,16 +1604,16 @@
 TAGE_9,%0A
-
 %09%09STAGE_
@@ -1614,16 +1614,25 @@
 STAGE_10
+,%0A%09%09RESET
 ;%0A%09%7D%0A%09%0A%7D

Add Stage.RESET to ServerBlockBreakAnimPacket