Guest User

Untitled

a guest
Jul 5th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public class TestDiamondToss {
  2.  
  3. @SubscribeEvent
  4. public void diamondDropped(ItemTossEvent e){
  5. int counter;
  6. World world = e.player.getEntityWorld();
  7. int x,y,z;
  8. x = (int) e.entityItem.posX;
  9. y = (int) e.entityItem.posY;
  10. z = (int) e.entityItem.posZ;
  11.  
  12. if(e.entityItem.getEntityItem().getItem() == Items.diamond){
  13. System.out.println("Item detected");
  14. e.entityItem.lifespan = 20;
  15. }
  16. }
  17.  
  18. @SubscribeEvent
  19. public void diamondExpire(ItemExpireEvent e){
  20. World world = e.entityItem.worldObj;
  21. int x,y,z;
  22. x = (int) e.entityItem.posX;
  23. y = (int)e.entityItem.posY;
  24. z = (int) e.entityItem.posZ;
  25. if(e.entityItem.getEntityItem().getItem() == Items.diamond){
  26. if(world.getBlock(x, y, z) == Blocks.water && world.getBlock(x, y-1, z) == Blocks.diamond_block ){
  27. e.entityItem.dropItem(testmod.testitem, 1);
  28. }else{
  29. EntityItem diamond = new EntityItem(world,e.entityItem.posX,e.entityItem.posY,e.entityItem.posZ);
  30. diamond.setEntityItemStack(new ItemStack(Items.diamond));
  31. diamond.setPosition(e.entityItem.posX,e.entityItem.posY,e.entityItem.posZ);
  32. world.spawnEntityInWorld(diamond);
  33. }
  34.  
  35. }
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment