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

The following examples show how to use net.minecraft.world.World#scheduleBlockUpdate() . 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: FrostedIce.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
	if (world.isRemote)
		return;

	int surroundingBlockCount = 0;
	for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
		Block block = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
		if (block == this || block == Blocks.ice || block == Blocks.packed_ice)
			if (++surroundingBlockCount >= 4)
				break;
	}

	if (surroundingBlockCount < 4 || rand.nextInt(100) <= 33) {
		int meta = world.getBlockMetadata(x, y, z);
		if (meta < 3)
			world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
		else
			world.setBlock(x, y, z, Blocks.water);
	}

	world.scheduleBlockUpdate(x, y, z, this, 40 + rand.nextInt(40));
}
 
Example 2
Source File: BlockTrap.java    From Artifacts with MIT License 6 votes vote down vote up
/**
 * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
 * their own) Args: x, y, z, neighbor blockID
 */
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block)
{
    boolean flag = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
    int i1 = par1World.getBlockMetadata(par2, par3, par4);
    boolean flag1 = (i1 & 8) != 0;

    if (flag && !flag1)
    {
        par1World.scheduleBlockUpdate(par2, par3, par4, this.instance, this.tickRate(par1World));
        par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 | 8, 4);
    }
    else if (!flag && flag1)
    {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 & -9, 4);
    }
    else if(flag1) {
    	//System.out.println("Stuck on");
    }
}
 
Example 3
Source File: BlockEndEye.java    From Ex-Aliquo with MIT License 6 votes vote down vote up
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
{
	if (!world.isRemote)
	{
		world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world));
		this.getBlockTexture(world, x, y, z, 0);
	}
	
	if (world.getBlockMetadata(x, y, z) == 0)
	{
		world.setBlock(x, y, z, this.blockID, 1, 2);
	}
	else
	{
		world.setBlock(x, y, z, this.blockID, 0, 2);
	}
}
 
Example 4
Source File: BlockFireFlower.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){
    if(world.getBlockMetadata(x, y, z) == 14) {
        world.setBlockMetadataWithNotify(x, y, z, 11, 3);
        if(!world.isRemote) {
            ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.FIRE_FLOWER_DAMAGE);
            EntityItem plant = new EntityItem(world, x + 0.5D, y + 0.8D, z + 0.5D, seed);
            plant.motionX = (rand.nextFloat() - 0.5F) / 2;
            plant.motionY = 0.5F;
            plant.motionZ = (rand.nextFloat() - 0.5F) / 2;
            plant.lifespan = 300;
            ItemPlasticPlants.markInactive(plant);
            world.spawnEntityInWorld(plant);
            plant.playSound("mob.newsound.chickenplop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
        }
    } else {
        world.setBlockMetadataWithNotify(x, y, z, 14, 2);
        world.scheduleBlockUpdate(x, y, z, this, 60);
    }
}
 
Example 5
Source File: FrostedIce.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void onBlockAdded(World world, int x, int y, int z) {
	if (world.isRemote)
		return;

	world.scheduleBlockUpdate(x, y, z, this, 40 + world.rand.nextInt(40));
}
 
Example 6
Source File: BlockWallPlate.java    From Artifacts with 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));
	}
}
 
Example 7
Source File: BlockLaserBeamSource.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5) {
   	int m = par2World.getBlockMetadata(par3, par4, par5);
   	if((m&8) != 8) {
    	par2World.setBlockMetadataWithNotify(par3, par4, par5, m|8, 3);
    	notifyNeighborOfChange(par2World, par3, par4, par5, m);
    	par2World.scheduleBlockUpdate(par3, par4, par5, this.instance, this.tickRate(par2World));
   	}
   	return super.getPlayerRelativeBlockHardness(par1EntityPlayer, par2World, par3, par4, par5);
   }
 
Example 8
Source File: BlockLaserBeamSource.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
{
	int meta = world.getBlockMetadata(x, y, z);
    this.updateLaserState(world, x, y, z, this.instance, meta, true, -1, 0);
    if((meta&8) == 8) {
    	world.setBlockMetadataWithNotify(x, y, z, meta&3, 3);
    	notifyNeighborOfChange(world, x, y, z, meta&3);
        world.scheduleBlockUpdate(x, y, z, this.instance, this.tickRate(world));
    }
}
 
