How to respawn items after he disappears?

Discussion in 'Plugin Development' started by lucasdidur, Sep 24, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    lucasdidur

    After drop a item, he disappears after while, how do I check if it is still there, and if not, how do I show it again?

    I tried to use item.isDead() but not work.
     
  2. Offline

    ienze

    I mean than there is ItemDespwnEvent, or somethnig like this..
     
  3. Offline

    lucasdidur

    Last edited by a moderator: May 28, 2016
  4. Offline

    LukeSFT

    I think you can update a chunk

    Maybe with chunk.load();

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  5. Offline

    lucasdidur

    I used this, but not work

    Code:
    @EventHandler(priority = EventPriority.HIGH)
        public void onItemDespawnEvent(ItemDespawnEvent event)
        {
            Item item = event.getEntity();
                 
            if (item.hasMetadata("nodespawn"))
            {
                event.setCancelled(true);
                log.debug("ItemDespawnEvent: Evento Cancelado");
             
                World  w    = item.getWorld();
                int x  = (int)(double)item.getLocation().getX();
                int z  = (int)(double)item.getLocation().getZ();
             
                Chunk c = w.getChunkAt(x, z);
                c.unload();
                c.load();
            }
        }
    
     
Thread Status:
Not open for further replies.

Share This Page