Search in sources :

Example 1 with TubeModuleRedstoneEmitting

use of pneumaticCraft.common.block.tubes.TubeModuleRedstoneEmitting in project PneumaticCraft by MineMaarten.

the class BlockPressureTube method canConnectRedstone.

/**
     * Determine if this block can make a redstone connection on the side provided,
     * Useful to control which sides are inputs and outputs for redstone wires.
     *
     * Side:
     *  -1: UP
     *   0: NORTH
     *   1: EAST
     *   2: SOUTH
     *   3: WEST
     *
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @param side The side that is trying to make the connection
     * @return True to make the connection
     */
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
    if (side < 0 || side > 3)
        return false;
    TileEntityPressureTube tube = (TileEntityPressureTube) world.getTileEntity(x, y, z);
    ForgeDirection d = ForgeDirection.NORTH;
    for (int i = 0; i < side; i++) {
        d = d.getRotation(ForgeDirection.UP);
    }
    side = d.ordinal();
    for (int i = 0; i < 6; i++) {
        if (tube.modules[i] != null) {
            if ((side ^ 1) == i || i != side && tube.modules[i].isInline()) {
                //if we are on the same side, or when we have an 'in line' module that is not on the opposite side.
                if (tube.modules[i] instanceof TubeModuleRedstoneEmitting)
                    return true;
            }
        }
    }
    return false;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TileEntityPressureTube(pneumaticCraft.common.tileentity.TileEntityPressureTube) TubeModuleRedstoneEmitting(pneumaticCraft.common.block.tubes.TubeModuleRedstoneEmitting)

Aggregations

ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 TubeModuleRedstoneEmitting (pneumaticCraft.common.block.tubes.TubeModuleRedstoneEmitting)1 TileEntityPressureTube (pneumaticCraft.common.tileentity.TileEntityPressureTube)1