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

The following are Jave code examples for showing how to use scheduleUpdate() 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.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: BlockDispenser.java   View Source Code Vote up 6 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
    boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
    }
    else if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
    }
}
 
Example 2
Project: Backmemed   File: BlockDispenser.java   View Source Code Vote up 6 votes
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_)
{
    boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
    boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
    }
    else if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
    }
}
 
Example 3
Project: DecompiledMinecraft   File: BlockDispenser.java   View Source Code Vote up 6 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
    boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
    }
    else if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
    }
}
 
Example 4
Project: CustomWorldGen   File: BlockChorusPlant.java   View Source Code Vote up 5 votes
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    if (!this.canSurviveAt(worldIn, pos))
    {
        worldIn.scheduleUpdate(pos, this, 1);
    }
}
 
Example 5
Project: BaseClient   File: BlockRedstoneLight.java   View Source Code Vote up 5 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    if (!worldIn.isRemote)
    {
        if (this.isOn && !worldIn.isBlockPowered(pos))
        {
            worldIn.scheduleUpdate(pos, this, 4);
        }
        else if (!this.isOn && worldIn.isBlockPowered(pos))
        {
            worldIn.setBlockState(pos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
        }
    }
}
 
Example 6
Project: CustomWorldGen   File: EnchantmentFrostWalker.java   View Source Code Vote up 5 votes
public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
{
    if (living.onGround)
    {
        float f = (float)Math.min(16, 2 + level);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);

        for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
        {
            if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
            {
                blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
                IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

                if (iblockstate.getMaterial() == Material.AIR)
                {
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);

                    if (iblockstate1.getMaterial() == Material.WATER && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.canBlockBePlaced(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null, (ItemStack)null))
                    {
                        worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
                        worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getRandomIntegerInRange(living.getRNG(), 60, 120));
                    }
                }
            }
        }
    }
}
 
Example 7
Project: BaseClient   File: BlockButton.java   View Source Code Vote up 5 votes
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
{
    this.updateBlockBounds(state);
    List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
}
 
Example 8
Project: Backmemed   File: BlockFrostedIce.java   View Source Code Vote up 5 votes
protected void slightlyMelt(World p_185681_1_, BlockPos p_185681_2_, IBlockState p_185681_3_, Random p_185681_4_, boolean p_185681_5_)
{
    int i = ((Integer)p_185681_3_.getValue(AGE)).intValue();

    if (i < 3)
    {
        p_185681_1_.setBlockState(p_185681_2_, p_185681_3_.withProperty(AGE, Integer.valueOf(i + 1)), 2);
        p_185681_1_.scheduleUpdate(p_185681_2_, this, MathHelper.getInt(p_185681_4_, 20, 40));
    }
    else
    {
        this.turnIntoWater(p_185681_1_, p_185681_2_);

        if (p_185681_5_)
        {
            for (EnumFacing enumfacing : EnumFacing.values())
            {
                BlockPos blockpos = p_185681_2_.offset(enumfacing);
                IBlockState iblockstate = p_185681_1_.getBlockState(blockpos);

                if (iblockstate.getBlock() == this)
                {
                    this.slightlyMelt(p_185681_1_, blockpos, iblockstate, p_185681_4_, false);
                }
            }
        }
    }
}
 
Example 9
Project: BaseClient   File: BlockRailDetector.java   View Source Code Vote up 5 votes
private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state)
{
    boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
    boolean flag1 = false;
    List<EntityMinecart> list = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]);

    if (!list.isEmpty())
    {
        flag1 = true;
    }

    if (flag1 && !flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (!flag1 && flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }

    worldIn.updateComparatorOutputLevel(pos, this);
}
 
Example 10
Project: Backmemed   File: BlockRedstoneTorch.java   View Source Code Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    boolean flag = this.shouldBeOff(worldIn, pos, state);
    List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);

    while (list != null && !list.isEmpty() && worldIn.getTotalWorldTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).time > 60L)
    {
        list.remove(0);
    }

    if (this.isOn)
    {
        if (flag)
        {
            worldIn.setBlockState(pos, Blocks.UNLIT_REDSTONE_TORCH.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);

            if (this.isBurnedOut(worldIn, pos, true))
            {
                worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int i = 0; i < 5; ++i)
                {
                    double d0 = (double)pos.getX() + rand.nextDouble() * 0.6D + 0.2D;
                    double d1 = (double)pos.getY() + rand.nextDouble() * 0.6D + 0.2D;
                    double d2 = (double)pos.getZ() + rand.nextDouble() * 0.6D + 0.2D;
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
                }

                worldIn.scheduleUpdate(pos, worldIn.getBlockState(pos).getBlock(), 160);
            }
        }
    }
    else if (!flag && !this.isBurnedOut(worldIn, pos, false))
    {
        worldIn.setBlockState(pos, Blocks.REDSTONE_TORCH.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);
    }
}
 
