Class AbstractBuildingGuards
java.lang.Object
com.minecolonies.core.colony.buildings.AbstractSchematicProvider
com.minecolonies.core.colony.buildings.AbstractBuildingContainer
com.minecolonies.core.colony.buildings.AbstractBuilding
com.minecolonies.core.colony.buildings.AbstractBuildingGuards
- All Implemented Interfaces:
IBuilding,IBuildingContainer,ICommonBuilding,IGuardBuilding,ISchematicProvider,IBuildingModuleContainer,IModuleContainer<IBuildingModule>,IRequester,IRequestResolverProvider,IItemHandlerCapProvider,net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
BuildingBarracksTower,BuildingGateHouse,BuildingGuardTower,BuildingStable
Abstract class for Guard huts.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe client view for the Guard building. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intBase Vision range per building level.protected static final intThe Bonus Health for each building levelstatic final ISettingKey<GuardFollowModeSetting> static final ISettingKey<GuardTaskSetting> static final ISettingKey<BoolSetting> static final StringList of hostiles.static final ISettingKey<GuardPatrolModeSetting> protected List<net.minecraft.core.BlockPos> The list of manual patrol targets.static final ISettingKey<BoolSetting> Settings.protected net.minecraft.core.BlockPosA temporary next patrol point, which gets consumed and used onceprotected static final intVision range per building level.Fields inherited from class com.minecolonies.core.colony.buildings.AbstractBuilding
BREEDING, modules, modulesMap, USE_SHEARSFields inherited from class com.minecolonies.core.colony.buildings.AbstractBuildingContainer
containerList, keepX, tileEntityFields inherited from class com.minecolonies.core.colony.buildings.AbstractSchematicProvider
colonyFields inherited from interface com.minecolonies.api.colony.buildings.IBuilding
WOOD_HUT_LEVELFields inherited from interface com.minecolonies.api.colony.buildings.IGuardBuilding
PATROL_DISTANCE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBuildingGuards(@NotNull IColony c, net.minecraft.core.BlockPos l) The abstract constructor of the building. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPatrolTarget(net.minecraft.core.BlockPos target) Adds new patrolTarget.voidCalled when a guard is at the current patrol pointvoidPopulates the mobs list from the BuiltInRegistries.voiddeserializeNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) intBonus guard hp per bulding levelintGet the Vision bonus range for the building levelnet.minecraft.core.BlockPosgetGuardPos(@NotNull AbstractEntityCitizen worker) Get the position the guard should guard.net.minecraft.core.BlockPosReturn the position of the mine to guard@Nullable net.minecraft.core.BlockPosgetNextPatrolTarget(boolean newTarget) Returns a patrolTarget to patrol to.intGetter for the patrol distance the guard currently has.@Nullable net.minecraft.world.entity.player.PlayerEntity of player to follow or rally.net.minecraft.core.BlockPosGets the position to follow.@Nullable ILocationLocation to to rally to.protected @Nullable net.minecraft.core.BlockPosGets a random automatic patrol target for this guard building.getTask()Get the guard's task.booleanReturns whether tight grouping in Follow mode is being used.voidonColonyTick(IColony colony) Regularly tick this building and check if we got the minimum stock(like once a minute is still fine) - If not: Check if there is a request for this already.voidonUpgradeComplete(@Nullable com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, int newLevel) We use this to set possible health multipliers and give achievements.booleanIf we have to calculate a new target manually.voidResets the patrolTargets list.net.minecraft.nbt.CompoundTagserializeNBT(net.minecraft.core.HolderLookup.Provider provider) voidserializeToView(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf, boolean fullSync) Serializes to view.voidsetGuardPos(net.minecraft.core.BlockPos guardPos) Set where the guard should guard.voidsetMinePos(net.minecraft.core.BlockPos pos) Set the position of the mine the guard is patrolling Check whether the given position is actually a minevoidsetPatrolTimer(int timer) Set the patroll timer.voidsetPlayerToFollow(net.minecraft.world.entity.player.Player player) Sets the player to follow.voidsetRallyLocation(ILocation location) Sets the location to rally.voidsetTempNextPatrolPoint(net.minecraft.core.BlockPos pos) Sets a one time consumed temporary next position to patrol towardsbooleanGet whether the guard should patrol manually.booleanGet the guard's RetrieveOnLowHeath.voidStarts the patrol to the next pointMethods inherited from class com.minecolonies.core.colony.buildings.AbstractBuilding
buildingRequiresCertainAmountOfItem, calculateCorners, calculatePrestige, canBeBuiltByBuilder, canBeGathered, cancelAllRequestsOfCitizenOrBuilding, canDeconstruct, clearDirty, createPickupRequest, createRequest, createRequest, createResolvers, deconstruct, destroy, forceTransferStack, getAllAssignedCitizen, getBuildingDisplayName, getCitizenForRequest, getClaimRadius, getClassType, getCompletedRequestsOfCitizenOrBuilding, getCompletedRequestsOfCitizenOrBuilding, getCompletedRequestsOfType, getCompletedRequestsOfTypeFiltered, getCraftingModuleForRecipe, getCustomName, getHandlers, getId, getLocation, getMaxBuildingLevel, getModule, getModule, getModules, getOpenRequests, getOpenRequestsByCitizen, getOpenRequestsByRequestableType, getOpenRequestsOfCitizenOrBuilding, getOpenRequestsOfType, getOpenRequestsOfTypeFiltered, getPrestige, getRequester, getRequesterDisplayName, getRequiredItemsAndAmount, getResolvers, getSetting, getSettingValueOrDefault, getTileEntity, hasCitizenCompletedRequests, hasCitizenCompletedRequestsToPickup, hasModule, hasOpenSyncRequest, hasWorkerOpenRequests, hasWorkerOpenRequestsFiltered, hasWorkerOpenRequestsOfType, isBuilt, isDirty, isGuardBuildingNear, isItemStackInRequest, isMatchingBlock, isPendingConstruction, keepFood, markDirty, markRequestAsAccepted, moveToSyncCitizen, onCleanUp, onDestroyed, onPlacement, onPlayerEnterBuilding, onPlayerEnterNearby, onRequestedRequestCancelled, onRequestedRequestComplete, onRestart, onWakeUp, overruleNextOpenRequestOfCitizenWithStack, overruleNextOpenRequestWithStack, pickUp, processOfflineTime, registerBlockPosition, registerModule, removeWorkOrder, requestRemoval, requestRepair, requestUpgrade, requestWorkOrder, reservedStacksExcluding, resetGuardBuildingNear, setCustomBuildingName, setupRsDataStore, writeRequestSystemToNBTMethods inherited from class com.minecolonies.core.colony.buildings.AbstractBuildingContainer
addContainerPosition, alterPickUpPriority, getContainers, getFirstLocationFromTag, getItemHandlerCap, getLocationsFromTag, getPickUpPriority, registerBlockPosition, removeContainerPosition, setTileEntityMethods inherited from class com.minecolonies.core.colony.buildings.AbstractSchematicProvider
asyncPrestigeRecalc, equals, getBlueprintPath, getBuildingLevel, getBuildingType, getChildren, getColony, getCorners, getID, getParent, getPosition, getRotationMirror, getStructurePack, hashCode, hasParent, isDeconstructed, isInBuilding, onUpgradeSchematicTo, safeUpdateTEDataFromSchematic, setBlueprintPath, setBuildingLevel, setBuildingType, setCorners, setDeconstructed, setParent, setRotationMirror, setStructurePack, upgradeBuildingLevelToSchematicDataMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.buildings.IBuilding
asyncPrestigeRecalc, buildingRequiresCertainAmountOfItem, buildingRequiresCertainAmountOfItem, calculateCorners, calculatePrestige, canAssignCitizens, canBeBuiltByBuilder, canBeGathered, cancelAllRequestsOfCitizenOrBuilding, canEat, canSort, createPickupRequest, createRequest, createRequest, createResolvers, deconstruct, destroy, forceTransferStack, getAllAssignedCitizen, getBuildingDisplayName, getCitizenForRequest, getClaimRadius, getCompletedRequestsOfCitizenOrBuilding, getCompletedRequestsOfType, getCompletedRequestsOfTypeFiltered, getCustomName, getHandlers, getLocationsFromTag, getMaxEquipmentLevel, getOpenRequests, getOpenRequestsByRequestableType, getOpenRequestsOfType, getOpenRequestsOfTypeFiltered, getRequester, getRequiredItemsAndAmount, getResolvers, getSetting, getSettingValueOrDefault, hasCitizenCompletedRequests, hasCitizenCompletedRequestsToPickup, hasOpenSyncRequest, hasWorkerOpenRequests, hasWorkerOpenRequestsFiltered, hasWorkerOpenRequestsOfType, isBuilt, isGuardBuildingNear, isInBuilding, isItemStackInRequest, isMatchingBlock, isPendingConstruction, markDirty, markRequestAsAccepted, onCleanUp, onDestroyed, onPlacement, onPlayerEnterBuilding, onPlayerEnterNearby, onRestart, onWakeUp, overruleNextOpenRequestOfCitizenWithStack, overruleNextOpenRequestWithStack, pickUp, processOfflineTime, removeWorkOrder, requestRemoval, requestRepair, requestUpgrade, reservedStacksExcluding, resetGuardBuildingNear, setBuildingType, setCustomBuildingName, sort, upgradeBuildingLevelToSchematicData, writeToItemStackMethods inherited from interface com.minecolonies.api.colony.buildings.IBuildingContainer
addContainerPosition, alterPickUpPriority, getContainers, getPickUpPriority, getTileEntity, registerBlockPosition, registerBlockPosition, removeContainerPosition, setTileEntityMethods inherited from interface com.minecolonies.api.colony.modules.IBuildingModuleContainer
getModule, getModule, hasModule, registerModuleMethods inherited from interface com.minecolonies.api.colony.buildings.ICommonBuilding
getBuildingLevel, getBuildingLevelEquivalent, getBuildingType, getColony, getContainers, getPosition, getPrestigeMethods inherited from interface com.minecolonies.api.util.IItemHandlerCapProvider
getItemHandlerCap, getItemHandlerCap, getItemHandlerCapMethods inherited from interface com.minecolonies.api.colony.modules.IModuleContainer
getClassType, getFirstModuleOccurance, getModule, getModule, getModule, getModuleMatching, getModules, getModules, getModules, getModules, getModulesByType, hasModule, hasModule, hasModuleMethods inherited from interface com.minecolonies.api.colony.requestsystem.requester.IRequester
getId, getLocation, getRequesterDisplayName, onRequestedRequestCancelled, onRequestedRequestCompleteMethods inherited from interface com.minecolonies.api.colony.requestsystem.resolver.IRequestResolverProvider
getIdMethods inherited from interface com.minecolonies.api.colony.buildings.ISchematicProvider
clearDirty, getBlueprintPath, getChildren, getCorners, getID, getMaxBuildingLevel, getParent, getRotationMirror, getSchematicName, getStructurePack, hasParent, isDeconstructed, isDirty, onUpgradeSchematicTo, setBlueprintPath, setBuildingLevel, setCorners, setDeconstructed, setParent, setRotationMirror, setStructurePack
-
Field Details
-
RETREAT
Settings. -
HIRE_TRAINEE
-
PATROL_MODE
-
FOLLOW_MODE
-
GUARD_TASK
-
BONUS_HEALTH_PER_LEVEL
protected static final int BONUS_HEALTH_PER_LEVELThe Bonus Health for each building level- See Also:
-
VISION_RANGE_PER_LEVEL
protected static final int VISION_RANGE_PER_LEVELVision range per building level.- See Also:
-
BASE_VISION_RANGE
protected static final int BASE_VISION_RANGEBase Vision range per building level.- See Also:
-
patrolTargets
The list of manual patrol targets. -
tempNextPatrolPoint
protected net.minecraft.core.BlockPos tempNextPatrolPointA temporary next patrol point, which gets consumed and used once -
HOSTILE_LIST
List of hostiles.- See Also:
-
-
Constructor Details
-
AbstractBuildingGuards
The abstract constructor of the building.- Parameters:
c- the colonyl- the position
-
-
Method Details
-
onUpgradeComplete
public void onUpgradeComplete(@Nullable @Nullable com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, int newLevel) We use this to set possible health multipliers and give achievements.- Specified by:
onUpgradeCompletein interfaceIBuilding- Overrides:
onUpgradeCompletein classAbstractBuilding- Parameters:
newLevel- The new level.
-
deserializeNBT
public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) - Specified by:
deserializeNBTin interfaceIBuildingContainer- Specified by:
deserializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
deserializeNBTin classAbstractBuilding
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider) - Specified by:
serializeNBTin interfaceIBuildingContainer- Specified by:
serializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
serializeNBTin classAbstractBuilding
-
serializeToView
public void serializeToView(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf, boolean fullSync) Description copied from class:AbstractBuildingSerializes to view.- Specified by:
serializeToViewin interfaceIBuilding- Overrides:
serializeToViewin classAbstractBuilding- Parameters:
buf- RegistryFriendlyByteBuf to write to.fullSync- Whether it's a full sync
-
getTask
Description copied from interface:IGuardBuildingGet the guard's task.- Specified by:
getTaskin interfaceIGuardBuilding- Returns:
- The task of the guard.
-
getPlayerToFollowOrRally
@Nullable public @Nullable net.minecraft.world.entity.player.Player getPlayerToFollowOrRally()Description copied from interface:IGuardBuildingEntity of player to follow or rally.- Specified by:
getPlayerToFollowOrRallyin interfaceIGuardBuilding- Returns:
- the PlayerEntity reference.
-
onColonyTick
Description copied from class:AbstractBuildingRegularly tick this building and check if we got the minimum stock(like once a minute is still fine) - If not: Check if there is a request for this already. -- If not: Create a request. - If so: Check if there is a request for this still. -- If so: cancel it.- Specified by:
onColonyTickin interfaceIBuilding- Overrides:
onColonyTickin classAbstractBuilding
-
requiresManualTarget
public boolean requiresManualTarget()Description copied from interface:IGuardBuildingIf we have to calculate a new target manually.- Specified by:
requiresManualTargetin interfaceIGuardBuilding- Returns:
- true if so.
-
arrivedAtPatrolPoint
Description copied from interface:IGuardBuildingCalled when a guard is at the current patrol point- Specified by:
arrivedAtPatrolPointin interfaceIGuardBuilding- Parameters:
guard- guard which arrived
-
setPatrolTimer
public void setPatrolTimer(int timer) Set the patroll timer.- Parameters:
timer- the timer to set.
-
startPatrolNext
public void startPatrolNext()Starts the patrol to the next point -
getNextPatrolTarget
@Nullable public @Nullable net.minecraft.core.BlockPos getNextPatrolTarget(boolean newTarget) Description copied from interface:IGuardBuildingReturns a patrolTarget to patrol to.- Specified by:
getNextPatrolTargetin interfaceIGuardBuilding- Parameters:
newTarget- whether to search a new target- Returns:
- the position of the next target.
-
getRandomPatrolTarget
@Nullable protected @Nullable net.minecraft.core.BlockPos getRandomPatrolTarget()Gets a random automatic patrol target for this guard building.- Returns:
- the next random patrol target.
-
getPatrolDistance
public int getPatrolDistance()Description copied from interface:IGuardBuildingGetter for the patrol distance the guard currently has.- Specified by:
getPatrolDistancein interfaceIGuardBuilding- Returns:
- The distance in whole numbers.
-
setTempNextPatrolPoint
public void setTempNextPatrolPoint(net.minecraft.core.BlockPos pos) Description copied from interface:IGuardBuildingSets a one time consumed temporary next position to patrol towards- Specified by:
setTempNextPatrolPointin interfaceIGuardBuilding- Parameters:
pos- Position to set
-
getMinePos
public net.minecraft.core.BlockPos getMinePos()Return the position of the mine to guard- Specified by:
getMinePosin interfaceIGuardBuilding- Returns:
- the position of the mine
-
setMinePos
public void setMinePos(net.minecraft.core.BlockPos pos) Set the position of the mine the guard is patrolling Check whether the given position is actually a mine- Parameters:
pos- the position of the mine
-
shallRetrieveOnLowHealth
public boolean shallRetrieveOnLowHealth()Description copied from interface:IGuardBuildingGet the guard's RetrieveOnLowHeath.- Specified by:
shallRetrieveOnLowHealthin interfaceIGuardBuilding- Returns:
- if so.
-
shallPatrolManually
public boolean shallPatrolManually()Description copied from interface:IGuardBuildingGet whether the guard should patrol manually.- Specified by:
shallPatrolManuallyin interfaceIGuardBuilding- Returns:
- if so.
-
isTightGrouping
public boolean isTightGrouping()Description copied from interface:IGuardBuildingReturns whether tight grouping in Follow mode is being used.- Specified by:
isTightGroupingin interfaceIGuardBuilding- Returns:
- whether tight grouping is being used.
-
getGuardPos
Description copied from interface:IGuardBuildingGet the position the guard should guard.- Specified by:
getGuardPosin interfaceIGuardBuilding- Returns:
- the
BlockPosof the guard position.
-
setGuardPos
public void setGuardPos(net.minecraft.core.BlockPos guardPos) Description copied from interface:IGuardBuildingSet where the guard should guard.- Specified by:
setGuardPosin interfaceIGuardBuilding- Parameters:
guardPos- theBlockPosto guard.
-
getPositionToFollow
public net.minecraft.core.BlockPos getPositionToFollow()Description copied from interface:IGuardBuildingGets the position to follow.- Specified by:
getPositionToFollowin interfaceIGuardBuilding- Returns:
- the position the guard is supposed to be while following.
-
getRallyLocation
Description copied from interface:IGuardBuildingLocation to to rally to.- Specified by:
getRallyLocationin interfaceIGuardBuilding- Returns:
- the ILocation reference.
-
setRallyLocation
Description copied from interface:IGuardBuildingSets the location to rally.- Specified by:
setRallyLocationin interfaceIGuardBuilding- Parameters:
location- The location to rally to.
-
setPlayerToFollow
public void setPlayerToFollow(net.minecraft.world.entity.player.Player player) Description copied from interface:IGuardBuildingSets the player to follow.- Specified by:
setPlayerToFollowin interfaceIGuardBuilding- Parameters:
player- the player to follow.
-
getBonusHealth
public int getBonusHealth()Bonus guard hp per bulding level- Returns:
- the bonus health.
-
addPatrolTarget
public void addPatrolTarget(net.minecraft.core.BlockPos target) Adds new patrolTarget.- Specified by:
addPatrolTargetin interfaceIGuardBuilding- Parameters:
target- the target to add
-
resetPatrolTargets
public void resetPatrolTargets()Resets the patrolTargets list.- Specified by:
resetPatrolTargetsin interfaceIGuardBuilding
-
getBonusVision
public int getBonusVision()Get the Vision bonus range for the building level- Specified by:
getBonusVisionin interfaceIGuardBuilding- Returns:
- an integer for the additional range.
-
calculateMobs
public void calculateMobs()Populates the mobs list from the BuiltInRegistries.- Specified by:
calculateMobsin interfaceIGuardBuilding
-