net.minecraft.block.BlockRedstoneWire Java Examples

The following examples show how to use net.minecraft.block.BlockRedstoneWire. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftBlock.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public int getBlockPower(BlockFace face) {
    int power = 0;
    BlockRedstoneWire wire = Blocks.REDSTONE_WIRE;
    net.minecraft.world.World world = chunk.getHandle().getWorld();
    if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isSidePowered(new BlockPos(x, y - 1, z), EnumFacing.DOWN))
        power = wire.getMaxCurrentStrength(world, new BlockPos(x, y - 1, z), power);
    if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isSidePowered(new BlockPos(x, y + 1, z), EnumFacing.UP))
        power = wire.getMaxCurrentStrength(world, new BlockPos(x, y + 1, z), power);
    if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isSidePowered(new BlockPos(x + 1, y, z), EnumFacing.EAST))
        power = wire.getMaxCurrentStrength(world, new BlockPos(x + 1, y, z), power);
    if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isSidePowered(new BlockPos(x - 1, y, z), EnumFacing.WEST))
        power = wire.getMaxCurrentStrength(world, new BlockPos(x - 1, y, z), power);
    if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isSidePowered(new BlockPos(x, y, z - 1), EnumFacing.NORTH))
        power = wire.getMaxCurrentStrength(world, new BlockPos(x, y, z - 1), power);
    if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isSidePowered(new BlockPos(x, y, z + 1), EnumFacing.SOUTH))
        power = wire.getMaxCurrentStrength(world, new BlockPos(x, y, z - 1), power);
    return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
}
 
Example #2
Source File: GTUtility.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static int getRedstonePower(World world, BlockPos blockPos, EnumFacing side) {
    BlockPos offsetPos = blockPos.offset(side);
    int worldPower = world.getRedstonePower(offsetPos, side);
    if (worldPower >= 15) {
        return worldPower;
    } else {
        IBlockState offsetState = world.getBlockState(offsetPos);
        if(offsetState.getBlock() instanceof BlockRedstoneWire) {
            int wirePower = offsetState.getValue(BlockRedstoneWire.POWER);
            return Math.max(worldPower, wirePower);
        }
        return worldPower;
    }
}
 
Example #3
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public int getBlockPower(BlockFace face) {
    int power = 0;
    BlockRedstoneWire wire = Blocks.redstone_wire;
    net.minecraft.world.World world = chunk.getHandle().worldObj;
    if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y - 1, z, 0)) power = wire.func_150178_a(world, x, y - 1, z, power);
    if ((face == BlockFace.UP || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y + 1, z, 1)) power = wire.func_150178_a(world, x, y + 1, z, power);
    if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.getIndirectPowerOutput(x + 1, y, z, 2)) power = wire.func_150178_a(world, x + 1, y, z, power);
    if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.getIndirectPowerOutput(x - 1, y, z, 3)) power = wire.func_150178_a(world, x - 1, y, z, power);
    if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y, z - 1, 4)) power = wire.func_150178_a(world, x, y, z - 1, power);
    if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y, z + 1, 5)) power = wire.func_150178_a(world, x, y, z - 1, power);
    return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
}
 
Example #4
Source File: BlockMinecoprocessor.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
protected static int calculateInputStrength(World worldIn, BlockPos pos, EnumFacing enumfacing) {
  IBlockState adjacentState = worldIn.getBlockState(pos);
  Block block = adjacentState.getBlock();

  int i = worldIn.getRedstonePower(pos, enumfacing);

  if (i >= 15) {
    return 15;
  }

  int redstoneWirePower = 0;

  if (block == Blocks.REDSTONE_WIRE) {
    redstoneWirePower = adjacentState.getValue(BlockRedstoneWire.POWER);
  }

  return Math.max(i, redstoneWirePower);

}