Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestDiamondToss {
- @SubscribeEvent
- public void diamondDropped(ItemTossEvent e){
- int counter;
- World world = e.player.getEntityWorld();
- int x,y,z;
- x = (int) e.entityItem.posX;
- y = (int) e.entityItem.posY;
- z = (int) e.entityItem.posZ;
- if(e.entityItem.getEntityItem().getItem() == Items.diamond){
- System.out.println("Item detected");
- e.entityItem.lifespan = 20;
- }
- }
- @SubscribeEvent
- public void diamondExpire(ItemExpireEvent e){
- World world = e.entityItem.worldObj;
- int x,y,z;
- x = (int) e.entityItem.posX;
- y = (int)e.entityItem.posY;
- z = (int) e.entityItem.posZ;
- if(e.entityItem.getEntityItem().getItem() == Items.diamond){
- if(world.getBlock(x, y, z) == Blocks.water && world.getBlock(x, y-1, z) == Blocks.diamond_block ){
- e.entityItem.dropItem(testmod.testitem, 1);
- }else{
- EntityItem diamond = new EntityItem(world,e.entityItem.posX,e.entityItem.posY,e.entityItem.posZ);
- diamond.setEntityItemStack(new ItemStack(Items.diamond));
- diamond.setPosition(e.entityItem.posX,e.entityItem.posY,e.entityItem.posZ);
- world.spawnEntityInWorld(diamond);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment