mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-26 13:28:33 +01:00
removed chest special handling (since it was fixed in Forge) and added getNeighborCap to PipeTileEntity
This commit is contained in:
parent
64e2b9c4fe
commit
b46fd3be72
2 changed files with 7 additions and 10 deletions
|
@ -299,7 +299,7 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphL
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
continue;
|
continue;
|
||||||
// check if this handler already exists (double-connected pipes, double chests etc.)
|
// check if this handler already exists (double-connected pipes, double chests etc.)
|
||||||
if (info.stream().anyMatch(l -> l.getItemHandler(this.world) == handler))
|
if (info.stream().anyMatch(l -> handler.equals(l.getItemHandler(this.world))))
|
||||||
continue;
|
continue;
|
||||||
NetworkLocation location = new NetworkLocation(dest, dir);
|
NetworkLocation location = new NetworkLocation(dest, dir);
|
||||||
if (!location.isEmpty(this.world))
|
if (!location.isEmpty(this.world))
|
||||||
|
|
|
@ -302,19 +302,16 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
}
|
}
|
||||||
|
|
||||||
public IItemHandler getItemHandler(Direction dir) {
|
public IItemHandler getItemHandler(Direction dir) {
|
||||||
|
return this.getNeighborCap(dir, CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T getNeighborCap(Direction dir, Capability<T> cap) {
|
||||||
if (!this.isConnected(dir))
|
if (!this.isConnected(dir))
|
||||||
return null;
|
return null;
|
||||||
BlockPos pos = this.pos.offset(dir);
|
BlockPos pos = this.pos.offset(dir);
|
||||||
TileEntity tile = this.world.getTileEntity(pos);
|
TileEntity tile = this.world.getTileEntity(pos);
|
||||||
if (tile != null) {
|
if (tile != null)
|
||||||
// if we don't do this, then chests get really weird
|
return tile.getCapability(cap, dir.getOpposite()).orElse(null);
|
||||||
if (tile instanceof ChestTileEntity) {
|
|
||||||
BlockState state = this.world.getBlockState(tile.getPos());
|
|
||||||
if (state.getBlock() instanceof ChestBlock)
|
|
||||||
return new InvWrapper(ChestBlock.getChestInventory((ChestBlock) state.getBlock(), state, this.world, tile.getPos(), true));
|
|
||||||
}
|
|
||||||
return tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getOpposite()).orElse(null);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue