Class 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

public abstract class AbstractBuildingGuards extends AbstractBuilding implements IGuardBuilding
Abstract class for Guard huts.
  • Field Details

    • RETREAT

      public static final ISettingKey<BoolSetting> RETREAT
      Settings.
    • HIRE_TRAINEE

      public static final ISettingKey<BoolSetting> HIRE_TRAINEE
    • PATROL_MODE

      public static final ISettingKey<GuardPatrolModeSetting> PATROL_MODE
    • FOLLOW_MODE

      public static final ISettingKey<GuardFollowModeSetting> FOLLOW_MODE
    • GUARD_TASK

      public static final ISettingKey<GuardTaskSetting> GUARD_TASK
    • BONUS_HEALTH_PER_LEVEL

      protected static final int BONUS_HEALTH_PER_LEVEL
      The Bonus Health for each building level
      See Also:
    • VISION_RANGE_PER_LEVEL

      protected static final int VISION_RANGE_PER_LEVEL
      Vision range per building level.
      See Also:
    • BASE_VISION_RANGE

      protected static final int BASE_VISION_RANGE
      Base Vision range per building level.
      See Also:
    • patrolTargets

      protected List<net.minecraft.core.BlockPos> patrolTargets
      The list of manual patrol targets.
    • tempNextPatrolPoint

      protected net.minecraft.core.BlockPos tempNextPatrolPoint
      A temporary next patrol point, which gets consumed and used once
    • HOSTILE_LIST

      public static final String HOSTILE_LIST
      List of hostiles.
      See Also:
  • Constructor Details

    • AbstractBuildingGuards

      public AbstractBuildingGuards(@NotNull @NotNull IColony c, net.minecraft.core.BlockPos l)
      The abstract constructor of the building.
      Parameters:
      c - the colony
      l - 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:
      onUpgradeComplete in interface IBuilding
      Overrides:
      onUpgradeComplete in class AbstractBuilding
      Parameters:
      newLevel - The new level.
    • deserializeNBT

      public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound)
      Specified by:
      deserializeNBT in interface IBuildingContainer
      Specified by:
      deserializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      deserializeNBT in class AbstractBuilding
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider)
      Specified by:
      serializeNBT in interface IBuildingContainer
      Specified by:
      serializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      serializeNBT in class AbstractBuilding
    • serializeToView

      public void serializeToView(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf, boolean fullSync)
      Description copied from class: AbstractBuilding
      Serializes to view.
      Specified by:
      serializeToView in interface IBuilding
      Overrides:
      serializeToView in class AbstractBuilding
      Parameters:
      buf - RegistryFriendlyByteBuf to write to.
      fullSync - Whether it's a full sync
    • getTask

      public String getTask()
      Description copied from interface: IGuardBuilding
      Get the guard's task.
      Specified by:
      getTask in interface IGuardBuilding
      Returns:
      The task of the guard.
    • getPlayerToFollowOrRally

      @Nullable public @Nullable net.minecraft.world.entity.player.Player getPlayerToFollowOrRally()
      Description copied from interface: IGuardBuilding
      Entity of player to follow or rally.
      Specified by:
      getPlayerToFollowOrRally in interface IGuardBuilding
      Returns:
      the PlayerEntity reference.
    • onColonyTick

      public void onColonyTick(IColony colony)
      Description copied from class: AbstractBuilding
      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. -- If not: Create a request. - If so: Check if there is a request for this still. -- If so: cancel it.
      Specified by:
      onColonyTick in interface IBuilding
      Overrides:
      onColonyTick in class AbstractBuilding
    • requiresManualTarget

      public boolean requiresManualTarget()
      Description copied from interface: IGuardBuilding
      If we have to calculate a new target manually.
      Specified by:
      requiresManualTarget in interface IGuardBuilding
      Returns:
      true if so.
    • arrivedAtPatrolPoint

      public void arrivedAtPatrolPoint(AbstractEntityCitizen guard)
      Description copied from interface: IGuardBuilding
      Called when a guard is at the current patrol point
      Specified by:
      arrivedAtPatrolPoint in interface IGuardBuilding
      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: IGuardBuilding
      Returns a patrolTarget to patrol to.
      Specified by:
      getNextPatrolTarget in interface IGuardBuilding
      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: IGuardBuilding
      Getter for the patrol distance the guard currently has.
      Specified by:
      getPatrolDistance in interface IGuardBuilding
      Returns:
      The distance in whole numbers.
    • setTempNextPatrolPoint

      public void setTempNextPatrolPoint(net.minecraft.core.BlockPos pos)
      Description copied from interface: IGuardBuilding
      Sets a one time consumed temporary next position to patrol towards
      Specified by:
      setTempNextPatrolPoint in interface IGuardBuilding
      Parameters:
      pos - Position to set
    • getMinePos

      public net.minecraft.core.BlockPos getMinePos()
      Return the position of the mine to guard
      Specified by:
      getMinePos in interface IGuardBuilding
      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: IGuardBuilding
      Get the guard's RetrieveOnLowHeath.
      Specified by:
      shallRetrieveOnLowHealth in interface IGuardBuilding
      Returns:
      if so.
    • shallPatrolManually

      public boolean shallPatrolManually()
      Description copied from interface: IGuardBuilding
      Get whether the guard should patrol manually.
      Specified by:
      shallPatrolManually in interface IGuardBuilding
      Returns:
      if so.
    • isTightGrouping

      public boolean isTightGrouping()
      Description copied from interface: IGuardBuilding
      Returns whether tight grouping in Follow mode is being used.
      Specified by:
      isTightGrouping in interface IGuardBuilding
      Returns:
      whether tight grouping is being used.
    • getGuardPos

      public net.minecraft.core.BlockPos getGuardPos(@NotNull @NotNull AbstractEntityCitizen worker)
      Description copied from interface: IGuardBuilding
      Get the position the guard should guard.
      Specified by:
      getGuardPos in interface IGuardBuilding
      Returns:
      the BlockPos of the guard position.
    • setGuardPos

      public void setGuardPos(net.minecraft.core.BlockPos guardPos)
      Description copied from interface: IGuardBuilding
      Set where the guard should guard.
      Specified by:
      setGuardPos in interface IGuardBuilding
      Parameters:
      guardPos - the BlockPos to guard.
    • getPositionToFollow

      public net.minecraft.core.BlockPos getPositionToFollow()
      Description copied from interface: IGuardBuilding
      Gets the position to follow.
      Specified by:
      getPositionToFollow in interface IGuardBuilding
      Returns:
      the position the guard is supposed to be while following.
    • getRallyLocation

      @Nullable public @Nullable ILocation getRallyLocation()
      Description copied from interface: IGuardBuilding
      Location to to rally to.
      Specified by:
      getRallyLocation in interface IGuardBuilding
      Returns:
      the ILocation reference.
    • setRallyLocation

      public void setRallyLocation(ILocation location)
      Description copied from interface: IGuardBuilding
      Sets the location to rally.
      Specified by:
      setRallyLocation in interface IGuardBuilding
      Parameters:
      location - The location to rally to.
    • setPlayerToFollow

      public void setPlayerToFollow(net.minecraft.world.entity.player.Player player)
      Description copied from interface: IGuardBuilding
      Sets the player to follow.
      Specified by:
      setPlayerToFollow in interface IGuardBuilding
      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:
      addPatrolTarget in interface IGuardBuilding
      Parameters:
      target - the target to add
    • resetPatrolTargets

      public void resetPatrolTargets()
      Resets the patrolTargets list.
      Specified by:
      resetPatrolTargets in interface IGuardBuilding
    • getBonusVision

      public int getBonusVision()
      Get the Vision bonus range for the building level
      Specified by:
      getBonusVision in interface IGuardBuilding
      Returns:
      an integer for the additional range.
    • calculateMobs

      public void calculateMobs()
      Populates the mobs list from the BuiltInRegistries.
      Specified by:
      calculateMobs in interface IGuardBuilding