Added a delay to Digital Miner eject, have multipart Logistical Transporters drop contents when broken, fixed transporters insertion logic

This commit is contained in:
Aidan C. Brady 2013-12-25 17:43:44 -05:00
parent 7010f03b65
commit 047ead8d09
2 changed files with 26 additions and 6 deletions
common/mekanism/common

View file

@ -417,13 +417,13 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
stack.homeLocation = original; stack.homeLocation = original;
stack.color = color; stack.color = color;
ItemStack rejected = stack.recalculatePath(this, min);
if(!canReceiveFrom(original.getTileEntity(world()), ForgeDirection.getOrientation(stack.getSide(this))) || !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; return itemStack;
} }
ItemStack rejected = stack.recalculatePath(this, min);
if(TransporterManager.didEmit(stack.itemStack, rejected)) if(TransporterManager.didEmit(stack.itemStack, rejected))
{ {
stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected);
@ -447,13 +447,13 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
stack.homeLocation = Coord4D.get(outputter); stack.homeLocation = Coord4D.get(outputter);
stack.color = color; stack.color = color;
ItemStack rejected = stack.recalculateRRPath(outputter, this, min);
if(!canReceiveFrom(outputter, ForgeDirection.getOrientation(stack.getSide(this))) || !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; return itemStack;
} }
ItemStack rejected = stack.recalculateRRPath(outputter, this, min);
if(TransporterManager.didEmit(stack.itemStack, rejected)) if(TransporterManager.didEmit(stack.itemStack, rejected))
{ {
stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected);
@ -788,6 +788,18 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
return getConnectionType(side) == ConnectionType.NORMAL; return getConnectionType(side) == ConnectionType.NORMAL;
} }
@Override
public void onRemoved()
{
if(!world().isRemote)
{
for(TransporterStack stack : transit)
{
TransporterUtils.drop(this, stack);
}
}
}
@Override @Override
public int getPriority() public int getPriority()
{ {

View file

@ -86,6 +86,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
public double prevEnergy; public double prevEnergy;
public int delayTicks;
public boolean initCalc = false; public boolean initCalc = false;
/** This machine's current RedstoneControl type. */ /** This machine's current RedstoneControl type. */
@ -209,7 +211,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
} }
} }
if(doEject && getTopEject(false, null) != null && getEjectInv() != null) if(doEject && delayTicks == 0 && getTopEject(false, null) != null && getEjectInv() != null)
{ {
if(getEjectInv() instanceof IInventory) if(getEjectInv() instanceof IInventory)
{ {
@ -220,12 +222,18 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
else if(getEjectInv() instanceof ILogisticalTransporter) else if(getEjectInv() instanceof ILogisticalTransporter)
{ {
ItemStack rejected = TransporterUtils.insert(getEjectTile(), (ILogisticalTransporter)getEjectInv(), getTopEject(false, null), null, true, 0); ItemStack rejected = TransporterUtils.insert(getEjectTile(), (ILogisticalTransporter)getEjectInv(), getTopEject(false, null), null, true, 0);
System.out.println(rejected + " " + (rejected != null ? rejected.stackSize : 0));
if(TransporterManager.didEmit(getTopEject(false, null), rejected)) if(TransporterManager.didEmit(getTopEject(false, null), rejected))
{ {
getTopEject(true, rejected); getTopEject(true, rejected);
} }
} }
delayTicks = 10;
}
else if(delayTicks > 0)
{
delayTicks--;
} }
if(playersUsing.size() > 0) if(playersUsing.size() > 0)