Skip to content

Commit 6135c07

Browse files
committed
Rename plugins to modifiers
1 parent 4309b17 commit 6135c07

File tree

5 files changed

+50
-50
lines changed

5 files changed

+50
-50
lines changed

src/main/java/net/neoforged/neoforge/client/event/ModelEvent.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import net.neoforged.fml.event.IModBusEvent;
2424
import net.neoforged.neoforge.client.model.UnbakedModelLoader;
2525
import net.neoforged.neoforge.client.model.loadingplugin.BlockStateResolver;
26-
import net.neoforged.neoforge.client.model.loadingplugin.ModelLoadingPlugin;
26+
import net.neoforged.neoforge.client.model.loadingplugin.ModelModifier;
2727
import org.jetbrains.annotations.ApiStatus;
2828
import org.jetbrains.annotations.Nullable;
2929

@@ -49,7 +49,7 @@ protected ModelEvent() {}
4949
*
5050
* <p>This event is fired on the mod-specific event bus, only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
5151
*
52-
* @deprecated Use {@link BlockStateResolver}s or {@link ModelLoadingPlugin}s instead
52+
* @deprecated Use {@link BlockStateResolver}s or {@link ModelModifier}s instead
5353
*/
5454
@Deprecated
5555
public static class ModifyBakingResult extends ModelEvent implements IModBusEvent {
@@ -94,7 +94,7 @@ public ModelBakery getModelBakery() {
9494
* Fired when the {@link ModelManager} is notified of the resource manager reloading.
9595
* Called after the model registry is set up and cached in the {@link net.minecraft.client.renderer.block.BlockModelShaper}.<br>
9696
* The model registry given by this event is unmodifiable. To modify the model registry, use
97-
* {@link BlockStateResolver}s or {@link ModelLoadingPlugin}s instead.
97+
* {@link BlockStateResolver}s or {@link ModelModifier}s instead.
9898
*
9999
* <p>This event is not {@linkplain ICancellableEvent cancellable}.</p>
100100
*
@@ -193,12 +193,12 @@ public void register(ResourceLocation key, UnbakedModelLoader<?> loader) {
193193

194194
public static class RegisterLoadingPlugins extends ModelEvent implements IModBusEvent {
195195
private final Map<Block, BlockStateResolver> resolvers;
196-
private final BiFunction<ResourceLocation, ModelLoadingPlugin, @Nullable ModelLoadingPlugin> pluginRegistrar;
196+
private final BiFunction<ResourceLocation, ModelModifier, @Nullable ModelModifier> modifierRegistrar;
197197

198198
@ApiStatus.Internal
199-
public RegisterLoadingPlugins(Map<Block, BlockStateResolver> resolvers, BiFunction<ResourceLocation, ModelLoadingPlugin, @Nullable ModelLoadingPlugin> pluginRegistrar) {
199+
public RegisterLoadingPlugins(Map<Block, BlockStateResolver> resolvers, BiFunction<ResourceLocation, ModelModifier, @Nullable ModelModifier> modifierRegistrar) {
200200
this.resolvers = resolvers;
201-
this.pluginRegistrar = pluginRegistrar;
201+
this.modifierRegistrar = modifierRegistrar;
202202
}
203203

204204
public void registerResolver(Block block, BlockStateResolver resolver) {
@@ -207,8 +207,8 @@ public void registerResolver(Block block, BlockStateResolver resolver) {
207207
}
208208
}
209209

210-
public void registerPlugin(ResourceLocation id, ModelLoadingPlugin plugin) {
211-
if (pluginRegistrar.apply(id, plugin) != null) {
210+
public void registerModifier(ResourceLocation id, ModelModifier modifier) {
211+
if (modifierRegistrar.apply(id, modifier) != null) {
212212
throw new IllegalStateException("Duplicate ModelLoadingPlugin registration with ID " + id);
213213
}
214214
}

src/main/java/net/neoforged/neoforge/client/model/loadingplugin/ModelLoadingPluginManager.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,32 @@
3636
public final class ModelLoadingPluginManager {
3737
private static final Logger LOGGER = LogUtils.getLogger();
3838
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<>();
4545

4646
private ModelLoadingPluginManager() {}
4747

4848
public static void init() {
4949
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);
5656
}));
5757
}
5858

5959
@Nullable
6060
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;
6262

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()) {
6565
try {
6666
model = entry.getValue().modifyModelOnLoad(model, context);
6767
} catch (Throwable t) {
@@ -72,10 +72,10 @@ public static UnbakedModel modifyModelOnLoad(ResourceLocation id, @Nullable Unba
7272
}
7373

7474
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;
7676

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()) {
7979
try {
8080
model = entry.getValue().modifyModelBeforeBake(model, context);
8181
} catch (Throwable t) {
@@ -86,10 +86,10 @@ public static UnbakedModel modifyModelBeforeBake(ResourceLocation id, UnbakedMod
8686
}
8787

8888
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;
9090

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()) {
9393
try {
9494
model = entry.getValue().modifyModelAfterBake(model, context);
9595
} catch (Throwable t) {
@@ -100,7 +100,7 @@ public static BakedModel modifyModelAfterBake(ResourceLocation id, BakedModel mo
100100
}
101101

102102
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;
104104

105105
Map<ModelResourceLocation, BlockStateModelLoader.LoadedModel> map = models.models();
106106
if (!(map instanceof HashMap)) {
@@ -111,7 +111,7 @@ public static BlockStateModelLoader.LoadedModels modifyBlockModelsOnLoad(BlockSt
111111
if (!RESOLVERS.isEmpty()) {
112112
resolveBlockStates(map);
113113
}
114-
if (!ON_LOAD_BLOCK_PLUGINS.isEmpty()) {
114+
if (!ON_LOAD_BLOCK_MODIFIERS.isEmpty()) {
115115
modifyBlockModelsOnLoad(map);
116116
}
117117

@@ -189,7 +189,7 @@ public void setModel(BlockState state, UnbakedBlockStateModel model) {
189189
}
190190

191191
private static void modifyBlockModelsOnLoad(Map<ModelResourceLocation, BlockStateModelLoader.LoadedModel> map) {
192-
var context = new ModelLoadingPlugin.ModifyBlockOnLoad.Context() {
192+
var context = new ModelModifier.ModifyBlockOnLoad.Context() {
193193
private ModelResourceLocation id;
194194
private BlockState state;
195195

@@ -208,7 +208,7 @@ public BlockState state() {
208208
context.state = loadedModel.state();
209209

210210
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()) {
212212
try {
213213
model = entry.getValue().modifyBlockModelOnLoad(model, context);
214214
} catch (Throwable t) {
@@ -223,10 +223,10 @@ public BlockState state() {
223223
}
224224

225225
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;
227227

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()) {
230230
try {
231231
model = entry.getValue().modifyBlockModelBeforeBake(model, context);
232232
} catch (Throwable t) {
@@ -237,10 +237,10 @@ public static UnbakedBlockStateModel modifyBlockModelBeforeBake(ModelResourceLoc
237237
}
238238

239239
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;
241241

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()) {
244244
try {
245245
model = entry.getValue().modifyBlockModelAfterBake(model, context);
246246
} catch (Throwable t) {

src/main/java/net/neoforged/neoforge/client/model/loadingplugin/ModelLoadingPlugin.java renamed to src/main/java/net/neoforged/neoforge/client/model/loadingplugin/ModelModifier.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import net.minecraft.world.level.block.state.BlockState;
1616
import org.jetbrains.annotations.Nullable;
1717

18-
public sealed interface ModelLoadingPlugin {
19-
non-sealed interface ModifyOnLoad extends ModelLoadingPlugin {
18+
public sealed interface ModelModifier {
19+
non-sealed interface ModifyOnLoad extends ModelModifier {
2020
@Nullable
2121
default UnbakedModel modifyModelOnLoad(@Nullable UnbakedModel model, Context context) {
2222
return model;
@@ -25,23 +25,23 @@ default UnbakedModel modifyModelOnLoad(@Nullable UnbakedModel model, Context con
2525
record Context(ResourceLocation id) {}
2626
}
2727

28-
non-sealed interface ModifyBeforeBake extends ModelLoadingPlugin {
28+
non-sealed interface ModifyBeforeBake extends ModelModifier {
2929
default UnbakedModel modifyModelBeforeBake(UnbakedModel model, Context context) {
3030
return model;
3131
}
3232

3333
record Context(ResourceLocation id, ModelState modelState, ModelBaker baker) {}
3434
}
3535

36-
non-sealed interface ModifyAfterBake extends ModelLoadingPlugin {
36+
non-sealed interface ModifyAfterBake extends ModelModifier {
3737
default BakedModel modifyModelAfterBake(BakedModel model, Context context) {
3838
return model;
3939
}
4040

4141
record Context(ResourceLocation id, UnbakedModel sourceModel, ModelState modelState, ModelBaker baker) {}
4242
}
4343

44-
non-sealed interface ModifyBlockOnLoad extends ModelLoadingPlugin {
44+
non-sealed interface ModifyBlockOnLoad extends ModelModifier {
4545
default UnbakedBlockStateModel modifyBlockModelOnLoad(UnbakedBlockStateModel model, Context context) {
4646
return model;
4747
}
@@ -53,15 +53,15 @@ interface Context {
5353
}
5454
}
5555

56-
non-sealed interface ModifyBlockBeforeBake extends ModelLoadingPlugin {
56+
non-sealed interface ModifyBlockBeforeBake extends ModelModifier {
5757
default UnbakedBlockStateModel modifyBlockModelBeforeBake(UnbakedBlockStateModel model, Context context) {
5858
return model;
5959
}
6060

6161
record Context(ModelResourceLocation id, ModelBaker baker) {}
6262
}
6363

64-
non-sealed interface ModifyBlockAfterBake extends ModelLoadingPlugin {
64+
non-sealed interface ModifyBlockAfterBake extends ModelModifier {
6565
default BakedModel modifyBlockModelAfterBake(BakedModel model, Context context) {
6666
return model;
6767
}

tests/src/main/java/net/neoforged/neoforge/oldtest/client/model/MegaModelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import net.neoforged.neoforge.client.model.QuadTransformers;
4444
import net.neoforged.neoforge.client.model.data.ModelData;
4545
import net.neoforged.neoforge.client.model.data.ModelProperty;
46-
import net.neoforged.neoforge.client.model.loadingplugin.ModelLoadingPlugin;
46+
import net.neoforged.neoforge.client.model.loadingplugin.ModelModifier;
4747
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
4848
import net.neoforged.neoforge.registries.DeferredBlock;
4949
import net.neoforged.neoforge.registries.DeferredHolder;
@@ -100,7 +100,7 @@ public static class ClientEvents {
100100

101101
@SubscribeEvent
102102
public static void onRegisterModelLoadingPlugins(ModelEvent.RegisterLoadingPlugins event) {
103-
event.registerPlugin(ResourceLocation.fromNamespaceAndPath(MOD_ID, "wrap"), new ModelLoadingPlugin.ModifyBlockAfterBake() {
103+
event.registerModifier(ResourceLocation.fromNamespaceAndPath(MOD_ID, "wrap"), new ModelModifier.ModifyBlockAfterBake() {
104104
@Override
105105
public BakedModel modifyBlockModelAfterBake(BakedModel model, Context context) {
106106
if (context.id().equals(BLOCK_MODEL_LOC)) {

tests/src/main/java/net/neoforged/neoforge/oldtest/client/model/TRSRTransformerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import net.neoforged.neoforge.client.model.IDynamicBakedModel;
2929
import net.neoforged.neoforge.client.model.QuadTransformers;
3030
import net.neoforged.neoforge.client.model.data.ModelData;
31-
import net.neoforged.neoforge.client.model.loadingplugin.ModelLoadingPlugin;
31+
import net.neoforged.neoforge.client.model.loadingplugin.ModelModifier;
3232
import net.neoforged.neoforge.common.util.TransformationHelper;
3333
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
3434
import net.neoforged.neoforge.registries.DeferredBlock;
@@ -63,7 +63,7 @@ private void addCreative(BuildCreativeModeTabContentsEvent event) {
6363
}
6464

6565
private void onRegisterModelLoadingPlugins(ModelEvent.RegisterLoadingPlugins e) {
66-
e.registerPlugin(ResourceLocation.fromNamespaceAndPath(MODID, "wrap"), new ModelLoadingPlugin.ModifyBlockAfterBake() {
66+
e.registerModifier(ResourceLocation.fromNamespaceAndPath(MODID, "wrap"), new ModelModifier.ModifyBlockAfterBake() {
6767
private static final ModelResourceLocation BLOCK_MODEL_LOC = new ModelResourceLocation(TEST_BLOCK.getId(), "");
6868

6969
@Override

0 commit comments

Comments
 (0)