Interface IBuilding

All Superinterfaces:
IBuildingContainer, IBuildingModuleContainer, net.minecraftforge.common.capabilities.ICapabilityProvider, ICommonBuilding, IModuleContainer<IBuildingModule>, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, IRequester, IRequestResolverProvider, ISchematicProvider
All Known Subinterfaces:
IBuildingDeliveryman, IBuildingWorker, IGuardBuilding, IMysticalSite, ITownHall, IWareHouse
All Known Implementing Classes:
AbstractBuilding, AbstractBuildingContainer, AbstractBuildingGuards, AbstractBuildingStructureBuilder, AbstractSchematicProvider, BuildingAlchemist, BuildingArchery, BuildingBaker, BuildingBarracks, BuildingBarracksTower, BuildingBeekeeper, BuildingBlacksmith, BuildingBuilder, BuildingChickenHerder, BuildingCombatAcademy, BuildingComposter, BuildingConcreteMixer, BuildingCook, BuildingCowboy, BuildingCrusher, BuildingDeliveryman, BuildingDyer, BuildingEnchanter, BuildingFarmer, BuildingFisherman, BuildingFletcher, BuildingFlorist, BuildingGateHouse, BuildingGlassblower, BuildingGraveyard, BuildingGuardTower, BuildingHospital, BuildingKitchen, BuildingLibrary, BuildingLumberjack, BuildingMechanic, BuildingMiner, BuildingMysticalSite, BuildingNetherWorker, BuildingPlantation, BuildingRabbitHutch, BuildingSawmill, BuildingSchool, BuildingShepherd, BuildingSifter, BuildingSmeltery, BuildingStable, BuildingStonemason, BuildingStoneSmeltery, BuildingSwineHerder, BuildingTownHall, BuildingUniversity, BuildingWareHouse, DefaultBuildingInstance, PostBox, Stash

  • Field Details

    • WOOD_HUT_LEVEL

      static final int WOOD_HUT_LEVEL
      Minimal level to ask for wood tools. (WOOD_HUT_LEVEL + 1 == stone)
      See Also:
  • Method Details

    • getCustomName

      @NotNull @NotNull String getCustomName()
      Getter for the custom name of a building.
      Returns:
      the custom name.
    • getBuildingDisplayName

      @NotNull @NotNull String getBuildingDisplayName()
      Getter for the display name of a building. Returns either the custom name (if any) or the schematic name.
      Returns:
      the display name.
    • onWakeUp

      default void onWakeUp()
      Executed when a new day start.
    • onCleanUp

      void onCleanUp(ICitizenData citizen)
      Executed every time when citizen finish inventory cleanup called after citizen got paused. Use for cleaning a state only.
      Parameters:
      citizen - cleanup for citizen.
    • onRestart

      void onRestart(ICitizenData citizen)
      Executed when RestartCitizenMessage is called and worker is paused. Use for reseting, onCleanUp is called before this
      Parameters:
      citizen - the citizen assigned to the building.
    • onPlacement

      void onPlacement()
      Called when the building is placed in the world.
    • onPlayerEnterNearby

      default void onPlayerEnterNearby(net.minecraft.world.entity.player.Player player)
      Called when a player comes close to the building.
      Parameters:
      player - entering player
    • onPlayerEnterBuilding

      default void onPlayerEnterBuilding(net.minecraft.world.entity.player.Player player)
      Called when a player enters the building area
      Parameters:
      player - entering player
    • isMatchingBlock

      boolean isMatchingBlock(@NotNull @NotNull net.minecraft.world.level.block.Block block)
      Checks if a block matches the current object.
      Parameters:
      block - Block you want to know whether it matches this class or not.
      Returns:
      True if the block matches this class, otherwise false.
    • destroy

      void destroy()
      Destroys the block. Calls onDestroyed().
    • onDestroyed

      void onDestroyed()
    • canBeBuiltByBuilder

      boolean canBeBuiltByBuilder(int newLevel)
      Method to define if a builder can build this although the builder is not level 1 yet.
      Parameters:
      newLevel - the new level of the building.
      Returns:
      true if so.
    • markDirty

      void markDirty()
      Description copied from interface: ISchematicProvider
      Marks the instance and the building dirty.
      Specified by:
      markDirty in interface ISchematicProvider
    • isPendingConstruction

      boolean isPendingConstruction()
      Checks if this building have a work order.
      Returns:
      true if the building is building, upgrading or repairing.
    • removeWorkOrder

      void removeWorkOrder()
      Remove the work order for the building.

      Remove either the upgrade or repair work order

    • getClaimRadius

      int getClaimRadius(int buildingLevel)
      Method to calculate the radius to be claimed by this building depending on the level.
      Parameters:
      buildingLevel - the building level.
      Returns:
      the radius.
    • serializeToView

      void serializeToView(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf, boolean fullSync)
      Serializes to view.
      Parameters:
      buf - FriendlyByteBuf to write to.
      fullSync - Whether it's a full sync
    • setCustomBuildingName

      void setCustomBuildingName(String name)
      Set the custom building name of the building.
      Parameters:
      name - the name to set.
    • canBeGathered

      boolean canBeGathered()
      Check if the building should be gathered by the dman.
      Returns:
      true if so.
    • requestUpgrade

      void requestUpgrade(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos builder)
      Requests an upgrade for the current building.
      Parameters:
      player - the requesting player.
      builder - the assigned builder.
    • requestRemoval

      void requestRemoval(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos builder)
      Requests a removal for the current building.
      Parameters:
      player - the requesting player.
      builder - the assigned builder.
    • requestRepair

      void requestRepair(net.minecraft.core.BlockPos builder)
      Requests a repair for the current building.
      Parameters:
      builder - the assigned builder.
    • isBuilt

      boolean isBuilt()
      Check if the building was built already.
      Returns:
      true if so.
    • deconstruct

      void deconstruct()
      Deconstruct the building on destroyed.
    • onUpgradeComplete

      void onUpgradeComplete(@Nullable @Nullable com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, int newLevel)
      Called upon completion of an upgrade process. We suppress this warning since this parameter will be used in child classes which override this method.
      Parameters:
      newLevel - The new level.
    • isGuardBuildingNear

      boolean isGuardBuildingNear()
      Whether this building has a guard building nearby
      Returns:
      true/false
    • resetGuardBuildingNear

      void resetGuardBuildingNear()
      Requests recalculation of whether this building has a guard building nearby
    • buildingRequiresCertainAmountOfItem

      int buildingRequiresCertainAmountOfItem(net.minecraft.world.item.ItemStack stack, List<ItemStorage> localAlreadyKept, boolean inventory, @Nullable @Nullable JobEntry jobEntry)
      Check if the worker requires a certain amount of that item and the alreadykept list contains it. Always leave one stack behind if the worker requires a certain amount of it. Just to be sure.
      Parameters:
      stack - the stack to check it with.
      localAlreadyKept - already kept items.
      inventory - if it should be in the inventory or in the building.
      jobEntry - the job entry trying to dump.
      Returns:
      the amount which can get dumped or 0 if not.
    • buildingRequiresCertainAmountOfItem

      default int buildingRequiresCertainAmountOfItem(net.minecraft.world.item.ItemStack stack, List<ItemStorage> localAlreadyKept, boolean inventory)
      Check if the building requires a certain amount of that item and the alreadykept list contains it. Always leave one stack behind if the worker requires a certain amount of it. Just to be sure.
      Parameters:
      stack - the stack to check it with.
      localAlreadyKept - already kept items.
      inventory - if it should be in the inventory or in the building.
      Returns:
      the amount which can get dumped or 0 if not.
    • getRequiredItemsAndAmount

      Map<Predicate<net.minecraft.world.item.ItemStack>,net.minecraft.util.Tuple<Integer,Boolean>> getRequiredItemsAndAmount()
      Override this method if you want to keep an amount of items in inventory. When the inventory is full, everything get's dumped into the building chest. But you can use this method to hold some stacks back.
      Returns:
      a list of objects which should be kept.
    • forceTransferStack

      @Nullable @Nullable net.minecraft.world.item.ItemStack forceTransferStack(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level world)
      Try to transfer a stack to one of the inventories of the building and force the transfer.
      Parameters:
      stack - the stack to transfer.
      world - the world to do it in.
      Returns:
      the itemStack which has been replaced or the itemStack which could not be transfered
    • createRequest

      <R extends IRequestable> IToken<?> createRequest(@NotNull @NotNull ICitizenData citizenData, @NotNull R requested, boolean async)
      Create a request for a citizen.
      Type Parameters:
      R - the type of the request.
      Parameters:
      citizenData - the data of the citizen.
      requested - the request to create.
      async - if async or not.
      Returns:
      the Token of the request.
    • createRequest

      <R extends IRequestable> IToken<?> createRequest(@NotNull R requested, boolean async)
      Create a request for the building.
      Type Parameters:
      R - the type of the request.
      Parameters:
      requested - the request to create.
      async - if async or not.
      Returns:
      the Token of the request.
    • hasWorkerOpenRequests

      boolean hasWorkerOpenRequests(int citizenid)
    • getOpenRequests

      Collection<IRequest<?>> getOpenRequests(int citizenid)
    • hasWorkerOpenRequestsFiltered

      boolean hasWorkerOpenRequestsFiltered(int citizenid, @NotNull @NotNull Predicate<IRequest<?>> selectionPredicate)
    • hasOpenSyncRequest

      boolean hasOpenSyncRequest(@NotNull @NotNull ICitizenData citizen)
      Checks whether the citizen has an open sync request, preventing it from working
      Parameters:
      citizen - citizen data to check
      Returns:
      true if an open non async request exists
    • hasWorkerOpenRequestsOfType

      <R> boolean hasWorkerOpenRequestsOfType(int citizenid, com.google.common.reflect.TypeToken<R> requestType)
    • getOpenRequestsOfType

      <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getOpenRequestsOfType(int citizenid, com.google.common.reflect.TypeToken<R> requestType)
    • hasCitizenCompletedRequests

      boolean hasCitizenCompletedRequests(@NotNull @NotNull ICitizenData data)
    • hasCitizenCompletedRequestsToPickup

      boolean hasCitizenCompletedRequestsToPickup(@NotNull @NotNull ICitizenData data)
    • getCompletedRequestsOfCitizenOrBuilding

      Collection<IRequest<?>> getCompletedRequestsOfCitizenOrBuilding(@Nullable @Nullable ICitizenData data)
      Get completed requests for citizen or building (citizen independent, so if data is null)
      Parameters:
      data - the citizen data (or null).
      Returns:
      a collection of request.
    • getCompletedRequestsOfType

      <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getCompletedRequestsOfType(@NotNull @NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType)
    • getCompletedRequestsOfTypeFiltered

      <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getCompletedRequestsOfTypeFiltered(@NotNull @NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType, Predicate<IRequest<? extends R>> filter)
    • markRequestAsAccepted

      void markRequestAsAccepted(@NotNull @NotNull ICitizenData data, @NotNull @NotNull IToken<?> token)
    • cancelAllRequestsOfCitizenOrBuilding

      void cancelAllRequestsOfCitizenOrBuilding(@Nullable @Nullable ICitizenData data)
      Cancel all requests of citizen or building (if citizen data is null)
      Parameters:
      data - the citizen data (or null).
    • overruleNextOpenRequestWithStack

      void overruleNextOpenRequestWithStack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Overrule the next open request with a give stack.

      We squid:s135 which takes care that there are not too many continue statements in a loop since it makes sense here out of performance reasons.

      Parameters:
      stack - the stack.
    • getOpenRequestsOfTypeFiltered

      <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getOpenRequestsOfTypeFiltered(@NotNull @NotNull ICitizenData citizenData, com.google.common.reflect.TypeToken<R> requestType, Predicate<IRequest<? extends R>> filter)
    • overruleNextOpenRequestOfCitizenWithStack

      boolean overruleNextOpenRequestOfCitizenWithStack(@NotNull @NotNull ICitizenData citizenData, @NotNull @NotNull net.minecraft.world.item.ItemStack stack)
    • createPickupRequest

      boolean createPickupRequest(int qty, boolean force)
      Creates a pickup request for the building. It will make sure that only one pickup request exists per building, so it's safe to call multiple times. The call will return false if a pickup request already exists, or if the priority is not within the proper range, or if the pickup priority is set to NEVER (0).
      Parameters:
      qty - the qty of items to be picked up.
      force - if the pickup should be forced.
      Returns:
      true if a pickup request could be created, false if not.
    • getResolvers

      com.google.common.collect.ImmutableCollection<IRequestResolver<?>> getResolvers()
      Description copied from interface: IRequestResolverProvider
      Method to get the resolvers that this provider provides.
      Specified by:
      getResolvers in interface IRequestResolverProvider
      Returns:
      a list of resolvers.
    • createResolvers

      com.google.common.collect.ImmutableCollection<IRequestResolver<?>> createResolvers()
    • getRequester

      IRequester getRequester()
    • getCitizenForRequest

      Optional<ICitizenData> getCitizenForRequest(@NotNull @NotNull IToken<?> token)
    • reservedStacksExcluding

      Map<ItemStorage,Integer> reservedStacksExcluding(@NotNull @NotNull IRequest<? extends IDeliverable> request)
      Calculate the number of reserved stacks the resolver can't touch.
      Parameters:
      request - ignore reservations that would exist for the current request.
      Returns:
      a list of itemstorages.
    • processOfflineTime

      void processOfflineTime(long time)
      Process time the colony was offline.
      Parameters:
      time - the time in seconds.
    • calculateCorners

      void calculateCorners()
      Calculate all building corners from the schematic data.
    • isInBuilding

      boolean isInBuilding(@NotNull @NotNull net.minecraft.core.BlockPos pos)
      Check if a certain vec is within this building.
      Parameters:
      pos - the pos to check.
      Returns:
      true if so.
    • upgradeBuildingLevelToSchematicData

      void upgradeBuildingLevelToSchematicData()
      Upgrades the buildings level to fit its schematic data
    • getOpenRequestsByRequestableType

      Map<com.google.common.reflect.TypeToken<?>,Collection<IToken<?>>> getOpenRequestsByRequestableType()
      Get a map of all open requests by type.
      Returns:
      the map.
    • pickUp

      void pickUp(net.minecraft.world.entity.player.Player player)
      Pickup the building including the level and put it in the players inv.
      Parameters:
      player - the player picking it up.
    • setBuildingType

      void setBuildingType(BuildingEntry buildingType)
      Set the building type
      Parameters:
      buildingType -
    • onColonyTick

      void onColonyTick(IColony colony)
      On tick of the colony.
    • isItemStackInRequest

      boolean isItemStackInRequest(@Nullable @Nullable net.minecraft.world.item.ItemStack stack)
      Check if a certain ItemStack is in the request of a worker.
      Parameters:
      stack - the stack to chest.
      Returns:
      true if so.
    • getMaxEquipmentLevel

      default int getMaxEquipmentLevel()
      Get the max equipment level useable by the worker.
      Returns:
      the integer.
    • canAssignCitizens

      default boolean canAssignCitizens()
      Check if this building is sufficiently built to be able to assign workers.
      Returns:
      true if so.
    • getAllAssignedCitizen

      Set<ICitizenData> getAllAssignedCitizen()
      Get the set of all assigned citizens in the colony.
      Returns:
      the list
    • getHandlers

      List<net.minecraftforge.items.IItemHandler> getHandlers()
      Get all handlers associated with this building.
      Returns:
      the handlers of the building + citizen.
    • getSetting

      <T extends ISetting<S>, S> T getSetting(@NotNull @NotNull ISettingKey<T> key)
      Get setting for key. Utility function.
      Type Parameters:
      T - the key type.
      Parameters:
      key - the key.
      Returns:
      the setting.
    • getSettingValueOrDefault

      <T extends ISetting<S>, S> S getSettingValueOrDefault(@NotNull @NotNull ISettingKey<T> key, @NotNull S def)
      Get setting value for key or some default. Utility function.
      Type Parameters:
      T - the key type.
      Parameters:
      key - the key.
      def - the default.
      Returns:
      the setting.
    • canEat

      default boolean canEat(net.minecraft.world.item.ItemStack stack)
      Check if the assigned citizens are allowed to eat the following stack.
      Parameters:
      stack - the stack to test.
      Returns:
      true if so.
    • getLocationsFromTag

      @NotNull @NotNull List<net.minecraft.core.BlockPos> getLocationsFromTag(@NotNull @NotNull String tagName)
      Gets the list of tags, and finds all locations registered there.
      Parameters:
      tagName - the name of the tag to query
      Returns:
      all the matching BlockPos, or an empty list if not found
    • canSort

      default boolean canSort()
      Checks if the building can be sorted.
      Returns:
      true if the building can be sorted, false otherwise.
    • sort

      default void sort(CombinedItemHandler inventoryHandler)
      Sort the inventory of this building using the given provider. The implementation of this method is usually a call to SortingUtils.sort(CombinedItemHandler).
      Parameters:
      inventoryHandler - the inventory handler to sort.
    • calculatePrestige

      void calculatePrestige(com.ldtteam.structurize.blueprints.v1.Blueprint blueprint)
      Recalculate prestige for building.
      Parameters:
      blueprint - the blueprint as a basis.
    • asyncPrestigeRecalc

      void asyncPrestigeRecalc()
      Trigger for async prestige recalculation.