diff --git a/src/main/java/api/hbm/energy/IEnergyConnector.java b/src/main/java/api/hbm/energy/IEnergyConnector.java index a560a6737..7045ef1d0 100644 --- a/src/main/java/api/hbm/energy/IEnergyConnector.java +++ b/src/main/java/api/hbm/energy/IEnergyConnector.java @@ -26,6 +26,7 @@ public interface IEnergyConnector extends ILoadedTile { /** * Whether the given side can be connected to + * dir refers to the side of this block, not the connecting block doing the check * @param dir * @return */ diff --git a/src/main/java/api/hbm/energy/IEnergyUser.java b/src/main/java/api/hbm/energy/IEnergyUser.java index 002dca53f..a4a0a4ed5 100644 --- a/src/main/java/api/hbm/energy/IEnergyUser.java +++ b/src/main/java/api/hbm/energy/IEnergyUser.java @@ -58,7 +58,7 @@ public interface IEnergyUser extends IEnergyConnector { if(te instanceof IEnergyConductor) { IEnergyConductor con = (IEnergyConductor) te; - if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this)) { + if(con.canConnect(dir.getOpposite()) && con.getPowerNet() != null && con.getPowerNet().isSubscribed(this)) { con.getPowerNet().unsubscribe(this); wasSubscribed = true; } @@ -105,7 +105,8 @@ public interface IEnergyUser extends IEnergyConnector { public default void updateStandardConnections(World world, int x, int y, int z) { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { this.trySubscribe(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir); + } } } diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKLoader.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKLoader.java index 8b566a481..52955a187 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKLoader.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKLoader.java @@ -18,8 +18,8 @@ public class RBMKLoader extends BlockGeneric implements IFluidConnectorBlock { @Override public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir) { - if(type.hasTrait(FT_Heatable.class)) return dir == ForgeDirection.DOWN; - return type.hasTrait(FT_Coolable.class) && dir != ForgeDirection.DOWN; + if(dir == ForgeDirection.UP) return type.hasTrait(FT_Heatable.class); + return type.hasTrait(FT_Coolable.class); } } diff --git a/src/main/java/com/hbm/lib/Library.java b/src/main/java/com/hbm/lib/Library.java index 90d63b9dc..e1858d75c 100644 --- a/src/main/java/com/hbm/lib/Library.java +++ b/src/main/java/com/hbm/lib/Library.java @@ -107,25 +107,26 @@ public class Library { /* * Is putting this into this trash can a good idea? No. Do I have a better idea? Not currently. */ - public static boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir) { + public static boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir /* cable's connecting side */) { if(y > 255 || y < 0) return false; Block b = world.getBlock(x, y, z); - TileEntity te = world.getTileEntity(x, y, z); if(b instanceof IEnergyConnectorBlock) { IEnergyConnectorBlock con = (IEnergyConnectorBlock) b; - if(con.canConnect(world, x, y, z, dir)) + if(con.canConnect(world, x, y, z, dir.getOpposite() /* machine's connecting side */)) return true; } + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof IEnergyConnector) { IEnergyConnector con = (IEnergyConnector) te; - if(con.canConnect(dir)) + if(con.canConnect(dir.getOpposite() /* machine's connecting side */)) return true; } @@ -133,25 +134,26 @@ public class Library { } /** dir is the direction along the fluid duct entering the block */ - public static boolean canConnectFluid(IBlockAccess world, int x, int y, int z, ForgeDirection dir, FluidType type) { + public static boolean canConnectFluid(IBlockAccess world, int x, int y, int z, ForgeDirection dir /* duct's connecting side */, FluidType type) { if(y > 255 || y < 0) return false; Block b = world.getBlock(x, y, z); - TileEntity te = world.getTileEntity(x, y, z); if(b instanceof IFluidConnectorBlock) { IFluidConnectorBlock con = (IFluidConnectorBlock) b; - if(con.canConnect(type, world, x, y, z, dir.getOpposite())) + if(con.canConnect(type, world, x, y, z, dir.getOpposite() /* machine's connecting side */)) return true; } + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof IFluidConnector) { IFluidConnector con = (IFluidConnector) te; - if(con.canConnect(type, dir.getOpposite())) + if(con.canConnect(type, dir.getOpposite() /* machine's connecting side */)) return true; } diff --git a/src/main/java/com/hbm/render/block/RenderCable.java b/src/main/java/com/hbm/render/block/RenderCable.java index 62683e60a..7f69aa02e 100644 --- a/src/main/java/com/hbm/render/block/RenderCable.java +++ b/src/main/java/com/hbm/render/block/RenderCable.java @@ -56,12 +56,12 @@ public class RenderCable implements ISimpleBlockRenderingHandler { tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tessellator.setColorOpaque_F(1, 1, 1); - boolean pX = Library.canConnect(world, x + 1, y, z, Library.NEG_X); - boolean nX = Library.canConnect(world, x - 1, y, z, Library.POS_X); - boolean pY = Library.canConnect(world, x, y + 1, z, Library.NEG_Y); - boolean nY = Library.canConnect(world, x, y - 1, z, Library.POS_Y); - boolean pZ = Library.canConnect(world, x, y, z + 1, Library.NEG_Z); - boolean nZ = Library.canConnect(world, x, y, z - 1, Library.POS_Z); + boolean pX = Library.canConnect(world, x + 1, y, z, Library.POS_X); + boolean nX = Library.canConnect(world, x - 1, y, z, Library.NEG_X); + boolean pY = Library.canConnect(world, x, y + 1, z, Library.POS_Y); + boolean nY = Library.canConnect(world, x, y - 1, z, Library.NEG_Y); + boolean pZ = Library.canConnect(world, x, y, z + 1, Library.POS_Z); + boolean nZ = Library.canConnect(world, x, y, z - 1, Library.NEG_Z); tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F); diff --git a/src/main/java/com/hbm/render/block/RenderTestPipe.java b/src/main/java/com/hbm/render/block/RenderTestPipe.java index 30958f977..770e2ed7f 100644 --- a/src/main/java/com/hbm/render/block/RenderTestPipe.java +++ b/src/main/java/com/hbm/render/block/RenderTestPipe.java @@ -81,12 +81,12 @@ public class RenderTestPipe implements ISimpleBlockRenderingHandler { tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tessellator.setColorOpaque_F(1, 1, 1); - boolean pX = Library.canConnectFluid(world, x + 1, y, z, Library.NEG_X, type); - boolean nX = Library.canConnectFluid(world, x - 1, y, z, Library.POS_X, type); - boolean pY = Library.canConnectFluid(world, x, y + 1, z, Library.NEG_Y, type); - boolean nY = Library.canConnectFluid(world, x, y - 1, z, Library.POS_Y, type); - boolean pZ = Library.canConnectFluid(world, x, y, z + 1, Library.NEG_Z, type); - boolean nZ = Library.canConnectFluid(world, x, y, z - 1, Library.POS_Z, type); + boolean pX = Library.canConnectFluid(world, x + 1, y, z, Library.POS_X, type); + boolean nX = Library.canConnectFluid(world, x - 1, y, z, Library.NEG_X, type); + boolean pY = Library.canConnectFluid(world, x, y + 1, z, Library.POS_Y, type); + boolean nY = Library.canConnectFluid(world, x, y - 1, z, Library.NEG_Y, type); + boolean pZ = Library.canConnectFluid(world, x, y, z + 1, Library.POS_Z, type); + boolean nZ = Library.canConnectFluid(world, x, y, z - 1, Library.NEG_Z, type); int mask = 0 + (pX ? 32 : 0) + (nX ? 16 : 0) + (pY ? 8 : 0) + (nY ? 4 : 0) + (pZ ? 2 : 0) + (nZ ? 1 : 0); diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java index f6a4d9f09..6c41047f2 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java @@ -206,7 +206,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I //if it's a cable, buffer both the network and all subscribers of the net if(te instanceof IEnergyConductor) { IEnergyConductor con = (IEnergyConductor) te; - if(con.getPowerNet() != null) { + if(con.canConnect(dir.getOpposite()) && con.getPowerNet() != null) { nets.add(con.getPowerNet()); con.getPowerNet().unsubscribe(this); consumers.addAll(con.getPowerNet().getSubscribers()); diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCableBaseNT.java b/src/main/java/com/hbm/tileentity/network/TileEntityCableBaseNT.java index 63216f451..71b37ab3c 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCableBaseNT.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCableBaseNT.java @@ -72,7 +72,7 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto @Override public boolean canConnect(ForgeDirection dir) { - return true; + return dir != ForgeDirection.UNKNOWN; } @Override diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityConnector.java b/src/main/java/com/hbm/tileentity/network/TileEntityConnector.java index 18908ba92..97943f1bf 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityConnector.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityConnector.java @@ -3,6 +3,8 @@ package com.hbm.tileentity.network; import java.util.ArrayList; import java.util.List; +import api.hbm.energy.IEnergyConductor; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; @@ -27,14 +29,32 @@ public class TileEntityConnector extends TileEntityPylonBase { public List getConnectionPoints() { List pos = new ArrayList(connected); - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - pos.add(new int[] {xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ}); + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite(); + //pos.add(new int[] {xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ}); + + TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord); + + if(te instanceof IEnergyConductor) { + + IEnergyConductor conductor = (IEnergyConductor) te; + + if(conductor.canConnect(dir.getOpposite())) { + + if(this.getPowerNet() == null && conductor.getPowerNet() != null) { + conductor.getPowerNet().joinLink(this); + } + + if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) { + conductor.getPowerNet().joinNetworks(this.getPowerNet()); + } + } } + return pos; } @Override public boolean canConnect(ForgeDirection dir) { //i've about had it with your fucking bullshit - return true; + return ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite() == dir; } } diff --git a/src/main/resources/assets/hbm/textures/items/chem_icon_NITRIC_ACID.png b/src/main/resources/assets/hbm/textures/items/chem_icon_NITRIC_ACID.png new file mode 100644 index 000000000..fa0bcdc67 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/chem_icon_NITRIC_ACID.png differ diff --git a/src/main/resources/assets/hbm/textures/items/chem_icon_SOLVENT.png b/src/main/resources/assets/hbm/textures/items/chem_icon_SOLVENT.png new file mode 100644 index 000000000..16dee86f2 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/chem_icon_SOLVENT.png differ