Non `isVanillaAdapter` item models cause a crash
SuperMartijn642 opened this issue · 4 comments
Bug Description
This concerns the Fabric version of Sodium for Minecraft 1.21.3 and is specifically related to the Fabric Rendering API.
Returning false
for FabricBakedModel#isVanillaAdapter
for an item model results in a crash when that model is rendered. Even when overriding FabricBakedModel#emitItemQuads
to do nothing, it still results in a crash, hence it seems it is caused purely by the FabricBakedModel#isVanillaAdapter
result.
Reproduction Steps
Add the following snippet to the client initialization entry point:
ModelLoadingPluginManager.registerPlugin(pluginContext -> {
pluginContext.modifyModelAfterBake().register((bakedModel, modelContext) ->{
if(modelContext.sourceModel() instanceof ItemModel itemModel && itemModel.id.equals(ResourceLocation.parse("minecraft:item/cobblestone"))){
var forwardingBakedModel = new ForwardingBakedModel() {
@Override
public boolean isVanillaAdapter(){
return false;
}
public void setModel(BakedModel model){
this.wrapped = model;
}
};
forwardingBakedModel.setModel(bakedModel);
return forwardingBakedModel;
}
return bakedModel;
});
});
The snippet replaces the cobblestone item model with a ForwardingBakedModel
wrapping the original item model, but which returns false
for FabricBakedModel#isVanillaAdapter
. The ForwardingBakedModel
returns the same as the original model for any other methods in BakedModel
.
The snippet also requires an access widener entry for the ItemModel#id
field:
accessible field net/minecraft/client/resources/model/ItemModel id Lnet/minecraft/resources/ResourceLocation;
With the snippet added, simply try to look at a cobblestone item and it will cause a crash.
Log File
latest.log
The log shows Moving Elevators as a mod as that is what I used for testing, but it is stripped down to include nothing but the snippet given.
Crash Report
Fixed with 7401075. The latest nightly build contains the fix but we haven't packaged it into a release yet.
@IMS212 This random PoseStack#popStack()
in the code for FRAPI item model integration seems highly suspect...