Class VillagerProfessionBuilder

java.lang.Object
net.fabricmc.fabric.api.object.builder.v1.villager.VillagerProfessionBuilder

public final class VillagerProfessionBuilder extends Object
Allows for the creation of new VillagerProfessions.

The texture for the villagers are located at assets/IDENTIFIER_NAMESPACE/textures/entity/villager/profession/IDENTIFIER_PATH.png

A corresponding IDENTIFIER_PATH.mcmeta file exits in the same directory to define properties such as the HatType this profession would use.

Note this does not register any trades to these villagers. To register trades, add a new entry with your profession as the key to TradeOffers.PROFESSION_TO_LEVELED_TRADE.

  • Method Details

    • create

      public static VillagerProfessionBuilder create()
      Creates a builder instance to allow for creation of a VillagerProfession.
      Returns:
      A new builder.
    • id

      public VillagerProfessionBuilder id(net.minecraft.util.Identifier id)
      The Identifier used to identify this villager profession.
      Parameters:
      id - The identifier to assign to this profession.
      Returns:
      this builder
    • workstation

      public VillagerProfessionBuilder workstation(net.minecraft.util.registry.RegistryKey<net.minecraft.world.poi.PointOfInterestType> key)
      The PointOfInterestType the Villager of this profession will search for when finding a workstation.
      Parameters:
      key - The PointOfInterestType the Villager will attempt to find.
      Returns:
      this builder.
    • workstation

      public VillagerProfessionBuilder workstation(Predicate<net.minecraft.util.registry.RegistryEntry<net.minecraft.world.poi.PointOfInterestType>> predicate)
      The PointOfInterestType the Villager of this profession will search for when finding a workstation.
      Parameters:
      predicate - The PointOfInterestType the Villager will attempt to find.
      Returns:
      this builder.
    • jobSite

      public VillagerProfessionBuilder jobSite(Predicate<net.minecraft.util.registry.RegistryEntry<net.minecraft.world.poi.PointOfInterestType>> predicate)
    • harvestableItems

      public VillagerProfessionBuilder harvestableItems(net.minecraft.item.Item... items)
      Items that a Villager may harvest in this profession.

      In Vanilla, this is used by the farmer to define what type of crops the farmer can harvest.

      Parameters:
      items - Items harvestable by this profession.
      Returns:
      this builder.
    • harvestableItems

      public VillagerProfessionBuilder harvestableItems(Iterable<net.minecraft.item.Item> items)
      Items that a Villager may harvest in this profession.

      In Vanilla, this is used by the farmer to define what type of crops the farmer can harvest.

      Parameters:
      items - Items harvestable by this profession.
      Returns:
      this builder.
    • secondaryJobSites

      public VillagerProfessionBuilder secondaryJobSites(net.minecraft.block.Block... blocks)
      A collection of blocks blocks which may suffice as a secondary job site for a Villager.

      In Vanilla, this is used by the Farmer to stay near Farmland when at it's job site.

      Parameters:
      blocks - Collection of secondary job site blocks.
      Returns:
      this builder.
    • secondaryJobSites

      public VillagerProfessionBuilder secondaryJobSites(Iterable<net.minecraft.block.Block> blocks)
      A collection of blocks blocks which may suffice as a secondary job site for a Villager.

      In Vanilla, this is used by the Farmer to stay near Farmland when at it's job site.

      Parameters:
      blocks - Collection of secondary job site blocks.
      Returns:
      this builder.
    • workSound

      public VillagerProfessionBuilder workSound(@Nullable @Nullable net.minecraft.sound.SoundEvent workSoundEvent)
      Provides the sound made when a Villager works.
      Parameters:
      workSoundEvent - The SoundEvent to be played.
      Returns:
      this builder.
    • build

      public net.minecraft.village.VillagerProfession build()
      Creates the VillagerProfession.
      Returns:
      a new VillagerProfession.
      Throws:
      IllegalStateException - if the builder is missing an id and workstation.