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

The following examples show how to use net.minecraft.world.World#scheduleUpdate() . 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: BlockSoulGlass.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
{
	boolean powered = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());

	if (powered)
	{
		if(!state.getValue(POWERED))
		{
			worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
			worldIn.setBlockState(pos, state.withProperty(POWERED, true));
			worldIn.playSound(null, pos, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, 1F, 0.25F + worldIn.rand.nextFloat());
		}
	}
	else
	{
		if(state.getValue(POWERED))
		{
			worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
			worldIn.setBlockState(pos, state.withProperty(POWERED, false));
			worldIn.playSound(null, pos, SoundEvents.BLOCK_NOTE_BASEDRUM, SoundCategory.BLOCKS, 1F, 0.25F + worldIn.rand.nextFloat());
		}
	}
}
 
Example 2
Source File: BlockButton.java    From customstuff4 with GNU General Public License v3.0 6 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)
{
    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 3
Source File: BlockSoulGlass.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
	if(worldIn.isBlockPowered(pos))
	{
		worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
		worldIn.setBlockState(pos, state.withProperty(POWERED, true));
	}
}
 
Example 4
Source File: TileEntityEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void scheduleBlockUpdate(int delay, boolean force)
{
    World world = this.getWorld();

    if (world != null && (force || world.isUpdateScheduled(this.getPos(), this.getBlockType()) == false))
    {
        //System.out.printf("scheduleBlockUpdate(), actually scheduling for %s\n", this.getPos());
        world.scheduleUpdate(this.getPos(), this.getBlockType(), delay);
    }
}
 
Example 5
Source File: BlockEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void scheduleBlockUpdate(World world, BlockPos pos, IBlockState state, int delay, boolean force)
{
    if (force || world.isUpdateScheduled(pos, state.getBlock()) == false)
    {
        world.scheduleUpdate(pos, state.getBlock(), delay);
    }
}
 
Example 6
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
	//this.modelState.neighborChanged(worldIn, pos, Blocks.AIR, pos);
	//this.modelBlock.onBlockAdded(worldIn, pos, this.modelState);
	worldIn.scheduleUpdate(pos, this, tickRate(worldIn));
}
 
Example 7
Source File: BlockCollapsible.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
protected void scheduleNeighbors(World world, BlockPos pos)
{
	for(int x = -1; x <= 1; x++)
	{
		for(int z = -1; z <= 1; z++)
		{
			for(int y = 0; y <= 2; y++)
			{
				world.scheduleUpdate(pos.add(x, y, z), world.getBlockState(pos.add(x, y, z)).getBlock(), tickRate(world));
			}
		}
	}
}
 
Example 8
Source File: BlockButton.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
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 9
Source File: GTEventNeighborNotifyEvent.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onNeighborNotified(BlockEvent.NeighborNotifyEvent event) {
	World world = event.getWorld();
	for (EnumFacing side : event.getNotifiedSides()) {
		BlockPos sidePos = event.getPos().offset(side);
		IBlockState sideState = world.getBlockState(sidePos);
		Block block = sideState.getBlock();
		if (block.isLeaves(sideState, world, sidePos))
			world.scheduleUpdate(sidePos, block, 8 + world.rand.nextInt(16));
	}
}
 
Example 10
Source File: BlockSmoulderingAsh.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
{
	if(worldIn.rand.nextInt(10) == 0)
	{
		worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
	}

	super.onEntityWalk(worldIn, pos, entityIn);
}
 
Example 11
Source File: BlockValkyriumOre.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
 
Example 12
Source File: BlockValkyriumOre.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn,
    BlockPos fromPos) {
    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
 
Example 13
Source File: BlockCollapsible.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
/*******************************************************************************
 * 1. Content 
 *******************************************************************************/
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
{
	world.scheduleUpdate(pos, this, tickRate(world));
}
 
Example 14
Source File: BlockOre.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
    if (state.getValue(STONE_TYPE).affectedByGravity)
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
 
Example 15
Source File: BlockOre.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (state.getValue(STONE_TYPE).affectedByGravity)
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
 
Example 16
Source File: BlockLeaves.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
{
	world.scheduleUpdate(pos, this, tickRate(world));
}
 
Example 17
Source File: BlockLeaves.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
	if(world.isRemote || state.getBlock() != this)
		return;
	IBlockState scanState;
	WoodType wood = (WoodType)state.getValue(getMetaProperty());
	BlockPos scanPos;

	if(wood == WoodType.Palm)
	{
		scanState = world.getBlockState(pos.down());
		if(scanState.getBlock() != TFCBlocks.LogNaturalPalm)
			world.setBlockToAir(pos);
		return;
	}

	if (world.isAreaLoaded(pos.add(-5, -5, -5), pos.add(5, 5, 5)))
	{
		for(int y = -4; y <= 4; y++)
		{
			for(int x = -4; x <= 4; x++)
			{
				for(int z = -4; z <= 4; z++)
				{
					scanPos = pos.add(x, y, z);
					scanState = world.getBlockState(pos.add(x, y, z));
					if((state.getBlock() == TFCBlocks.Leaves && scanState.getBlock() == TFCBlocks.LogNatural && scanState.getValue(BlockLogNatural.WOOD) == wood) ||
							(state.getBlock() == TFCBlocks.Leaves2 && scanState.getBlock() == TFCBlocks.LogNatural2 && scanState.getValue(BlockLogNatural2.WOOD) == wood))
						return;
				}
			}
		}

		for(int y = -1; y <= 1; y++)
		{
			for(int x = -1; x <= 1; x++)
			{
				for(int z = -1; z <= 1; z++)
				{
					world.scheduleUpdate(pos.add(x, y, z), this, tickRate(world));
				}
			}
		}
		world.setBlockToAir(pos);
	}
}
 
Example 18
Source File: BlockGravity.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
	worldIn.scheduleUpdate(pos, this, tickRate(worldIn));
}
 
Example 19
Source File: BlockPipe.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    worldIn.scheduleUpdate(pos, this, 1);
}