mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +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)
|
||||
continue;
|
||||
// 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;
|
||||
NetworkLocation location = new NetworkLocation(dest, dir);
|
||||
if (!location.isEmpty(this.world))
|
||||
|
|
|
@ -302,19 +302,16 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
}
|
||||
|
||||
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))
|
||||
return null;
|
||||
BlockPos pos = this.pos.offset(dir);
|
||||
TileEntity tile = this.world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
// if we don't do this, then chests get really weird
|
||||
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);
|
||||
}
|
||||
if (tile != null)
|
||||
return tile.getCapability(cap, dir.getOpposite()).orElse(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue