Java Code Examples for net.minecraft.world.World#getRedstonePower()

The following examples show how to use net.minecraft.world.World#getRedstonePower() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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 2
Source Project: AdvancedRocketry   File: TileRocketFluidLoader.java    License: MIT License 5 votes vote down vote up
protected boolean getStrongPowerForSides(World world, BlockPos pos) {
	for(int i = 0; i < 6; i++) {
		if(sideSelectorModule.getStateForSide(i) == ALLOW_REDSTONEOUT && world.getRedstonePower(pos.offset(EnumFacing.VALUES[i]), EnumFacing.VALUES[i]) > 0)
			return true;
	}
	return false;
}
 
Example 3
Source Project: AdvancedRocketry   File: TileRocketLoader.java    License: MIT License 5 votes vote down vote up
protected boolean getStrongPowerForSides(World world, BlockPos pos) {
	for(int i = 0; i < 6; i++) {
		if(sideSelectorModule.getStateForSide(i) == ALLOW_REDSTONEOUT && world.getRedstonePower(pos.offset(EnumFacing.VALUES[i]), EnumFacing.VALUES[i]) > 0)
			return true;
	}
	return false;
}
 
Example 4
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);

}