Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple subclasses of FowardingBakedModel will always be unwrapped during item rendering #177

Open
PepperCode1 opened this issue Dec 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@PepperCode1
Copy link
Contributor

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.

@PepperCode1
Copy link
Contributor Author

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.

@Su5eD Su5eD self-assigned this Dec 14, 2024
@Su5eD Su5eD added the bug Something isn't working label Dec 14, 2024
Su5eD added a commit that referenced this issue Dec 14, 2024
Su5eD added a commit that referenced this issue Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants