Egg custom name is null on ProjectileHitEvent even though it is set on EggThrowEvent

Discussion in 'Plugin Development' started by qLate, Feb 15, 2021.

  1. Offline

    qLate

    I'm currently storing data in egg's custom name for further usage. I'm setting it up in the EggThrowEvent and taking info at ProjectileHitEvent and it returns null. Here's my code upload_2021-2-15_12-27-1.png

    And there is a "null" in console, what's wrong with my code?
     
  2. Offline

    Kars

    Because the egg is not named.
    setCustomName is ment for mobs/blocks and not for eggs.
     
  3. Offline

    qLate

    Thanks for the reply!! So how can i do this right?
     
  4. Online

    timtower Administrator Administrator Moderator

    Save the UUID of the egg.
     
  5. Offline

    qLate

    Can you give a little more information how to do this?
     
  6. Online

    timtower Administrator Administrator Moderator

    Make a list<uuid> in the class, on throw: add the egg, on hit: check if egg is in the list, if so: spawn tnt, remove uuid from list
     
  7. Offline

    Kars

    @qLate he probably means HashMap<UUID, Egg>
     
  8. Online

    timtower Administrator Administrator Moderator

    Entity has uuid, don't see why I need both sides
     

Share This Page