mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-12 16:27:45 +00:00
Fix items hanging around on auto chisel render. Closes #136
This commit is contained in:
1 parent
ebd6dedca9
commit
c2d0baef74
2 files changed
+14
-8
No files matched your search
@@ -59,6 +59,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
public static final int rotAmnt = 15;
|
||||
public float chiselRot;
|
||||
public boolean chiseling = false;
|
||||
public int toChisel = 1;
|
||||
|
||||
private ItemStack lastBase;
|
||||
|
||||
@@ -150,7 +151,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
slotChanged(OUTPUT);
|
||||
}
|
||||
|
||||
chiselItem();
|
||||
chiselItem(chiseled.stackSize);
|
||||
|
||||
// remove what we made from the stack
|
||||
base.stackSize -= chiseled.stackSize;
|
||||
@@ -166,7 +167,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
if (chiseling) {
|
||||
chiselRot += rotAmnt;
|
||||
if (chiselRot >= maxRot) {
|
||||
chiselItem();
|
||||
chiselItem(0);
|
||||
}
|
||||
} else {
|
||||
chiselRot = Math.max(chiselRot - rotAmnt, 0);
|
||||
@@ -204,15 +205,15 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
/** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
|
||||
private void chiselItem() {
|
||||
private void chiselItem(int chiseled) {
|
||||
if (!worldObj.isRemote) {
|
||||
((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, this, CHISEL, inventory[CHISEL], inventory[TARGET]);
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, true), worldObj.provider.dimensionId);
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true), worldObj.provider.dimensionId);
|
||||
} else {
|
||||
GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]);
|
||||
chiseling = false;
|
||||
if (lastBase != null) {
|
||||
lastBase.stackSize--;
|
||||
lastBase.stackSize -= toChisel;
|
||||
if (lastBase.stackSize <= 0) {
|
||||
lastBase = null;
|
||||
}
|
||||
@@ -401,8 +402,9 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
}
|
||||
}
|
||||
|
||||
public void doChiselAnim(ItemStack lastChiseled, boolean playSound) {
|
||||
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound) {
|
||||
this.lastBase = lastChiseled == null ? null : lastChiseled.copy();
|
||||
this.toChisel = chiseled;
|
||||
if (playSound) {
|
||||
this.chiseling = true;
|
||||
}
|
||||
|
||||
@@ -19,20 +19,23 @@ public class MessageAutoChisel extends MessageCoords {
|
||||
|
||||
ItemStack base;
|
||||
boolean playSound;
|
||||
int chiseled;
|
||||
|
||||
public MessageAutoChisel(TileEntityAutoChisel tile, boolean playSound) {
|
||||
public MessageAutoChisel(TileEntityAutoChisel tile, int chiseled, boolean playSound) {
|
||||
super(tile);
|
||||
this.base = tile.getStackInSlot(TileEntityAutoChisel.BASE);
|
||||
if (base != null) {
|
||||
base = base.copy();
|
||||
}
|
||||
this.playSound = playSound;
|
||||
this.chiseled = chiseled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeBoolean(playSound);
|
||||
buf.writeInt(chiseled);
|
||||
ByteBufUtils.writeItemStack(buf, base);
|
||||
}
|
||||
|
||||
@@ -40,6 +43,7 @@ public class MessageAutoChisel extends MessageCoords {
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
this.playSound = buf.readBoolean();
|
||||
this.chiseled = buf.readInt();
|
||||
this.base = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
|
||||
@@ -49,7 +53,7 @@ public class MessageAutoChisel extends MessageCoords {
|
||||
|
||||
TileEntity te = message.getTileEntity(ctx);
|
||||
if (te instanceof TileEntityAutoChisel) {
|
||||
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.playSound);
|
||||
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.chiseled, message.playSound);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user