Guest User

Untitled

a guest
Apr 24th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int worldX, int worldY, int worldZ, EntityLivingBase entityLivingBase)
  2. {
  3. if(itemStack.stackTagCompound == null)
  4. {
  5. itemStack.stackTagCompound = new NBTTagCompound();
  6. itemStack.stackTagCompound.setInteger("ShearMode", 0);
  7. }
  8. EntityPlayer player;
  9.  
  10. int xRange = 1;
  11. int yRange = 1;
  12. int zRange = 1;
  13.  
  14. if(!(entityLivingBase instanceof EntityPlayer)) return false;
  15. {
  16. player = (EntityPlayer)entityLivingBase;
  17. }
  18.  
  19. Block tempBlock = world.getBlock(worldX, worldY, worldZ);
  20. int tempMeta = world.getBlockMetadata(worldX, worldY, worldZ);
  21.  
  22. for(int xx = worldX - xRange; xx <= worldX + xRange; ++xx)
  23. {
  24. for(int yy = worldY - yRange; yy <= worldY + yRange; ++yy)
  25. {
  26. for(int zz = worldZ - zRange; zz <= worldZ + zRange; ++zz)
  27. {
  28. if(world.getBlock(xx, yy, zz).isLeaves(world, xx, yy, zz))
  29. {
  30. if(itemStack.stackTagCompound.getInteger("shearMode") == 0)
  31. {
  32. block.harvestBlock(world, player, xx, yy, zz, tempMeta);
  33. }
  34.  
  35. else if(itemStack.stackTagCompound.getInteger("shearMode") == 1)
  36. {
  37. if(!world.isRemote)
  38. {
  39. world.spawnEntityInWorld(new EntityItem(world, worldX, worldY, worldZ, new ItemStack(tempBlock, 1)));
  40. }
  41. }
  42. world.setBlockToAir(xx, yy, zz);
  43. itemStack.damageItem(1, player);
  44. }
  45. }
  46. }
  47. }
  48. return true;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment