Search in sources :

Example 1 with IMultipartBlockAccess

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;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IMultipartContainer(mcmultipart.api.container.IMultipartContainer) IMultipartBlockAccess(mcmultipart.api.world.IMultipartBlockAccess) IMultipartTile(mcmultipart.api.multipart.IMultipartTile) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)1 IMultipartContainer (mcmultipart.api.container.IMultipartContainer)1 IMultipartTile (mcmultipart.api.multipart.IMultipartTile)1 IMultipartBlockAccess (mcmultipart.api.world.IMultipartBlockAccess)1 TileEntity (net.minecraft.tileentity.TileEntity)1