Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD committed Jun 10, 2024
1 parent fa4553f commit d684d7c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
--- a/net/minecraft/client/resources/model/ModelBakery.java
+++ b/net/minecraft/client/resources/model/ModelBakery.java
@@ -117,6 +_,13 @@
@@ -117,6 +_,12 @@
p_252014_.popPush("special");
this.loadSpecialItemModelAndDependencies(ItemRenderer.TRIDENT_IN_HAND_MODEL);
this.loadSpecialItemModelAndDependencies(ItemRenderer.SPYGLASS_IN_HAND_MODEL);
+ Set<ModelResourceLocation> additionalModels = new HashSet<>();
+ net.neoforged.neoforge.client.ClientHooks.onRegisterAdditionalModels(additionalModels);
+ for (ModelResourceLocation rl : additionalModels) {
+ UnbakedModel unbakedmodel = this.getModel(rl.id());
+ this.unbakedCache.put(rl.id(), unbakedmodel);
+ this.registerModelAndLoadDependencies(rl, unbakedmodel);
+ }
this.topLevelModels.values().forEach(p_247954_ -> p_247954_.resolveParents(this::getModel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
@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 static final String NEOFORGE_STANDALONE_VARIANT = "neoforge_standalone";

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

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);
+ /**
+ * Construct a {@code ModelResourceLocation} for use in the {@link net.neoforged.neoforge.client.event.ModelEvent.RegisterAdditional}
+ */
+ public static ModelResourceLocation neoForgeStandalone(ResourceLocation id) {
+ return new ModelResourceLocation(id, NEOFORGE_STANDALONE_VARIANT);
}

private static String lowercaseVariant(String p_248567_) {
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public ModelBakery getModelBakery() {

/**
* Fired when the {@link net.minecraft.client.resources.model.ModelBakery} is notified of the resource manager reloading.
* Allows developers to register models to be loaded, along with their dependencies.
* Allows developers to register models to be loaded, along with their dependencies. Models registered through this
* event must use the {@link ModelResourceLocation#NEOFORGE_STANDALONE_VARIANT} variant
*
* <p>This event is not {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
Expand All @@ -148,8 +149,8 @@ public RegisterAdditional(Set<ModelResourceLocation> models) {
*/
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");
model.getVariant().equals(ModelResourceLocation.NEOFORGE_STANDALONE_VARIANT),
"Side-loaded models must use the '" + ModelResourceLocation.NEOFORGE_STANDALONE_VARIANT + "' variant");
models.add(model);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public RenderableTest(IEventBus modEventBus) {
}

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

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

0 comments on commit d684d7c

Please sign in to comment.