use of net.minecraft.block.BlockLilyPad in project BluePower by Qmunity.
the class ItemSickle method onBlockDestroyed.
@Override
public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase entityLiving) {
boolean used = false;
if (!(entityLiving instanceof EntityPlayer))
return false;
EntityPlayer player = (EntityPlayer) entityLiving;
if ((block != null) && (block.isLeaves(world, x, y, z))) {
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
for (int k = -1; k <= 1; k++) {
Block blockToCheck = world.getBlock(x + i, y + j, z + k);
int meta = world.getBlockMetadata(x + i, y + j, z + k);
if ((blockToCheck != null) && (blockToCheck.isLeaves(world, x + i, y + j, z + k))) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y + j, z + k, meta);
}
world.setBlock(x + i, y + j, z + k, Blocks.air);
used = true;
}
}
}
}
if (used) {
itemStack.damageItem(1, entityLiving);
}
return used;
}
if ((block != null) && (block instanceof BlockLilyPad)) {
for (int i = -2; i <= 2; i++) {
for (int j = -2; j <= 2; j++) {
Block blockToCheck = world.getBlock(x + i, y, z + j);
int meta = world.getBlockMetadata(x + i, y, z + j);
if (blockToCheck != null && blockToCheck instanceof BlockLilyPad) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y, z + j, meta);
}
world.setBlock(x + i, y, z + j, Blocks.air);
used = true;
}
}
}
}
if ((block != null) && !(block instanceof BlockLilyPad)) {
for (int i = -2; i <= 2; i++) {
for (int j = -2; j <= 2; j++) {
Block blockToCheck = world.getBlock(x + i, y, z + j);
int meta = world.getBlockMetadata(x + i, y, z + j);
if (blockToCheck != null) {
if (blockToCheck instanceof BlockBush && !(blockToCheck instanceof BlockLilyPad)) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y, z + j, meta);
}
world.setBlock(x + i, y, z + j, Blocks.air);
used = true;
}
}
}
}
}
if (used) {
itemStack.damageItem(1, entityLiving);
}
return used;
}
Aggregations