From e8bbbcc7c3f9b99e4ec9f1aa40fc95bb9ee70857 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 25 Jul 2015 17:55:03 +0100 Subject: [PATCH] Some changes to the way rf is handled. --- .../java/techreborn/powerSystem/TilePowerAcceptor.java | 10 ++++++++-- src/main/java/techreborn/tiles/TileAesu.java | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java b/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java index ae110c76c..efd8308b6 100644 --- a/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java +++ b/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java @@ -144,7 +144,7 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements public boolean canConnectEnergy(ForgeDirection from) { if (!PowerSystem.RFPOWENET) return false; - return canAcceptEnergy(from); + return canAcceptEnergy(from) || canProvideEnergy(from); } @Override @@ -154,7 +154,12 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements if (!canAcceptEnergy(from)) { return 0; } - return (int) ((int) addEnergy(maxReceive, simulate) / PowerSystem.euPerRF); + int energyReceived = Math.min(getMaxEnergyStored(ForgeDirection.UNKNOWN) - getEnergyStored(ForgeDirection.UNKNOWN), Math.min((int)this.getMaxInput(), maxReceive)); + + if (!simulate) { + energy += energyReceived; + } + return energyReceived; } @Override @@ -178,6 +183,7 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements if (!canAcceptEnergy(from)) { return 0; } + maxExtract *= PowerSystem.euPerRF; return (int) ((int) useEnergy(maxExtract, simulate) / PowerSystem.euPerRF); } //END COFH diff --git a/src/main/java/techreborn/tiles/TileAesu.java b/src/main/java/techreborn/tiles/TileAesu.java index 002bcc2fd..3cee4c143 100644 --- a/src/main/java/techreborn/tiles/TileAesu.java +++ b/src/main/java/techreborn/tiles/TileAesu.java @@ -7,6 +7,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; +import techreborn.lib.Functions; import techreborn.powerSystem.TilePowerAcceptor; import techreborn.util.Inventory; @@ -153,12 +154,12 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable { @Override public boolean canAcceptEnergy(ForgeDirection direction) { - return true; + return worldObj.getBlockMetadata(xCoord, yCoord, zCoord) != Functions.getIntDirFromDirection(direction); } @Override public boolean canProvideEnergy(ForgeDirection direction) { - return true; + return worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == Functions.getIntDirFromDirection(direction); } @Override