Interface ICitizenManager
- All Superinterfaces:
IEntityManager
- All Known Implementing Classes:
CitizenManager
The interface of the citizen manager.
-
Method Summary
Modifier and TypeMethodDescriptionvoidPost building load actionsvoidRecalculates how many citizen can be in the colony.voidCheck for the citizen happiness and update the colony happiness with it.Creates Civilian Data for a new civilianGet all citizens.getCivilian(int citizenId) Get civilian by ID.intGet the current amount of citizens, might be bigger thengetMaxCitizens()@Nullable ICitizenDataGet the first unemployed citizen.intGet max citizens of the colony.intGet potential max citizens of the colony.Get a random citizen.voidinjectModifier(IHappinessModifier modifier) Inject a modifier into all citizensdoubleGet the max citizens based on the research.voidCall this when citizens sleepvoidCalled when flag is changedvoidonWakeUp()Called in the morning.resurrectCivilianData(@NotNull net.minecraft.nbt.CompoundTag compoundNBT, boolean resetId, @NotNull net.minecraft.world.level.Level world, net.minecraft.core.BlockPos spawnPos) Resurrect a citizen from its saved NBT.voidsetMaxCitizens(int newMaxCitizens) Set the new max citizens.voidsetPotentialMaxCitizens(int newMaxCitizens) Set the new potential max citizens.voidSpawn a brand new Citizen.default ICitizenDataspawnOrCreateCitizen(ICitizenData data, @NotNull net.minecraft.world.level.Level world) Spawn a citizen with specific citizen data.default ICitizenDataspawnOrCreateCitizen(ICitizenData data, @NotNull net.minecraft.world.level.Level world, net.minecraft.core.BlockPos spawnPos) Spawn a citizen with specific citizen data.booleantickCitizenData(int tickRate) Tick the citizen data of all active citizens.voidupdateCitizenMourn(ICitizenData data, boolean mourn) Call this to set all the citizens in the colony to mourn or not.voidupdateCitizenSleep(boolean sleep) Call this to set all citizens asleepMethods inherited from interface com.minecolonies.api.colony.managers.interfaces.IEntityManager
clearDirty, getCivilianDataMap, markDirty, onColonyTick, read, registerCivilian, removeCivilian, sendPackets, spawnOrCreateCivilian, unregisterCivilian, write
-
Method Details
-
spawnOrCreateCitizen
void spawnOrCreateCitizen()Spawn a brand new Citizen. -
spawnOrCreateCitizen
default ICitizenData spawnOrCreateCitizen(ICitizenData data, @NotNull @NotNull net.minecraft.world.level.Level world) Spawn a citizen with specific citizen data.- Parameters:
data- Data to use to spawn citizen.world- the world to spawn it in.- Returns:
- the citizen data of the spawned citizen.
-
spawnOrCreateCitizen
default ICitizenData spawnOrCreateCitizen(ICitizenData data, @NotNull @NotNull net.minecraft.world.level.Level world, net.minecraft.core.BlockPos spawnPos) Spawn a citizen with specific citizen data.- Parameters:
data- Data to use to spawn citizen.world- the world to spawn it in.spawnPos- the Blockposition to spawn at- Returns:
- the new citizen.
-
getJoblessCitizen
Get the first unemployed citizen.- Returns:
- Citizen with no current job.
-
calculateMaxCitizens
void calculateMaxCitizens()Recalculates how many citizen can be in the colony. -
createAndRegisterCivilianData
ICitizenData createAndRegisterCivilianData()Description copied from interface:IEntityManagerCreates Civilian Data for a new civilian- Specified by:
createAndRegisterCivilianDatain interfaceIEntityManager- Returns:
- new ICivilianData
-
resurrectCivilianData
ICitizenData resurrectCivilianData(@NotNull @NotNull net.minecraft.nbt.CompoundTag compoundNBT, boolean resetId, @NotNull @NotNull net.minecraft.world.level.Level world, net.minecraft.core.BlockPos spawnPos) Resurrect a citizen from its saved NBT.- Parameters:
compoundNBT- the saved citizen NBTresetId- if true, will calculate a new citizen IDworld-spawnPos- position where to resurrect the citizen- Returns:
- the citizenData of the resurrected citizen
-
getCitizens
List<ICitizenData> getCitizens()Get all citizens.- Returns:
- a copy of the list of citizens.
-
getMaxCitizens
int getMaxCitizens()Get max citizens of the colony.- Returns:
- the amount.
-
getPotentialMaxCitizens
int getPotentialMaxCitizens()Get potential max citizens of the colony. The potential considers all available beds including not assigned guard towers.- Returns:
- the amount.
-
maxCitizensFromResearch
double maxCitizensFromResearch()Get the max citizens based on the research.- Returns:
- the max.
-
getCurrentCitizenCount
int getCurrentCitizenCount()Get the current amount of citizens, might be bigger thengetMaxCitizens()- Returns:
- The current amount of citizens in the colony.
-
setMaxCitizens
void setMaxCitizens(int newMaxCitizens) Set the new max citizens.- Parameters:
newMaxCitizens- the amount to set.
-
setPotentialMaxCitizens
void setPotentialMaxCitizens(int newMaxCitizens) Set the new potential max citizens. The potential considers all available beds including not assigned guard towers.- Parameters:
newMaxCitizens- the potential amount to set.
-
checkCitizensForHappiness
void checkCitizensForHappiness()Check for the citizen happiness and update the colony happiness with it. -
tickCitizenData
boolean tickCitizenData(int tickRate) Tick the citizen data of all active citizens. -
updateCitizenMourn
Call this to set all the citizens in the colony to mourn or not.- Parameters:
mourn- boolean to indicate if citizen should mourn or not
-
updateCitizenSleep
void updateCitizenSleep(boolean sleep) Call this to set all citizens asleep- Parameters:
sleep- boolean to indicate whether the citizens are all asleep
-
getRandomCitizen
ICitizenData getRandomCitizen()Get a random citizen.- Returns:
- the random citizen.
-
injectModifier
Inject a modifier into all citizens- Parameters:
modifier- the modifier.
-
onCitizenSleep
void onCitizenSleep()Call this when citizens sleep -
getCivilian
Description copied from interface:IEntityManagerGet civilian by ID.- Specified by:
getCivilianin interfaceIEntityManager- Parameters:
citizenId- ID of the civilian.- Returns:
- ICivilianData associated with the ID, or null if it was not found.
-
onWakeUp
void onWakeUp()Called in the morning. -
afterBuildingLoad
void afterBuildingLoad()Post building load actions -
onFlagChange
void onFlagChange()Called when flag is changed
-