From d764fbd4ad223f11ed3fb9ebf0c38bfbc2724a2b Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:41:11 +0100 Subject: [PATCH] fix: Allow loadModel to auto-resolve once present on Fabric --- .../mods/balm/fabric/client/rendering/FabricBalmModels.java | 5 +++++ .../main/java/net/blay09/mods/balm/api/DeferredObject.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java index cb0dec68..5acaff02 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java @@ -78,6 +78,11 @@ public DeferredObject loadModel(final ResourceLocation identifier) { public BakedModel resolve(ModelBakery bakery, BiFunction spriteBiFunction) { return modelBakery.getBakedTopLevelModels().get(identifier); } + + @Override + public boolean canResolve() { + return modelBakery.getBakedTopLevelModels().containsKey(identifier); + } }; additionalModels.add(identifier); return deferredModel; diff --git a/shared/src/main/java/net/blay09/mods/balm/api/DeferredObject.java b/shared/src/main/java/net/blay09/mods/balm/api/DeferredObject.java index a932c068..8b5d34c1 100644 --- a/shared/src/main/java/net/blay09/mods/balm/api/DeferredObject.java +++ b/shared/src/main/java/net/blay09/mods/balm/api/DeferredObject.java @@ -28,6 +28,10 @@ protected void set(T object) { this.object = object; } + public boolean canResolve() { + return canResolveFunc.get(); + } + public T resolve() { if (object == null) { object = supplier.get(); @@ -37,7 +41,7 @@ public T resolve() { public T get() { if (object == null) { - if (canResolveFunc.get()) { + if (canResolve()) { return resolve(); }