Skip to content

Commit 7e1ccf5

Browse files
Simplify book model
1 parent f0df654 commit 7e1ccf5

File tree

5 files changed

+38
-58
lines changed

5 files changed

+38
-58
lines changed

Fabric/src/main/java/vazkii/patchouli/fabric/client/FabricClientInitializer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public void onInitializeClient() {
6262
PatchouliItems.BOOK_ID.equals(ctx.topLevelId().id()) // checks namespace and path
6363
&& ctx.topLevelId().getVariant().equals("inventory")
6464
&& oldModel != null) {
65-
return new BookModel(oldModel, ctx.loader(), (model) -> {
66-
return Minecraft.getInstance().getModelManager().getModel(model);
67-
});
65+
return new BookModel(oldModel, (model) -> Minecraft.getInstance().getModelManager().getModel(model));
6866
}
6967
return oldModel;
7068
}

NeoForge/src/main/java/vazkii/patchouli/neoforge/client/NeoForgeClientInitializer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ public static void onInitializeClient(FMLClientSetupEvent evt) {
151151
@SubscribeEvent
152152
public static void replaceBookModel(ModelEvent.ModifyBakingResult evt) {
153153
ModelResourceLocation key = ModelResourceLocation.inventory(PatchouliItems.BOOK_ID);
154-
evt.getModels().computeIfPresent(key, (k, oldModel) -> new BookModel(oldModel, evt.getModelBakery(), (model) -> {
155-
ModelResourceLocation modelPath = ModelResourceLocation.standalone(model);
156-
return Minecraft.getInstance().getModelManager().getModel(modelPath);
157-
}));
154+
evt.getModels().computeIfPresent(key, (k, oldModel) -> new BookModel(oldModel, (model) -> Minecraft.getInstance().getModelManager().getModel(ModelResourceLocation.standalone(model))));
158155
}
159156
}

Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import net.minecraft.client.multiplayer.ClientLevel;
44
import net.minecraft.client.renderer.block.model.BakedQuad;
5-
import net.minecraft.client.renderer.block.model.BlockModel;
65
import net.minecraft.client.renderer.block.model.ItemOverrides;
76
import net.minecraft.client.renderer.block.model.ItemTransforms;
87
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -16,7 +15,6 @@
1615

1716
import vazkii.patchouli.common.book.Book;
1817
import vazkii.patchouli.common.item.ItemModBook;
19-
import vazkii.patchouli.mixin.client.AccessorModelBakery;
2018

2119
import org.jetbrains.annotations.NotNull;
2220
import org.jetbrains.annotations.Nullable;
@@ -29,42 +27,10 @@ public class BookModel implements BakedModel {
2927
private final BakedModel original;
3028
private final ItemOverrides itemHandler;
3129

32-
public BookModel(BakedModel original, ModelBakery loader, Function<ResourceLocation, BakedModel> modelGetter) {
30+
public BookModel(BakedModel original, Function<ResourceLocation, BakedModel> modelGetter) {
3331
this.original = original;
34-
BlockModel missing = (BlockModel) ((AccessorModelBakery) loader).invokeGetModel(ModelBakery.MISSING_MODEL_LOCATION);
35-
36-
this.itemHandler = new ItemOverrides(new ModelBaker() {
37-
// soft implement IModelBakerExtension
38-
public Function<Material, TextureAtlasSprite> getModelTextureGetter() {
39-
return null;
40-
}
41-
42-
// soft implement IModelBakerExtension
43-
public BakedModel bake(ResourceLocation location, ModelState state, Function<Material, TextureAtlasSprite> sprites) {
44-
return null;
45-
}
46-
47-
// soft implement IModelBakerExtension
48-
public BakedModel bakeUncached(UnbakedModel model, ModelState state, Function<Material, TextureAtlasSprite> sprites) {
49-
return null;
50-
}
51-
52-
// soft implement IModelBakerExtension
53-
public UnbakedModel getTopLevelModel(ModelResourceLocation location) {
54-
return null;
55-
}
5632

57-
@Override
58-
public UnbakedModel getModel(ResourceLocation resourceLocation) {
59-
return null;
60-
}
61-
62-
@Nullable
63-
@Override
64-
public BakedModel bake(ResourceLocation resourceLocation, ModelState modelState) {
65-
return null;
66-
}
67-
}, missing, Collections.emptyList()) {
33+
this.itemHandler = new ItemOverrides(DummyModelBaker.INSTANCE, null, Collections.emptyList()) {
6834
@Override
6935
public BakedModel resolve(@NotNull BakedModel original, @NotNull ItemStack stack,
7036
@Nullable ClientLevel world, @Nullable LivingEntity entity, int seed) {
@@ -119,4 +85,38 @@ public TextureAtlasSprite getParticleIcon() {
11985
public ItemTransforms getTransforms() {
12086
return original.getTransforms();
12187
}
88+
89+
private static class DummyModelBaker implements ModelBaker {
90+
static ModelBaker INSTANCE = new DummyModelBaker();
91+
// soft implement IModelBakerExtension
92+
public Function<Material, TextureAtlasSprite> getModelTextureGetter() {
93+
return null;
94+
}
95+
96+
// soft implement IModelBakerExtension
97+
public BakedModel bake(ResourceLocation location, ModelState state, Function<Material, TextureAtlasSprite> sprites) {
98+
return null;
99+
}
100+
101+
// soft implement IModelBakerExtension
102+
public BakedModel bakeUncached(UnbakedModel model, ModelState state, Function<Material, TextureAtlasSprite> sprites) {
103+
return null;
104+
}
105+
106+
// soft implement IModelBakerExtension
107+
public UnbakedModel getTopLevelModel(ModelResourceLocation location) {
108+
return null;
109+
}
110+
111+
@Override
112+
public UnbakedModel getModel(ResourceLocation resourceLocation) {
113+
return null;
114+
}
115+
116+
@Nullable
117+
@Override
118+
public BakedModel bake(ResourceLocation resourceLocation, ModelState modelState) {
119+
return null;
120+
}
121+
}
122122
}

Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorModelBakery.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

Xplat/src/main/resources/patchouli_xplat.mixins.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"client": [
1111
"client.AccessorClientAdvancements",
1212
"client.AccessorKeyMapping",
13-
"client.AccessorModelBakery",
1413
"client.AccessorMultiBufferSource",
1514
"client.AccessorScreen",
1615
"client.MixinClientAdvancements",

0 commit comments

Comments
 (0)