Example 9
Source File: BlockSmallFire.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public void onBlockAdded (World world, int x, int y, int z) {
    if (!blockCanHostSmallFlame(world, x, y - 1, z))
        world.setBlockToAir(x, y, z);
    else
        world.scheduleBlockUpdate(x, y, z, this, tickRate(world) + world.rand.nextInt(10));
}
 
Example 10
Source File: BlockEnderUtilitiesPortal.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns false if the block can't stay and should be broken,
 * and also schedules the checks for all the adjacent blocks.
 */
private boolean checkCanStayAndScheduleBreaking(World world, BlockPos pos, IBlockState state)
{
    EnumFacing facing = state.getValue(FACING);
    BlockPos[] positions = PositionUtils.getAdjacentPositions(pos, facing, false);
    boolean canStay = true;

    for (BlockPos posTmp : positions)
    {
        Block block = world.getBlockState(posTmp).getBlock();

        if (block != this && block != EnderUtilitiesBlocks.PORTAL_FRAME)
        {
            for (BlockPos posTmp2 : positions)
            {
                block = world.getBlockState(posTmp2).getBlock();

                if (block == this)
                {
                    world.scheduleBlockUpdate(posTmp2, block, 0, 0);
                }
            }

            canStay = false;
            break;
        }
    }

    return canStay;
}
 
Example 11
Source File: BlockEnderUtilitiesPortal.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
{
    if (worldIn.isRemote == false && this.checkCanStayAndScheduleBreaking(worldIn, pos, state) == false)
    {
        worldIn.scheduleBlockUpdate(pos, this, 0, 0);
    }
}
 
Example 12
Source File: BlockEndCake.java    From Ex-Aliquo with MIT License 5 votes vote down vote up
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
{
	if (world.provider.dimensionId == 1)
	{
		int meta = world.getBlockMetadata(x, y, z) - 1;
		if (meta > 0) world.setBlockMetadataWithNotify(x, y, z, meta, 2);
		world.scheduleBlockUpdate(x, y, z, this.blockID, 12000);
	}
}
 
Example 13
Source File: BlockEndCake.java    From Ex-Aliquo with MIT License 5 votes vote down vote up
@Override
public void onBlockAdded(World world, int x, int y, int z)
   {
	if (world.provider.dimensionId == 1)
	{
		world.scheduleBlockUpdate(x, y, z, this.blockID, 12000);
	}
   }
 
Example 14
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void waterLocation(ChunkCoordinates coordinates, World world) {
    Block block = world.getBlock(coordinates.posX, coordinates.posY, coordinates.posZ);
    if (block.getTickRandomly()) {
        world.scheduleBlockUpdate(coordinates.posX, coordinates.posY, coordinates.posZ, block, world.rand.nextInt(8) + 2);
    }
    if(IntegrationThaumicTinkerer.isCropBlock(block)) {
        TileEntity te = world.getTileEntity(coordinates.posX, coordinates.posY, coordinates.posZ);
        if(te != null && IntegrationThaumicTinkerer.isCropTile(te)) {
            for (int i = 0; i < 10; i++) {
                te.updateEntity(); //Badumm tss..
            }
        }
    }
}
 
Example 15
Source File: BlockEndEye.java    From Ex-Aliquo with MIT License 4 votes vote down vote up
@Override
public void onBlockAdded(World world, int x, int y, int z)
   {
	world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world));
   }
 
Example 16
Source File: BlockQuickSand.java    From Artifacts with MIT License 4 votes vote down vote up
/**
 * Called whenever the block is added into the world. Args: world, x, y, z
 */
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
	world.scheduleBlockUpdate(x, y, z, this.instance, flowDelay);
}
 
