Last-minute recalculation for Diversion Transporters
This commit is contained in:
parent
028c6f8aea
commit
14259f2251
3 changed files with 44 additions and 20 deletions
|
@ -174,7 +174,20 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!stack.canInsertToTransporter(stack.getNext(this).getTileEntity(worldObj)))
|
TileEntity next = stack.getNext(this).getTileEntity(worldObj);
|
||||||
|
boolean recalculate = false;
|
||||||
|
|
||||||
|
if(!stack.canInsertToTransporter(next))
|
||||||
|
{
|
||||||
|
recalculate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!TransporterUtils.checkDiversionLogic(this, next, stack.getSide(this)))
|
||||||
|
{
|
||||||
|
recalculate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(recalculate)
|
||||||
{
|
{
|
||||||
if(!recalculate(stack, null))
|
if(!recalculate(stack, null))
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||||
import mekanism.common.transporter.TransporterPathfinder.Pathfinder.DestChecker;
|
import mekanism.common.transporter.TransporterPathfinder.Pathfinder.DestChecker;
|
||||||
import mekanism.common.transporter.TransporterStack.Path;
|
import mekanism.common.transporter.TransporterStack.Path;
|
||||||
import mekanism.common.util.InventoryUtils;
|
import mekanism.common.util.InventoryUtils;
|
||||||
|
import mekanism.common.util.TransporterUtils;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -433,27 +434,10 @@ public final class TransporterPathfinder
|
||||||
|
|
||||||
TileEntity currTile = currentNode.getTileEntity(worldObj);
|
TileEntity currTile = currentNode.getTileEntity(worldObj);
|
||||||
|
|
||||||
if(currTile instanceof TileEntityDiversionTransporter)
|
if(!TransporterUtils.checkDiversionLogic(currTile, tile, i))
|
||||||
{
|
|
||||||
int mode = ((TileEntityDiversionTransporter)currTile).modes[i];
|
|
||||||
boolean redstone = currTile.worldObj.isBlockIndirectlyGettingPowered(currTile.xCoord, currTile.yCoord, currTile.zCoord);
|
|
||||||
|
|
||||||
if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(tile instanceof TileEntityDiversionTransporter)
|
|
||||||
{
|
|
||||||
int mode = ((TileEntityDiversionTransporter)tile).modes[ForgeDirection.getOrientation(i).getOpposite().ordinal()];
|
|
||||||
boolean redstone = tile.worldObj.isBlockIndirectlyGettingPowered(tile.xCoord, tile.yCoord, tile.zCoord);
|
|
||||||
|
|
||||||
if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor))
|
if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor))
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,6 +214,33 @@ public final class TransporterUtils
|
||||||
return colors.get(colors.indexOf(color)+1);
|
return colors.get(colors.indexOf(color)+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkDiversionLogic(TileEntity currTile, TileEntity tile, int side)
|
||||||
|
{
|
||||||
|
if(currTile instanceof TileEntityDiversionTransporter)
|
||||||
|
{
|
||||||
|
int mode = ((TileEntityDiversionTransporter)currTile).modes[side];
|
||||||
|
boolean redstone = currTile.worldObj.isBlockIndirectlyGettingPowered(currTile.xCoord, currTile.yCoord, currTile.zCoord);
|
||||||
|
|
||||||
|
if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tile instanceof TileEntityDiversionTransporter)
|
||||||
|
{
|
||||||
|
int mode = ((TileEntityDiversionTransporter)tile).modes[ForgeDirection.getOrientation(side).getOpposite().ordinal()];
|
||||||
|
boolean redstone = tile.worldObj.isBlockIndirectlyGettingPowered(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||||
|
|
||||||
|
if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void drop(TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
public static void drop(TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
||||||
{
|
{
|
||||||
float[] pos = null;
|
float[] pos = null;
|
||||||
|
|
Loading…
Reference in a new issue