36
36
public final class ModelLoadingPluginManager {
37
37
private static final Logger LOGGER = LogUtils .getLogger ();
38
38
private static final Map <Block , BlockStateResolver > RESOLVERS = new Reference2ReferenceLinkedOpenHashMap <>();
39
- private static final Map <ResourceLocation , ModelLoadingPlugin .ModifyOnLoad > ON_LOAD_PLUGINS = new Object2ReferenceLinkedOpenHashMap <>();
40
- private static final Map <ResourceLocation , ModelLoadingPlugin .ModifyBeforeBake > BEFORE_BAKE_PLUGINS = new Object2ReferenceLinkedOpenHashMap <>();
41
- private static final Map <ResourceLocation , ModelLoadingPlugin .ModifyAfterBake > AFTER_BAKE_PLUGINS = new Object2ReferenceLinkedOpenHashMap <>();
42
- private static final Map <ResourceLocation , ModelLoadingPlugin .ModifyBlockOnLoad > ON_LOAD_BLOCK_PLUGINS = new Object2ReferenceLinkedOpenHashMap <>();
43
- private static final Map <ResourceLocation , ModelLoadingPlugin .ModifyBlockBeforeBake > BEFORE_BAKE_BLOCK_PLUGINS = new Object2ReferenceLinkedOpenHashMap <>();
44
- private static final Map <ResourceLocation , ModelLoadingPlugin .ModifyBlockAfterBake > AFTER_BAKE_BLOCK_PLUGINS = new Object2ReferenceLinkedOpenHashMap <>();
39
+ private static final Map <ResourceLocation , ModelModifier .ModifyOnLoad > ON_LOAD_MODIFIERS = new Object2ReferenceLinkedOpenHashMap <>();
40
+ private static final Map <ResourceLocation , ModelModifier .ModifyBeforeBake > BEFORE_BAKE_MODIFIERS = new Object2ReferenceLinkedOpenHashMap <>();
41
+ private static final Map <ResourceLocation , ModelModifier .ModifyAfterBake > AFTER_BAKE_MODIFIERS = new Object2ReferenceLinkedOpenHashMap <>();
42
+ private static final Map <ResourceLocation , ModelModifier .ModifyBlockOnLoad > ON_LOAD_BLOCK_MODIFIERS = new Object2ReferenceLinkedOpenHashMap <>();
43
+ private static final Map <ResourceLocation , ModelModifier .ModifyBlockBeforeBake > BEFORE_BAKE_BLOCK_MODIFIERS = new Object2ReferenceLinkedOpenHashMap <>();
44
+ private static final Map <ResourceLocation , ModelModifier .ModifyBlockAfterBake > AFTER_BAKE_BLOCK_MODIFIERS = new Object2ReferenceLinkedOpenHashMap <>();
45
45
46
46
private ModelLoadingPluginManager () {}
47
47
48
48
public static void init () {
49
49
ModLoader .postEvent (new ModelEvent .RegisterLoadingPlugins (RESOLVERS , (id , plugin ) -> switch (plugin ) {
50
- case ModelLoadingPlugin .ModifyOnLoad onLoad -> ON_LOAD_PLUGINS .putIfAbsent (id , onLoad );
51
- case ModelLoadingPlugin .ModifyBeforeBake beforeBake -> BEFORE_BAKE_PLUGINS .putIfAbsent (id , beforeBake );
52
- case ModelLoadingPlugin .ModifyAfterBake afterBake -> AFTER_BAKE_PLUGINS .putIfAbsent (id , afterBake );
53
- case ModelLoadingPlugin .ModifyBlockOnLoad onLoadBlock -> ON_LOAD_BLOCK_PLUGINS .putIfAbsent (id , onLoadBlock );
54
- case ModelLoadingPlugin .ModifyBlockBeforeBake beforeBakeBlock -> BEFORE_BAKE_BLOCK_PLUGINS .putIfAbsent (id , beforeBakeBlock );
55
- case ModelLoadingPlugin .ModifyBlockAfterBake afterBakeBlock -> AFTER_BAKE_BLOCK_PLUGINS .putIfAbsent (id , afterBakeBlock );
50
+ case ModelModifier .ModifyOnLoad onLoad -> ON_LOAD_MODIFIERS .putIfAbsent (id , onLoad );
51
+ case ModelModifier .ModifyBeforeBake beforeBake -> BEFORE_BAKE_MODIFIERS .putIfAbsent (id , beforeBake );
52
+ case ModelModifier .ModifyAfterBake afterBake -> AFTER_BAKE_MODIFIERS .putIfAbsent (id , afterBake );
53
+ case ModelModifier .ModifyBlockOnLoad onLoadBlock -> ON_LOAD_BLOCK_MODIFIERS .putIfAbsent (id , onLoadBlock );
54
+ case ModelModifier .ModifyBlockBeforeBake beforeBakeBlock -> BEFORE_BAKE_BLOCK_MODIFIERS .putIfAbsent (id , beforeBakeBlock );
55
+ case ModelModifier .ModifyBlockAfterBake afterBakeBlock -> AFTER_BAKE_BLOCK_MODIFIERS .putIfAbsent (id , afterBakeBlock );
56
56
}));
57
57
}
58
58
59
59
@ Nullable
60
60
public static UnbakedModel modifyModelOnLoad (ResourceLocation id , @ Nullable UnbakedModel model ) {
61
- if (ON_LOAD_PLUGINS .isEmpty ()) return model ;
61
+ if (ON_LOAD_MODIFIERS .isEmpty ()) return model ;
62
62
63
- ModelLoadingPlugin .ModifyOnLoad .Context context = new ModelLoadingPlugin .ModifyOnLoad .Context (id );
64
- for (Map .Entry <ResourceLocation , ModelLoadingPlugin .ModifyOnLoad > entry : ON_LOAD_PLUGINS .entrySet ()) {
63
+ ModelModifier .ModifyOnLoad .Context context = new ModelModifier .ModifyOnLoad .Context (id );
64
+ for (Map .Entry <ResourceLocation , ModelModifier .ModifyOnLoad > entry : ON_LOAD_MODIFIERS .entrySet ()) {
65
65
try {
66
66
model = entry .getValue ().modifyModelOnLoad (model , context );
67
67
} catch (Throwable t ) {
@@ -72,10 +72,10 @@ public static UnbakedModel modifyModelOnLoad(ResourceLocation id, @Nullable Unba
72
72
}
73
73
74
74
public static UnbakedModel modifyModelBeforeBake (ResourceLocation id , UnbakedModel model , ModelState modelState , ModelBaker baker ) {
75
- if (BEFORE_BAKE_PLUGINS .isEmpty ()) return model ;
75
+ if (BEFORE_BAKE_MODIFIERS .isEmpty ()) return model ;
76
76
77
- ModelLoadingPlugin .ModifyBeforeBake .Context context = new ModelLoadingPlugin .ModifyBeforeBake .Context (id , modelState , baker );
78
- for (Map .Entry <ResourceLocation , ModelLoadingPlugin .ModifyBeforeBake > entry : BEFORE_BAKE_PLUGINS .entrySet ()) {
77
+ ModelModifier .ModifyBeforeBake .Context context = new ModelModifier .ModifyBeforeBake .Context (id , modelState , baker );
78
+ for (Map .Entry <ResourceLocation , ModelModifier .ModifyBeforeBake > entry : BEFORE_BAKE_MODIFIERS .entrySet ()) {
79
79
try {
80
80
model = entry .getValue ().modifyModelBeforeBake (model , context );
81
81
} catch (Throwable t ) {
@@ -86,10 +86,10 @@ public static UnbakedModel modifyModelBeforeBake(ResourceLocation id, UnbakedMod
86
86
}
87
87
88
88
public static BakedModel modifyModelAfterBake (ResourceLocation id , BakedModel model , UnbakedModel sourceModel , ModelState modelState , ModelBaker baker ) {
89
- if (AFTER_BAKE_PLUGINS .isEmpty ()) return model ;
89
+ if (AFTER_BAKE_MODIFIERS .isEmpty ()) return model ;
90
90
91
- ModelLoadingPlugin .ModifyAfterBake .Context context = new ModelLoadingPlugin .ModifyAfterBake .Context (id , sourceModel , modelState , baker );
92
- for (Map .Entry <ResourceLocation , ModelLoadingPlugin .ModifyAfterBake > entry : AFTER_BAKE_PLUGINS .entrySet ()) {
91
+ ModelModifier .ModifyAfterBake .Context context = new ModelModifier .ModifyAfterBake .Context (id , sourceModel , modelState , baker );
92
+ for (Map .Entry <ResourceLocation , ModelModifier .ModifyAfterBake > entry : AFTER_BAKE_MODIFIERS .entrySet ()) {
93
93
try {
94
94
model = entry .getValue ().modifyModelAfterBake (model , context );
95
95
} catch (Throwable t ) {
@@ -100,7 +100,7 @@ public static BakedModel modifyModelAfterBake(ResourceLocation id, BakedModel mo
100
100
}
101
101
102
102
public static BlockStateModelLoader .LoadedModels modifyBlockModelsOnLoad (BlockStateModelLoader .LoadedModels models ) {
103
- if (RESOLVERS .isEmpty () && ON_LOAD_BLOCK_PLUGINS .isEmpty ()) return models ;
103
+ if (RESOLVERS .isEmpty () && ON_LOAD_BLOCK_MODIFIERS .isEmpty ()) return models ;
104
104
105
105
Map <ModelResourceLocation , BlockStateModelLoader .LoadedModel > map = models .models ();
106
106
if (!(map instanceof HashMap )) {
@@ -111,7 +111,7 @@ public static BlockStateModelLoader.LoadedModels modifyBlockModelsOnLoad(BlockSt
111
111
if (!RESOLVERS .isEmpty ()) {
112
112
resolveBlockStates (map );
113
113
}
114
- if (!ON_LOAD_BLOCK_PLUGINS .isEmpty ()) {
114
+ if (!ON_LOAD_BLOCK_MODIFIERS .isEmpty ()) {
115
115
modifyBlockModelsOnLoad (map );
116
116
}
117
117
@@ -189,7 +189,7 @@ public void setModel(BlockState state, UnbakedBlockStateModel model) {
189
189
}
190
190
191
191
private static void modifyBlockModelsOnLoad (Map <ModelResourceLocation , BlockStateModelLoader .LoadedModel > map ) {
192
- var context = new ModelLoadingPlugin .ModifyBlockOnLoad .Context () {
192
+ var context = new ModelModifier .ModifyBlockOnLoad .Context () {
193
193
private ModelResourceLocation id ;
194
194
private BlockState state ;
195
195
@@ -208,7 +208,7 @@ public BlockState state() {
208
208
context .state = loadedModel .state ();
209
209
210
210
UnbakedBlockStateModel model = loadedModel .model ();
211
- for (Map .Entry <ResourceLocation , ModelLoadingPlugin .ModifyBlockOnLoad > entry : ON_LOAD_BLOCK_PLUGINS .entrySet ()) {
211
+ for (Map .Entry <ResourceLocation , ModelModifier .ModifyBlockOnLoad > entry : ON_LOAD_BLOCK_MODIFIERS .entrySet ()) {
212
212
try {
213
213
model = entry .getValue ().modifyBlockModelOnLoad (model , context );
214
214
} catch (Throwable t ) {
@@ -223,10 +223,10 @@ public BlockState state() {
223
223
}
224
224
225
225
public static UnbakedBlockStateModel modifyBlockModelBeforeBake (ModelResourceLocation id , UnbakedBlockStateModel model , ModelBaker baker ) {
226
- if (BEFORE_BAKE_BLOCK_PLUGINS .isEmpty ()) return model ;
226
+ if (BEFORE_BAKE_BLOCK_MODIFIERS .isEmpty ()) return model ;
227
227
228
- ModelLoadingPlugin .ModifyBlockBeforeBake .Context context = new ModelLoadingPlugin .ModifyBlockBeforeBake .Context (id , baker );
229
- for (Map .Entry <ResourceLocation , ModelLoadingPlugin .ModifyBlockBeforeBake > entry : BEFORE_BAKE_BLOCK_PLUGINS .entrySet ()) {
228
+ ModelModifier .ModifyBlockBeforeBake .Context context = new ModelModifier .ModifyBlockBeforeBake .Context (id , baker );
229
+ for (Map .Entry <ResourceLocation , ModelModifier .ModifyBlockBeforeBake > entry : BEFORE_BAKE_BLOCK_MODIFIERS .entrySet ()) {
230
230
try {
231
231
model = entry .getValue ().modifyBlockModelBeforeBake (model , context );
232
232
} catch (Throwable t ) {
@@ -237,10 +237,10 @@ public static UnbakedBlockStateModel modifyBlockModelBeforeBake(ModelResourceLoc
237
237
}
238
238
239
239
public static BakedModel modifyBlockModelAfterBake (ModelResourceLocation id , BakedModel model , UnbakedBlockStateModel sourceModel , ModelBaker baker ) {
240
- if (AFTER_BAKE_BLOCK_PLUGINS .isEmpty ()) return model ;
240
+ if (AFTER_BAKE_BLOCK_MODIFIERS .isEmpty ()) return model ;
241
241
242
- ModelLoadingPlugin .ModifyBlockAfterBake .Context context = new ModelLoadingPlugin .ModifyBlockAfterBake .Context (id , sourceModel , baker );
243
- for (Map .Entry <ResourceLocation , ModelLoadingPlugin .ModifyBlockAfterBake > entry : AFTER_BAKE_BLOCK_PLUGINS .entrySet ()) {
242
+ ModelModifier .ModifyBlockAfterBake .Context context = new ModelModifier .ModifyBlockAfterBake .Context (id , sourceModel , baker );
243
+ for (Map .Entry <ResourceLocation , ModelModifier .ModifyBlockAfterBake > entry : AFTER_BAKE_BLOCK_MODIFIERS .entrySet ()) {
244
244
try {
245
245
model = entry .getValue ().modifyBlockModelAfterBake (model , context );
246
246
} catch (Throwable t ) {
0 commit comments