Class BuildingUtils

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

public final class BuildingUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Predicate<JobEntry>
    Indicates that there are no explicit restrictions on which jobs are allowed at a building.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canAutoHire(@NotNull IBuilding building, @NotNull HiringMode hiringMode, @Nullable JobEntry job)
    Check if the given building should try to automatically hire a new citizen.
    commonBuildingFromPosition(@NotNull net.minecraft.world.level.Level level, @NotNull net.minecraft.core.BlockPos pos)
    Retrieves the ICommonBuilding at the given position in the given level.
    static @NotNull Predicate<JobEntry>
    getAllowedJobs(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos buildingPos)
    Checks a hut block for job= tags to restrict which jobs are allowed to exist there.
    static net.minecraft.world.item.ItemStack
    getItemStackForHutFromInventory(net.minecraft.world.entity.player.Inventory inventory, String hut)
    Get the hut from the inventory.
    static int
    getRotationFromBlock(@NotNull net.minecraft.world.level.block.state.BlockState blockState)
    Reports the clockwise rotations for a hut or decoration block.
    static int
    getRotationFromBlueprint(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos pos)
    Reports the clockwise rotations for a hut or decoration relative to its original blueprint.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.
    • getRotationFromBlueprint

      public static int getRotationFromBlueprint(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Reports the clockwise rotations for a hut or decoration relative to its original blueprint.
      Parameters:
      world - the world.
      pos - the anchor pos.
      Returns:
      the number of rotations, or -1 if unable to calculate.
    • getRotationFromBlock

      public static int getRotationFromBlock(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState blockState)
      Reports the clockwise rotations for a hut or decoration block.
      Parameters:
      blockState - the hut or decoration block.
      Returns:
      the number of rotations, or -1 if an unexpected block type.
    • 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.