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

The following examples show how to use net.minecraft.world.World#markBlockRangeForRenderUpdate() . 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
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (state.getValue(POWERED))
    {
        return true;
    } else
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, true), 3);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        this.playClickSound(playerIn, worldIn, pos);
        this.notifyNeighbors(worldIn, pos, state.getValue(FACING));
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
        return true;
    }
}
 
Example 2
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        if (state.getValue(POWERED))
        {
            if (content.triggeredByArrows)
            {
                this.checkPressed(state, worldIn, pos);
            } else
            {
                worldIn.setBlockState(pos, state.withProperty(POWERED, false));
                this.notifyNeighbors(worldIn, pos, state.getValue(FACING));
                this.playReleaseSound(worldIn, pos);
                worldIn.markBlockRangeForRenderUpdate(pos, pos);
            }
        }
    }
}
 
Example 3
@Override
  public boolean onBlockActivated(final World world, final BlockPos coord, IBlockState blockstate, 
  		                        final EntityPlayer player,
                                  final EnumHand hand, ItemStack heldItem,
                                  final EnumFacing face,
  		                        final float partialX, final float partialY, final float partialZ) {
if (this.metal.getToolHarvestLevel() > 1) {
          return false;
      }
      final BlockPos pos = (blockstate.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) ? coord : coord.down();
      final IBlockState bs = coord.equals(pos) ? blockstate : world.getBlockState(pos);
      if (bs.getBlock() != this) {
          return false;
      }
      blockstate = bs.cycleProperty(BlockDoor.OPEN);
      world.setBlockState(pos, blockstate, 2);
      world.markBlockRangeForRenderUpdate(pos, coord);
      world.playEvent(player, ((Boolean)blockstate.getValue(BlockDoor.OPEN)) ? 1003 : 1006, coord, 0);
      return true;
  }
 
Example 4
private void updateFilterState(boolean updateHilightBoxes)
{
    if (this.getWorld() != null)
    {
        World world = this.getWorld();
        IBlockState state = world.getBlockState(this.getPos());

        if (state.getBlock() == EnderUtilitiesBlocks.INSERTER)
        {
            this.setIsFiltered(state.getValue(BlockInserter.TYPE) == BlockInserter.InserterType.FILTERED);

            if (updateHilightBoxes)
            {
                EnderUtilitiesBlocks.INSERTER.updateBlockHilightBoxes(world, this.getPos(), this.getFacing());
            }

            world.markBlockRangeForRenderUpdate(this.getPos(), this.getPos());
        }
    }
}
 
Example 5
Source Project: Sakura_mod   File: BlockShoji.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    state = state.cycleProperty(OPEN);
    worldIn.setBlockState(pos, state, 10);
    worldIn.markBlockRangeForRenderUpdate(pos, pos);
    worldIn.playEvent(playerIn, state.getValue(OPEN) ? 1006 : 1012, pos, 0);
    TileEntityShoji te = (TileEntityShoji) worldIn.getTileEntity(pos);
    if (te != null) {
        te.setOpen(!te.isOpen());
        te.setAnimation(10);
    }
    return true;
}
 
Example 6
private void checkPressed(IBlockState state, World worldIn, BlockPos pos)
{
    List<? extends Entity> list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, state.getBoundingBox(worldIn, pos).offset(pos));
    boolean flag = !list.isEmpty();
    boolean flag1 = state.getValue(POWERED);

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, true));
        this.notifyNeighbors(worldIn, pos, state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        this.playClickSound(null, worldIn, pos);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, false));
        this.notifyNeighbors(worldIn, pos, state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        this.playReleaseSound(worldIn, pos);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
    }
}
 
Example 7
Source Project: Artifacts   File: BlockWallPlate.java    License: MIT License 5 votes vote down vote up
@Override
//setStateIfMobInteractsWithPlate
protected void func_150062_a(World world, int x, int y, int z, int meta)
{
	int i1 = this.func_150065_e/*getPlateState*/(world, x, y, z);
	boolean flag = meta > 0;
	boolean flag1 = (i1 > 0);
	if (meta != i1)
	{
		int side = world.getBlockMetadata(x, y, z)&7;
		int m = this.func_150060_c/*getMetaFromWeight*/(i1)*8 + side;
		world.setBlockMetadataWithNotify(x, y, z, m, 2);
		this.func_150064_a_(world, x, y, z);
		world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
	}

	if (!flag1 && flag)
	{
		world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.5F);
	}
	else if (flag1 && !flag)
	{
		world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.6F);
	}

	if (flag1)
	{
		world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
	}
}