Search in sources :

Example 1 with RedstoneProxyBlock

use of mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock in project XNet by McJty.

the class ConnectorBlock method isConnectable.

public static boolean isConnectable(IBlockAccess world, BlockPos connectorPos, EnumFacing facing) {
    BlockPos pos = connectorPos.offset(facing);
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    if (block.isAir(state, world, pos)) {
        return false;
    }
    ConnectorTileEntity connectorTE = (ConnectorTileEntity) world.getTileEntity(connectorPos);
    if (connectorTE == null) {
        return false;
    }
    if (!connectorTE.isEnabled(facing)) {
        return false;
    }
    TileEntity te = world.getTileEntity(pos);
    if (block instanceof IConnectable) {
        IConnectable.ConnectResult result = ((IConnectable) block).canConnect(world, connectorPos, pos, te, facing);
        if (result == IConnectable.ConnectResult.NO) {
            return false;
        } else if (result == IConnectable.ConnectResult.YES) {
            return true;
        }
    }
    for (IConnectable connectable : XNet.xNetApi.getConnectables()) {
        IConnectable.ConnectResult result = connectable.canConnect(world, connectorPos, pos, te, facing);
        if (result == IConnectable.ConnectResult.NO) {
            return false;
        } else if (result == IConnectable.ConnectResult.YES) {
            return true;
        }
    }
    if (block instanceof ConnectorBlock) {
        return false;
    }
    if (block instanceof RedstoneProxyBlock || block == Blocks.REDSTONE_LAMP || block == Blocks.LIT_REDSTONE_LAMP || block == Blocks.PISTON || block == Blocks.STICKY_PISTON) {
        return true;
    }
    if (block.canConnectRedstone(state, world, pos, null) || state.canProvidePower()) {
        return true;
    }
    if (te == null) {
        return false;
    }
    if (te instanceof IInventory) {
        return true;
    }
    if (EnergyTools.isEnergyTE(te)) {
        return true;
    }
    if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
        return true;
    }
    if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
        return true;
    }
    if (te instanceof TileEntityController) {
        return true;
    }
    if (te instanceof TileEntityRouter) {
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RedstoneProxyBlock(mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock) IInventory(net.minecraft.inventory.IInventory) IConnectable(mcjty.xnet.api.channels.IConnectable) TileEntityRouter(mcjty.xnet.blocks.router.TileEntityRouter) IBlockState(net.minecraft.block.state.IBlockState) TileEntityController(mcjty.xnet.blocks.controller.TileEntityController) Block(net.minecraft.block.Block) FacadeItemBlock(mcjty.xnet.blocks.facade.FacadeItemBlock) GenericCableBlock(mcjty.xnet.blocks.generic.GenericCableBlock) RedstoneProxyBlock(mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with RedstoneProxyBlock

use of mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock in project XNet by McJty.

the class ModBlocks method init.

public static void init() {
    controllerBlock = new ControllerBlock();
    routerBlock = new RouterBlock();
    facadeBlock = new FacadeBlock();
    redstoneProxyBlock = new RedstoneProxyBlock();
    redstoneProxyUBlock = new RedstoneProxyUBlock();
    NetCableSetup.init();
}
Also used : FacadeBlock(mcjty.xnet.blocks.facade.FacadeBlock) RedstoneProxyBlock(mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock) ControllerBlock(mcjty.xnet.blocks.controller.ControllerBlock) RedstoneProxyUBlock(mcjty.xnet.blocks.redstoneproxy.RedstoneProxyUBlock) RouterBlock(mcjty.xnet.blocks.router.RouterBlock)

Aggregations

RedstoneProxyBlock (mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock)2 IConnectable (mcjty.xnet.api.channels.IConnectable)1 ControllerBlock (mcjty.xnet.blocks.controller.ControllerBlock)1 TileEntityController (mcjty.xnet.blocks.controller.TileEntityController)1 FacadeBlock (mcjty.xnet.blocks.facade.FacadeBlock)1 FacadeItemBlock (mcjty.xnet.blocks.facade.FacadeItemBlock)1 GenericCableBlock (mcjty.xnet.blocks.generic.GenericCableBlock)1 RedstoneProxyUBlock (mcjty.xnet.blocks.redstoneproxy.RedstoneProxyUBlock)1 RouterBlock (mcjty.xnet.blocks.router.RouterBlock)1 TileEntityRouter (mcjty.xnet.blocks.router.TileEntityRouter)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 IInventory (net.minecraft.inventory.IInventory)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1