From 88acdcae12581c022c73756b6d7020f798365b85 Mon Sep 17 00:00:00 2001 From: stfwi Date: Sat, 17 Apr 2021 08:29:57 +0200 Subject: [PATCH] Hotfix issue #174 (E-Furnace inventory pulling from Storage Drawers). --- gradle.properties | 2 +- meta/update.json | 3 ++- readme.md | 2 ++ .../blocks/EdElectricalFurnace.java | 25 ++++++------------- .../libmc/detail/Inventories.java | 2 +- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5a8e5ca..407c84e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ version_minecraft=1.16.4 version_forge_minecraft=1.16.4-35.1.10 version_fml_mappings=20201028-1.16.3 version_jei=1.16.4:7.6.1.63 -version_engineersdecor=1.1.12 +version_engineersdecor=1.1.13-b1 diff --git a/meta/update.json b/meta/update.json index bca0582..9a6a2c8 100644 --- a/meta/update.json +++ b/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.16.4": { + "1.1.13-b1": "[F] Hotfix Electrical Furnace inventory import from Storage Drawers (issue #174, ty anto-fire/IchigoGames).", "1.1.12": "[F] Chisels&Bits compatibility addressed (issue #172, ty rodg88).\n[F] Labeled Crate drop list made stateless (issue #173, ty HopsandBarley && Harmonised).", "1.1.11": "[F] Fixed Window placement dupe (issue #170, ty NillerMedDild).", "1.1.10": "[A] Added Small Lab Furnace config for accepted speed-boost heaters (PR#165, ty mrh0).\n[F] Fixed Labeled Crate mouse scrolling crash (issue #169, ty vaelzan).", @@ -33,6 +34,6 @@ }, "promos": { "1.16.4-recommended": "1.1.12", - "1.16.4-latest": "1.1.12" + "1.16.4-latest": "1.1.13-b1" } } \ No newline at end of file diff --git a/readme.md b/readme.md index f9590dc..f4b0bb1 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,8 @@ Mod sources for Minecraft version 1.16.x. ## Version history + - v1.1.13-b1 [F] Hotfix Electrical Furnace inventory import from Storage Drawers (issue #174, ty anto-fire/IchigoGames). + - v1.1.12 [F] Chisels&Bits compatibility addressed (issue #172, ty rodg88). [F] Labeled Crate drop list made stateless (issue #173, ty HopsandBarley && Harmonised). diff --git a/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java b/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java index d0a0c91..81989cd 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java +++ b/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java @@ -453,24 +453,13 @@ public class EdElectricalFurnace } if(with_automatic_inventory_pulling_ || is_accepted_hopper(inventory_.getStackInSlot(SMELTING_AUX_SLOT_NO))) { final Direction inp_facing = state.get(ElectricalFurnaceBlock.HORIZONTAL_FACING).getOpposite(); - if(inp && (inventory_.getStackInSlot(FIFO_INPUT_1_SLOT_NO).isEmpty())) { - TileEntity te = world.getTileEntity(pos.offset(inp_facing)); - if(te!=null) { - IItemHandler hnd = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inp_facing).orElse(null); - if(hnd != null) { - for(int i=0; i< hnd.getSlots(); ++i) { - ItemStack adj_stack = hnd.getStackInSlot(i); - if(!adj_stack.isEmpty()) { - ItemStack my_stack = adj_stack.copy(); - if(my_stack.getCount() > inventory_.getInventoryStackLimit()) my_stack.setCount(inventory_.getInventoryStackLimit()); - adj_stack.shrink(my_stack.getCount()); - inventory_.setInventorySlotContents(FIFO_INPUT_1_SLOT_NO, my_stack); - battery_.draw(transfer_energy_consumption_); - dirty = true; - break; - } - } - } + if(inp && (inventory_.getStackInSlot(FIFO_INPUT_1_SLOT_NO).isEmpty()) && (battery_.getEnergyStored() >= transfer_energy_consumption_)) { + final int max_count = MathHelper.clamp((transfer_energy_consumption_ <= 0) ? (64) : (battery_.getEnergyStored()/transfer_energy_consumption_), 1, 64); + final ItemStack retrieved = Inventories.extract(Inventories.itemhandler(world, pos.offset(inp_facing), inp_facing), null, max_count, false); + if(!retrieved.isEmpty()) { + inventory_.setInventorySlotContents(FIFO_INPUT_1_SLOT_NO, retrieved); + battery_.draw(max_count * transfer_energy_consumption_); + dirty = true; } } } diff --git a/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java b/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java index 589053a..6fc06bd 100644 --- a/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java +++ b/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java @@ -86,7 +86,7 @@ public class Inventories public static ItemStack insert(World world, BlockPos pos, @Nullable Direction side, ItemStack stack, boolean simulate) { return insert(world.getTileEntity(pos), side, stack, simulate); } - public static ItemStack extract(IItemHandler inventory, @Nullable ItemStack match, int amount, boolean simulate) + public static ItemStack extract(@Nullable IItemHandler inventory, @Nullable ItemStack match, int amount, boolean simulate) { if((inventory==null) || (amount<=0)) return ItemStack.EMPTY; final int max = inventory.getSlots();