fix: Item assets not being loaded properly when paths overlap

This commit is contained in:
Linnea Gräf
2025-01-22 15:19:11 +01:00
parent 36cf26be6d
commit 9e32d3029f

View File

@@ -54,6 +54,7 @@ public class SupplyFakeModelPatch {
var resource = model.getValue(); var resource = model.getValue();
var itemModelId = model.getKey().withPath(it -> it.substring("models/item/".length(), it.length() - ".json".length())); var itemModelId = model.getKey().withPath(it -> it.substring("models/item/".length(), it.length() - ".json".length()));
var genericModelId = itemModelId.withPrefixedPath("item/"); var genericModelId = itemModelId.withPrefixedPath("item/");
var itemAssetId = itemModelId.withPrefixedPath("items/");
// TODO: inject tint indexes based on the json data here // TODO: inject tint indexes based on the json data here
ItemModel.Unbaked unbakedModel = new BasicItemModel.Unbaked(genericModelId, List.of()); ItemModel.Unbaked unbakedModel = new BasicItemModel.Unbaked(genericModelId, List.of());
// TODO: add a filter using the pack.mcmeta to opt out of this behaviour // TODO: add a filter using the pack.mcmeta to opt out of this behaviour
@@ -63,7 +64,7 @@ public class SupplyFakeModelPatch {
} catch (Exception e) { } catch (Exception e) {
ErrorUtil.INSTANCE.softError("Could not create resource for fake model supplication: " + model.getKey(), e); ErrorUtil.INSTANCE.softError("Could not create resource for fake model supplication: " + model.getKey(), e);
} }
if (resourceManager.getResource(itemModelId) if (resourceManager.getResource(itemAssetId.withSuffixedPath(".json"))
.map(Resource::getPack) .map(Resource::getPack)
.map(it -> isResourcePackNewer(resourceManager, it, resource.getPack())) .map(it -> isResourcePackNewer(resourceManager, it, resource.getPack()))
.orElse(true)) { .orElse(true)) {
@@ -82,7 +83,7 @@ public class SupplyFakeModelPatch {
var pack = manager.streamResourcePacks() var pack = manager.streamResourcePacks()
.filter(it -> it == null_ || it == proposal) .filter(it -> it == null_ || it == proposal)
.collect(findLast()); .collect(findLast());
return pack.orElse(null) == proposal; return pack.orElse(null_) != null_;
} }
private static <T> Collector<T, ?, Optional<T>> findLast() { private static <T> Collector<T, ?, Optional<T>> findLast() {