From c3ce0cc58df41e3f04503ed75f6b9cae381e559a Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Thu, 26 Dec 2013 02:05:25 -0500 Subject: [PATCH] Cleaned up multipart transmitter code a bit, fixed a chunk-related connection issue --- .../common/ILogisticalTransporter.java | 7 +--- .../multipart/PartDiversionTransporter.java | 4 +- .../multipart/PartLogisticalTransporter.java | 38 +++++-------------- .../TileEntityDiversionTransporter.java | 4 +- .../TileEntityLogisticalTransporter.java | 8 ++-- .../common/transporter/TransporterStack.java | 2 +- .../common/util/TransporterUtils.java | 2 +- 7 files changed, 22 insertions(+), 43 deletions(-) diff --git a/common/mekanism/common/ILogisticalTransporter.java b/common/mekanism/common/ILogisticalTransporter.java index 677063672..42ca76c73 100644 --- a/common/mekanism/common/ILogisticalTransporter.java +++ b/common/mekanism/common/ILogisticalTransporter.java @@ -2,13 +2,14 @@ package mekanism.common; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.transmitters.IBlockableConnection; import mekanism.common.tileentity.TileEntityLogisticalSorter; import mekanism.common.transporter.TransporterStack; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; -public interface ILogisticalTransporter +public interface ILogisticalTransporter extends IBlockableConnection { public ItemStack insert(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min); @@ -22,10 +23,6 @@ public interface ILogisticalTransporter public TileEntity getTile(); - boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side); - - public boolean canTransporterConnectMutual(TileEntity tileEntity, ForgeDirection side); - public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side); public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side); diff --git a/common/mekanism/common/multipart/PartDiversionTransporter.java b/common/mekanism/common/multipart/PartDiversionTransporter.java index 7b77e5daa..439d9b5ea 100644 --- a/common/mekanism/common/multipart/PartDiversionTransporter.java +++ b/common/mekanism/common/multipart/PartDiversionTransporter.java @@ -130,9 +130,9 @@ public class PartDiversionTransporter extends PartLogisticalTransporter } @Override - public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side) + public boolean canConnect(ForgeDirection side) { - if(!super.canTransporterConnect(tileEntity, side)) + if(!super.canConnect(side)) { return false; } diff --git a/common/mekanism/common/multipart/PartLogisticalTransporter.java b/common/mekanism/common/multipart/PartLogisticalTransporter.java index 627b523cd..b792405e9 100644 --- a/common/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/common/mekanism/common/multipart/PartLogisticalTransporter.java @@ -108,6 +108,11 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti public byte getPossibleTransmitterConnections() { byte connections = 0x00; + + if(world().isBlockIndirectlyGettingPowered(x(), y(), z())) + { + return connections; + } for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { @@ -119,7 +124,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { ILogisticalTransporter transporter = (ILogisticalTransporter)tileEntity; - if(canTransporterConnectMutual(tileEntity, side) && (getColor() == null || transporter.getColor() == null || getColor() == transporter.getColor())) + if(getColor() == null || transporter.getColor() == null || getColor() == transporter.getColor()) { connections |= 1 << side.ordinal(); } @@ -746,35 +751,10 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti return color; } - @Override - public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side) - { - return canConnect(side); - } - - @Override - public boolean canTransporterConnectMutual(TileEntity tileEntity, ForgeDirection side) - { - if(!canTransporterConnect(tileEntity, side)) - { - return false; - } - - if(tileEntity instanceof ILogisticalTransporter) - { - if(!((ILogisticalTransporter)tileEntity).canTransporterConnect(tile(), side.getOpposite())) - { - return false; - } - } - - return true; - } - @Override public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side) { - if(!canTransporterConnect(tileEntity, side)) + if(!canConnect(side)) { return false; } @@ -785,7 +765,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti @Override public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side) { - if(!canTransporterConnect(tileEntity, side)) + if(!canConnect(side)) { return false; } @@ -796,6 +776,8 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti @Override public void onRemoved() { + super.onRemoved(); + if(!world().isRemote) { for(TransporterStack stack : transit) diff --git a/common/mekanism/common/tileentity/TileEntityDiversionTransporter.java b/common/mekanism/common/tileentity/TileEntityDiversionTransporter.java index 001d4797c..f4f07968d 100644 --- a/common/mekanism/common/tileentity/TileEntityDiversionTransporter.java +++ b/common/mekanism/common/tileentity/TileEntityDiversionTransporter.java @@ -108,9 +108,9 @@ public class TileEntityDiversionTransporter extends TileEntityLogisticalTranspor } @Override - public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side) + public boolean canConnect(ForgeDirection side) { - if(!super.canTransporterConnect(tileEntity, side)) + if(!super.canConnect(side)) { return false; } diff --git a/common/mekanism/common/tileentity/TileEntityLogisticalTransporter.java b/common/mekanism/common/tileentity/TileEntityLogisticalTransporter.java index 1b6acdad6..233f8e86a 100644 --- a/common/mekanism/common/tileentity/TileEntityLogisticalTransporter.java +++ b/common/mekanism/common/tileentity/TileEntityLogisticalTransporter.java @@ -570,13 +570,13 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile } @Override - public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side) + public boolean canConnect(ForgeDirection side) { return true; } @Override - public boolean canTransporterConnectMutual(TileEntity tileEntity, ForgeDirection side) + public boolean canConnectMutual(ForgeDirection side) { return true; } @@ -584,7 +584,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile @Override public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side) { - if(!canTransporterConnect(tileEntity, side)) + if(!canConnect(side)) { return false; } @@ -595,7 +595,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile @Override public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side) { - if(!canTransporterConnect(tileEntity, side)) + if(!canConnect(side)) { return false; } diff --git a/common/mekanism/common/transporter/TransporterStack.java b/common/mekanism/common/transporter/TransporterStack.java index 095922b4b..b649504e9 100644 --- a/common/mekanism/common/transporter/TransporterStack.java +++ b/common/mekanism/common/transporter/TransporterStack.java @@ -279,7 +279,7 @@ public class TransporterStack TileEntity from = Coord4D.get(tileEntity).getFromSide(side.getOpposite()).getTileEntity(tileEntity.worldObj); ILogisticalTransporter transporter = (ILogisticalTransporter)tileEntity; - if(!transporter.canTransporterConnectMutual(from, side.getOpposite())) + if(!transporter.canConnectMutual(side.getOpposite())) { return false; } diff --git a/common/mekanism/common/util/TransporterUtils.java b/common/mekanism/common/util/TransporterUtils.java index 5ae3ac3d9..cce0431ca 100644 --- a/common/mekanism/common/util/TransporterUtils.java +++ b/common/mekanism/common/util/TransporterUtils.java @@ -121,7 +121,7 @@ public final class TransporterUtils { int side = Arrays.asList(connectedTransporters).indexOf(tile); - if(tileEntity.canTransporterConnectMutual(tile, ForgeDirection.getOrientation(side))) + if(tileEntity.canConnectMutual(ForgeDirection.getOrientation(side))) { connectable[side] = true; }