Class EntityMobGriefingEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.EntityMobGriefingEvent

public class EntityMobGriefingEvent extends EntityEvent
EntityMobGriefingEvent is fired when mob griefing is about to occur and allows an event listener to specify whether it should or not.
This event is fired when ever the mob griefing game rule is checked.
  • Field Details

    • isMobGriefingEnabled

      private final boolean isMobGriefingEnabled
    • canGrief

      private boolean canGrief
  • Constructor Details

    • EntityMobGriefingEvent

      public EntityMobGriefingEvent(Level level, Entity entity)
  • Method Details

    • isMobGriefingEnabled

      public boolean isMobGriefingEnabled()
      Returns if the mob griefing game rule is enabled.

      The default state of this event is equivalent to this value.

    • setCanGrief

      public void setCanGrief(boolean canGrief)
      Changes if the entity is allowed to perform the griefing action.
      Parameters:
      canGrief - True if the action should be allowed, false otherwise.
    • canGrief

      public boolean canGrief()
      Returns if the entity is allowed to perform the griefing action.
      Returns:
      if the entity is allowed to perform the griefing action