Class BuildingUtils

java.lang.Object
com.minecolonies.core.util.BuildingUtils

public final class BuildingUtils extends Object
  • Field Details

    • UNRESTRICTED

      public static final Predicate<JobEntry> UNRESTRICTED
      Indicates that there are no explicit restrictions on which jobs are allowed at a building.
  • Method Details

    • getItemStackForHutFromInventory

      public static net.minecraft.world.item.ItemStack getItemStackForHutFromInventory(net.minecraft.world.entity.player.Inventory inventory, String hut)
      Get the hut from the inventory.
      Parameters:
      inventory - the inventory to search.
      hut - the hut to fetch.
      Returns:
      the stack or if not found empty.
    • getAllowedJobs

      @NotNull public static @NotNull Predicate<JobEntry> getAllowedJobs(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos buildingPos)
      Checks a hut block for job= tags to restrict which jobs are allowed to exist there.
      Parameters:
      world - the world.
      buildingPos - the position of the hut block.
      Returns:
      a predicate that returns true if the specified job is permitted. (note that there may be other reasons the job isn't allowed, such as being the wrong building type for that job; this does not check that.) it returns UNRESTRICTED when there are no explicit restrictions.
    • canAutoHire

      public static boolean canAutoHire(@NotNull @NotNull IBuilding building, @NotNull @NotNull HiringMode hiringMode, @Nullable @Nullable JobEntry job)
      Check if the given building should try to automatically hire a new citizen.
      Parameters:
      building - the building to check.
      hiringMode - the current hiring mode of the job.
      job - the job to hire, or null for a non-specific check.
      Returns:
      true if automatic hiring is allowed.
    • commonBuildingFromPosition

      public static ICommonBuilding commonBuildingFromPosition(@NotNull @NotNull net.minecraft.world.level.Level level, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Retrieves the ICommonBuilding at the given position in the given level.
      Parameters:
      level - the level to search in.
      pos - the position to search for.
      Returns:
      the ICommonBuilding at the given position, or null if none exists.