Skip to content

Commit 8041d50

Browse files
authored
Fix extra models registered through ModelLoadingPlugin only loading top level (#4356)
- Adjust testmod to make test extra model have a parent that is not referenced by any other model
1 parent 50f0feb commit 8041d50

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/mixin/client/model/loading/ReferencedModelsCollectorMixin.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2727

2828
import net.minecraft.client.render.model.ReferencedModelsCollector;
29+
import net.minecraft.client.render.model.ResolvableModel;
2930
import net.minecraft.client.render.model.UnbakedModel;
3031
import net.minecraft.util.Identifier;
3132

@@ -37,6 +38,9 @@ abstract class ReferencedModelsCollectorMixin {
3738
@Nullable
3839
private ModelLoadingEventDispatcher fabric_eventDispatcher;
3940

41+
@Shadow
42+
public abstract void add(ResolvableModel model);
43+
4044
@Shadow
4145
abstract UnbakedModel computeResolvedModel(Identifier id);
4246

@@ -45,7 +49,7 @@ private void onReturnInit(CallbackInfo ci) {
4549
fabric_eventDispatcher = ModelLoadingEventDispatcher.CURRENT.get();
4650

4751
if (fabric_eventDispatcher != null) {
48-
fabric_eventDispatcher.forEachExtraModel(this::computeResolvedModel);
52+
fabric_eventDispatcher.forEachExtraModel(id -> add(computeResolvedModel(id)));
4953
}
5054
}
5155

Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
{
2+
"parent": "fabric-model-loading-api-v1-testmod:template_half",
23
"textures": {
3-
"sand": "minecraft:block/sand",
4-
"red_sand": "minecraft:block/red_sand",
5-
"particle": "#sand"
6-
},
7-
"elements": [
8-
{
9-
"from": [ 0, 0, 0 ],
10-
"to": [ 16, 16, 16 ],
11-
"faces": {
12-
"down": { "texture": "#sand" },
13-
"up": { "texture": "#red_sand" },
14-
"north": { "texture": "#sand" },
15-
"south": { "texture": "#red_sand" },
16-
"west": { "texture": "#sand" },
17-
"east": { "texture": "#red_sand" }
18-
}
19-
}
20-
]
4+
"half1": "minecraft:block/sand",
5+
"half2": "minecraft:block/red_sand"
6+
}
217
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"textures": {
3+
"particle": "#half1"
4+
},
5+
"elements": [
6+
{
7+
"from": [ 0, 0, 0 ],
8+
"to": [ 16, 16, 16 ],
9+
"faces": {
10+
"down": { "texture": "#half1" },
11+
"up": { "texture": "#half2" },
12+
"north": { "texture": "#half1" },
13+
"south": { "texture": "#half2" },
14+
"west": { "texture": "#half1" },
15+
"east": { "texture": "#half2" }
16+
}
17+
}
18+
]
19+
}

0 commit comments

Comments
 (0)