Search in sources :

Example 1 with ColonyViewRemoveBuildingMessage

use of com.minecolonies.coremod.network.messages.ColonyViewRemoveBuildingMessage in project minecolonies by Minecolonies.

the class BuildingManager method removeBuilding.

@Override
public void removeBuilding(@NotNull final AbstractBuilding building, final Set<EntityPlayerMP> subscribers) {
    if (buildings.remove(building.getID()) != null) {
        for (final EntityPlayerMP player : subscribers) {
            MineColonies.getNetwork().sendTo(new ColonyViewRemoveBuildingMessage(colony, building.getID()), player);
        }
        Log.getLogger().info(String.format("Colony %d - removed AbstractBuilding %s of type %s", colony.getID(), building.getID(), building.getSchematicName()));
    }
    if (building instanceof BuildingTownHall) {
        townHall = null;
    } else if (building instanceof BuildingWareHouse) {
        wareHouse = null;
    }
    colony.getRequestManager().onProviderRemovedFromColony(building);
    // Allow Citizens to fix up any data that wasn't fixed up by the AbstractBuilding's own onDestroyed
    for (@NotNull final CitizenData citizen : colony.getCitizenManager().getCitizens()) {
        citizen.onRemoveBuilding(building);
    }
    colony.getCitizenManager().calculateMaxCitizens();
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CitizenData(com.minecolonies.coremod.colony.CitizenData) ColonyViewRemoveBuildingMessage(com.minecolonies.coremod.network.messages.ColonyViewRemoveBuildingMessage) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CitizenData (com.minecolonies.coremod.colony.CitizenData)1 ColonyViewRemoveBuildingMessage (com.minecolonies.coremod.network.messages.ColonyViewRemoveBuildingMessage)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 NotNull (org.jetbrains.annotations.NotNull)1