From 5ff388a888c72ee506be32dbcb96d48149ee25bf Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Wed, 4 Sep 2013 18:46:56 -0400 Subject: [PATCH] connection changes --- src/dark/api/fluid/INetworkFluidPart.java | 2 +- .../core/network/fluid/HydraulicNetworkHelper.java | 2 +- .../core/network/fluid/NetworkFluidContainers.java | 2 +- src/dark/core/network/fluid/NetworkFluidTiles.java | 2 +- src/dark/core/network/fluid/NetworkPipes.java | 2 +- src/dark/fluid/common/machines/BlockSink.java | 8 +++----- src/dark/fluid/common/machines/BlockTank.java | 2 +- .../fluid/common/machines/TileEntityReleaseValve.java | 11 +++++++---- src/dark/fluid/common/machines/TileEntityTank.java | 6 ++++-- .../fluid/common/pipes/TileEntityGenericPipe.java | 5 +++-- src/dark/fluid/common/pipes/TileEntityPipe.java | 9 +++++---- .../fluid/common/prefab/TileEntityFluidDevice.java | 4 ++-- .../fluid/common/prefab/TileEntityFluidStorage.java | 4 +++- .../fluid/common/pump/TileEntityConstructionPump.java | 9 +++++---- src/dark/fluid/common/pump/TileEntityDrain.java | 2 +- src/dark/fluid/common/pump/TileEntityStarterPump.java | 8 ++++---- 16 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/dark/api/fluid/INetworkFluidPart.java b/src/dark/api/fluid/INetworkFluidPart.java index 31a13af39..b1a09ee72 100644 --- a/src/dark/api/fluid/INetworkFluidPart.java +++ b/src/dark/api/fluid/INetworkFluidPart.java @@ -3,7 +3,7 @@ package dark.api.fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; -import dark.core.interfaces.INetworkPart; +import dark.api.parts.INetworkPart; import dark.core.interfaces.ColorCode.IColorCoded; public interface INetworkFluidPart extends IColorCoded, IFluidHandler, INetworkPart diff --git a/src/dark/core/network/fluid/HydraulicNetworkHelper.java b/src/dark/core/network/fluid/HydraulicNetworkHelper.java index 125b6f5d9..36add7656 100644 --- a/src/dark/core/network/fluid/HydraulicNetworkHelper.java +++ b/src/dark/core/network/fluid/HydraulicNetworkHelper.java @@ -4,7 +4,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.VectorHelper; -import dark.core.interfaces.INetworkPart; +import dark.api.parts.INetworkPart; import dark.core.prefab.tilenetwork.NetworkTileEntities; public class HydraulicNetworkHelper diff --git a/src/dark/core/network/fluid/NetworkFluidContainers.java b/src/dark/core/network/fluid/NetworkFluidContainers.java index c220a4db2..7976ea627 100644 --- a/src/dark/core/network/fluid/NetworkFluidContainers.java +++ b/src/dark/core/network/fluid/NetworkFluidContainers.java @@ -8,8 +8,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; import dark.api.fluid.INetworkFluidPart; +import dark.api.parts.INetworkPart; import dark.core.interfaces.ColorCode; -import dark.core.interfaces.INetworkPart; import dark.core.prefab.tilenetwork.NetworkTileEntities; /** Side note: the network should act like this when done {@link http diff --git a/src/dark/core/network/fluid/NetworkFluidTiles.java b/src/dark/core/network/fluid/NetworkFluidTiles.java index e6d80c923..5cab228d2 100644 --- a/src/dark/core/network/fluid/NetworkFluidTiles.java +++ b/src/dark/core/network/fluid/NetworkFluidTiles.java @@ -21,8 +21,8 @@ import universalelectricity.core.vector.Vector3; import dark.api.fluid.AdvancedFluidEvent; import dark.api.fluid.AdvancedFluidEvent.FluidMergeEvent; import dark.api.fluid.INetworkFluidPart; +import dark.api.parts.INetworkPart; import dark.core.interfaces.ColorCode; -import dark.core.interfaces.INetworkPart; import dark.core.prefab.helpers.FluidHelper; import dark.core.prefab.helpers.Pair; import dark.core.prefab.tilenetwork.NetworkTileEntities; diff --git a/src/dark/core/network/fluid/NetworkPipes.java b/src/dark/core/network/fluid/NetworkPipes.java index 00d4ed688..382b6e96e 100644 --- a/src/dark/core/network/fluid/NetworkPipes.java +++ b/src/dark/core/network/fluid/NetworkPipes.java @@ -10,8 +10,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import dark.api.fluid.INetworkPipe; +import dark.api.parts.INetworkPart; import dark.core.interfaces.ColorCode; -import dark.core.interfaces.INetworkPart; import dark.core.prefab.helpers.ConnectionHelper; import dark.core.prefab.helpers.FluidHelper; import dark.core.prefab.tilenetwork.NetworkTileEntities; diff --git a/src/dark/fluid/common/machines/BlockSink.java b/src/dark/fluid/common/machines/BlockSink.java index c92bf9ce5..255a6ac52 100644 --- a/src/dark/fluid/common/machines/BlockSink.java +++ b/src/dark/fluid/common/machines/BlockSink.java @@ -32,13 +32,11 @@ public class BlockSink extends BlockFM public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) { int meta = par1World.getBlockMetadata(x, y, z); - int g = MetaGroup.getGrouping(meta); - TileEntity ent = par1World.getBlockTileEntity(x, y, z); - int angle = MathHelper.floor_double((par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int metaGroup = MetaGroup.getGrouping(meta); - if (meta == (g * 4) + 3) + if (meta == (metaGroup * 4) + 3) { - par1World.setBlockMetadataWithNotify(x, y, z, (g * 4), 3); + par1World.setBlockMetadataWithNotify(x, y, z, (metaGroup * 4), 3); return true; } else diff --git a/src/dark/fluid/common/machines/BlockTank.java b/src/dark/fluid/common/machines/BlockTank.java index fbf31113c..3a78d685a 100644 --- a/src/dark/fluid/common/machines/BlockTank.java +++ b/src/dark/fluid/common/machines/BlockTank.java @@ -13,7 +13,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; -import dark.core.interfaces.INetworkPart; +import dark.api.parts.INetworkPart; import dark.core.prefab.helpers.AutoCraftingManager; import dark.core.prefab.helpers.FluidHelper; import dark.fluid.client.render.BlockRenderHelper; diff --git a/src/dark/fluid/common/machines/TileEntityReleaseValve.java b/src/dark/fluid/common/machines/TileEntityReleaseValve.java index 4a9ab2856..6c01deca5 100644 --- a/src/dark/fluid/common/machines/TileEntityReleaseValve.java +++ b/src/dark/fluid/common/machines/TileEntityReleaseValve.java @@ -3,6 +3,8 @@ package dark.fluid.common.machines; import java.util.ArrayList; import java.util.List; +import universalelectricity.core.vector.Vector3; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -10,10 +12,10 @@ import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; +import dark.api.IToolReadOut; import dark.api.fluid.INetworkPipe; +import dark.api.parts.ITileConnector; import dark.core.interfaces.ColorCode; -import dark.core.interfaces.ITileConnector; -import dark.core.interfaces.IToolReadOut; import dark.core.interfaces.ColorCode.IColorCoded; import dark.core.network.fluid.NetworkPipes; import dark.core.prefab.helpers.ConnectionHelper; @@ -105,7 +107,7 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi } /** if any of allowed list is true - * + * * @return true */ public boolean isRestricted() { @@ -159,8 +161,9 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) + public boolean canTileConnect(Connection type, ForgeDirection dir) { + TileEntity entity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); return entity != null && entity instanceof IFluidHandler && entity instanceof IColorCoded && this.canConnect(((IColorCoded) entity).getColor()); } diff --git a/src/dark/fluid/common/machines/TileEntityTank.java b/src/dark/fluid/common/machines/TileEntityTank.java index 7dec69033..674c78903 100644 --- a/src/dark/fluid/common/machines/TileEntityTank.java +++ b/src/dark/fluid/common/machines/TileEntityTank.java @@ -22,6 +22,7 @@ import net.minecraftforge.fluids.IFluidTank; import org.bouncycastle.util.Arrays; +import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.PacketManager; @@ -29,10 +30,10 @@ import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import dark.api.IToolReadOut; import dark.api.fluid.INetworkFluidPart; import dark.api.fluid.INetworkPipe; import dark.core.interfaces.ColorCode; -import dark.core.interfaces.IToolReadOut; import dark.core.interfaces.ColorCode.IColorCoded; import dark.core.network.fluid.NetworkFluidContainers; import dark.core.network.fluid.NetworkFluidTiles; @@ -250,8 +251,9 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) + public boolean canTileConnect(Connection type, ForgeDirection dir) { + TileEntity entity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); return entity != null && entity instanceof IFluidHandler; } diff --git a/src/dark/fluid/common/pipes/TileEntityGenericPipe.java b/src/dark/fluid/common/pipes/TileEntityGenericPipe.java index a19af0e01..bce4b1d64 100644 --- a/src/dark/fluid/common/pipes/TileEntityGenericPipe.java +++ b/src/dark/fluid/common/pipes/TileEntityGenericPipe.java @@ -24,8 +24,9 @@ public class TileEntityGenericPipe extends TileEntityPipe } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) + public boolean canTileConnect(Connection type, ForgeDirection dir) { + TileEntity entity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); Vector3 vec = new Vector3(entity); int meta = vec.getBlockMetadata(this.worldObj); int blockID = vec.getBlockID(this.worldObj); @@ -35,7 +36,7 @@ public class TileEntityGenericPipe extends TileEntityPipe return meta == this.getBlockMetadata(); } - return super.canTileConnect(entity, dir); + return super.canTileConnect(type, dir); } @Override diff --git a/src/dark/fluid/common/pipes/TileEntityPipe.java b/src/dark/fluid/common/pipes/TileEntityPipe.java index a7aecaf6f..9cabf4707 100644 --- a/src/dark/fluid/common/pipes/TileEntityPipe.java +++ b/src/dark/fluid/common/pipes/TileEntityPipe.java @@ -33,10 +33,10 @@ import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import dark.api.IToolReadOut; import dark.api.fluid.INetworkPipe; +import dark.api.parts.ITileConnector; import dark.core.interfaces.ColorCode; -import dark.core.interfaces.ITileConnector; -import dark.core.interfaces.IToolReadOut; import dark.core.interfaces.ColorCode.IColorCoded; import dark.core.network.fluid.NetworkPipes; import dark.core.prefab.helpers.FluidHelper; @@ -432,7 +432,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, } if (tileEntity instanceof ITileConnector) { - if (((ITileConnector) tileEntity).canTileConnect(this, side.getOpposite())) + if (((ITileConnector) tileEntity).canTileConnect(Connection.NETWORK, side.getOpposite())) { if (tileEntity instanceof INetworkPipe) { @@ -505,8 +505,9 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) + public boolean canTileConnect(Connection type, ForgeDirection dir) { + TileEntity entity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); return entity != null && this.subEntities[dir.ordinal()] == null; } diff --git a/src/dark/fluid/common/prefab/TileEntityFluidDevice.java b/src/dark/fluid/common/prefab/TileEntityFluidDevice.java index cc1b59678..f9fe8758b 100644 --- a/src/dark/fluid/common/prefab/TileEntityFluidDevice.java +++ b/src/dark/fluid/common/prefab/TileEntityFluidDevice.java @@ -5,8 +5,8 @@ import java.util.Random; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.ForgeDirection; import universalelectricity.prefab.tile.TileEntityAdvanced; -import dark.core.interfaces.ITileConnector; -import dark.core.interfaces.IToolReadOut; +import dark.api.IToolReadOut; +import dark.api.parts.ITileConnector; import dark.core.network.fluid.HydraulicNetworkHelper; public abstract class TileEntityFluidDevice extends TileEntityAdvanced implements IToolReadOut, ITileConnector diff --git a/src/dark/fluid/common/prefab/TileEntityFluidStorage.java b/src/dark/fluid/common/prefab/TileEntityFluidStorage.java index 25569dc4a..f8802f7fd 100644 --- a/src/dark/fluid/common/prefab/TileEntityFluidStorage.java +++ b/src/dark/fluid/common/prefab/TileEntityFluidStorage.java @@ -1,5 +1,6 @@ package dark.fluid.common.prefab; +import universalelectricity.core.vector.Vector3; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -34,8 +35,9 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) + public boolean canTileConnect(Connection type, ForgeDirection dir) { + TileEntity entity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); return entity instanceof IFluidHandler; } diff --git a/src/dark/fluid/common/pump/TileEntityConstructionPump.java b/src/dark/fluid/common/pump/TileEntityConstructionPump.java index a0de82594..9a9779429 100644 --- a/src/dark/fluid/common/pump/TileEntityConstructionPump.java +++ b/src/dark/fluid/common/pump/TileEntityConstructionPump.java @@ -16,7 +16,7 @@ import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.VectorHelper; import dark.api.fluid.IDrain; import dark.api.fluid.INetworkPipe; -import dark.core.interfaces.ITileConnector; +import dark.api.parts.ITileConnector; import dark.core.network.fluid.HydraulicNetworkHelper; import dark.core.network.fluid.NetworkFluidTiles; import dark.core.prefab.helpers.MetaGroup; @@ -36,7 +36,7 @@ public class TileEntityConstructionPump extends TileEntityStarterPump implements } /** Gets the facing direction - * + * * @param input true for input side, false for output side * @return */ public ForgeDirection getFacing(boolean input) @@ -78,7 +78,7 @@ public class TileEntityConstructionPump extends TileEntityStarterPump implements } /** Gets the nextDrain in the list - * + * * @param inputTile - input tile must be an instance of INetworkPipe * @param outputTile - output tile must be an instance of IFluidHandler * @param ignoreList - list of drains to ignore so that the next one is selected @@ -162,8 +162,9 @@ public class TileEntityConstructionPump extends TileEntityStarterPump implements } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) + public boolean canTileConnect(Connection type, ForgeDirection dir) { + TileEntity entity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); return entity instanceof IFluidHandler && (dir == this.getFacing(false) || dir == this.getFacing(true)); } diff --git a/src/dark/fluid/common/pump/TileEntityDrain.java b/src/dark/fluid/common/pump/TileEntityDrain.java index 1acaaf1c7..1138bd5d1 100644 --- a/src/dark/fluid/common/pump/TileEntityDrain.java +++ b/src/dark/fluid/common/pump/TileEntityDrain.java @@ -188,7 +188,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) + public boolean canTileConnect(Connection type, ForgeDirection dir) { return dir != this.getDirection(); } diff --git a/src/dark/fluid/common/pump/TileEntityStarterPump.java b/src/dark/fluid/common/pump/TileEntityStarterPump.java index 79ef3aace..17d9a52f4 100644 --- a/src/dark/fluid/common/pump/TileEntityStarterPump.java +++ b/src/dark/fluid/common/pump/TileEntityStarterPump.java @@ -11,9 +11,9 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; import universalelectricity.core.vector.Vector3; +import dark.api.IToolReadOut; import dark.api.fluid.IDrain; -import dark.core.interfaces.ITileConnector; -import dark.core.interfaces.IToolReadOut; +import dark.api.parts.ITileConnector; import dark.core.prefab.TileEntityMachine; import dark.core.prefab.helpers.FluidHelper; import dark.core.prefab.helpers.Pair; @@ -86,7 +86,7 @@ public class TileEntityStarterPump extends TileEntityMachine implements IToolRea } /** Drains an area starting at the given location - * + * * @param world - world to drain in, most cases will be the TileEntities world * @param loc - origin to start the path finder with. If this is an instance of IDrain this * method will act different */ @@ -212,7 +212,7 @@ public class TileEntityStarterPump extends TileEntityMachine implements IToolRea } @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection direction) + public boolean canTileConnect(Connection type, ForgeDirection direction) { return direction != ForgeDirection.DOWN; }