From e36e62b6bec085f992960b32e27bfbcaf2604e7c Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Fri, 27 Dec 2013 21:50:24 -0500 Subject: [PATCH] Better client energy scales in universal cables, made Logistical Transporter pull mode take one item at a time to give L. Sorter an advantage --- common/mekanism/common/EnergyNetwork.java | 3 +-- .../common/multipart/PartLogisticalTransporter.java | 4 ++-- .../common/tileentity/TileEntityLogisticalSorter.java | 4 ++-- common/mekanism/common/transporter/Finder.java | 2 +- common/mekanism/common/util/InventoryUtils.java | 10 +++------- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/common/mekanism/common/EnergyNetwork.java b/common/mekanism/common/EnergyNetwork.java index 8ad415e62..c12027edf 100644 --- a/common/mekanism/common/EnergyNetwork.java +++ b/common/mekanism/common/EnergyNetwork.java @@ -394,12 +394,11 @@ public class EnergyNetwork extends DynamicNetwork { needsUpdate = true; } - - lastPowerScale = currentPowerScale; if(needsUpdate) { MinecraftForge.EVENT_BUS.post(new EnergyTransferEvent(this, currentPowerScale)); + lastPowerScale = currentPowerScale; needsUpdate = false; } diff --git a/common/mekanism/common/multipart/PartLogisticalTransporter.java b/common/mekanism/common/multipart/PartLogisticalTransporter.java index 64fa01480..75265184b 100644 --- a/common/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/common/mekanism/common/multipart/PartLogisticalTransporter.java @@ -15,7 +15,7 @@ import mekanism.common.PacketHandler.Transmission; import mekanism.common.network.PacketDataRequest; import mekanism.common.network.PacketTileEntity; import mekanism.common.tileentity.TileEntityLogisticalSorter; -import mekanism.common.transporter.Finder.FreeFinder; +import mekanism.common.transporter.Finder.FirstFinder; import mekanism.common.transporter.InvStack; import mekanism.common.transporter.TransporterManager; import mekanism.common.transporter.TransporterStack; @@ -368,7 +368,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti if(tile instanceof IInventory) { IInventory inv = (IInventory)tile; - InvStack stack = InventoryUtils.takeTopStack(inv, side.ordinal(), new FreeFinder()); + InvStack stack = InventoryUtils.takeTopItem(inv, side.ordinal()); if(stack != null && stack.getStack() != null) { diff --git a/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java b/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java index 9bc1575d0..12e55447e 100644 --- a/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java +++ b/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java @@ -13,7 +13,7 @@ import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity; -import mekanism.common.transporter.Finder.FreeFinder; +import mekanism.common.transporter.Finder.FirstFinder; import mekanism.common.transporter.InvStack; import mekanism.common.transporter.TItemStackFilter; import mekanism.common.transporter.TransporterFilter; @@ -119,7 +119,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen if(!hasFilter && autoEject) { - inInventory = InventoryUtils.takeTopStack(inventory, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), new FreeFinder()); + inInventory = InventoryUtils.takeTopStack(inventory, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), new FirstFinder()); } if(inInventory != null && inInventory.getStack() != null) diff --git a/common/mekanism/common/transporter/Finder.java b/common/mekanism/common/transporter/Finder.java index 468b8ea67..2cb6d5c6b 100644 --- a/common/mekanism/common/transporter/Finder.java +++ b/common/mekanism/common/transporter/Finder.java @@ -10,7 +10,7 @@ public abstract class Finder { public abstract boolean modifies(ItemStack stack); - public static class FreeFinder extends Finder + public static class FirstFinder extends Finder { @Override public boolean modifies(ItemStack stack) diff --git a/common/mekanism/common/util/InventoryUtils.java b/common/mekanism/common/util/InventoryUtils.java index 012e67f6a..1e7fefe61 100644 --- a/common/mekanism/common/util/InventoryUtils.java +++ b/common/mekanism/common/util/InventoryUtils.java @@ -168,7 +168,7 @@ public final class InventoryUtils return toInsert; } - public static ItemStack takeTopItemFromInventory(IInventory inventory, int side) + public static InvStack takeTopItem(IInventory inventory, int side) { inventory = checkChestInv(inventory); @@ -181,9 +181,7 @@ public final class InventoryUtils ItemStack toSend = inventory.getStackInSlot(i).copy(); toSend.stackSize = 1; - inventory.decrStackSize(i, 1); - - return toSend; + return new InvStack(inventory, i, toSend); } } } @@ -204,9 +202,7 @@ public final class InventoryUtils if(sidedInventory.canExtractItem(slotID, toSend, side)) { - sidedInventory.decrStackSize(slotID, 1); - - return toSend; + return new InvStack(inventory, slotID, toSend); } } }