Class ThrownEggHatchEvent

java.lang.Object
org.bukkit.event.Event
com.destroystokyo.paper.event.entity.ThrownEggHatchEvent

@NullMarked public class ThrownEggHatchEvent extends Event
Called when a thrown egg might hatch.

This event fires for all thrown eggs that may hatch, players, dispensers, etc.

Since:
1.15.2
  • Constructor Details

    • ThrownEggHatchEvent

      @Internal public ThrownEggHatchEvent(Egg egg, boolean hatching, byte numHatches, EntityType hatchingType)
  • Method Details

    • getEgg

      public Egg getEgg()
      Gets the egg involved in this event.
      Returns:
      the egg involved in this event
      Since:
      1.15.2
    • isHatching

      public boolean isHatching()
      Gets whether the egg is hatching or not. Will be what the server would've done without interaction.
      Returns:
      boolean Whether the egg is going to hatch or not
      Since:
      1.15.2
    • setHatching

      public void setHatching(boolean hatching)
      Sets whether the egg will hatch or not.
      Parameters:
      hatching - true if you want the egg to hatch, false if you want it not to
      Since:
      1.15.2
    • getHatchingType

      public EntityType getHatchingType()
      Get the type of the mob being hatched (EntityType.CHICKEN by default)
      Returns:
      The type of the mob being hatched by the egg
      Since:
      1.15.2
    • setHatchingType

      public void setHatchingType(EntityType hatchType)
      Change the type of mob being hatched by the egg
      Parameters:
      hatchType - The type of the mob being hatched by the egg
      Since:
      1.15.2
    • getNumHatches

      public byte getNumHatches()
      Get the number of mob hatches from the egg. By default, the number will be the number the server would've done
      • 7/8 chance of being 0
      • 31/256 ~= 1/8 chance to be 1
      • 1/256 chance to be 4
      Returns:
      The number of mobs going to be hatched by the egg
      Since:
      1.15.2
    • setNumHatches

      public void setNumHatches(byte numHatches)
      Change the number of mobs coming out of the hatched egg

      The boolean hatching will override this number. I.e. If hatching is false, this number will not matter

      Parameters:
      numHatches - The number of mobs coming out of the egg
      Since:
      1.15.2
    • getHandlers

      public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
      Since:
      1.15.2
    • getHandlerList

      public static HandlerList getHandlerList()
      Since:
      1.15.2