/** * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with * plants. */ public boolean canBlockStay(World par1World, int par2, int par3, int par4) { int l = getDirection(par1World.getBlockMetadata(par2, par3, par4)); par2 += Direction.offsetX[l]; par4 += Direction.offsetZ[l]; int i1 = par1World.getBlockId(par2, par3, par4); return i1 == Block.wood.blockID && BlockLog.limitToValidMetadata(par1World.getBlockMetadata(par2, par3, par4)) == 3; }
public boolean interactWith( ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { int i1; int j1; int k1; if (itemstack.getData() == 15) { i1 = world.getTypeId(i, j, k); if (i1 == Block.SAPLING.id) { if (!world.isStatic) { // CraftBukkit start Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null; ((BlockSapling) Block.SAPLING) .grow(world, i, j, k, world.random, true, player, itemstack); // --itemstack.count; - called later if the bonemeal attempt was succesful // CraftBukkit end } return true; } if (i1 == Block.BROWN_MUSHROOM.id || i1 == Block.RED_MUSHROOM.id) { // CraftBukkit start if (!world.isStatic) { Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null; ((BlockMushroom) Block.byId[i1]) .grow(world, i, j, k, world.random, true, player, itemstack); // --itemstack.count; - called later if the bonemeal attempt was succesful // CraftBukkit end } return true; } if (i1 == Block.MELON_STEM.id || i1 == Block.PUMPKIN_STEM.id) { if (world.getData(i, j, k) == 7) { return false; } if (!world.isStatic) { ((BlockStem) Block.byId[i1]).l(world, i, j, k); --itemstack.count; } return true; } if (i1 > 0 && Block.byId[i1] instanceof BlockCrops) { if (world.getData(i, j, k) == 7) { return false; } if (!world.isStatic) { ((BlockCrops) Block.byId[i1]).c_(world, i, j, k); --itemstack.count; } return true; } if (i1 == Block.COCOA.id) { if (!world.isStatic) { world.setData(i, j, k, 8 | BlockDirectional.e(world.getData(i, j, k))); --itemstack.count; } return true; } if (i1 == Block.GRASS.id) { if (!world.isStatic) { --itemstack.count; label133: for (j1 = 0; j1 < 128; ++j1) { k1 = i; int l1 = j + 1; int i2 = k; for (int j2 = 0; j2 < j1 / 16; ++j2) { k1 += d.nextInt(3) - 1; l1 += (d.nextInt(3) - 1) * d.nextInt(3) / 2; i2 += d.nextInt(3) - 1; if (world.getTypeId(k1, l1 - 1, i2) != Block.GRASS.id || world.t(k1, l1, i2)) { continue label133; } } if (world.getTypeId(k1, l1, i2) == 0) { if (d.nextInt(10) != 0) { if (Block.LONG_GRASS.d(world, k1, l1, i2)) { world.setTypeIdAndData(k1, l1, i2, Block.LONG_GRASS.id, 1); } } else if (d.nextInt(3) != 0) { if (Block.YELLOW_FLOWER.d(world, k1, l1, i2)) { world.setTypeId(k1, l1, i2, Block.YELLOW_FLOWER.id); } } else if (Block.RED_ROSE.d(world, k1, l1, i2)) { world.setTypeId(k1, l1, i2, Block.RED_ROSE.id); } } } } return true; } } else if (itemstack.getData() == 3) { i1 = world.getTypeId(i, j, k); j1 = world.getData(i, j, k); if (i1 == Block.LOG.id && BlockLog.e(j1) == 3) { if (l == 0) { return false; } if (l == 1) { return false; } if (l == 2) { --k; } if (l == 3) { ++k; } if (l == 4) { --i; } if (l == 5) { ++i; } if (world.isEmpty(i, j, k)) { k1 = Block.byId[Block.COCOA.id].getPlacedData(world, i, j, k, l, f, f1, f2, 0); world.setTypeIdAndData(i, j, k, Block.COCOA.id, k1); if (!entityhuman.abilities.canInstantlyBuild) { --itemstack.count; } } return true; } } return false; } }
public void checkInitBlockLog() { BlockLog inst = BlockLog.inst(); if (inst == null) { BlockLog.init(getApplicationContext()); } }