java.lang.Object
com.minecolonies.core.colony.eventhooks.citizenEvents.AbstractCitizenEvent
com.minecolonies.core.colony.eventhooks.citizenEvents.CitizenDiedEvent
All Implemented Interfaces:
ICitizenEventDescription, IColonyEventDescription, net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>

public class CitizenDiedEvent extends AbstractCitizenEvent
The event for handling a citizen death.
  • Field Details

    • CITIZEN_DIED_EVENT_ID

      public static final net.minecraft.resources.ResourceLocation CITIZEN_DIED_EVENT_ID
      This events id, registry entries use res locations as ids.
  • Constructor Details

    • CitizenDiedEvent

      public CitizenDiedEvent()
      Creates a new citizen died event.
    • CitizenDiedEvent

      public CitizenDiedEvent(net.minecraft.core.BlockPos eventPos, String citizenName, String deathCause)
      Creates a new citizen died event.
      Parameters:
      eventPos - the position of the hut block of the building.
      citizenName - the name of the building.
      deathCause - the cause of the citizen death.
  • Method Details

    • getEventTypeId

      public net.minecraft.resources.ResourceLocation getEventTypeId()
      Description copied from interface: IColonyEventDescription
      Gets this event types registry id.
      Returns:
      this event types registry id.
    • getName

      public String getName()
      Description copied from interface: IColonyEventDescription
      Gets the name of this event type.
      Returns:
      the name of this event type.
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider)
      Specified by:
      serializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      serializeNBT in class AbstractCitizenEvent
    • deserializeNBT

      public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound)
      Specified by:
      deserializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      deserializeNBT in class AbstractCitizenEvent
    • serialize

      public void serialize(net.minecraft.network.RegistryFriendlyByteBuf buf)
      Description copied from interface: IColonyEventDescription
      Serializes this event to the given RegistryFriendlyByteBuf.
      Specified by:
      serialize in interface IColonyEventDescription
      Overrides:
      serialize in class AbstractCitizenEvent
      Parameters:
      buf - the RegistryFriendlyByteBuf to serialize to.
    • deserialize

      public void deserialize(net.minecraft.network.RegistryFriendlyByteBuf buf)
      Description copied from interface: IColonyEventDescription
      Deserializes this event from the given RegistryFriendlyByteBuf.
      Specified by:
      deserialize in interface IColonyEventDescription
      Overrides:
      deserialize in class AbstractCitizenEvent
      Parameters:
      buf - the RegistryFriendlyByteBuf to deserialize from.
    • getDeathCause

      public String getDeathCause()
      Gets the cause of the citizen death.
      Returns:
      the cause of the citizen death.
    • setDeathCause

      public void setDeathCause(String deathCause)
      Sets the cause of the citizen death.
      Parameters:
      deathCause - the cause of the citizen death.
    • loadFromNBT

      public static CitizenDiedEvent loadFromNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Loads the citizen died event from the given nbt.
      Parameters:
      compound - the NBT compound
      Returns:
      the colony to load.
    • loadFromFriendlyByteBuf

      public static CitizenDiedEvent loadFromFriendlyByteBuf(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
      Loads the citizen died event from the given packet buffer.
      Parameters:
      buf - the packet buffer.
      Returns:
      the colony to load.