Got things working

This commit is contained in:
Aidan Brady 2013-12-21 01:13:09 -05:00
parent 5c3943bd5d
commit f2a3923c18
8 changed files with 88 additions and 19 deletions

View file

@ -22,7 +22,11 @@ public interface ILogisticalTransporter
public TileEntity getTile();
boolean canConnect(TileEntity tileEntity, ForgeDirection side);
boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side);
public boolean canConnectMutual(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);
}

View file

@ -130,9 +130,9 @@ public class PartDiversionTransporter extends PartLogisticalTransporter
}
@Override
public boolean canConnect(TileEntity tileEntity, ForgeDirection side)
public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side)
{
if(!super.canConnect(tileEntity, side))
if(!super.canTransporterConnect(tileEntity, side))
{
return false;
}

View file

@ -113,7 +113,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
{
ILogisticalTransporter transporter = (ILogisticalTransporter)tileEntity;
if(canConnectMutual(tileEntity, side) && (getColor() == null || transporter.getColor() == null || getColor() == transporter.getColor()))
if(canTransporterConnectMutual(tileEntity, side) && (getColor() == null || transporter.getColor() == null || getColor() == transporter.getColor()))
{
connections |= 1 << side.ordinal();
}
@ -365,7 +365,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
stack.homeLocation = original;
stack.color = color;
if(!stack.canInsertToTransporter(tile(), ForgeDirection.getOrientation(stack.getSide(this))))
if(!canReceiveFrom(original.getTileEntity(world()), ForgeDirection.getOrientation(stack.getSide(this))) || !stack.canInsertToTransporter(tile(), ForgeDirection.getOrientation(stack.getSide(this))))
{
return itemStack;
}
@ -395,7 +395,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
stack.homeLocation = Coord4D.get(outputter);
stack.color = color;
if(!stack.canInsertToTransporter(tile(), ForgeDirection.getOrientation(stack.getSide(this))))
if(!canReceiveFrom(outputter, ForgeDirection.getOrientation(stack.getSide(this))) || !stack.canInsertToTransporter(tile(), ForgeDirection.getOrientation(stack.getSide(this))))
{
return itemStack;
}
@ -690,22 +690,22 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
}
@Override
public boolean canConnect(TileEntity tileEntity, ForgeDirection side)
public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side)
{
return true;
return canConnect(side);
}
@Override
public boolean canConnectMutual(TileEntity tileEntity, ForgeDirection side)
public boolean canTransporterConnectMutual(TileEntity tileEntity, ForgeDirection side)
{
if(!canConnect(tileEntity, side))
if(!canTransporterConnect(tileEntity, side))
{
return false;
}
if(tileEntity instanceof ILogisticalTransporter)
{
if(!((ILogisticalTransporter)tileEntity).canConnect(tile(), side.getOpposite()))
if(!((ILogisticalTransporter)tileEntity).canTransporterConnect(tile(), side.getOpposite()))
{
return false;
}
@ -713,4 +713,26 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
return true;
}
@Override
public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side)
{
if(!canTransporterConnect(tileEntity, side))
{
return false;
}
return getConnectionType(side) == ConnectionType.NORMAL || getConnectionType(side) == ConnectionType.PUSH;
}
@Override
public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side)
{
if(!canTransporterConnect(tileEntity, side))
{
return false;
}
return getConnectionType(side) == ConnectionType.NORMAL;
}
}

View file

@ -11,7 +11,9 @@ import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent;
import net.minecraftforge.common.ForgeDirection;
import com.google.common.io.ByteArrayDataInput;
@ -104,4 +106,23 @@ public class TileEntityDiversionTransporter extends TileEntityLogisticalTranspor
return true;
}
@Override
public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side)
{
if(!super.canTransporterConnect(tileEntity, side))
{
return false;
}
int mode = modes[side.ordinal()];
boolean redstone = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
{
return false;
}
return true;
}
}

View file

@ -247,7 +247,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
stack.homeLocation = original;
stack.color = color;
if(!stack.canInsertToTransporter(this, ForgeDirection.getOrientation(stack.getSide(this))))
if(!canReceiveFrom(original.getTileEntity(worldObj), ForgeDirection.getOrientation(stack.getSide(this))) || !stack.canInsertToTransporter(this, ForgeDirection.getOrientation(stack.getSide(this))))
{
return itemStack;
}
@ -277,7 +277,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
stack.homeLocation = Coord4D.get(outputter);
stack.color = color;
if(!stack.canInsertToTransporter(this, ForgeDirection.getOrientation(stack.getSide(this))))
if(!canReceiveFrom(outputter, ForgeDirection.getOrientation(stack.getSide(this))) || !stack.canInsertToTransporter(this, ForgeDirection.getOrientation(stack.getSide(this))))
{
return itemStack;
}
@ -570,14 +570,36 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
}
@Override
public boolean canConnect(TileEntity tileEntity, ForgeDirection side)
public boolean canTransporterConnect(TileEntity tileEntity, ForgeDirection side)
{
return true;
}
@Override
public boolean canConnectMutual(TileEntity tileEntity, ForgeDirection side)
public boolean canTransporterConnectMutual(TileEntity tileEntity, ForgeDirection side)
{
return true;
}
@Override
public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side)
{
if(!canTransporterConnect(tileEntity, side))
{
return false;
}
return true;
}
@Override
public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side)
{
if(!canTransporterConnect(tileEntity, side))
{
return false;
}
return true;
}
}

View file

@ -199,7 +199,7 @@ public final class TransporterPathfinder
{
ILogisticalTransporter trans = (ILogisticalTransporter)pointer.getTileEntity(worldObj);
if(!trans.canConnectMutual(tile, side))
if(!trans.canEmitTo(tile, side))
{
continue;
}

View file

@ -279,7 +279,7 @@ public class TransporterStack
TileEntity from = Coord4D.get(tileEntity).getFromSide(side.getOpposite()).getTileEntity(tileEntity.worldObj);
ILogisticalTransporter transporter = (ILogisticalTransporter)tileEntity;
if(!transporter.canConnectMutual(from, side.getOpposite()))
if(!transporter.canTransporterConnectMutual(from, side.getOpposite()))
{
return false;
}

View file

@ -121,7 +121,7 @@ public final class TransporterUtils
{
int side = Arrays.asList(connectedTransporters).indexOf(tile);
if(tileEntity.canConnectMutual(tile, ForgeDirection.getOrientation(side)))
if(tileEntity.canTransporterConnectMutual(tile, ForgeDirection.getOrientation(side)))
{
connectable[side] = true;
}