-
-
Notifications
You must be signed in to change notification settings - Fork 133
Split Sources Support
By default, GeckoLib is built to safely encapsulate all of its code in one place, preventing the need to spread your code across different classes for a single usage.
However on environments which are built using split-sources (in which the client sources are in a completely isolated sourceset from the common sources), this poses a problem because the client code GeckoLib uses to render doesn't exist in the common sourceset.
This only really affects Items and Armour, since Entities and BlockEntities already have their renderers registered in client-only code.
To utilise the GeoRenderProvider system with split-sources, we have to take an extra step in the implementation. First, create your GeoItem class just like you normally would any GeoItem class (see here).
Then, follow the below steps:
- Create a
public
instanceofMutableObject<GeoRenderProvider>
in your item class as a final field - In your
createGeoRenderer
method, pass thegetValue()
call from the MutableObject to the consumer - In your client setup (ClientModInitializer on Fabric, or your client registration class on Neo/Forge), call
setValue()
on your registered item instance's cachedMutableObject
, passing your GeoRenderer instance as explained in the GeckoLib Items wiki page
public class ExampleItem extends Item implements GeoItem {
// Create the object to store the RenderProvider
public final MutableObject<GeoRenderProvider> renderProviderHolder = new MutableObject<>();
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);
public ExampleItem(Settings settings) {
super(settings);
}
@Override
public void createGeoRenderer(Consumer<GeoRenderProvider> consumer) {
// Return the cached RenderProvider
consumer.accept(this.renderProviderHolder.getValue());
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.geoCache;
}
}
@Override
public void onInitializeClient() {
ExampleModItems.EXAMPLE_ITEM.renderProviderHolder.setValue(new GeoRenderProvider() {
private ExampleItemRenderer renderer;
@Override
public BlockEntityWithoutLevelRenderer getGeoItemRenderer() {
if (this.renderer == null)
this.renderer = new ExampleItemRenderer();
return this.renderer;
}
});
}
Geckolib 3
Geckolib 4
- Installation
- Getting Started
- Upgrading from GeckoLib 3.1.x to 4.0
- Updating to GeckoLib 4.5
- Basic
- Advanced
- Miscellaneous
Package repository hosting is graciously provided by Cloudsmith.
Cloudsmith is the only fully hosted, cloud-native, universal package management solution that enables your organization to create, store and share packages in any format, to any place, with total confidence.