Skip to content

Commit

Permalink
Enforce special variant for "side-loaded" models
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD committed Jun 10, 2024
1 parent fa58a94 commit 9429b42
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
+ for (ModelResourceLocation rl : additionalModels) {
+ UnbakedModel unbakedmodel = this.getModel(rl.id());
+ this.unbakedCache.put(rl.id(), unbakedmodel);
+ this.topLevelModels.put(rl, unbakedmodel);
+ this.registerModelAndLoadDependencies(rl, unbakedmodel);
+ }
this.topLevelModels.values().forEach(p_247954_ -> p_247954_.resolveParents(this::getModel));
p_252014_.pop();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- a/net/minecraft/client/resources/model/ModelResourceLocation.java
+++ b/net/minecraft/client/resources/model/ModelResourceLocation.java
@@ -8,6 +_,7 @@
@OnlyIn(Dist.CLIENT)
public record ModelResourceLocation(ResourceLocation id, String variant) {
public static final String INVENTORY_VARIANT = "inventory";
+ public static final String NEOFORGE_SPECIAL_VARIANT = "neoforge_special";

public ModelResourceLocation(ResourceLocation id, String variant) {
variant = lowercaseVariant(variant);
@@ -21,6 +_,10 @@

public static ModelResourceLocation inventory(ResourceLocation p_352141_) {
return new ModelResourceLocation(p_352141_, "inventory");
+ }
+
+ public static ModelResourceLocation neoforgeSpecial(ResourceLocation id) {
+ return new ModelResourceLocation(id, NEOFORGE_SPECIAL_VARIANT);
}

private static String lowercaseVariant(String p_248567_) {
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public RegisterAdditional(Set<ModelResourceLocation> models) {
* Registers a model to be loaded, along with its dependencies.
*/
public void register(ModelResourceLocation model) {
Preconditions.checkArgument(
model.getVariant().equals(ModelResourceLocation.NEOFORGE_SPECIAL_VARIANT),
"Side-loaded models must use the '" + ModelResourceLocation.NEOFORGE_SPECIAL_VARIANT + "' variant");
models.add(model);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ public RenderableTest(IEventBus modEventBus) {
}

private static class Client {
private static ModelResourceLocation MODEL_LOC = new ModelResourceLocation(
ResourceLocation.fromNamespaceAndPath("minecraft", "block/blue_stained_glass"),
"");
private static ModelResourceLocation MODEL_LOC = ModelResourceLocation.neoforgeSpecial(
ResourceLocation.fromNamespaceAndPath("minecraft", "block/blue_stained_glass"));

private static IRenderable<CompositeRenderable.Transforms> renderable;
private static IRenderable<ModelData> bakedRenderable;
Expand Down

0 comments on commit 9429b42

Please sign in to comment.