Jump to content

[1.16.4/1.16.5] [Solved] How to add a custom Trunk Placer Type


killerjdog51

Recommended Posts

I'm trying to add custom trees to my mod and to do that I need a custom Trunk. The only way to do this is to register my own type using: 

private static <P extends AbstractTrunkPlacer> TrunkPlacerType<P> register(String key, Codec<P> type) {
	      return Registry.register(Registry.TRUNK_REPLACER, key, new TrunkPlacerType<>(type));
	   }

 

The issue though is that it errors on the new TrunkPlacerType<>(type) saying "Cannot infer type arguments for TrunkPlacerType<>". 

And if I delete TrunkPlacerType<> I get an error on Register.register saying "The method register(Registry<V>, ResourceLocation, T) in the type Registry is not applicable for the arguments (Registry<TrunkPlacerType<?>>, ResourceLocation, Codec<P>)".

 

My next thought process was to add my Trunk Placer Type to a forge deferred register, except that it doesn't exist. There's a Forge registry for FoliagePlacerType and TreeDecorationType, but not one for TrunkPlacerType. 

 

So I'm wondering if anyone has an idea that I haven't thought of? 
Like is there a way for me to add my trunk type to the minecraft registry? Or is there a way to create a custom Forge registry/deferred register?

Edited by killerjdog51
Link to comment
Share on other sites

8 hours ago, diesieben07 said:

Registry.TRUNK_REPLACER != Registry.TRUNK_PLACER_TYPES

Even though the registry has?

public static final Registry<TrunkPlacerType<?>> TRUNK_REPLACER = createRegistry(TRUNK_PLACER_TYPE_KEY, () -> {
      return TrunkPlacerType.STRAIGHT_TRUNK_PLACER;
   });

 

Link to comment
Share on other sites

Thanks, it worked! I generally try to avoid reflection because I don't want to accidently break the game... I was hoping there would be a better way to implement trees, but considering the constructor itself is private, I guess there's not many options available.
 

I kinda wish there was a consistent tutorial for trees, but I suppose that'd be hard since mojang keeps changing things between updates. The mod I'm working on is for 1.14, 1.15, and now 1.16, and each update has different code for trees, like they keep getting more and more modularized/customizable. Which certainly isn't a bad thing.

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.