Class EventManager
java.lang.Object
com.minecolonies.core.colony.managers.EventManager
- All Implemented Interfaces:
IEventManager
Manager for all colony related events.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvent(IColonyEvent colonyEvent) Adds an eventintIncrements the id, and returns the taken id.getEventByID(int ID) Gets an event by its IDReturns the full event MapReturns the associated structure manager, which manages structure spawn/despawn for events.voidonColonyTick(@NotNull IColony colony) Updates the current events.voidonEntityDeath(net.minecraft.world.entity.LivingEntity entity, int eventID) Triggers on entity death(killed by player/environment) of an entityvoidAllows events to react to nightfall, which is always calculated by the colony itselfvoidonTileEntityBreak(int eventID, net.minecraft.world.level.block.entity.BlockEntity te) Forwards a broken tileEntity to the given event, to react to TE breaks.voidreadFromNBT(@NotNull net.minecraft.nbt.CompoundTag compound) Reads the eventManager nbt and creates events from itvoidregisterEntity(@NotNull net.minecraft.world.entity.Entity entity, int eventID) Registers an entity with the given event.voidunregisterEntity(@NotNull net.minecraft.world.entity.Entity entity, int eventID) Unregisters an entity with the given eventvoidwriteToNBT(@NotNull net.minecraft.nbt.CompoundTag compound) Write the eventmanager and all events to NBT
-
Constructor Details
-
EventManager
-
-
Method Details
-
addEvent
Description copied from interface:IEventManagerAdds an event- Specified by:
addEventin interfaceIEventManager- Parameters:
colonyEvent- event to add
-
getAndTakeNextEventID
public int getAndTakeNextEventID()Increments the id, and returns the taken id.- Specified by:
getAndTakeNextEventIDin interfaceIEventManager- 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:
registerEntityin interfaceIEventManager- 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:
unregisterEntityin interfaceIEventManager- 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:
onEntityDeathin interfaceIEventManager- 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:IEventManagerForwards a broken tileEntity to the given event, to react to TE breaks. The TE needs to call this on break- Specified by:
onTileEntityBreakin interfaceIEventManager- Parameters:
eventID- ID of the related eventte- tileentity to use
-
onNightFall
public void onNightFall()Description copied from interface:IEventManagerAllows events to react to nightfall, which is always calculated by the colony itself- Specified by:
onNightFallin interfaceIEventManager
-
getEventByID
Gets an event by its ID- Specified by:
getEventByIDin interfaceIEventManager- Parameters:
ID- the id of the event.- Returns:
- the event or null.
-
onColonyTick
Updates the current events.- Specified by:
onColonyTickin interfaceIEventManager- Parameters:
colony- the colony being ticked.
-
getEvents
Description copied from interface:IEventManagerReturns the full event Map- Specified by:
getEventsin interfaceIEventManager- Returns:
- the map of events per colony.
-
readFromNBT
public void readFromNBT(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Description copied from interface:IEventManagerReads the eventManager nbt and creates events from it- Specified by:
readFromNBTin interfaceIEventManager- Parameters:
compound- the compound to read from.
-
writeToNBT
public void writeToNBT(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Description copied from interface:IEventManagerWrite the eventmanager and all events to NBT- Specified by:
writeToNBTin interfaceIEventManager- Parameters:
compound- the compound to write to.
-
getStructureManager
Description copied from interface:IEventManagerReturns the associated structure manager, which manages structure spawn/despawn for events.- Specified by:
getStructureManagerin interfaceIEventManager- Returns:
- the manager.
-