Forgified Fabric API

Forgified Fabric API

13M Downloads

Simple subclasses of `FowardingBakedModel` will always be unwrapped during item rendering

PepperCode1 opened this issue ยท 1 comments

commented

NeoForge patches the ItemRenderer to allow replacing the model based on transforms: https://github.com/neoforged/NeoForge/blob/1.21.1/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch#L17 (Note that Forgified Indigo's ItemRenderer hook comes after this patch)

The default implementation of IBakedModelExtension#applyTransform returns itself as the target model: https://github.com/neoforged/NeoForge/blob/1.21.1/src/main/java/net/neoforged/neoforge/client/extensions/IBakedModelExtension.java#L67

Forgified Fabric API's ForwardingBakedModel forwards that result: https://github.com/Sinytra/ForgifiedFabricAPI/blob/1.21.1/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/model/ForwardingBakedModel.java#L120-L123, meaning the final model used by the renderer will be the wrapped model of the ForwardingBakedModel instead of the ForwardingBakedModel itself.

This breaks Continuity's emissive item model textures.

commented

Replacing Forgified's ForwardingBakedModel#applyTransform implementation with the following code will fix the Continuity issue in the common case where the wrapped model returns itself, but will still break with custom NeoForge models that change that behavior.

BakedModel result = wrapped.applyTransform(transformType, poseStack, applyLeftHandTransform);

if (result == wrapped) {
    return this;
}

return result;

Fixing the edge case likely requires duplicating this via unsafe and swapping out the value of the wrapped field for result.