Solved - CreatureSpawnEvent Item doesn't remove

Discussion in 'Spigot Plugin Development' started by Script1996, May 4, 2015.

  1. Hey guys,

    since I made a custom spawnegg and wanted to spawn a "normal" chicken, my itemstack doesn't want to remove 1 item on activate.

    Code (Text):
    @EventHandler
        public void ChickSpawn(CreatureSpawnEvent e) {
            if(e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG){
                if (e.getEntity().getName().equalsIgnoreCase("Chicken") && e.getCreatureType().toString().equals("CHICKEN")) {
                Location loc = e.getEntity().getLocation();
                e.getEntity().getWorld().spawnEntity(loc, EntityType.CHICKEN);
                e.getEntity().remove();
                }
            }
        }
    This is the code which fu*ks up.

    Short: I have 3customspawneggs, I use one, the chicken spawns but my item in hand is still on 3
     
  2. Get the player that spawned the egg, get their inventory, call the removeItem method.
     
  3. yeah but how to get a Player in the CreatureSpawnEvent ??
     
  4. Check if the player right clicked with a spawn egg recently using the player interact event.
     
  5. E: Okay did it
     
    #5 Script1996, May 4, 2015
    Last edited: May 5, 2015