Java Code Examples for net.minecraft.world.World.isBlockIndirectlyGettingPowered()

The following are Jave code examples for showing how to use isBlockIndirectlyGettingPowered() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: PowerProbe   File: PowerOverlayRender.java   Source Code and License Vote up 6 votes
private void updateOverlayForPos(World world, BlockPos pos, PowerOverlayData overlay) {
  if (world.isAirBlock(pos)) {
    return;
  }
  overlay.pos = pos;
  overlay.power = world.getStrongPower(overlay.pos);
  if (overlay.power == 0) {
    overlay.strongPowered = false;
    overlay.power = world.isBlockIndirectlyGettingPowered(overlay.pos);
  } else {
    overlay.strongPowered = true;
  }
  if (!world.getBlockState(overlay.pos).isOpaqueCube()) {
    overlay.power = 0;
  }
}
 
Example 2
Project: pnc-repressurized   File: BlockPneumaticDoor.java   Source Code and License Vote up 5 votes
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
    boolean powered = world.isBlockIndirectlyGettingPowered(pos) > 0;
    if (!powered) {
        powered = world.isBlockIndirectlyGettingPowered(pos.offset(isTopDoor(state) ? EnumFacing.DOWN : EnumFacing.UP)) > 0;
    }
    TileEntityPneumaticDoorBase doorBase = getDoorBase(world, pos);
    if (!world.isRemote && doorBase != null && doorBase.getPressure() >= PneumaticValues.MIN_PRESSURE_PNEUMATIC_DOOR) {
        if (powered != doorBase.wasPowered) {
            doorBase.wasPowered = powered;
            doorBase.setOpening(powered);
        }
    }
}
 
Example 3
Project: uniquecrops   File: BlockHourglass.java   Source Code and License Vote up 5 votes
@Override
  public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
  	
if (world.isBlockIndirectlyGettingPowered(pos) > 0) {
	Iterable<BlockPos> poslist = BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range));
	Iterator it = poslist.iterator();
	while (it.hasNext()) {
		BlockPos posit = (BlockPos)it.next();
		if (!world.isRemote && !world.isAirBlock(posit)) {
			Block loopblock = world.getBlockState(posit).getBlock();
			boolean flag = rand.nextInt(10) == 0;
			if (loopblock == Blocks.GRASS && flag) {
				EntityItemHourglass.setOldBlock(world, posit, UCBlocks.oldGrass); break;
			}
			if (loopblock == Blocks.COBBLESTONE && flag) {
				EntityItemHourglass.setOldBlock(world, posit, UCBlocks.oldCobble); break;
			}
			if (loopblock == Blocks.MOSSY_COBBLESTONE && flag) {
				EntityItemHourglass.setOldBlock(world, posit, UCBlocks.oldCobbleMoss); break;
			}
			if (loopblock == Blocks.BRICK_BLOCK && flag) {
				EntityItemHourglass.setOldBlock(world, posit, UCBlocks.oldBrick); break;
			}
			if (loopblock == Blocks.GRAVEL && flag) {
				EntityItemHourglass.setOldBlock(world, posit, UCBlocks.oldGravel); break;
			}
		}
	}
}
  }
 
