Keep players from acquiring dragon egg blocks

Discussion in 'Plugin Development' started by Ne0nx3r0, Mar 8, 2013.

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

    Ne0nx3r0

    So, my goal is to keep a dragon egg block from ending up as a dragon egg in a player's hand. I track the block in a list, and use metadata to mark the block as unavailable. Underneath them is a bedrock block.

    I also stop pistons from pushing dragon eggs that are unavailable, and cancel click events as well.

    Is there anything else I need to do in order to keep players from getting the eggs?
     
  2. Offline

    -_Husky_-

    Ne0nx3r0 Does water / lava effect them?
     
  3. Offline

    ZeusAllMighty11

    -_Husky_- likes this.
  4. Offline

    Ne0nx3r0

    -_Husky_- likes this.
  5. Offline

    Tirelessly

  6. Offline

    Ne0nx3r0

    I've taken care of this with:
    Code:
    @EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true)
     
        public void onPistonExtend(BlockPistonExtendEvent e)
        {
            BlockFace bf = e.getDirection();
     
            for(int i=1;i<=12;i++)
            {
                if(plugin.bossManager.isBossEgg(e.getBlock().getRelative(bf,i)))
                {
                    e.setCancelled(true);
     
                    break;
                }
            }
        }
    I'm not a fan of having to iterate all 12 blocks, but for some reason just using e.getBlocks() wouldn't return the dragon egg block.

    Oh fair point. I suppose I should iterate the blocks in an explosion radius, presuming the egg would be dropped instead of just blown away.

    Well I'm not fond of it, but this works for explosions:
    Code:
    @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
        public void onEntityExplode(EntityExplodeEvent e)
        {
            for(Block b : e.blockList())
            {
                if(plugin.bossManager.isBossEgg(b))
                {
                    plugin.bossManager.removeBossEgg(b.getLocation());
                }
            }
        }
    
    Sets the egg to air before the explosion to get rid of it.

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

    -_Husky_-

    Ne0nx3r0 My apologies, just throwing out ideas, never messed with Dragon eggs
     
  8. Offline

    Ne0nx3r0

    -_Husky_- It was a good thing to check, I just wanted to document that it didn't seem to be an issue.
     
    -_Husky_- likes this.
Thread Status:
Not open for further replies.

Share This Page