From 74c00b802f52475ac743e5e72c7182bc9a9bc41a Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 8 Mar 2014 19:47:27 -0800 Subject: [PATCH] Fixed #358 and framed wire not connecting properly --- .../electrical/multimeter/ItemMultimeter.java | 18 +-- .../wire/framed/PartFramedWire.java | 63 ++++------ .../mechanical/Mechanical.java | 2 +- .../mechanical/logistic/rail/PartRailing.java | 2 +- .../core/grid/fluid/PressureNode.java | 114 +++++++++--------- .../prefab/part/PartFramedConnection.java | 43 +------ .../languages/en_US.properties | 1 + 7 files changed, 99 insertions(+), 144 deletions(-) diff --git a/electrical/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java b/electrical/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java index 32ac5c961..b55466b4f 100644 --- a/electrical/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java +++ b/electrical/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java @@ -2,6 +2,8 @@ package resonantinduction.electrical.multimeter; import java.util.List; +import org.lwjgl.input.Keyboard; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -10,6 +12,9 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import resonantinduction.core.prefab.part.IHighlight; import resonantinduction.electrical.wire.EnumWireMaterial; +import universalelectricity.api.energy.UnitDisplay; +import universalelectricity.api.energy.UnitDisplay.Unit; +import calclavia.lib.render.EnumColor; import calclavia.lib.utility.LanguageUtility; import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.Vector3; @@ -45,20 +50,15 @@ public class ItemMultimeter extends JItemMultiPart implements IHighlight } @Override - public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) { - par3List.add(LanguageUtility.getLocal("tooltip.multimeter.line1")); - par3List.add(LanguageUtility.getLocal("tooltip.multimeter.line2")); - - float detection = this.getDetection(itemStack); - - if (detection != -1) + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - par3List.add(LanguageUtility.getLocal("tooltip.multimeter.lastSave").replace("%v", detection + "")); + list.add(LanguageUtility.getLocal("tooltip.noShift").replace("%0", EnumColor.AQUA.toString()).replace("%1", EnumColor.GREY.toString())); } else { - par3List.add(LanguageUtility.getLocal("tooltip.multimeter.noSave")); + list.addAll(LanguageUtility.splitStringPerWord(LanguageUtility.getLocal("item.resonantinduction:multimeter.tooltip"), 5)); } } diff --git a/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java b/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java index a06ca9d5c..3d3b1851c 100644 --- a/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java +++ b/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java @@ -48,7 +48,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @UniversalClass -public class PartFramedWire extends PartFramedConnection implements IConductor, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects +public class PartFramedWire extends PartFramedConnection implements IConductor, TSlottedPart, JNormalOcclusion, IHollowConnect { public PartFramedWire() { @@ -101,6 +101,8 @@ public class PartFramedWire extends PartFramedConnection collisionBoxes = new HashSet(); collisionBoxes.addAll((Collection) getSubParts()); - return collisionBoxes; } @@ -241,41 +245,11 @@ public class PartFramedWire extends PartFramedConnection implements IRailing, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects +public class PartRailing extends PartFramedConnection implements IRailing, TSlottedPart, JNormalOcclusion, IHollowConnect { RedstoneControl control; diff --git a/src/main/java/resonantinduction/core/grid/fluid/PressureNode.java b/src/main/java/resonantinduction/core/grid/fluid/PressureNode.java index e5424c44e..b3fb32586 100644 --- a/src/main/java/resonantinduction/core/grid/fluid/PressureNode.java +++ b/src/main/java/resonantinduction/core/grid/fluid/PressureNode.java @@ -85,86 +85,90 @@ public class PressureNode extends Node> it = getConnections().entrySet().iterator(); - - while (it.hasNext()) + synchronized (getConnections()) { - Entry entry = it.next(); - Object obj = entry.getKey(); - ForgeDirection dir = entry.getValue(); + Iterator> it = getConnections().entrySet().iterator(); - if (obj instanceof PressureNode) + while (it.hasNext()) { - PressureNode otherPipe = (PressureNode) obj; + Entry entry = it.next(); + Object obj = entry.getKey(); + ForgeDirection dir = entry.getValue(); - /** - * Move fluid from higher pressure to lower. In this case, move from tankA to tankB. - */ - int pressureA = getPressure(dir); - int pressureB = otherPipe.getPressure(dir.getOpposite()); - - if (pressureA >= pressureB) + if (obj instanceof PressureNode) { - FluidTank tankA = parent.getPressureTank(); + PressureNode otherPipe = (PressureNode) obj; - if (tankA != null) + /** + * Move fluid from higher pressure to lower. In this case, move from tankA to + * tankB. + */ + int pressureA = getPressure(dir); + int pressureB = otherPipe.getPressure(dir.getOpposite()); + + if (pressureA >= pressureB) { - FluidStack fluidA = tankA.getFluid(); + FluidTank tankA = parent.getPressureTank(); - if (fluidA != null) + if (tankA != null) { - int amountA = fluidA.amount; + FluidStack fluidA = tankA.getFluid(); - if (amountA > 0) + if (fluidA != null) { - FluidTank tankB = otherPipe.parent.getPressureTank(); + int amountA = fluidA.amount; - if (tankB != null) + if (amountA > 0) { - int amountB = tankB.getFluidAmount(); + FluidTank tankB = otherPipe.parent.getPressureTank(); - int quantity = Math.max(pressureA > pressureB ? (pressureA - pressureB) * getMaxFlowRate() : 0, Math.min((amountA - amountB) / 2, getMaxFlowRate())); - quantity = Math.min(Math.min(quantity, tankB.getCapacity() - amountB), amountA); - - if (quantity > 0) + if (tankB != null) { - FluidStack drainStack = parent.drain(dir.getOpposite(), quantity, false); + int amountB = tankB.getFluidAmount(); - if (drainStack != null && drainStack.amount > 0) - parent.drain(dir.getOpposite(), otherPipe.parent.fill(dir, drainStack, true), true); + int quantity = Math.max(pressureA > pressureB ? (pressureA - pressureB) * getMaxFlowRate() : 0, Math.min((amountA - amountB) / 2, getMaxFlowRate())); + quantity = Math.min(Math.min(quantity, tankB.getCapacity() - amountB), amountA); + + if (quantity > 0) + { + FluidStack drainStack = parent.drain(dir.getOpposite(), quantity, false); + + if (drainStack != null && drainStack.amount > 0) + parent.drain(dir.getOpposite(), otherPipe.parent.fill(dir, drainStack, true), true); + } } } } } } } - } - else if (obj instanceof IFluidHandler) - { - IFluidHandler fluidHandler = (IFluidHandler) obj; - int pressure = getPressure(dir); - int tankPressure = fluidHandler instanceof IPressureNodeProvider ? ((IPressureNodeProvider) fluidHandler).getNode(PressureNode.class, dir.getOpposite()).getPressure(dir.getOpposite()) : 0; - FluidTank sourceTank = parent.getPressureTank(); - - int transferAmount = (Math.max(pressure, tankPressure) - Math.min(pressure, tankPressure)) * getMaxFlowRate(); - - if (pressure > tankPressure) + else if (obj instanceof IFluidHandler) { - if (sourceTank.getFluidAmount() > 0 && transferAmount > 0) - { - FluidStack drainStack = parent.drain(dir.getOpposite(), transferAmount, false); - parent.drain(dir.getOpposite(), fluidHandler.fill(dir.getOpposite(), drainStack, true), true); - } - } - else if (pressure < tankPressure) - { - if (transferAmount > 0) - { - FluidStack drainStack = fluidHandler.drain(dir.getOpposite(), transferAmount, false); + IFluidHandler fluidHandler = (IFluidHandler) obj; + int pressure = getPressure(dir); + int tankPressure = fluidHandler instanceof IPressureNodeProvider ? ((IPressureNodeProvider) fluidHandler).getNode(PressureNode.class, dir.getOpposite()).getPressure(dir.getOpposite()) : 0; + FluidTank sourceTank = parent.getPressureTank(); - if (drainStack != null) + int transferAmount = (Math.max(pressure, tankPressure) - Math.min(pressure, tankPressure)) * getMaxFlowRate(); + + if (pressure > tankPressure) + { + if (sourceTank.getFluidAmount() > 0 && transferAmount > 0) { - fluidHandler.drain(dir.getOpposite(), parent.fill(dir.getOpposite(), drainStack, true), true); + FluidStack drainStack = parent.drain(dir.getOpposite(), transferAmount, false); + parent.drain(dir.getOpposite(), fluidHandler.fill(dir.getOpposite(), drainStack, true), true); + } + } + else if (pressure < tankPressure) + { + if (transferAmount > 0) + { + FluidStack drainStack = fluidHandler.drain(dir.getOpposite(), transferAmount, false); + + if (drainStack != null) + { + fluidHandler.drain(dir.getOpposite(), parent.fill(dir.getOpposite(), drainStack, true), true); + } } } } diff --git a/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java b/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java index 4499b2c39..a9379bb9e 100644 --- a/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java +++ b/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java @@ -35,7 +35,7 @@ import codechicken.multipart.TileMultipart; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public abstract class PartFramedConnection, N extends INodeNetwork> extends PartColorableMaterial implements IConnector, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects +public abstract class PartFramedConnection, N extends INodeNetwork> extends PartColorableMaterial implements IConnector, TSlottedPart, JNormalOcclusion, IHollowConnect { public static IndexedCuboid6[] sides = new IndexedCuboid6[7]; @@ -134,24 +134,6 @@ public abstract class PartFramedConnection getOcclusionBoxes() { @@ -170,18 +152,6 @@ public abstract class PartFramedConnection