All Implemented Interfaces:
IBuilding, IBuildingContainer, ICommonBuilding, IGuardBuilding, ISchematicProvider, IBuildingModuleContainer, IModuleContainer<IBuildingModule>, IRequester, IRequestResolverProvider, net.minecraftforge.common.capabilities.ICapabilityProvider, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>

public class BuildingStable extends AbstractBuildingGuards
Building of the stable. Supports cavalry military units and the Stablemaster job.
  • Field Details

    • CAVALRY_PATROL_RANGE_BOOST

      public static final float CAVALRY_PATROL_RANGE_BOOST
      See Also:
    • PATROL_INTERVAL

      public static final ISettingKey<IntSetting> PATROL_INTERVAL
      Setting key for the patrol interval.
  • Constructor Details

    • BuildingStable

      public BuildingStable(@NotNull @NotNull IColony colony, net.minecraft.core.BlockPos pos)
      Constructor.
      Parameters:
      colony - the colony.
      pos - the position of the building.
  • Method Details

    • getSchematicName

      public String getSchematicName()
      Gets the schematic name of the building.
      Returns:
      the schematic name of the building.
    • stallPositions

      public List<net.minecraft.core.BlockPos> stallPositions()
      Reads the tag positions
    • getNextStallPosition

      public net.minecraft.core.BlockPos getNextStallPosition()
      Gets the next stable position to use for a horse. Just keeps iterating the aviable positions, so we do not have to keep track of what horse is where.
      Returns:
      horse stable position
    • deserializeNBT

      public void deserializeNBT(net.minecraft.nbt.CompoundTag compound)
      Deserializes the compound tag and sets the last patrol time.
      Specified by:
      deserializeNBT in interface IBuildingContainer
      Specified by:
      deserializeNBT in interface net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      deserializeNBT in class AbstractBuildingGuards
      Parameters:
      compound - the compound tag to read from.
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT()
      Serializes the data of this building to NBT.
      Specified by:
      serializeNBT in interface IBuildingContainer
      Specified by:
      serializeNBT in interface net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      serializeNBT in class AbstractBuildingGuards
      Returns:
      the serialized compound tag.
    • getTask

      public String getTask()
      Returns the task that the guards should perform when patrolling.

      This can be either 'patrol', 'patrol_mine', or 'follow'.

      The task is determined by the setting in the Stable Settings module.

      Specified by:
      getTask in interface IGuardBuilding
      Overrides:
      getTask in class AbstractBuildingGuards
      Returns:
      the task to perform when patrolling
    • getLastPatrolTime

      public long getLastPatrolTime()
      Gets the last time the guards patrolled from this stable.
      Returns:
      the game time of when the guards last patrolled.
    • setLastPatrolTime

      public void setLastPatrolTime(long lastPatrolTime)
      Sets the last time the guards patrolled from this stable.
      Parameters:
      lastPatrolTime - the time in milliseconds since the epoch
    • minutesSinceLastPatrol

      public int minutesSinceLastPatrol()
      Returns the time in minutes since the last patrol from this stable. This is based on the game time of the world.
      Returns:
      the time in minutes since the last patrol.
    • getPatrolDistance

      public int getPatrolDistance()
      Gets the patrol distance for cavalry guards assigned to this stable. This range is based on the base patrol distance of guards, and is multiplied by a constant to give cavalry guards a wider patrol range.
      Specified by:
      getPatrolDistance in interface IGuardBuilding
      Overrides:
      getPatrolDistance in class AbstractBuildingGuards
      Returns:
      the patrol distance for cavalry guards assigned to this stable.
    • startPatrolNext

      public void startPatrolNext()
      Initiate the next patrol.
      Overrides:
      startPatrolNext in class AbstractBuildingGuards
    • getRandomPatrolTarget

      protected net.minecraft.core.BlockPos getRandomPatrolTarget()
      Get a patrol target.
      Overrides:
      getRandomPatrolTarget in class AbstractBuildingGuards
      Returns:
      the next random patrol target.
    • patrolPointForBuilding

      public net.minecraft.core.BlockPos patrolPointForBuilding(net.minecraft.core.BlockPos targetPos)
      If the building structure includes potential patrol points, pick one and use it. Otherwise, use the hut (or tagged ground-level) Y and nominate one of the exterior corners.
      Parameters:
      targetPos - the building position to patrol.
      Returns:
      a patrol point designated by a tag, a building corner, or the target position.
    • cavalryPatrolFilter

      public static Predicate<IBuilding> cavalryPatrolFilter()