From 20162970d85fc973b6fbe888573792e6968d9f83 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Fri, 29 Nov 2013 13:04:39 -0500 Subject: [PATCH] Fixes! --- common/mekanism/api/gas/GasNetwork.java | 18 +++---- .../RenderLogisticalTransporter.java | 3 +- common/mekanism/common/EnergyNetwork.java | 25 ++++++--- common/mekanism/common/FluidNetwork.java | 18 +++---- common/mekanism/common/Mekanism.java | 2 +- .../tileentity/TileEntityElectricChest.java | 2 +- .../mekanism/common/util/MekanismUtils.java | 51 +++++++++++-------- 7 files changed, 70 insertions(+), 49 deletions(-) diff --git a/common/mekanism/api/gas/GasNetwork.java b/common/mekanism/api/gas/GasNetwork.java index 8d194bcfe..f4b3178fd 100644 --- a/common/mekanism/api/gas/GasNetwork.java +++ b/common/mekanism/api/gas/GasNetwork.java @@ -45,6 +45,12 @@ public class GasNetwork extends DynamicNetwork { if(net != null) { + if(net.refGas != null && net.gasScale > gasScale) + { + refGas = net.refGas; + gasScale = net.gasScale; + } + addAllTransmitters(net.transmitters); net.deregister(); } @@ -267,18 +273,12 @@ public class GasNetwork extends DynamicNetwork { GasNetwork network = new GasNetwork(networks); - for(GasNetwork iterNet : networks) + if(refGas != null && gasScale > network.gasScale) { - if(iterNet.refGas != null && iterNet.gasScale > network.gasScale) - { - network.refGas = iterNet.refGas; - network.gasScale = iterNet.gasScale; - break; - } + network.refGas = refGas; + network.gasScale = gasScale; } - System.out.println(network.gasScale); - return network; } diff --git a/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java b/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java index b3a374e88..e623c4a7a 100644 --- a/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java +++ b/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java @@ -152,7 +152,6 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer { int mode = ((TileEntityDiversionTransporter)tileEntity).modes[pos.sideHit]; ForgeDirection side = ForgeDirection.getOrientation(pos.sideHit); - int offset = MekanismUtils.getSideOffset(side); push(); @@ -161,7 +160,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer bindTexture(mode == 0 ? MekanismRenderer.getItemsTexture() : MekanismRenderer.getBlocksTexture()); GL11.glTranslatef((float)x, (float)y, (float)z); GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(0.5F*Math.abs(offset), 0.5F*Math.abs(offset), 0.5F*Math.abs(offset)); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); int display = getOverlayDisplay(world, side, mode).display; GL11.glCallList(display); diff --git a/common/mekanism/common/EnergyNetwork.java b/common/mekanism/common/EnergyNetwork.java index ac15c8aef..840e3420e 100644 --- a/common/mekanism/common/EnergyNetwork.java +++ b/common/mekanism/common/EnergyNetwork.java @@ -57,6 +57,14 @@ public class EnergyNetwork extends DynamicNetwork { if(net != null) { + if(net.joulesLastTick > joulesLastTick || net.clientEnergyScale > clientEnergyScale) + { + clientEnergyScale = net.clientEnergyScale; + joulesLastTick = net.joulesLastTick; + joulesTransmitted = net.joulesTransmitted; + lastPowerScale = net.lastPowerScale; + } + addAllTransmitters(net.transmitters); net.deregister(); } @@ -421,6 +429,9 @@ public class EnergyNetwork extends DynamicNetwork { EnergyNetwork network = new EnergyNetwork(varTransmitters); network.clientEnergyScale = clientEnergyScale; + network.joulesLastTick = joulesLastTick; + network.joulesTransmitted = joulesTransmitted; + network.lastPowerScale = lastPowerScale; return network; } @@ -429,6 +440,9 @@ public class EnergyNetwork extends DynamicNetwork { EnergyNetwork network = new EnergyNetwork(collection); network.clientEnergyScale = clientEnergyScale; + network.joulesLastTick = joulesLastTick; + network.joulesTransmitted = joulesTransmitted; + network.lastPowerScale = lastPowerScale; return network; } @@ -436,14 +450,13 @@ public class EnergyNetwork extends DynamicNetwork protected EnergyNetwork create(Set networks) { EnergyNetwork network = new EnergyNetwork(networks); - network.clientEnergyScale = clientEnergyScale; - for(EnergyNetwork iterNet : networks) + if(joulesLastTick > network.joulesLastTick || clientEnergyScale > network.clientEnergyScale) { - if(iterNet.clientEnergyScale > network.clientEnergyScale) - { - network.clientEnergyScale = iterNet.clientEnergyScale; - } + network.clientEnergyScale = clientEnergyScale; + network.joulesLastTick = joulesLastTick; + network.joulesTransmitted = joulesTransmitted; + network.lastPowerScale = lastPowerScale; } return network; diff --git a/common/mekanism/common/FluidNetwork.java b/common/mekanism/common/FluidNetwork.java index d10c081ab..4190df649 100644 --- a/common/mekanism/common/FluidNetwork.java +++ b/common/mekanism/common/FluidNetwork.java @@ -52,6 +52,12 @@ public class FluidNetwork extends DynamicNetwork { if(net != null) { + if(net.refFluid != null && net.fluidScale > fluidScale) + { + refFluid = net.refFluid; + fluidScale = net.fluidScale; + } + addAllTransmitters(net.transmitters); net.deregister(); } @@ -288,17 +294,11 @@ public class FluidNetwork extends DynamicNetwork protected FluidNetwork create(Set networks) { FluidNetwork network = new FluidNetwork(networks); - network.refFluid = refFluid; - network.fluidScale = fluidScale; - for(FluidNetwork iterNet : networks) + if(refFluid != null && fluidScale > network.fluidScale) { - if(iterNet.refFluid != null && iterNet.fluidScale > network.fluidScale) - { - network.refFluid = iterNet.refFluid; - network.fluidScale = iterNet.fluidScale; - break; - } + network.refFluid = refFluid; + network.fluidScale = fluidScale; } return network; diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 8a0fb7043..fd28c2202 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -434,7 +434,7 @@ public class Mekanism "ACA", "SES", "TIT", Character.valueOf('A'), AtomicCore, Character.valueOf('C'), "circuitBasic", Character.valueOf('S'), new ItemStack(MachineBlock, 1, 15), Character.valueOf('E'), Robit.getUnchargedItem(), Character.valueOf('I'), new ItemStack(BasicBlock, 1, 8), Character.valueOf('T'), TeleportationCore })); - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Transmitter, 1, 4), new Object[] { + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Transmitter, 1, 5), new Object[] { "RRR", "SBS", "RRR", Character.valueOf('R'), Item.redstone, Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Block.fenceIron })); CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MachineBlock2, 1, 0), new Object[] { diff --git a/common/mekanism/common/tileentity/TileEntityElectricChest.java b/common/mekanism/common/tileentity/TileEntityElectricChest.java index 7773cd24a..e0a2f15f0 100644 --- a/common/mekanism/common/tileentity/TileEntityElectricChest.java +++ b/common/mekanism/common/tileentity/TileEntityElectricChest.java @@ -137,7 +137,7 @@ public class TileEntityElectricChest extends TileEntityElectricBlock { if(side == 0 || !canAccess()) { - return null; + return new int[0]; } else { int[] ret = new int[55]; diff --git a/common/mekanism/common/util/MekanismUtils.java b/common/mekanism/common/util/MekanismUtils.java index 6d8be258e..083667550 100644 --- a/common/mekanism/common/util/MekanismUtils.java +++ b/common/mekanism/common/util/MekanismUtils.java @@ -462,6 +462,11 @@ public final class MekanismUtils return hasResource; } + /** + * Gets the ore dictionary name of a defined ItemStack. + * @param check - ItemStack to check OreDict name of + * @return OreDict name + */ public static String getOreDictName(ItemStack check) { HashMap> oreStacks = (HashMap>)MekanismUtils.getPrivateValue(null, OreDictionary.class, new String[] {"oreStacks"}); @@ -531,6 +536,11 @@ public final class MekanismUtils return side; } + /** + * Localizes the defined string. + * @param s - string to localized + * @return localized string + */ public static String localize(String s) { return StatCollector.translateToLocal(s); @@ -556,6 +566,11 @@ public final class MekanismUtils } } + /** + * Decrements the output type of a machine's side. + * @param config - configurable machine + * @param side - side to increment output of + */ public static void decrementOutput(IConfigurable config, int side) { int max = config.getSideData().size()-1; @@ -623,6 +638,14 @@ public final class MekanismUtils } } + /** + * Places a fake advanced bounding block at the defined location. + * @param world - world to place block in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @param orig - original block + */ public static void makeAdvancedBoundingBlock(World world, int x, int y, int z, Object3D orig) { world.setBlock(x, y, z, Mekanism.BoundingBlock.blockID, 1, 3); @@ -1004,6 +1027,10 @@ public final class MekanismUtils return didRemove; } + /** + * Marks the chunk this TileEntity is in as modified. Call this method to be sure NBT is written by the defined tile entity. + * @param tileEntity - TileEntity to save + */ public static void saveChunk(TileEntity tileEntity) { if(tileEntity == null || tileEntity.isInvalid() || tileEntity.worldObj == null) @@ -1036,11 +1063,11 @@ public final class MekanismUtils } else if(control.getControlType() == RedstoneControl.HIGH) { - return world.getBlockPowerInput(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) > 0; + return world.isBlockIndirectlyGettingPowered(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); } else if(control.getControlType() == RedstoneControl.LOW) { - return world.getBlockPowerInput(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) == 0; + return !world.isBlockIndirectlyGettingPowered(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); } return false; @@ -1057,7 +1084,7 @@ public final class MekanismUtils return world.rayTraceBlocks_do_do(headVec, endVec, true, false); } - public static Vec3 getHeadVec(EntityPlayer player) + private static Vec3 getHeadVec(EntityPlayer player) { Vec3 vec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); @@ -1084,24 +1111,6 @@ public final class MekanismUtils return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft; } - public static int getSideOffset(ForgeDirection side) - { - if(side.offsetX != 0) - { - return side.offsetX; - } - else if(side.offsetY != 0) - { - return side.offsetY; - } - else if(side.offsetZ != 0) - { - return side.offsetZ; - } - - return 0; - } - public static enum ResourceType { GUI("gui"),