diff --git a/electrical/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java b/electrical/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java index 32ac5c96..b55466b4 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 a06ca9d5..3d3b1851 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 e5424c44..b3fb3258 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 4499b2c3..a9379bb9 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