From fed49fbb05271d4a16b879ede1f858e64bc9a646 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Tue, 17 Dec 2013 20:42:52 -0500 Subject: [PATCH] Cleanup, fix a few things --- common/mekanism/api/gas/GasNetwork.java | 16 ++++ common/mekanism/common/FluidNetwork.java | 19 ++++- .../common/ILogisticalTransporter.java | 16 ++++ .../common/multipart/PartSidedPipe.java | 77 ++++++++++++------- .../common/multipart/PartTransmitter.java | 1 + 5 files changed, 101 insertions(+), 28 deletions(-) create mode 100644 common/mekanism/common/ILogisticalTransporter.java diff --git a/common/mekanism/api/gas/GasNetwork.java b/common/mekanism/api/gas/GasNetwork.java index f0000f6b6..76a7ddfa7 100644 --- a/common/mekanism/api/gas/GasNetwork.java +++ b/common/mekanism/api/gas/GasNetwork.java @@ -58,6 +58,8 @@ public class GasNetwork extends DynamicNetwork { gasScale = net.gasScale; refGas = net.refGas; + net.gasScale = 0; + net.refGas = null; } if(net.gasStored != null) @@ -69,6 +71,8 @@ public class GasNetwork extends DynamicNetwork else { gasStored.amount += net.gasStored.amount; } + + net.gasStored = null; } addAllTransmitters(net.transmitters); @@ -109,6 +113,10 @@ public class GasNetwork extends DynamicNetwork } } } + + gasScale = 0; + refGas = null; + gasStored = null; } public synchronized int getGasNeeded() @@ -391,6 +399,10 @@ public class GasNetwork extends DynamicNetwork } } + gasScale = 0; + refGas = null; + gasStored = null; + return network; } @@ -412,6 +424,10 @@ public class GasNetwork extends DynamicNetwork } } + gasScale = 0; + refGas = null; + gasStored = null; + return network; } diff --git a/common/mekanism/common/FluidNetwork.java b/common/mekanism/common/FluidNetwork.java index 1e9682218..f4b682649 100644 --- a/common/mekanism/common/FluidNetwork.java +++ b/common/mekanism/common/FluidNetwork.java @@ -56,9 +56,12 @@ public class FluidNetwork extends DynamicNetwork { if(net != null) { - if(net.fluidScale > fluidScale) + if(net.refFluid != null && net.fluidScale > fluidScale) { fluidScale = net.fluidScale; + refFluid = net.refFluid; + net.fluidScale = 0; + net.refFluid = null; } if(net.fluidStored != null) @@ -70,6 +73,8 @@ public class FluidNetwork extends DynamicNetwork else { fluidStored.amount += net.fluidStored.amount; } + + net.fluidStored = null; } addAllTransmitters(net.transmitters); @@ -110,6 +115,10 @@ public class FluidNetwork extends DynamicNetwork } } } + + fluidStored = null; + refFluid = null; + fluidScale = 0; } public synchronized int getFluidNeeded() @@ -367,6 +376,10 @@ public class FluidNetwork extends DynamicNetwork } } + fluidScale = 0; + refFluid = null; + fluidStored = null; + return network; } @@ -388,6 +401,10 @@ public class FluidNetwork extends DynamicNetwork } } + fluidScale = 0; + refFluid = null; + fluidStored = null; + return network; } diff --git a/common/mekanism/common/ILogisticalTransporter.java b/common/mekanism/common/ILogisticalTransporter.java new file mode 100644 index 000000000..77920d9e7 --- /dev/null +++ b/common/mekanism/common/ILogisticalTransporter.java @@ -0,0 +1,16 @@ +package mekanism.common; + +import mekanism.api.EnumColor; +import mekanism.api.Object3D; +import mekanism.common.tileentity.TileEntityLogisticalSorter; +import mekanism.common.transporter.TransporterStack; +import net.minecraft.item.ItemStack; + +public interface ILogisticalTransporter +{ + public ItemStack insert(Object3D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min); + + public ItemStack insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color, boolean doEmit, int min); + + public void entityEntering(TransporterStack stack); +} diff --git a/common/mekanism/common/multipart/PartSidedPipe.java b/common/mekanism/common/multipart/PartSidedPipe.java index 295aca1cf..e813eddb6 100644 --- a/common/mekanism/common/multipart/PartSidedPipe.java +++ b/common/mekanism/common/multipart/PartSidedPipe.java @@ -1,5 +1,27 @@ package mekanism.common.multipart; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import mekanism.api.Object3D; +import mekanism.api.transmitters.IBlockableConnection; +import mekanism.api.transmitters.TransmissionType; +import mekanism.client.render.RenderPartTransmitter; +import mekanism.common.IConfigurable; +import mekanism.common.ITileNetwork; +import mekanism.common.Mekanism; +import mekanism.common.item.ItemConfigurator; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.common.ForgeDirection; import buildcraft.api.tools.IToolWrench; import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataOutput; @@ -11,25 +33,18 @@ import codechicken.lib.render.CCModel; import codechicken.lib.vec.Cuboid6; import codechicken.lib.vec.Vector3; import codechicken.microblock.IHollowConnect; -import codechicken.multipart.*; +import codechicken.multipart.IconHitEffects; +import codechicken.multipart.JIconHitEffects; +import codechicken.multipart.JNormalOcclusion; +import codechicken.multipart.NormalOcclusionTest; +import codechicken.multipart.PartMap; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TSlottedPart; + import com.google.common.io.ByteArrayDataInput; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import mekanism.api.Object3D; -import mekanism.api.transmitters.*; -import mekanism.client.render.RenderPartTransmitter; -import mekanism.common.IConfigurable; -import mekanism.common.ITileNetwork; -import mekanism.common.Mekanism; -import net.minecraft.client.particle.EffectRenderer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.common.ForgeDirection; - -import java.util.*; public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, ITileNetwork, IBlockableConnection, IConfigurable { @@ -107,12 +122,12 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, public Icon getIconForSide(ForgeDirection side) { ConnectionType type = getConnectionType(side); + if(type == ConnectionType.NONE) { return getCenterIcon(); } - else - { + else { return getSideIcon(); } } @@ -212,6 +227,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { Set collisionBoxes = new HashSet(); collisionBoxes.addAll((Collection)getSubParts()); + return collisionBoxes; } @@ -301,7 +317,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, currentTransmitterConnections = packet.readByte(); currentAcceptorConnections = packet.readByte(); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) { connectionTypes[i] = ConnectionType.values()[packet.readInt()]; } @@ -314,7 +330,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, packet.writeByte(currentTransmitterConnections); packet.writeByte(currentAcceptorConnections); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) { packet.writeInt(connectionTypes[i].ordinal()); } @@ -327,7 +343,8 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { return false; } - if(item.getItem() instanceof IToolWrench && player.isSneaking()) + + if(item.getItem() instanceof IToolWrench && !(item.getItem() instanceof ItemConfigurator) && player.isSneaking()) { if(!world().isRemote) { @@ -374,6 +391,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, return ConnectionType.NONE; if(connectionMapContainsSide(currentTransmitterConnections, side)) return ConnectionType.NORMAL; + return connectionTypes[side.ordinal()]; } @@ -396,21 +414,22 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { String sideName = side.name().toLowerCase(); ConnectionType type = getConnectionType(side); + if(getTransmitterSize() == TransmissionType.Size.LARGE) { sideName += (type == ConnectionType.NONE) ? "In" : "Out"; + return RenderPartTransmitter.large_models.get(sideName); } - else - { + else { String typeName = getConnectionType(side).name().toUpperCase(); String name = sideName + typeName; + if(internal) { return RenderPartTransmitter.contents_models.get(name); } - else - { + else { return RenderPartTransmitter.small_models.get(name); } } @@ -419,15 +438,19 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, @Override public boolean onSneakRightClick(EntityPlayer player, int side) { - ExtendedMOP hit = (ExtendedMOP) RayTracer.retraceBlock(world(), player, x(), y(), z()); + ExtendedMOP hit = (ExtendedMOP)RayTracer.retraceBlock(world(), player, x(), y(), z()); + if(hit == null) + { return false; - if(hit.subHit < 6) + } + else if(hit.subHit < 6) { connectionTypes[hit.subHit] = ConnectionType.nextType[connectionTypes[hit.subHit].ordinal()]; sendDesc = true; return true; } + return false; } diff --git a/common/mekanism/common/multipart/PartTransmitter.java b/common/mekanism/common/multipart/PartTransmitter.java index 839f0ee52..8bb523822 100644 --- a/common/mekanism/common/multipart/PartTransmitter.java +++ b/common/mekanism/common/multipart/PartTransmitter.java @@ -79,6 +79,7 @@ public abstract class PartTransmitter> extends Pa getTransmitterNetwork().split((ITransmitter)tile()); setTransmitterNetwork(null); } + tile().notifyPartChange(this); redstonePowered = nowPowered; }