package net.minecraft.world.entity.npc; import com.google.common.collect.ImmutableSet; import java.util.function.Predicate; import javax.annotation.Nullable; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.PoiTypeTags; import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.entity.ai.village.poi.PoiTypes; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; public record VillagerProfession( Component name, Predicate> heldJobSite, Predicate> acquirableJobSite, ImmutableSet requestedItems, ImmutableSet secondaryPoi, @Nullable SoundEvent workSound ) { public static final Predicate> ALL_ACQUIRABLE_JOBS = p_238239_ -> p_238239_.is(PoiTypeTags.ACQUIRABLE_JOB_SITE); public static final ResourceKey NONE = createKey("none"); public static final ResourceKey ARMORER = createKey("armorer"); public static final ResourceKey BUTCHER = createKey("butcher"); public static final ResourceKey CARTOGRAPHER = createKey("cartographer"); public static final ResourceKey CLERIC = createKey("cleric"); public static final ResourceKey FARMER = createKey("farmer"); public static final ResourceKey FISHERMAN = createKey("fisherman"); public static final ResourceKey FLETCHER = createKey("fletcher"); public static final ResourceKey LEATHERWORKER = createKey("leatherworker"); public static final ResourceKey LIBRARIAN = createKey("librarian"); public static final ResourceKey MASON = createKey("mason"); public static final ResourceKey NITWIT = createKey("nitwit"); public static final ResourceKey SHEPHERD = createKey("shepherd"); public static final ResourceKey TOOLSMITH = createKey("toolsmith"); public static final ResourceKey WEAPONSMITH = createKey("weaponsmith"); private static ResourceKey createKey(String p_392057_) { return ResourceKey.create(Registries.VILLAGER_PROFESSION, ResourceLocation.withDefaultNamespace(p_392057_)); } private static VillagerProfession register( Registry p_393915_, ResourceKey p_219645_, ResourceKey p_392275_, @Nullable SoundEvent p_219646_ ) { return register(p_393915_, p_219645_, p_219668_ -> p_219668_.is(p_392275_), p_219640_ -> p_219640_.is(p_392275_), p_219646_); } private static VillagerProfession register( Registry p_394693_, ResourceKey p_219649_, Predicate> p_393436_, Predicate> p_397870_, @Nullable SoundEvent p_219652_ ) { return register(p_394693_, p_219649_, p_393436_, p_397870_, ImmutableSet.of(), ImmutableSet.of(), p_219652_); } private static VillagerProfession register( Registry p_395015_, ResourceKey p_394072_, ResourceKey p_395537_, ImmutableSet p_219662_, ImmutableSet p_219663_, @Nullable SoundEvent p_219664_ ) { return register( p_395015_, p_394072_, p_238234_ -> p_238234_.is(p_395537_), p_238237_ -> p_238237_.is(p_395537_), p_219662_, p_219663_, p_219664_ ); } private static VillagerProfession register( Registry p_395735_, ResourceKey p_397170_, Predicate> p_219655_, Predicate> p_219656_, ImmutableSet p_396051_, ImmutableSet p_394349_, @Nullable SoundEvent p_219657_ ) { return Registry.register( p_395735_, p_397170_, new VillagerProfession( Component.translatable("entity." + p_397170_.location().getNamespace() + ".villager." + p_397170_.location().getPath()), p_219655_, p_219656_, p_396051_, p_394349_, p_219657_ ) ); } public static VillagerProfession bootstrap(Registry p_393047_) { register(p_393047_, NONE, PoiType.NONE, ALL_ACQUIRABLE_JOBS, null); register(p_393047_, ARMORER, PoiTypes.ARMORER, SoundEvents.VILLAGER_WORK_ARMORER); register(p_393047_, BUTCHER, PoiTypes.BUTCHER, SoundEvents.VILLAGER_WORK_BUTCHER); register(p_393047_, CARTOGRAPHER, PoiTypes.CARTOGRAPHER, SoundEvents.VILLAGER_WORK_CARTOGRAPHER); register(p_393047_, CLERIC, PoiTypes.CLERIC, SoundEvents.VILLAGER_WORK_CLERIC); register( p_393047_, FARMER, PoiTypes.FARMER, ImmutableSet.of(Items.WHEAT, Items.WHEAT_SEEDS, Items.BEETROOT_SEEDS, Items.BONE_MEAL), ImmutableSet.of(Blocks.FARMLAND), SoundEvents.VILLAGER_WORK_FARMER ); register(p_393047_, FISHERMAN, PoiTypes.FISHERMAN, SoundEvents.VILLAGER_WORK_FISHERMAN); register(p_393047_, FLETCHER, PoiTypes.FLETCHER, SoundEvents.VILLAGER_WORK_FLETCHER); register(p_393047_, LEATHERWORKER, PoiTypes.LEATHERWORKER, SoundEvents.VILLAGER_WORK_LEATHERWORKER); register(p_393047_, LIBRARIAN, PoiTypes.LIBRARIAN, SoundEvents.VILLAGER_WORK_LIBRARIAN); register(p_393047_, MASON, PoiTypes.MASON, SoundEvents.VILLAGER_WORK_MASON); register(p_393047_, NITWIT, PoiType.NONE, PoiType.NONE, null); register(p_393047_, SHEPHERD, PoiTypes.SHEPHERD, SoundEvents.VILLAGER_WORK_SHEPHERD); register(p_393047_, TOOLSMITH, PoiTypes.TOOLSMITH, SoundEvents.VILLAGER_WORK_TOOLSMITH); return register(p_393047_, WEAPONSMITH, PoiTypes.WEAPONSMITH, SoundEvents.VILLAGER_WORK_WEAPONSMITH); } }