Example 11
Project: DecompiledMinecraft   File: BlockRedstoneLight.java   View Source Code Vote up 5 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    if (!worldIn.isRemote)
    {
        if (this.isOn && !worldIn.isBlockPowered(pos))
        {
            worldIn.scheduleUpdate(pos, this, 4);
        }
        else if (!this.isOn && worldIn.isBlockPowered(pos))
        {
            worldIn.setBlockState(pos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
        }
    }
}
 
Example 12
Project: DecompiledMinecraft   File: BlockBasePressurePlate.java   View Source Code Vote up 5 votes
/**
 * Updates the pressure plate when stepped on
 */
protected void updateState(World worldIn, BlockPos pos, IBlockState state, int oldRedstoneStrength)
{
    int i = this.computeRedstoneStrength(worldIn, pos);
    boolean flag = oldRedstoneStrength > 0;
    boolean flag1 = i > 0;

    if (oldRedstoneStrength != i)
    {
        state = this.setRedstoneStrength(state, i);
        worldIn.setBlockState(pos, state, 2);
        this.updateNeighbors(worldIn, pos);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (!flag1 && flag)
    {
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
    }
    else if (flag1 && !flag)
    {
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
}
 
Example 13
Project: Backmemed   File: BlockChorusPlant.java   View Source Code Vote up 5 votes
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_)
{
    if (!this.canSurviveAt(worldIn, pos))
    {
        worldIn.scheduleUpdate(pos, this, 1);
    }
}
 
Example 14
Project: FundamentalChemistry   File: BlockVersatileGenerator.java   View Source Code Vote up 5 votes
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand){
	world.scheduleUpdate(pos, this, FundamentalChemistry.RELAY_TICKS); //schedule next update
	
	TileVersatileGenerator ent = (TileVersatileGenerator)world.getTileEntity(pos);
	ent.tick();
}
 
Example 15
Project: FundamentalChemistry   File: BlockItemBreaker.java   View Source Code Vote up 4 votes
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
	world.scheduleUpdate(pos, this, FundamentalChemistry.RELAY_TICKS);
}
 
Example 16
Project: BaseClient   File: BlockFalling.java   View Source Code Vote up 4 votes
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
 
Example 17
Project: CustomWorldGen   File: BlockCommandBlock.java   View Source Code Vote up 4 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityCommandBlock)
        {
            TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity;
            CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic();
            boolean flag = !StringUtils.isNullOrEmpty(commandblockbaselogic.getCommand());
            TileEntityCommandBlock.Mode tileentitycommandblock$mode = tileentitycommandblock.getMode();
            boolean flag1 = !tileentitycommandblock.isConditional() || this.isNextToSuccessfulCommandBlock(worldIn, pos, state);
            boolean flag2 = tileentitycommandblock.isConditionMet();
            boolean flag3 = false;

            if (tileentitycommandblock$mode != TileEntityCommandBlock.Mode.SEQUENCE && flag2 && flag)
            {
                commandblockbaselogic.trigger(worldIn);
                flag3 = true;
            }

            if (tileentitycommandblock.isPowered() || tileentitycommandblock.isAuto())
            {
                if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.SEQUENCE && flag1 && flag)
                {
                    commandblockbaselogic.trigger(worldIn);
                    flag3 = true;
                }

                if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.AUTO)
                {
                    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));

                    if (flag1)
                    {
                        this.propagateUpdate(worldIn, pos);
                    }
                }
            }

            if (!flag3)
            {
                commandblockbaselogic.setSuccessCount(0);
            }

            tileentitycommandblock.setConditionMet(flag1);
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }
}
 
Example 18
Project: FundamentalChemistry   File: BlockMoleculeBreaker.java   View Source Code Vote up 4 votes
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
	world.scheduleUpdate(pos, this, FundamentalChemistry.RELAY_TICKS);
}
 
Example 19
Project: BaseClient   File: BlockDragonEgg.java   View Source Code Vote up 4 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
 
Example 20
Project: DecompiledMinecraft   File: BlockFalling.java   View Source Code Vote up 4 votes
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}