Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.21.4] Log warning for missing item models #1789

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
--- a/net/minecraft/client/resources/model/ModelManager.java
+++ b/net/minecraft/client/resources/model/ModelManager.java
@@ -83,11 +_,14 @@
@@ -83,11 +_,15 @@
private BakedModel missingModel;
private ItemModel missingItemModel;
private Object2IntMap<BlockState> modelGroups = Object2IntMaps.emptyMap();
+ private final java.util.concurrent.atomic.AtomicReference<ModelBakery> modelBakery = new java.util.concurrent.atomic.AtomicReference<>(null);
+ private Map<ResourceLocation, BakedModel> bakedStandaloneModels = Map.of();
+ private Set<ResourceLocation> reportedMissingItemModels = new java.util.HashSet<>();

public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) {
this.blockColors = p_119407_;
Expand All @@ -15,6 +16,22 @@
this.atlases = new AtlasSet(VANILLA_ATLASES, p_119406_);
}

@@ -100,7 +_,14 @@
}

public ItemModel getItemModel(ResourceLocation p_387691_) {
- return this.bakedItemStackModels.getOrDefault(p_387691_, this.missingItemModel);
+ ItemModel model = this.bakedItemStackModels.get(p_387691_);
+ if (model == null) {
+ if (this.reportedMissingItemModels.add(p_387691_)) {
+ LOGGER.warn("Missing item model for location {}", p_387691_);
+ }
+ return this.missingItemModel;
+ }
+ return model;
}

public ClientItem.Properties getItemProperties(ResourceLocation p_390438_) {
@@ -115,6 +_,7 @@
public final CompletableFuture<Void> reload(
PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, Executor p_250550_, Executor p_249221_
Expand Down Expand Up @@ -62,12 +79,20 @@
p_252136_.popPush("dispatch");
Map<BlockState, BakedModel> map = createBlockStateToModelDispatch(modelbakery$bakingresult.blockStateModels(), modelbakery$bakingresult.missingModel());
CompletableFuture<Void> completablefuture = CompletableFuture.allOf(
@@ -304,6 +_,8 @@
@@ -304,6 +_,16 @@
this.modelGroups = p_248996_.modelGroups;
this.missingModel = modelbakery$bakingresult.missingModel();
this.missingItemModel = modelbakery$bakingresult.missingItemModel();
+ this.bakedStandaloneModels = modelbakery$bakingresult.standaloneModels();
+ net.neoforged.neoforge.client.ClientHooks.onModelBake(this, modelbakery$bakingresult, this.modelBakery.get());
+ this.reportedMissingItemModels = new java.util.HashSet<>();
+ for (net.minecraft.world.item.Item item : BuiltInRegistries.ITEM) {
+ ResourceLocation modelId = item.components().get(net.minecraft.core.component.DataComponents.ITEM_MODEL);
+ if (modelId != null && !this.bakedItemStackModels.containsKey(modelId)) {
+ this.reportedMissingItemModels.add(modelId);
+ LOGGER.warn("No model loaded for default item ID {} of {}", modelId, item);
+ }
+ }
p_251960_.popPush("cache");
this.blockModelShaper.replaceCache(p_248996_.modelCache);
this.specialBlockModelRenderer = p_248996_.specialBlockModelRenderer;
Expand Down
Loading