From 4e09b6e9493b3d310d1318d9b78e85a5fab6367c Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 13:46:53 +0800 Subject: [PATCH 01/10] #589 Work around for crash when using Better Furnace blocks as paint sources for facades. --- .../enderio/conduit/facade/BlockConduitFacade.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/crazypants/enderio/conduit/facade/BlockConduitFacade.java b/common/crazypants/enderio/conduit/facade/BlockConduitFacade.java index e2f59646..fad75aa8 100644 --- a/common/crazypants/enderio/conduit/facade/BlockConduitFacade.java +++ b/common/crazypants/enderio/conduit/facade/BlockConduitFacade.java @@ -86,10 +86,12 @@ public class BlockConduitFacade extends Block { @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if(blockOverride != null) { - return blockOverride.colorMultiplier(par1IBlockAccess, par2, par3, par4); - } else { - return super.colorMultiplier(par1IBlockAccess, par2, par3, par4); + try { //work around for Issue #589 + return blockOverride.colorMultiplier(par1IBlockAccess, par2, par3, par4); + } catch (Exception e) { + } } + return super.colorMultiplier(par1IBlockAccess, par2, par3, par4); } public Block getIconOverrideBlock() { From 0aaf57c200d3bd31320752b7db59bbbefd935e5d Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 14:21:14 +0800 Subject: [PATCH 02/10] #591 Work around to avoid unreproducible crash. --- .../enderio/machine/recipe/OreDictionaryRecipeInput.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java b/common/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java index 97d8a404..006afb10 100644 --- a/common/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java +++ b/common/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java @@ -16,10 +16,14 @@ public class OreDictionaryRecipeInput extends RecipeInput { @Override public boolean isInput(ItemStack test) { - if(test == null) { + if(test == null || oreId < 0) { + return false; + } + try { //work around for issue #591 + return OreDictionary.getOreID(test) == oreId; + } catch (Exception e) { return false; } - return OreDictionary.getOreID(test) == oreId; } @Override From de0776712ca28605d1041729d9e2037fab760bde Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 14:28:22 +0800 Subject: [PATCH 03/10] #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench --- ReleaseNotes.txt | 5 +++++ common/crazypants/util/ItemUtil.java | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index e03adee3..940cf984 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,3 +1,8 @@ +1.0.1 +- #589 Work around for crash when using Better Furnace blocks as paint sources for facades. +- #591 Work around to avoid unreproducible crash. +- #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench + 1.0 - #447 Capacitor Bank and Quite Clear Glass causing rendering issues. - Registered EIO alloys in the ore dictionary. diff --git a/common/crazypants/util/ItemUtil.java b/common/crazypants/util/ItemUtil.java index 83c42aff..32d4deee 100644 --- a/common/crazypants/util/ItemUtil.java +++ b/common/crazypants/util/ItemUtil.java @@ -42,9 +42,12 @@ public class ItemUtil { inventorySide = ForgeDirection.UNKNOWN; } + int[] slots = sidedInv.getAccessibleSlotsFromSide(inventorySide.ordinal()); + if(slots == null) { + return 0; + } int numInserted = 0; int numToInsert = item.stackSize; - int[] slots = sidedInv.getAccessibleSlotsFromSide(inventorySide.ordinal()); for (int i = 0; i < slots.length && numToInsert > 0; i++) { int slot = slots[i]; if(sidedInv.canInsertItem(slot, item, inventorySide.ordinal())) { From 120b4ec709ed21ed6da4a9ca2d4f93293a0bb696 Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 15:17:53 +0800 Subject: [PATCH 04/10] #582 Dimensional Transceiver cannot be powered locally unless power mode is set to send --- ReleaseNotes.txt | 3 ++- common/crazypants/enderio/machine/hypercube/TileHyperCube.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 940cf984..4cb9f7d5 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,7 +1,8 @@ 1.0.1 - #589 Work around for crash when using Better Furnace blocks as paint sources for facades. -- #591 Work around to avoid unreproducible crash. +- #591 Work around to avoid non reproducible crash. - #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench +- #582 Dimensional Transceiver cannot be powered locally unless power mode is set to send 1.0 - #447 Capacitor Bank and Quite Clear Glass causing rendering issues. diff --git a/common/crazypants/enderio/machine/hypercube/TileHyperCube.java b/common/crazypants/enderio/machine/hypercube/TileHyperCube.java index 7e87225c..cdf78e07 100644 --- a/common/crazypants/enderio/machine/hypercube/TileHyperCube.java +++ b/common/crazypants/enderio/machine/hypercube/TileHyperCube.java @@ -429,7 +429,7 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor, @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - if(getModeForChannel(SubChannel.POWER).isSendEnabled()) { + if(getModeForChannel(SubChannel.POWER) != IoMode.RECIEVE) { return PowerHandlerUtil.recieveRedstoneFlux(from, powerHandler, maxReceive, simulate); } return 0; From 1d4e07255707da24fa53277a4eb8897b0ec8dac2 Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 15:42:01 +0800 Subject: [PATCH 05/10] #567 Improved server start up times when using large EnderIO power networks --- ReleaseNotes.txt | 1 + .../conduit/power/NetworkPowerManager.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 4cb9f7d5..707a9039 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -3,6 +3,7 @@ - #591 Work around to avoid non reproducible crash. - #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench - #582 Dimensional Transceiver cannot be powered locally unless power mode is set to send +- #567 Improved server startup times when using large EnderIO power networks 1.0 - #447 Capacitor Bank and Quite Clear Glass causing rendering issues. diff --git a/common/crazypants/enderio/conduit/power/NetworkPowerManager.java b/common/crazypants/enderio/conduit/power/NetworkPowerManager.java index c78d7e70..70be8b9b 100644 --- a/common/crazypants/enderio/conduit/power/NetworkPowerManager.java +++ b/common/crazypants/enderio/conduit/power/NetworkPowerManager.java @@ -39,6 +39,8 @@ public class NetworkPowerManager { private final List storageReceptors = new ArrayList(); + private boolean receptorsDirty = true; + private boolean lastActiveValue = false; private int ticksWithNoPower = 0; @@ -126,6 +128,8 @@ public class NetworkPowerManager { trackerStartTick(); + checkReceptors(); + // Update our energy stored based on what's in our conduits updateNetorkStorage(); networkPowerTracker.tickStart(energyStored); @@ -381,16 +385,25 @@ public class NetworkPowerManager { } public void receptorsChanged() { + receptorsDirty = true; + } + + private void checkReceptors() { + if(!receptorsDirty) { + return; + } receptors.clear(); storageReceptors.clear(); for (ReceptorEntry rec : network.getPowerReceptors()) { - if(rec.powerInterface.getDelegate() instanceof TileCapacitorBank) { + if(rec.powerInterface.getDelegate() != null && rec.powerInterface.getDelegate().getClass() == TileCapacitorBank.class) { storageReceptors.add(rec); } else { receptors.add(rec); } } receptorIterator = receptors.listIterator(); + + receptorsDirty = false; } void onNetworkDestroyed() { From 99e1fb6c3c032433e99c603d28b18db362f83c08 Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 19:50:37 +0800 Subject: [PATCH 06/10] #593 Crash when jumping on travel anchor while looking at an Ender IO --- ReleaseNotes.txt | 9 +- .../cofh/api/energy/ItemEnergyContainer.java | 144 +++++++++--------- 2 files changed, 77 insertions(+), 76 deletions(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 707a9039..a577bce0 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,9 +1,10 @@ 1.0.1 -- #589 Work around for crash when using Better Furnace blocks as paint sources for facades. -- #591 Work around to avoid non reproducible crash. +- #567 Improved server startup times when using large EnderIO power networks +- #582 Dimensional Transceiver cannot be powered locally unless power mode is set to send - #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench -- #582 Dimensional Transceiver cannot be powered locally unless power mode is set to send -- #567 Improved server startup times when using large EnderIO power networks +- #589 Work around for crash when using Better Furnace blocks as paint sources for facades. +- #591 Work around to avoid non reproducible crash. +- #593 Crash when jumping on travel anchor while looking at an 'Ender IO' block 1.0 - #447 Capacitor Bank and Quite Clear Glass causing rendering issues. diff --git a/common/cofh/api/energy/ItemEnergyContainer.java b/common/cofh/api/energy/ItemEnergyContainer.java index 3cc33e20..703a2b30 100644 --- a/common/cofh/api/energy/ItemEnergyContainer.java +++ b/common/cofh/api/energy/ItemEnergyContainer.java @@ -5,108 +5,108 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; /** - * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. + * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or + * implement your own. * * @author King Lemming * */ public class ItemEnergyContainer extends Item implements IEnergyContainerItem { - protected int capacity; - protected int maxReceive; - protected int maxExtract; + protected int capacity; + protected int maxReceive; + protected int maxExtract; - public ItemEnergyContainer(int itemID) { + public ItemEnergyContainer(int itemID) { - super(itemID); - } + super(itemID); + } - public ItemEnergyContainer(int itemID, int capacity) { + public ItemEnergyContainer(int itemID, int capacity) { - this(itemID, capacity, capacity, capacity); - } + this(itemID, capacity, capacity, capacity); + } - public ItemEnergyContainer(int itemID, int capacity, int maxTransfer) { + public ItemEnergyContainer(int itemID, int capacity, int maxTransfer) { - this(itemID, capacity, maxTransfer, maxTransfer); - } + this(itemID, capacity, maxTransfer, maxTransfer); + } - public ItemEnergyContainer(int itemID, int capacity, int maxReceive, int maxExtract) { + public ItemEnergyContainer(int itemID, int capacity, int maxReceive, int maxExtract) { - super(itemID); - this.capacity = capacity; - this.maxReceive = maxReceive; - this.maxExtract = maxExtract; - } + super(itemID); + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } - public ItemEnergyContainer setCapacity(int capacity) { + public ItemEnergyContainer setCapacity(int capacity) { - this.capacity = capacity; - return this; - } + this.capacity = capacity; + return this; + } - public void setMaxTransfer(int maxTransfer) { + public void setMaxTransfer(int maxTransfer) { - setMaxReceive(maxTransfer); - setMaxExtract(maxTransfer); - } + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } - public void setMaxReceive(int maxReceive) { + public void setMaxReceive(int maxReceive) { - this.maxReceive = maxReceive; - } + this.maxReceive = maxReceive; + } - public void setMaxExtract(int maxExtract) { + public void setMaxExtract(int maxExtract) { - this.maxExtract = maxExtract; - } + this.maxExtract = maxExtract; + } - /* IEnergyContainerItem */ - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + /* IEnergyContainerItem */ + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + if(container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyReceived; - } + if(!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyReceived; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if(container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - energy -= energyExtracted; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyExtracted; - } + if(!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyExtracted; + } - @Override - public int getEnergyStored(ItemStack container) { + @Override + public int getEnergyStored(ItemStack container) { + if(container == null || container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + return container.stackTagCompound.getInteger("Energy"); + } - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - return container.stackTagCompound.getInteger("Energy"); - } + @Override + public int getMaxEnergyStored(ItemStack container) { - @Override - public int getMaxEnergyStored(ItemStack container) { - - return capacity; - } + return capacity; + } } From d152575d8e05a84e0ba5f3d5f264b6bf2a2388d8 Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 20:00:03 +0800 Subject: [PATCH 07/10] #592 Power monitor reports larger capacitor bank size --- ReleaseNotes.txt | 1 + .../crazypants/enderio/conduit/power/NetworkPowerManager.java | 1 + common/crazypants/enderio/machine/power/TileCapacitorBank.java | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index a577bce0..ca0f6d38 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -4,6 +4,7 @@ - #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench - #589 Work around for crash when using Better Furnace blocks as paint sources for facades. - #591 Work around to avoid non reproducible crash. +- #592 Power monitor reports larger capacitor bank size - #593 Crash when jumping on travel anchor while looking at an 'Ender IO' block 1.0 diff --git a/common/crazypants/enderio/conduit/power/NetworkPowerManager.java b/common/crazypants/enderio/conduit/power/NetworkPowerManager.java index 70be8b9b..d6c1b174 100644 --- a/common/crazypants/enderio/conduit/power/NetworkPowerManager.java +++ b/common/crazypants/enderio/conduit/power/NetworkPowerManager.java @@ -455,6 +455,7 @@ public class NetworkPowerManager { maxCap = 0; for (ReceptorEntry rec : storageReceptors) { TileCapacitorBank cb = (TileCapacitorBank) rec.powerInterface.getDelegate(); + cb = cb.getController(); boolean processed = capBanks.contains(cb); diff --git a/common/crazypants/enderio/machine/power/TileCapacitorBank.java b/common/crazypants/enderio/machine/power/TileCapacitorBank.java index d1f88e37..cee900b2 100644 --- a/common/crazypants/enderio/machine/power/TileCapacitorBank.java +++ b/common/crazypants/enderio/machine/power/TileCapacitorBank.java @@ -829,7 +829,7 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep render = true; } - TileCapacitorBank getController() { + public TileCapacitorBank getController() { if(isMaster() || !isMultiblock()) { return this; } From 9cd48a009cec3a160bcd4f25264c5214c412d5cc Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 20:25:38 +0800 Subject: [PATCH 08/10] #594 Changing equipped item causes FPS drop --- ReleaseNotes.txt | 1 + common/crazypants/enderio/conduit/ConduitDisplayMode.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index ca0f6d38..eb791739 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -6,6 +6,7 @@ - #591 Work around to avoid non reproducible crash. - #592 Power monitor reports larger capacitor bank size - #593 Crash when jumping on travel anchor while looking at an 'Ender IO' block +- #594 Changing equipped item causes FPS drop 1.0 - #447 Capacitor Bank and Quite Clear Glass causing rendering issues. diff --git a/common/crazypants/enderio/conduit/ConduitDisplayMode.java b/common/crazypants/enderio/conduit/ConduitDisplayMode.java index 664a90ff..ca4ecbf8 100644 --- a/common/crazypants/enderio/conduit/ConduitDisplayMode.java +++ b/common/crazypants/enderio/conduit/ConduitDisplayMode.java @@ -2,6 +2,7 @@ package crazypants.enderio.conduit; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; +import crazypants.enderio.EnderIO; public enum ConduitDisplayMode { ALL, @@ -28,7 +29,7 @@ public enum ConduitDisplayMode { } public static ConduitDisplayMode getDisplayMode(ItemStack equipped) { - if(equipped == null) { + if(equipped == null || equipped.getItem() != EnderIO.itemYetaWench) { return ALL; } int index = equipped.getItemDamage(); From 783d7f4e132d1b2e94fbff3771e3960baff99f8c Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 21:03:23 +0800 Subject: [PATCH 09/10] 1.0.1 - #567 Improved server start up times when using large Ender IO power networks - #582 Dimensional Transceiver cannot be powered locally unless power mode is set to send - #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench - #589 Work around for crash when using Better Furnace blocks as paint sources for facades. - #591 Work around to avoid non reproducible crash. - #592 Power monitor reports larger capacitor bank size - #593 Crash when jumping on travel anchor while looking at an 'Ender IO' block - #594 Changing equipped item causes FPS drop --- build.xml | 2 +- common/crazypants/enderio/EnderIO.java | 2 +- resources/mcmod.info | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.xml b/build.xml index b8ab041c..86b524ed 100644 --- a/build.xml +++ b/build.xml @@ -20,7 +20,7 @@ - + diff --git a/common/crazypants/enderio/EnderIO.java b/common/crazypants/enderio/EnderIO.java index cdb44561..81b2c269 100644 --- a/common/crazypants/enderio/EnderIO.java +++ b/common/crazypants/enderio/EnderIO.java @@ -70,7 +70,7 @@ import crazypants.enderio.teleport.TeleportRecipes; import crazypants.enderio.trigger.TriggerEnderIO; import crazypants.enderio.trigger.TriggerProviderEIO; -@Mod(name = "EnderIO", modid = "EnderIO", version = "1.0.0", dependencies = "required-after:Forge@[9.11.0.883,)") +@Mod(name = "EnderIO", modid = "EnderIO", version = "1.0.1", dependencies = "required-after:Forge@[9.11.0.883,)") @NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = { "EnderIO" }, packetHandler = PacketHandler.class) public class EnderIO { diff --git a/resources/mcmod.info b/resources/mcmod.info index d41816a8..7f12069f 100644 --- a/resources/mcmod.info +++ b/resources/mcmod.info @@ -3,9 +3,9 @@ "modid": "EnderIO", "name": "Ender IO", "description": "Compact conduits, painted things and access to your stuff through an eye of ender.", - "version": "1.0.0", + "version": "1.0.1", "mcversion": "1.6.4", - "url": "http://www.minecraftforum.net/topic/1937619-162152-ender-io-how-many-pipes-in-one-block-updated-198/", + "url": "http://enderio.com", "updateUrl": "", "authors": [ "crazypants" From d0571aac32730b35f26c60ff39b9ce278d2431d0 Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sun, 13 Apr 2014 22:52:55 +0800 Subject: [PATCH 10/10] #580 Fixed infinite power when mixing TE and EIO conduits in certain ways --- ReleaseNotes.txt | 1 + .../enderio/conduit/power/PowerConduit.java | 48 ++++++++++++++----- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index eb791739..f49c6c66 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,5 +1,6 @@ 1.0.1 - #567 Improved server startup times when using large EnderIO power networks +- #580 Fixed infinite power when mixing TE and EIO conduits in certain ways - #582 Dimensional Transceiver cannot be powered locally unless power mode is set to send - #587 Crash placing Item Conduit between Iron Chest & Basic Project Bench - #589 Work around for crash when using Better Furnace blocks as paint sources for facades. diff --git a/common/crazypants/enderio/conduit/power/PowerConduit.java b/common/crazypants/enderio/conduit/power/PowerConduit.java index 3412896b..3b4df3e4 100644 --- a/common/crazypants/enderio/conduit/power/PowerConduit.java +++ b/common/crazypants/enderio/conduit/power/PowerConduit.java @@ -100,6 +100,8 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit { protected final EnumMap rsModes = new EnumMap(ForgeDirection.class); protected final EnumMap rsColors = new EnumMap(ForgeDirection.class); + protected EnumMap recievedTicks; + private final Map externalRedstoneSignals = new HashMap(); private boolean redstoneStateDirty = true; @@ -280,15 +282,6 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit { return powerHandler; } - @Override - public float getMaxEnergyExtracted(ForgeDirection dir) { - ConnectionMode mode = getConectionMode(dir); - if(mode == ConnectionMode.INPUT || mode == ConnectionMode.DISABLED || !isRedstoneEnabled(dir)) { - return 0; - } - return getCapacitor().getMaxEnergyExtracted(); - } - private boolean isRedstoneEnabled(ForgeDirection dir) { boolean result; RedstoneControlMode mode = getRedstoneMode(dir); @@ -341,6 +334,31 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit { return getCapacitor().getMaxEnergyReceived(); } + @Override + public float getMaxEnergyExtracted(ForgeDirection dir) { + ConnectionMode mode = getConectionMode(dir); + if(mode == ConnectionMode.INPUT || mode == ConnectionMode.DISABLED || !isRedstoneEnabled(dir)) { + return 0; + } + if(recievedRfThisTick(dir)) { + return 0; + } + return getCapacitor().getMaxEnergyExtracted(); + } + + private boolean recievedRfThisTick(ForgeDirection dir) { + if(recievedTicks == null || dir == null || recievedTicks.get(dir) == null || getBundle() == null || getBundle().getWorld() == null) { + return false; + } + + long curTick = getBundle().getWorld().getTotalWorldTime(); + long recT = recievedTicks.get(dir); + if(curTick >= (recT - 5)) { + return true; + } + return false; + } + @Override public PowerHandler getPowerHandler() { return powerHandler; @@ -370,13 +388,21 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit { @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - if(getMaxEnergyRecieved(from) == 0) { + if(getMaxEnergyRecieved(from) == 0 || maxReceive <= 0) { return 0; } float freeSpace = getCapacitor().getMaxEnergyStored() - energyStored; int result = (int) Math.min(maxReceive / 10, freeSpace); - if(!simulate) { + if(!simulate && result > 0) { energyStored += result; + + if(getBundle() != null) { + if(recievedTicks == null) { + recievedTicks = new EnumMap(ForgeDirection.class); + } + recievedTicks.put(from, getBundle().getWorld().getTotalWorldTime()); + } + } return result * 10; }