Jump to content

[1.16.3] Registering Villager Professions


TimmyRB

Recommended Posts

I'm trying to register a custom Villager Profession but I'm not sure if what I'm doing is correct. The following runs without a hitch however the villagers never run the the block like they do other Job blocks and even if they are getting the job when I'm not looking, I'm unsure how to set a custom texture so they appear uniquely.

 

// ModProfessions.java

public class ModProfessions {

    public static final DeferredRegister<VillagerProfession> PROFESSIONS = DeferredRegister
            .create(ForgeRegistries.PROFESSIONS, HuntingUpdate.MOD_ID);

    private static final ImmutableSet<Item> HUNTER_ITEMS = ImmutableSet.of(Items.BEEF, Items.PORKCHOP, Items.CHICKEN,
            Items.RABBIT, Items.RABBIT_HIDE, Items.MUTTON, Items.LEATHER, Items.COOKED_BEEF, Items.COOKED_PORKCHOP,
            Items.COOKED_CHICKEN, Items.COOKED_RABBIT, Items.COOKED_MUTTON);

    public static final RegistryObject<VillagerProfession> HUNTER = PROFESSIONS.register("hunter",
            () -> new VillagerProfession("hunter",
                    new PointOfInterestType("hunting_table",
                            ImmutableSet.of(ModBlocks.HUNTING_TABLE.get().getDefaultState()), 5, 40),
                    HUNTER_ITEMS, ImmutableSet.of(ModBlocks.HUNTING_TABLE.get()),
                    SoundEvents.ENTITY_VILLAGER_WORK_BUTCHER));

}
// HuntingUpdate.java (Main Class)

public HuntingUpdate() {
        // Register the setup method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        ModBlocks.BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
        ModItems.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        ModEntities.ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus());
        ModProfessions.PROFESSIONS.register(FMLJavaModLoadingContext.get().getModEventBus());

        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);
    }

 

Any help would be super appreciated thanks!

  • Like 1
Link to comment
Share on other sites

I would take a look at how the Never Needed or Wanted (NNOW) mod handles new villagers, PoI blocks, and trades. The unique villager textures are based on the names when you register the profession (here), which points to the corresponding file in your textures/entity. The mod creator also made some nifty reference classes, VillagerUtil and RandomTradeBuilder, that reduces some repetitive code when making multiple villager types. 

 

 

Edited by urbanxx001
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.