Cleaned up multipart transmitter code a bit, fixed a chunk-related connection issue
This commit is contained in:
parent
934f136d4f
commit
c3ce0cc58d
7 changed files with 22 additions and 43 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,11 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
|
|||
{
|
||||
byte connections = 0x00;
|
||||
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return connections;
|
||||
}
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(canConnectMutual(side))
|
||||
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue