Pipes shouldn't reorient if neighbor unloaded
This commit is contained in:
parent
acd3eb1af4
commit
2f5a61217f
9 changed files with 48 additions and 16 deletions
|
@ -80,6 +80,12 @@ public final class TileBuffer {
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
if(tile != null && !tile.isInvalid())
|
||||
return true;
|
||||
return world.blockExists(x, y, z);
|
||||
}
|
||||
|
||||
public static TileBuffer[] makeBuffer(World world, int x, int y, int z, boolean loadUnloaded) {
|
||||
TileBuffer[] buffer = new TileBuffer[6];
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
|
|
@ -377,7 +377,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
private TileBuffer[] getTileCache() {
|
||||
public TileBuffer[] getTileCache() {
|
||||
if (tileBuffer == null && pipe != null)
|
||||
tileBuffer = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, pipe.transport.delveIntoUnloadedChunks());
|
||||
return tileBuffer;
|
||||
|
|
|
@ -26,8 +26,7 @@ public class PipeFluidsIron extends Pipe<PipeTransportFluids> {
|
|||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllIron_Solid.ordinal();
|
||||
private PipeLogicIron logic = new PipeLogicIron(this) {
|
||||
@Override
|
||||
protected boolean isValidFacing(ForgeDirection facing) {
|
||||
TileEntity tile = pipe.container.getTile(facing);
|
||||
protected boolean isValidConnectingTile(TileEntity tile) {
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
Pipe otherPipe = ((TileGenericPipe) tile).pipe;
|
||||
if (otherPipe instanceof PipeFluidsWood || otherPipe instanceof PipeStructureCobblestone)
|
||||
|
|
|
@ -14,6 +14,7 @@ import buildcraft.api.power.PowerHandler;
|
|||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.TileBuffer;
|
||||
import buildcraft.core.network.TileNetworkData;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
|
@ -39,8 +40,7 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IPowerR
|
|||
boolean lastPower = false;
|
||||
private PipeLogicWood logic = new PipeLogicWood(this) {
|
||||
@Override
|
||||
protected boolean isValidFacing(ForgeDirection facing) {
|
||||
TileEntity tile = pipe.container.getTile(facing);
|
||||
protected boolean isValidConnectingTile(TileEntity tile) {
|
||||
if (!(tile instanceof IFluidHandler))
|
||||
return false;
|
||||
if (!PipeManager.canExtractFluids(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord))
|
||||
|
|
|
@ -43,8 +43,7 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements IPipeT
|
|||
private int color = EnumColor.WHITE.ordinal();
|
||||
private PipeLogicIron logic = new PipeLogicIron(this) {
|
||||
@Override
|
||||
protected boolean isValidFacing(ForgeDirection facing) {
|
||||
TileEntity tile = pipe.container.getTile(facing);
|
||||
protected boolean isValidConnectingTile(TileEntity tile) {
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
Pipe otherPipe = ((TileGenericPipe) tile).pipe;
|
||||
if (otherPipe instanceof PipeItemsWood)
|
||||
|
|
|
@ -32,8 +32,7 @@ public class PipeItemsIron extends Pipe<PipeTransportItems> {
|
|||
private int solidIconIndex = PipeIconProvider.TYPE.PipeAllIron_Solid.ordinal();
|
||||
private PipeLogicIron logic = new PipeLogicIron(this) {
|
||||
@Override
|
||||
protected boolean isValidFacing(ForgeDirection facing) {
|
||||
TileEntity tile = pipe.container.getTile(facing);
|
||||
protected boolean isValidConnectingTile(TileEntity tile) {
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
Pipe otherPipe = ((TileGenericPipe) tile).pipe;
|
||||
if (otherPipe instanceof PipeItemsWood)
|
||||
|
|
|
@ -16,6 +16,7 @@ import buildcraft.api.power.PowerHandler;
|
|||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.TileBuffer;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
import buildcraft.core.inventory.InventoryWrapper;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
@ -38,8 +39,7 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IPowerRec
|
|||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal();
|
||||
private PipeLogicWood logic = new PipeLogicWood(this) {
|
||||
@Override
|
||||
protected boolean isValidFacing(ForgeDirection facing) {
|
||||
TileEntity tile = pipe.container.getTile(facing);
|
||||
protected boolean isValidConnectingTile(TileEntity tile) {
|
||||
if (!(tile instanceof IInventory))
|
||||
return false;
|
||||
if (!PipeManager.canExtractItems(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord))
|
||||
|
@ -136,7 +136,7 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IPowerRec
|
|||
|
||||
entityPos.moveForwards(0.6);
|
||||
|
||||
TravelingItem entity = new TravelingItem( entityPos.x, entityPos.y, entityPos.z, stack);
|
||||
TravelingItem entity = new TravelingItem(entityPos.x, entityPos.y, entityPos.z, stack);
|
||||
|
||||
transport.injectItem(entity, entityPos.orientation);
|
||||
}
|
||||
|
@ -179,9 +179,9 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IPowerRec
|
|||
}
|
||||
|
||||
public ItemStack checkExtractGeneric(ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
if(inventory == null)
|
||||
if (inventory == null)
|
||||
return null;
|
||||
|
||||
|
||||
for (int k : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack slot = inventory.getStackInSlot(k);
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.TileBuffer;
|
||||
import buildcraft.transport.Pipe;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public abstract class PipeLogicIron {
|
||||
|
@ -43,7 +45,20 @@ public abstract class PipeLogicIron {
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract boolean isValidFacing(ForgeDirection facing);
|
||||
|
||||
private boolean isValidFacing(ForgeDirection side) {
|
||||
TileBuffer[] tileBuffer = pipe.container.getTileCache();
|
||||
if (tileBuffer == null)
|
||||
return true;
|
||||
|
||||
if (!tileBuffer[side.ordinal()].exists())
|
||||
return true;
|
||||
|
||||
TileEntity tile = tileBuffer[side.ordinal()].getTile();
|
||||
return isValidConnectingTile(tile);
|
||||
}
|
||||
|
||||
protected abstract boolean isValidConnectingTile(TileEntity tile);
|
||||
|
||||
public void initialize() {
|
||||
lastPower = pipe.container.worldObj.isBlockIndirectlyGettingPowered(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.TileBuffer;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.transport.Pipe;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public abstract class PipeLogicWood {
|
||||
|
@ -53,7 +55,19 @@ public abstract class PipeLogicWood {
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract boolean isValidFacing(ForgeDirection facing);
|
||||
private boolean isValidFacing(ForgeDirection side) {
|
||||
TileBuffer[] tileBuffer = pipe.container.getTileCache();
|
||||
if (tileBuffer == null)
|
||||
return true;
|
||||
|
||||
if (!tileBuffer[side.ordinal()].exists())
|
||||
return true;
|
||||
|
||||
TileEntity tile = tileBuffer[side.ordinal()].getTile();
|
||||
return isValidConnectingTile(tile);
|
||||
}
|
||||
|
||||
protected abstract boolean isValidConnectingTile(TileEntity tile);
|
||||
|
||||
public void initialize() {
|
||||
if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
|
||||
|
|
Loading…
Reference in a new issue