Class EventManager

java.lang.Object
com.minecolonies.core.colony.managers.EventManager
All Implemented Interfaces:
IEventManager

public class EventManager extends Object implements IEventManager
Manager for all colony related events.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEvent(IColonyEvent colonyEvent)
    Adds an event
    int
    Increments the id, and returns the taken id.
    getEventByID(int ID)
    Gets an event by its ID
    Returns the full event Map
    Returns the associated structure manager, which manages structure spawn/despawn for events.
    void
    onColonyTick(@NotNull IColony colony)
    Updates the current events.
    void
    onEntityDeath(net.minecraft.world.entity.LivingEntity entity, int eventID)
    Triggers on entity death(killed by player/environment) of an entity
    void
    Allows events to react to nightfall, which is always calculated by the colony itself
    void
    onTileEntityBreak(int eventID, net.minecraft.world.level.block.entity.BlockEntity te)
    Forwards a broken tileEntity to the given event, to react to TE breaks.
    void
    readFromNBT(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound)
    Reads the eventManager nbt and creates events from it
    void
    registerEntity(@NotNull net.minecraft.world.entity.Entity entity, int eventID)
    Registers an entity with the given event.
    void
    unregisterEntity(@NotNull net.minecraft.world.entity.Entity entity, int eventID)
    Unregisters an entity with the given event
    void
    writeToNBT(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound)
    Write the eventmanager and all events to NBT

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EventManager

      public EventManager(IColony colony)
  • Method Details

    • addEvent

      public void addEvent(IColonyEvent colonyEvent)
      Description copied from interface: IEventManager
      Adds an event
      Specified by:
      addEvent in interface IEventManager
      Parameters:
      colonyEvent - event to add
    • getAndTakeNextEventID

      public int getAndTakeNextEventID()
      Increments the id, and returns the taken id.
      Specified by:
      getAndTakeNextEventID in interface IEventManager
      Returns:
      the next event Id.
    • registerEntity

      public void registerEntity(@NotNull @NotNull net.minecraft.world.entity.Entity entity, int eventID)
      Registers an entity with the given event.
      Specified by:
      registerEntity in interface IEventManager
      Parameters:
      entity - the entity to register.
      eventID - the event id to register it to.
    • unregisterEntity

      public void unregisterEntity(@NotNull @NotNull net.minecraft.world.entity.Entity entity, int eventID)
      Unregisters an entity with the given event
      Specified by:
      unregisterEntity in interface IEventManager
      Parameters:
      entity - the entity.
      eventID - the id of th eevent.
    • onEntityDeath

      public void onEntityDeath(net.minecraft.world.entity.LivingEntity entity, int eventID)
      Triggers on entity death(killed by player/environment) of an entity
      Specified by:
      onEntityDeath in interface IEventManager
      Parameters:
      entity - the entity.
      eventID - the id of the event.
    • onTileEntityBreak

      public void onTileEntityBreak(int eventID, net.minecraft.world.level.block.entity.BlockEntity te)
      Description copied from interface: IEventManager
      Forwards a broken tileEntity to the given event, to react to TE breaks. The TE needs to call this on break
      Specified by:
      onTileEntityBreak in interface IEventManager
      Parameters:
      eventID - ID of the related event
      te - tileentity to use
    • onNightFall

      public void onNightFall()
      Description copied from interface: IEventManager
      Allows events to react to nightfall, which is always calculated by the colony itself
      Specified by:
      onNightFall in interface IEventManager
    • getEventByID

      public IColonyEvent getEventByID(int ID)
      Gets an event by its ID
      Specified by:
      getEventByID in interface IEventManager
      Parameters:
      ID - the id of the event.
      Returns:
      the event or null.
    • onColonyTick

      public void onColonyTick(@NotNull @NotNull IColony colony)
      Updates the current events.
      Specified by:
      onColonyTick in interface IEventManager
      Parameters:
      colony - the colony being ticked.
    • getEvents

      public Map<Integer,IColonyEvent> getEvents()
      Description copied from interface: IEventManager
      Returns the full event Map
      Specified by:
      getEvents in interface IEventManager
      Returns:
      the map of events per colony.
    • readFromNBT

      public void readFromNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IEventManager
      Reads the eventManager nbt and creates events from it
      Specified by:
      readFromNBT in interface IEventManager
      Parameters:
      compound - the compound to read from.
    • writeToNBT

      public void writeToNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IEventManager
      Write the eventmanager and all events to NBT
      Specified by:
      writeToNBT in interface IEventManager
      Parameters:
      compound - the compound to write to.
    • getStructureManager

      public IEventStructureManager getStructureManager()
      Description copied from interface: IEventManager
      Returns the associated structure manager, which manages structure spawn/despawn for events.
      Specified by:
      getStructureManager in interface IEventManager
      Returns:
      the manager.