Package org.bukkit.event.player

# Class PlayerEggThrowEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
org.bukkit.event.player.PlayerEggThrowEvent

public class PlayerEggThrowEvent extends PlayerEvent
Called when a player throws an egg and it might hatch

## Nested Class Summary

## Nested classes/interfaces inherited from class org.bukkit.event.Event

`Event.Result`

## Field Summary

### Fields inherited from class org.bukkit.event.player.PlayerEvent

`player`

## Constructor Summary

Constructors
Constructor
Description
`PlayerEggThrowEvent(@NotNull Player player, @NotNull Egg egg, boolean hatching, byte numHatches, @NotNull EntityType hatchingType)`

## Method Summary

Modifier and Type
Method
Description
`@NotNull Egg`
`getEgg()`
Gets the egg involved in this event.
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`@NotNull EntityType`
`getHatchingType()`
Get the type of the mob being hatched (EntityType.CHICKEN by default)
`byte`
`getNumHatches()`
Get the number of mob hatches from the egg.
`boolean`
`isHatching()`
Gets whether the egg is hatching or not.
`void`
`setHatching(boolean hatching)`
Sets whether the egg will hatch or not.
`void`
`setHatchingType(@NotNull EntityType hatchType)`
Change the type of mob being hatched by the egg
`void`
`setNumHatches(byte numHatches)`
Change the number of mobs coming out of the hatched egg

### Methods inherited from class org.bukkit.event.player.PlayerEvent

`getPlayer`

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PlayerEggThrowEvent

public PlayerEggThrowEvent(@NotNull @NotNull Player player, @NotNull @NotNull Egg egg, boolean hatching, byte numHatches, @NotNull @NotNull EntityType hatchingType)

## Method Details

### getEgg

@NotNull public @NotNull Egg getEgg()
Gets the egg involved in this event.

Returns:
  the egg involved in this event

### 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

### 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

### getHatchingType

@NotNull public @NotNull 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

### setHatchingType

public void setHatchingType(@NotNull @NotNull EntityType hatchType)
Change the type of mob being hatched by the egg

Parameters:
  `hatchType` - The type of the mob being hatched by the egg

### 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

### setNumHatches

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

The boolean hatching will override this number. Ie. If hatching = false, this number will not matter

Parameters:
  `numHatches` - The number of mobs coming out of the egg

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()