Example 17
Source File: BlockLaserBeamSource.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
  public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
  {
//System.out.println("Collide");
      if (!par1World.isRemote)
      {
      	/*int m = par1World.getBlockMetadata(par2, par3, par4);
          if ((m & 8) != 8)
          {
          	par1World.setBlockMetadataWithNotify(par2, par3, par4, m, 3);
          }*/
      	int l = par1World.getBlockMetadata(par2, par3, par4);
          boolean flag = (l & 8) == 8;
      	boolean flag1 = false;
      	List list = par1World.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.getBoundingBox((double)par2 + this.minX, (double)par3 + this.minY, (double)par4 + this.minZ, (double)par2 + this.maxX, (double)par3 + this.maxY, (double)par4 + this.maxZ));

          if (!list.isEmpty())
          {
              Iterator iterator = list.iterator();

              while (iterator.hasNext())
              {
                  Entity entity = (Entity)iterator.next();

                  if (entity instanceof EntityLivingBase && !entity.doesEntityNotTriggerPressurePlate())
                  {
                      flag1 = true;
                      break;
                  }
              }
          }
          if (flag1 && !flag)
          {
              l |= 8;
              par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 3);
              notifyNeighborOfChange(par1World, par2, par3, par4, l);
          //}
          //if (flag1)
          //{
              par1World.scheduleBlockUpdate(par2, par3, par4, this.instance, this.tickRate(par1World));
          }
      }
  }
 
Example 18
Source File: BlockQuickSand.java    From Artifacts with MIT License 4 votes vote down vote up
/**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
   * their own) Args: x, y, z, neighbor Block
   */
@Override
  public void onNeighborBlockChange(World world, int x, int y, int z, Block blockChanged)
  {
	world.scheduleBlockUpdate(x, y, z, this.instance, flowDelay);
  }
 
Example 19
Source File: BlockLaserBeam.java    From Artifacts with MIT License 4 votes vote down vote up
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
	par1World.scheduleBlockUpdate(par2, par3, par4, this.instance, 1);
}
 
Example 20
Source File: BlockLaserBeamSource.java    From Artifacts with MIT License 4 votes vote down vote up
public void updateLaserState(World world, int x, int y, int z, Block block, int meta, boolean triggered, int par8, int par9)
{
    int l1 = meta & 3;
    boolean flag1 = (meta & 8) == 8;
    //boolean flag2 = (meta & 8) == 8;
    //boolean isThis = id == this.blockID;
    //boolean flag4 = false;
    //boolean solidTop = !world.isBlockSolidOnSide(x, y - 1, z, UP);
    int offsetX = Direction.offsetX[l1];
    int offsetZ = Direction.offsetZ[l1];
    //int k2 = 0;
    //int[] aint = new int[42];
    int l2;
    int i3;
    Block j3;
    int k3;
    //int l3;
    boolean shouldbetriggered = false;
    boolean quitEarly = false;
    for (i3 = 1; i3 < 16; ++i3)
    {
    	l2 = x + offsetX * i3;
        k3 = z + offsetZ * i3;
        j3 = world.getBlock(l2, y, k3);
        if(j3 == Blocks.air || (j3 != BlockLaserBeam.instance && j3.getMaterial() == Material.air)) {
        	if(!quitEarly)
        		world.setBlock(l2, y, k3, BlockLaserBeam.instance, 0, 3);
        }
        if(j3 == BlockLaserBeam.instance) {
        	if(quitEarly) {
        		world.setBlockToAir(l2, y, k3);
        	}
        	else if(world.getBlockMetadata(l2, y, k3) != 0) {
        		shouldbetriggered = true;
        		//world.scheduleBlockUpdate(l2, y, k3, blockID, 10);
        		//world.setBlockMetadataWithNotify(l2, y, k3, 0, 3);
        	}
        }
        if (world.getBlock(l2, y, k3).isOpaqueCube()) {
        	quitEarly = true;
        }
    }
    
    if(triggered) {
    	if(shouldbetriggered) {
    		world.setBlockMetadataWithNotify(x, y, z, l1|8, 3);
    		world.scheduleBlockUpdate(x, y, z, this.instance, this.tickRate(world));
    		notifyNeighborOfChange(world, x, y, z, l1);
    	}
    }
}