Search in sources :

Example 1 with ColonyViewRemoveCitizenMessage

use of com.minecolonies.coremod.network.messages.client.colony.ColonyViewRemoveCitizenMessage in project minecolonies by Minecolonies.

the class CitizenManager method removeCivilian.

@Override
public void removeCivilian(@NotNull final ICivilianData citizen) {
    if (!(citizen instanceof ICitizenData)) {
        return;
    }
    // Remove the Citizen
    citizens.remove(citizen.getId());
    for (@NotNull final IBuilding building : colony.getBuildingManager().getBuildings().values()) {
        for (final AbstractAssignedCitizenModule assignedCitizenModule : building.getModules(AbstractAssignedCitizenModule.class)) {
            assignedCitizenModule.removeCitizen((ICitizenData) citizen);
        }
    }
    colony.getWorkManager().clearWorkForCitizen((ICitizenData) citizen);
    // Inform Subscribers of removed citizen
    for (final ServerPlayerEntity player : colony.getPackageManager().getCloseSubscribers()) {
        Network.getNetwork().sendToPlayer(new ColonyViewRemoveCitizenMessage(colony, citizen.getId()), player);
    }
    calculateMaxCitizens();
    markDirty();
    colony.markDirty();
}
Also used : ColonyViewRemoveCitizenMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewRemoveCitizenMessage) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ICitizenData(com.minecolonies.api.colony.ICitizenData) AbstractAssignedCitizenModule(com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ColonyViewRemoveCitizenMessage

use of com.minecolonies.coremod.network.messages.client.colony.ColonyViewRemoveCitizenMessage in project minecolonies by ldtteam.

the class CitizenManager method removeCivilian.

@Override
public void removeCivilian(@NotNull final ICivilianData citizen) {
    if (!(citizen instanceof ICitizenData)) {
        return;
    }
    // Remove the Citizen
    citizens.remove(citizen.getId());
    for (@NotNull final IBuilding building : colony.getBuildingManager().getBuildings().values()) {
        for (final AbstractAssignedCitizenModule assignedCitizenModule : building.getModules(AbstractAssignedCitizenModule.class)) {
            assignedCitizenModule.removeCitizen((ICitizenData) citizen);
        }
    }
    colony.getWorkManager().clearWorkForCitizen((ICitizenData) citizen);
    // Inform Subscribers of removed citizen
    for (final ServerPlayerEntity player : colony.getPackageManager().getCloseSubscribers()) {
        Network.getNetwork().sendToPlayer(new ColonyViewRemoveCitizenMessage(colony, citizen.getId()), player);
    }
    calculateMaxCitizens();
    markDirty();
    colony.markDirty();
}
Also used : ColonyViewRemoveCitizenMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewRemoveCitizenMessage) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ICitizenData(com.minecolonies.api.colony.ICitizenData) AbstractAssignedCitizenModule(com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ICitizenData (com.minecolonies.api.colony.ICitizenData)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 AbstractAssignedCitizenModule (com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule)2 ColonyViewRemoveCitizenMessage (com.minecolonies.coremod.network.messages.client.colony.ColonyViewRemoveCitizenMessage)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 NotNull (org.jetbrains.annotations.NotNull)2