Add tree types support to Object Builders API
kanpov opened this issue ยท 5 comments
Hello Fabric Team!
In the process of creating my new tutorial on the Fabric Wiki about trees, I discovered that Fabric API currently lacks the functionality to create TrunkPlacerType
s, FoliagePlacerType
s, TreeDecoratorType
s, BlockStateProviderType
s and additionally IntProviderType
s without possible conflicts due to using the minecraft
namespace.
These things are required for creating your own TrunkPlacer
s, FoliagePlacer
s, TreeDecorator
s, BlockStateProvider
s and IntProvider
s.
Unfortunately, the constructors are protected, and you have to use access wideners (highly not recommended) or mixin invokers.
Here's an example which I used in my tutorial for TrunkPlacerType
s:
@Mixin(TrunkPlacerType.class)
public interface TrunkPlacerTypeInvoker {
@Invoker
static <TTrunkPlacer extends TrunkPlacer> TrunkPlacerType<TTrunkPlacer> invokeRegister(String id, Codec<TTrunkPlacer> codec) {
throw new AssertionError();
}
}
public static final TrunkPlacerType<RichTrunkPlacer> RICH_TRUNK_PLACER = TrunkPlacerTypeInvoker.invokeRegister("rich_trunk_placer", RichTrunkPlacer.CODEC);
It would be great if we had an API to do this to reduce the usage of mixins in mods.
I could make a PR implementing this, though I haven't had any experience in creating and documenting APIs yet.
Thanks for your attention!
I think this has been addressed by the transitive access widener module by now.
There is no need to use an access widener, you can just create a new class that extends it? I havent done a huge amount with trees but TechReborn's rubber tree is done easily without any mixins.
Unfortunately, that solution didn't work since the constructor has private
access, not protected
, so it's impossible to inherit from the class.