Class CitizenManager
java.lang.Object
com.minecolonies.core.colony.managers.CitizenManager
- All Implemented Interfaces:
ICitizenManager,IEntityManager
-
Constructor Summary
Constructors -
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.voidClear dirty from all buildings.Creates Civilian Data for a new civilianGet all citizens.getCivilian(int citizenId) Get civilian by ID.@NotNull Map<Integer, ICivilianData> Returns a map of civilian in the colony.intGet the current amount of citizens, might be bigger thengetMaxCitizens()Get 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 citizensvoidMarks civilian data dirty.doubleGet the max citizens based on the research.voidCall this when citizens sleepvoidonColonyTick(IColony colony) Updates the citizen entities when needed and spawn the initial citizens on colony tick.voidCalled when flag is changedvoidonWakeUp()Called in the morning.voidread(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound) Read the civilian from nbt.voidRegister a civilian entity with the colonyvoidremoveCivilian(@NotNull ICivilianData citizen) Removes a civilian from the colony.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.voidsendPackets(@NotNull Set<net.minecraft.server.level.ServerPlayer> closeSubscribers, @NotNull Set<net.minecraft.server.level.ServerPlayer> newSubscribers) Sends packages to update the civilian.voidsetMaxCitizens(int newMaxCitizens) Set the new max citizens.voidsetPotentialMaxCitizens(int newPotentialMax) Set the new potential max citizens.voidSpawn a brand new Citizen.<T extends ICivilianData>
TspawnOrCreateCivilian(T data, net.minecraft.world.level.Level world, List<net.minecraft.core.BlockPos> spawnPositions, boolean force) Spawns a civilian with the specific civilian data.booleantickCitizenData(int tickRate) Tick the citizen data of all active citizens.voidUnregiters a civilian with the colonyvoidupdateCitizenMourn(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 asleepvoidwrite(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compoundNBT) Write the civilian to nbt.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.managers.interfaces.ICitizenManager
spawnOrCreateCitizen, spawnOrCreateCitizen
-
Constructor Details
-
CitizenManager
Creates the Citizenmanager for a colony.- Parameters:
colony- the colony.
-
-
Method Details
-
registerCivilian
Description copied from interface:IEntityManagerRegister a civilian entity with the colony- Specified by:
registerCivilianin interfaceIEntityManager- Parameters:
entity- civilian to register
-
unregisterCivilian
Description copied from interface:IEntityManagerUnregiters a civilian with the colony- Specified by:
unregisterCivilianin interfaceIEntityManager- Parameters:
entity- civilian to unregister
-
read
public void read(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Description copied from interface:IEntityManagerRead the civilian from nbt.- Specified by:
readin interfaceIEntityManager- Parameters:
compound- the compound to read it from.
-
write
public void write(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compoundNBT) Description copied from interface:IEntityManagerWrite the civilian to nbt.- Specified by:
writein interfaceIEntityManager- Parameters:
compoundNBT- the compound to write it to.
-
sendPackets
public void sendPackets(@NotNull @NotNull Set<net.minecraft.server.level.ServerPlayer> closeSubscribers, @NotNull @NotNull Set<net.minecraft.server.level.ServerPlayer> newSubscribers) Description copied from interface:IEntityManagerSends packages to update the civilian.- Specified by:
sendPacketsin interfaceIEntityManager- Parameters:
closeSubscribers- the existing subscribers.newSubscribers- new subscribers
-
spawnOrCreateCivilian
public <T extends ICivilianData> T spawnOrCreateCivilian(T data, net.minecraft.world.level.Level world, List<net.minecraft.core.BlockPos> spawnPositions, boolean force) Description copied from interface:IEntityManagerSpawns a civilian with the specific civilian data.- Specified by:
spawnOrCreateCivilianin interfaceIEntityManager- Parameters:
data- Data to use when spawn, null when new generation.world- THe world.spawnPositions- the positions to spawn it at, tried in order.force- True to skip max civilian test, false when not.- Returns:
- the new civilian.
-
createAndRegisterCivilianData
Description copied from interface:IEntityManagerCreates Civilian Data for a new civilian- Specified by:
createAndRegisterCivilianDatain interfaceICitizenManager- Specified by:
createAndRegisterCivilianDatain interfaceIEntityManager- Returns:
- new ICivilianData
-
resurrectCivilianData
public ICitizenData resurrectCivilianData(@NotNull @NotNull net.minecraft.nbt.CompoundTag compoundNBT, boolean resetId, @NotNull @NotNull net.minecraft.world.level.Level world, net.minecraft.core.BlockPos spawnPos) Description copied from interface:ICitizenManagerResurrect a citizen from its saved NBT.- Specified by:
resurrectCivilianDatain interfaceICitizenManager- 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
-
removeCivilian
Description copied from interface:IEntityManagerRemoves a civilian from the colony.- Specified by:
removeCivilianin interfaceIEntityManager- Parameters:
citizen- data to remove.
-
getJoblessCitizen
Description copied from interface:ICitizenManagerGet the first unemployed citizen.- Specified by:
getJoblessCitizenin interfaceICitizenManager- Returns:
- Citizen with no current job.
-
calculateMaxCitizens
public void calculateMaxCitizens()Description copied from interface:ICitizenManagerRecalculates how many citizen can be in the colony.- Specified by:
calculateMaxCitizensin interfaceICitizenManager
-
spawnOrCreateCitizen
public void spawnOrCreateCitizen()Spawn a brand new Citizen.- Specified by:
spawnOrCreateCitizenin interfaceICitizenManager
-
getCivilianDataMap
Description copied from interface:IEntityManagerReturns a map of civilian in the colony. The map has ID as key, and civilian data as value.- Specified by:
getCivilianDataMapin interfaceIEntityManager- Returns:
- Map of civilian in the colony, with as key the civilian ID, and as value the civilian data.
-
markDirty
public void markDirty()Description copied from interface:IEntityManagerMarks civilian data dirty.- Specified by:
markDirtyin interfaceIEntityManager
-
getCivilian
Description copied from interface:IEntityManagerGet civilian by ID.- Specified by:
getCivilianin interfaceICitizenManager- Specified by:
getCivilianin interfaceIEntityManager- Parameters:
citizenId- ID of the civilian.- Returns:
- ICivilianData associated with the ID, or null if it was not found.
-
clearDirty
public void clearDirty()Description copied from interface:IEntityManagerClear dirty from all buildings.- Specified by:
clearDirtyin interfaceIEntityManager
-
getCitizens
Description copied from interface:ICitizenManagerGet all citizens.- Specified by:
getCitizensin interfaceICitizenManager- Returns:
- a copy of the list of citizens.
-
getMaxCitizens
public int getMaxCitizens()Description copied from interface:ICitizenManagerGet max citizens of the colony.- Specified by:
getMaxCitizensin interfaceICitizenManager- Returns:
- the amount.
-
getPotentialMaxCitizens
public int getPotentialMaxCitizens()Description copied from interface:ICitizenManagerGet potential max citizens of the colony. The potential considers all available beds including not assigned guard towers.- Specified by:
getPotentialMaxCitizensin interfaceICitizenManager- Returns:
- the amount.
-
maxCitizensFromResearch
public double maxCitizensFromResearch()Description copied from interface:ICitizenManagerGet the max citizens based on the research.- Specified by:
maxCitizensFromResearchin interfaceICitizenManager- Returns:
- the max.
-
getCurrentCitizenCount
public int getCurrentCitizenCount()Get the current amount of citizens, might be bigger thengetMaxCitizens()- Specified by:
getCurrentCitizenCountin interfaceICitizenManager- Returns:
- The current amount of citizens in the colony.
-
setMaxCitizens
public void setMaxCitizens(int newMaxCitizens) Description copied from interface:ICitizenManagerSet the new max citizens.- Specified by:
setMaxCitizensin interfaceICitizenManager- Parameters:
newMaxCitizens- the amount to set.
-
setPotentialMaxCitizens
public void setPotentialMaxCitizens(int newPotentialMax) Description copied from interface:ICitizenManagerSet the new potential max citizens. The potential considers all available beds including not assigned guard towers.- Specified by:
setPotentialMaxCitizensin interfaceICitizenManager- Parameters:
newPotentialMax- the potential amount to set.
-
injectModifier
Description copied from interface:ICitizenManagerInject a modifier into all citizens- Specified by:
injectModifierin interfaceICitizenManager- Parameters:
modifier- the modifier.
-
checkCitizensForHappiness
public void checkCitizensForHappiness()Description copied from interface:ICitizenManagerCheck for the citizen happiness and update the colony happiness with it.- Specified by:
checkCitizensForHappinessin interfaceICitizenManager
-
tickCitizenData
public boolean tickCitizenData(int tickRate) Description copied from interface:ICitizenManagerTick the citizen data of all active citizens.- Specified by:
tickCitizenDatain interfaceICitizenManager
-
onColonyTick
Updates the citizen entities when needed and spawn the initial citizens on colony tick.- Specified by:
onColonyTickin interfaceIEntityManager- Parameters:
colony- the colony being ticked.
-
updateCitizenMourn
Description copied from interface:ICitizenManagerCall this to set all the citizens in the colony to mourn or not.- Specified by:
updateCitizenMournin interfaceICitizenManager- Parameters:
mourn- boolean to indicate if citizen should mourn or not
-
getRandomCitizen
Description copied from interface:ICitizenManagerGet a random citizen.- Specified by:
getRandomCitizenin interfaceICitizenManager- Returns:
- the random citizen.
-
updateCitizenSleep
public void updateCitizenSleep(boolean sleep) Description copied from interface:ICitizenManagerCall this to set all citizens asleep- Specified by:
updateCitizenSleepin interfaceICitizenManager- Parameters:
sleep- boolean to indicate whether the citizens are all asleep
-
onCitizenSleep
public void onCitizenSleep()Description copied from interface:ICitizenManagerCall this when citizens sleep- Specified by:
onCitizenSleepin interfaceICitizenManager
-
onWakeUp
public void onWakeUp()Description copied from interface:ICitizenManagerCalled in the morning.- Specified by:
onWakeUpin interfaceICitizenManager
-
afterBuildingLoad
public void afterBuildingLoad()Description copied from interface:ICitizenManagerPost building load actions- Specified by:
afterBuildingLoadin interfaceICitizenManager
-
onFlagChange
public void onFlagChange()Description copied from interface:ICitizenManagerCalled when flag is changed- Specified by:
onFlagChangein interfaceICitizenManager
-