Finalize auto chisel animation. Closes #135

This commit is contained in:
tterrag1098 committed 2015-01-12 00:19:05 -05:00
1 parent 1f253247f5
commit 648f57ed6a
4 files changed
+143 -100

No files matched your search

@@ -1,10 +1,13 @@
package com.cricketcraft.chisel.network.message;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
import com.cricketcraft.chisel.network.message.base.MessageCoords;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -14,8 +17,30 @@ public class MessageAutoChisel extends MessageCoords {
public MessageAutoChisel() {
}
public MessageAutoChisel(TileEntityAutoChisel tile) {
ItemStack base;
boolean playSound;
public MessageAutoChisel(TileEntityAutoChisel tile, boolean playSound) {
super(tile);
this.base = tile.getStackInSlot(TileEntityAutoChisel.BASE);
if (base != null) {
base = base.copy();
}
this.playSound = playSound;
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
buf.writeBoolean(playSound);
ByteBufUtils.writeItemStack(buf, base);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
this.playSound = buf.readBoolean();
this.base = ByteBufUtils.readItemStack(buf);
}
public static class Handler implements IMessageHandler<MessageAutoChisel, IMessage> {
@@ -24,7 +49,7 @@ public class MessageAutoChisel extends MessageCoords {
TileEntity te = message.getTileEntity(ctx);
if (te instanceof TileEntityAutoChisel) {
((TileEntityAutoChisel) te).doChiselAnim();
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.playSound);
}
return null;
}