use of mcmultipart.api.world.IMultipartBlockAccess in project Charset by CharsetMC.
the class WireUtils method getWire.
@Nullable
public static Wire getWire(IBlockAccess access, BlockPos pos, WireFace face) {
IMultipartContainer container = null;
if (access instanceof IMultipartBlockAccess) {
access = ((IMultipartBlockAccess) access).getActualWorld();
}
Optional<IMultipartContainer> containerOpt = MultipartHelper.getContainer(access, pos);
if (containerOpt.isPresent()) {
container = containerOpt.get();
}
if (container != null) {
Optional<IMultipartTile> tile = container.getPartTile(toPartSlot(face));
if (tile.isPresent() && tile.get().getTileEntity() instanceof TileWire) {
Wire wire = ((TileWire) tile.get().getTileEntity()).wire;
if (wire != null && wire.getLocation() == face) {
return ((TileWire) tile.get().getTileEntity()).wire;
}
}
return null;
}
TileEntity tile = access.getTileEntity(pos);
if (tile != null && tile instanceof TileWire && ((TileWire) tile).wire != null && ((TileWire) tile).wire.getLocation() == face) {
return ((TileWire) tile).wire;
} else {
return null;
}
}
Aggregations