Example 4
Project: BaseClient   File: BlockRedstoneWire.java   Source Code and License Vote up 4 votes
private IBlockState calculateCurrentChanges(World worldIn, BlockPos pos1, BlockPos pos2, IBlockState state) {
	IBlockState iblockstate = state;
	int i = ((Integer) state.getValue(POWER)).intValue();
	int j = 0;
	j = this.getMaxCurrentStrength(worldIn, pos2, j);
	this.canProvidePower = false;
	int k = worldIn.isBlockIndirectlyGettingPowered(pos1);
	this.canProvidePower = true;

	if (k > 0 && k > j - 1) {
		j = k;
	}

	int l = 0;

	for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL) {
		EnumFacing enumfacing = (EnumFacing) enumfacing0;
		BlockPos blockpos = pos1.offset(enumfacing);
		boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();

		if (flag) {
			l = this.getMaxCurrentStrength(worldIn, blockpos, l);
		}

		if (worldIn.getBlockState(blockpos).getBlock().isNormalCube()
				&& !worldIn.getBlockState(pos1.up()).getBlock().isNormalCube()) {
			if (flag && pos1.getY() >= pos2.getY()) {
				l = this.getMaxCurrentStrength(worldIn, blockpos.up(), l);
			}
		} else if (!worldIn.getBlockState(blockpos).getBlock().isNormalCube() && flag
				&& pos1.getY() <= pos2.getY()) {
			l = this.getMaxCurrentStrength(worldIn, blockpos.down(), l);
		}
	}

	if (l > j) {
		j = l - 1;
	} else if (j > 0) {
		--j;
	} else {
		j = 0;
	}

	if (k > j - 1) {
		j = k;
	}

	if (i != j) {
		state = state.withProperty(POWER, Integer.valueOf(j));

		if (worldIn.getBlockState(pos1) == iblockstate) {
			worldIn.setBlockState(pos1, state, 2);
		}

		this.blocksNeedingUpdate.add(pos1);

		for (EnumFacing enumfacing1 : EnumFacing.values()) {
			this.blocksNeedingUpdate.add(pos1.offset(enumfacing1));
		}
	}

	return state;
}
 
Example 5
Project: BaseClient   File: BlockRedstoneWire.java   Source Code and License Vote up 4 votes
private IBlockState calculateCurrentChanges(World worldIn, BlockPos pos1, BlockPos pos2, IBlockState state)
{
    IBlockState iblockstate = state;
    int i = ((Integer)state.getValue(POWER)).intValue();
    int j = 0;
    j = this.getMaxCurrentStrength(worldIn, pos2, j);
    this.canProvidePower = false;
    int k = worldIn.isBlockIndirectlyGettingPowered(pos1);
    this.canProvidePower = true;

    if (k > 0 && k > j - 1)
    {
        j = k;
    }

    int l = 0;

    for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL)
    {
        EnumFacing enumfacing = (EnumFacing) enumfacing0;
        BlockPos blockpos = pos1.offset(enumfacing);
        boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();

        if (flag)
        {
            l = this.getMaxCurrentStrength(worldIn, blockpos, l);
        }

        if (worldIn.getBlockState(blockpos).getBlock().isNormalCube() && !worldIn.getBlockState(pos1.up()).getBlock().isNormalCube())
        {
            if (flag && pos1.getY() >= pos2.getY())
            {
                l = this.getMaxCurrentStrength(worldIn, blockpos.up(), l);
            }
        }
        else if (!worldIn.getBlockState(blockpos).getBlock().isNormalCube() && flag && pos1.getY() <= pos2.getY())
        {
            l = this.getMaxCurrentStrength(worldIn, blockpos.down(), l);
        }
    }

    if (l > j)
    {
        j = l - 1;
    }
    else if (j > 0)
    {
        --j;
    }
    else
    {
        j = 0;
    }

    if (k > j - 1)
    {
        j = k;
    }

    if (i != j)
    {
        state = state.withProperty(POWER, Integer.valueOf(j));

        if (worldIn.getBlockState(pos1) == iblockstate)
        {
            worldIn.setBlockState(pos1, state, 2);
        }

        this.blocksNeedingUpdate.add(pos1);

        for (EnumFacing enumfacing1 : EnumFacing.values())
        {
            this.blocksNeedingUpdate.add(pos1.offset(enumfacing1));
        }
    }

    return state;
}
 
