Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int worldX, int worldY, int worldZ, EntityLivingBase entityLivingBase)
- {
- if(itemStack.stackTagCompound == null)
- {
- itemStack.stackTagCompound = new NBTTagCompound();
- itemStack.stackTagCompound.setInteger("ShearMode", 0);
- }
- EntityPlayer player;
- int xRange = 1;
- int yRange = 1;
- int zRange = 1;
- if(!(entityLivingBase instanceof EntityPlayer)) return false;
- {
- player = (EntityPlayer)entityLivingBase;
- }
- Block tempBlock = world.getBlock(worldX, worldY, worldZ);
- int tempMeta = world.getBlockMetadata(worldX, worldY, worldZ);
- for(int xx = worldX - xRange; xx <= worldX + xRange; ++xx)
- {
- for(int yy = worldY - yRange; yy <= worldY + yRange; ++yy)
- {
- for(int zz = worldZ - zRange; zz <= worldZ + zRange; ++zz)
- {
- if(world.getBlock(xx, yy, zz).isLeaves(world, xx, yy, zz))
- {
- if(itemStack.stackTagCompound.getInteger("shearMode") == 0)
- {
- block.harvestBlock(world, player, xx, yy, zz, tempMeta);
- }
- else if(itemStack.stackTagCompound.getInteger("shearMode") == 1)
- {
- if(!world.isRemote)
- {
- world.spawnEntityInWorld(new EntityItem(world, worldX, worldY, worldZ, new ItemStack(tempBlock, 1)));
- }
- }
- world.setBlockToAir(xx, yy, zz);
- itemStack.damageItem(1, player);
- }
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment