Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

  • Author
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;
   });

 

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.