Jump to content

[1.14] Custom VillagerProfession not "finding" custom PointOfIntrestType


appjackstudio

Recommended Posts

I am trying to create a custom "Baker" villager type but am having trouble getting it to be created naturally. I am able to summon a baker villager with "/summon minecraft:villager 92.70 63.00 214.65 {Brain: {memories: {"minecraft:job_site": {pos: [I; 91, 63, 214], dimension: "minecraft:overworld"}}}, VillagerData: {profession: "bakecraft:baker"}}", but it converts into an unemployed villager as soon as it turns time hits 2000. I have double-checked and the job site coordinates are correct. I cannot get one to generate naturally by putting it next to the workstation. I know the profession and POI are registered properly because they show up in the registry while debugging. What am I missing? Why aren't the villagers recognizing their workstations? Any help is appreciated. Thanks!

package com.appjackstudio.bakecraft.init;

import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.merchant.villager.VillagerProfession;
import net.minecraft.util.SoundEvent;
import net.minecraft.village.PointOfInterestType;
import net.minecraftforge.registries.IForgeRegistry;

import java.util.Set;

public class ModVillagers {
    public static Set<BlockState> getAllStates(Block block) {
        return ImmutableSet.copyOf(block.getStateContainer().getValidStates());
    }

    public static final PointOfInterestType OVEN = new PointOfInterestType("oven", getAllStates(ModBlocks.TRONA), 1, (SoundEvent)null, 1).setRegistryName("oven");

    public static void registerPointOfIntrestTypes(IForgeRegistry<PointOfInterestType> registry){
        registry.registerAll(
                OVEN
        );
    }


    public static final VillagerProfession BAKER = new VillagerProfession("baker", OVEN, ImmutableSet.of(), ImmutableSet.of()).setRegistryName("baker");

    public static void registerVillagerProfessions(IForgeRegistry<VillagerProfession> registry){
        registry.registerAll(
                BAKER
        );
    }
}
Edited by appjackstudio
Full Code
Link to comment
Share on other sites

30 minutes ago, appjackstudio said:

public static final PointOfInterestType OVEN = new PointOfInterestType("oven", getAllStates(ModBlocks.OVEN), 1, (SoundEvent)null, 1).setRegistryName("oven");

First off don't initialize any Registry entries in a static initializer.

 

35 minutes ago, appjackstudio said:

getAllStates

What does this method do?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

 
 
 
 
1 hour ago, Animefan8888 said:

First off don't initialize any Registry entries in a static initializer.

All mods I've seen and the all the vanilla classes do it that way. What would be the recommended way of doing it?

 

1 hour ago, Animefan8888 said:

What does this method do?

I've updated the post to contain the full code

Link to comment
Share on other sites

Just now, appjackstudio said:

All mods I've seen and the all the vanilla classes do it that way. What would be the recommended way of doing it?

You should do it in the their registry event and on top of your fields put the @ObjectHolder annotation.
 

 

2 hours ago, appjackstudio said:

public class ModVillagers {

You don't have the EventBusSubscriber annotation here so I assume you are registering the class in your setup method?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

3 minutes ago, Animefan8888 said:

You should do it in the their registry event and on top of your fields put the @ObjectHolder annotation.

Like This?

@ObjectHolder("bakecraft")
public class ModVillagers {
    public static Set<BlockState> getAllStates(Block block) {
        return ImmutableSet.copyOf(block.getStateContainer().getValidStates());
    }

    public static final PointOfInterestType oven = null;

    public static void registerPointOfIntrestTypes(IForgeRegistry<PointOfInterestType> registry){
        BakecraftMod.LOGGER.info(getAllStates(ModBlocks.TRONA));
        registry.registerAll(
            new PointOfInterestType("oven", getAllStates(ModBlocks.TRONA), 1, (SoundEvent)null, 1).setRegistryName("oven")
        );
    }


    public static final VillagerProfession baker = null;

    public static void registerVillagerProfessions(IForgeRegistry<VillagerProfession> registry){
        registry.registerAll(
                new VillagerProfession("baker", oven, ImmutableSet.of(), ImmutableSet.of()).setRegistryName("baker")
        );
    }
}

 

3 minutes ago, Animefan8888 said:

You don't have the EventBusSubscriber annotation here so I assume you are registering the class in your setup method?

Yes

    // ...
	@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {

		// ...

		@SubscribeEvent
        public static void onPointsOfInterestTypeRegistry(final RegistryEvent.Register<PointOfInterestType> event){
            LOGGER.info("Registering Points of Interest");
            ModVillagers.registerPointOfIntrestTypes(event.getRegistry());
        }

        @SubscribeEvent
        public static void onVillagerProfessionRegistry(final RegistryEvent.Register<VillagerProfession> event){
            LOGGER.info("Registering Villager Professions");
            ModVillagers.registerVillagerProfessions(event.getRegistry());
        }
	}
	// ...

 

Link to comment
Share on other sites

2 minutes ago, appjackstudio said:

Like This?

That looks good.
 

 

7 minutes ago, appjackstudio said:

getAllStates(ModBlocks.TRONA)

Can we confirm that this set isn't empty.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

47 minutes ago, appjackstudio said:

1025317283_Screenshotfrom2019-08-0422-32-45.png.c07bb4d211b8b023f497abb30cfa7d2d.png

I'm not sure what is going on maybe it was a bug and has been fixed have you tried updating to the latest forge version.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

  • 4 weeks later...

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.