diff --git a/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/AbstractCitizenModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/AbstractCitizenModEvent.java index eca9aa3123d..a8daefca5c2 100644 --- a/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/AbstractCitizenModEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/AbstractCitizenModEvent.java @@ -13,14 +13,15 @@ public class AbstractCitizenModEvent extends AbstractColonyModEvent /** * The citizen related to the event. */ - private final @NotNull ICitizenData citizen; + @NotNull + private final ICitizenData citizen; /** * Constructs a citizen-based event. * * @param citizen the citizen related to the event. */ - protected AbstractCitizenModEvent(final @NotNull ICitizenData citizen) + protected AbstractCitizenModEvent(@NotNull final ICitizenData citizen) { super(citizen.getColony()); this.citizen = citizen; diff --git a/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenRemovedModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenRemovedModEvent.java index 859bd3a0b34..9731d18b87d 100644 --- a/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenRemovedModEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenRemovedModEvent.java @@ -1,31 +1,50 @@ package com.minecolonies.api.eventbus.events.colony.citizens; -import com.minecolonies.api.colony.ICitizenData; +import com.minecolonies.api.colony.IColony; +import com.minecolonies.api.eventbus.events.colony.AbstractColonyModEvent; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; /** * Event for when a citizen was removed from the colony. */ -public final class CitizenRemovedModEvent extends AbstractCitizenModEvent +public final class CitizenRemovedModEvent extends AbstractColonyModEvent { + /** + * The id of the citizen. + */ + private final int citizenId; + /** * The damage source that caused a citizen to die. */ - private final @NotNull Entity.RemovalReason reason; + @NotNull + private final Entity.RemovalReason reason; /** * Citizen removed event. * - * @param citizen the citizen related to the event. - * @param reason the reason the citizen was removed. + * @param colony the colony related to the event. + * @param citizenId the id of the citizen. + * @param reason the reason the citizen was removed. */ - public CitizenRemovedModEvent(final @NotNull ICitizenData citizen, final @NotNull Entity.RemovalReason reason) + public CitizenRemovedModEvent(final @NotNull IColony colony, final int citizenId, final @NotNull Entity.RemovalReason reason) { - super(citizen); + super(colony); + this.citizenId = citizenId; this.reason = reason; } + /** + * The id of the citizen. + * + * @return the id. + */ + public int getCitizenId() + { + return citizenId; + } + /** * The damage source that caused the citizen to die. * diff --git a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java index a4e30440412..4a4297986ef 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -1582,10 +1582,7 @@ public void die(@NotNull final DamageSource damageSource) public void remove(final @NotNull RemovalReason reason) { super.remove(reason); - if (reason != RemovalReason.DISCARDED && citizenData != null) - { - IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenRemovedModEvent(citizenData, reason)); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenRemovedModEvent(citizenColonyHandler.getColony(), citizenId, reason)); } /**