Skip to content

Commit

Permalink
Fix Facade model cache not being collision-free
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Jul 1, 2024
1 parent c55b9fb commit 6be78d9
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package appeng.client.render;

import java.util.List;
import java.util.Objects;

import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -51,12 +50,15 @@ public List<BakedModel> getRenderPasses(ItemStack stack, boolean fabulous) {
}

ItemStack textureItem = itemFacade.getTextureItem(stack);
if (textureItem.isEmpty()) {
return List.of(this);
}

int hash = Objects.hash(BuiltInRegistries.ITEM.getKey(textureItem.getItem()), textureItem.getTag());
FacadeBakedItemModel model = cache.get(hash);
var itemId = BuiltInRegistries.ITEM.getId(textureItem.getItem());
var model = cache.get(itemId);
if (model == null) {
model = new FacadeBakedItemModel(getBaseModel(), textureItem, facadeBuilder);
cache.put(hash, model);
cache.put(itemId, model);
}

return List.of(model);
Expand Down

0 comments on commit 6be78d9

Please sign in to comment.