From 965d74d6415ba0b9cbf5444368534013482b1ee7 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 4 Oct 2017 10:12:15 +0100 Subject: [PATCH] Improvements to the iron furnace, closes #1016 --- .../techreborn/tiles/TileIronFurnace.java | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/main/java/techreborn/tiles/TileIronFurnace.java b/src/main/java/techreborn/tiles/TileIronFurnace.java index dfe37fab0..155824587 100644 --- a/src/main/java/techreborn/tiles/TileIronFurnace.java +++ b/src/main/java/techreborn/tiles/TileIronFurnace.java @@ -35,6 +35,7 @@ import reborncore.api.tile.IInventoryProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.util.Inventory; +import reborncore.common.util.ItemUtils; import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; @@ -42,9 +43,9 @@ import techreborn.client.container.builder.ContainerBuilder; public class TileIronFurnace extends TileLegacyMachineBase implements IInventoryProvider, ISidedInventory, IContainerProvider { - private static final int[] SLOTS_TOP = new int[] { 0 }; + private static final int[] SLOTS_TOP = new int[] { 0, 2 }; private static final int[] SLOTS_BOTTOM = new int[] { 1 }; - private static final int[] SLOTS_SIDES = new int[] { 2 }; + private static final int[] SLOTS_SIDES = new int[] { 0, 1 }; public int tickTime; public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this); @@ -73,6 +74,9 @@ public class TileIronFurnace extends TileLegacyMachineBase @Override public void updateEntity() { + if(world.isRemote){ + return; + } final boolean burning = this.isBurning(); boolean updateInventory = false; if (this.fuel > 0) { @@ -175,8 +179,27 @@ public class TileIronFurnace extends TileLegacyMachineBase } @Override - public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) { - return this.isItemValidForSlot(index, itemStackIn); + public boolean isItemValidForSlot(int index, ItemStack stack) { + boolean isFuel = TileEntityFurnace.isItemFuel(stack); + if(isFuel){ + ItemStack fuelSlotStack = getStackInSlot(fuelslot); + if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){ + return index == fuelslot; + } + } + return index != output; + } + + @Override + public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) { + boolean isFuel = TileEntityFurnace.isItemFuel(stack); + if(isFuel){ + ItemStack fuelSlotStack = getStackInSlot(fuelslot); + if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){ + return index == fuelslot; + } + } + return index != output; } @Override @@ -200,11 +223,20 @@ public class TileIronFurnace extends TileLegacyMachineBase this.fuelGague = totalBurnTime; } + public int getProgress() { + return progress; + } + + public void setProgress(int progress) { + this.progress = progress; + } + @Override public BuiltContainer createContainer(final EntityPlayer player) { return new ContainerBuilder("ironfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142) .addInventory().tile(this).slot(0, 56, 17).outputSlot(1, 116, 35).fuelSlot(2, 56, 53) .syncIntegerValue(this::getBurnTime, this::setBurnTime) + .syncIntegerValue(this::getProgress, this::setProgress) .syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this); } }