Example 6
Project: Backmemed   File: BlockRedstoneWire.java   Source Code and License Vote up 4 votes
private IBlockState calculateCurrentChanges(World worldIn, BlockPos pos1, BlockPos pos2, IBlockState state)
{
    IBlockState iblockstate = state;
    int i = ((Integer)state.getValue(POWER)).intValue();
    int j = 0;
    j = this.getMaxCurrentStrength(worldIn, pos2, j);
    this.canProvidePower = false;
    int k = worldIn.isBlockIndirectlyGettingPowered(pos1);
    this.canProvidePower = true;

    if (k > 0 && k > j - 1)
    {
        j = k;
    }

    int l = 0;

    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        BlockPos blockpos = pos1.offset(enumfacing);
        boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();

        if (flag)
        {
            l = this.getMaxCurrentStrength(worldIn, blockpos, l);
        }

        if (worldIn.getBlockState(blockpos).isNormalCube() && !worldIn.getBlockState(pos1.up()).isNormalCube())
        {
            if (flag && pos1.getY() >= pos2.getY())
            {
                l = this.getMaxCurrentStrength(worldIn, blockpos.up(), l);
            }
        }
        else if (!worldIn.getBlockState(blockpos).isNormalCube() && flag && pos1.getY() <= pos2.getY())
        {
            l = this.getMaxCurrentStrength(worldIn, blockpos.down(), l);
        }
    }

    if (l > j)
    {
        j = l - 1;
    }
    else if (j > 0)
    {
        --j;
    }
    else
    {
        j = 0;
    }

    if (k > j - 1)
    {
        j = k;
    }

    if (i != j)
    {
        state = state.withProperty(POWER, Integer.valueOf(j));

        if (worldIn.getBlockState(pos1) == iblockstate)
        {
            worldIn.setBlockState(pos1, state, 2);
        }

        this.blocksNeedingUpdate.add(pos1);

        for (EnumFacing enumfacing1 : EnumFacing.values())
        {
            this.blocksNeedingUpdate.add(pos1.offset(enumfacing1));
        }
    }

    return state;
}
 
Example 7
Project: CustomWorldGen   File: BlockRedstoneWire.java   Source Code and License Vote up 4 votes
private IBlockState calculateCurrentChanges(World worldIn, BlockPos pos1, BlockPos pos2, IBlockState state)
{
    IBlockState iblockstate = state;
    int i = ((Integer)state.getValue(POWER)).intValue();
    int j = 0;
    j = this.getMaxCurrentStrength(worldIn, pos2, j);
    this.canProvidePower = false;
    int k = worldIn.isBlockIndirectlyGettingPowered(pos1);
    this.canProvidePower = true;

    if (k > 0 && k > j - 1)
    {
        j = k;
    }

    int l = 0;

    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        BlockPos blockpos = pos1.offset(enumfacing);
        boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();

        if (flag)
        {
            l = this.getMaxCurrentStrength(worldIn, blockpos, l);
        }

        if (worldIn.getBlockState(blockpos).isNormalCube() && !worldIn.getBlockState(pos1.up()).isNormalCube())
        {
            if (flag && pos1.getY() >= pos2.getY())
            {
                l = this.getMaxCurrentStrength(worldIn, blockpos.up(), l);
            }
        }
        else if (!worldIn.getBlockState(blockpos).isNormalCube() && flag && pos1.getY() <= pos2.getY())
        {
            l = this.getMaxCurrentStrength(worldIn, blockpos.down(), l);
        }
    }

    if (l > j)
    {
        j = l - 1;
    }
    else if (j > 0)
    {
        --j;
    }
    else
    {
        j = 0;
    }

    if (k > j - 1)
    {
        j = k;
    }

    if (i != j)
    {
        state = state.withProperty(POWER, Integer.valueOf(j));

        if (worldIn.getBlockState(pos1) == iblockstate)
        {
            worldIn.setBlockState(pos1, state, 2);
        }

        this.blocksNeedingUpdate.add(pos1);

        for (EnumFacing enumfacing1 : EnumFacing.values())
        {
            this.blocksNeedingUpdate.add(pos1.offset(enumfacing1));
        }
    }

    return state;
}
 
Example 8
Project: pnc-repressurized   File: PneumaticCraftUtils.java   Source Code and License Vote up 2 votes
/**
 * Returns the redstone level at the given position. Use this when you don't care what side(s) the signal is
 * coming from, just the level of the signal at the position.
 *
 * @param world the world
 * @param pos the position to check
 * @return the redstone level
 */
public static int getRedstoneLevel(World world, BlockPos pos) {
    return world != null ? world.isBlockIndirectlyGettingPowered(pos) : 0;
}