Comparing Spawneggs

Discussion in 'Spigot Plugin Development' started by xxHell_Killerxx, May 22, 2016.

  1. Hi,
    I heard that Mojang changed the way the data is stored in spawneggs, and checking durability does not work anymore.
    So I want to ask for the correct way of comparing two spawnegg itemstacks, to check if their entity's the same.
    Thx~
     
  2. Maybe this works (I didn't test it):
    Code (Text):
    public void compare(ItemStack egg1, ItemStack egg2) {
         if (egg1.getTypeId.equals(egg2.getTypeId)) {
              //Do this when true
              return;
         } else {
              //Do this when false
         }
    }
    There's a big chance that this won't work because I never tested it or used it in a plugin.
     
  3. Type id returns "383", so.. it doesn't quite work.
     
  4. Serializator

    Supporter

    Minecraft now stores the type of entity the spawn egg is holding in its NBT tag. You will have to modify the NBT tag to modify the entity the spawn egg is holding.

    The type is embedded in an NBTTagCompound named "EntityTag", in this compound you will find a key named "id" that holds the type. It's equal to EntityType#getName().

    I wrote a simple wrapper to make it easier to modify the NBT tag of both items and entities.
    You can find the repository here.
     
    • Agree Agree x 1