Skip to content

Commit

Permalink
fix: 🐛 Fixed CME that could happen in backpack rendering when curio t…
Browse files Browse the repository at this point in the history
…ypes were getting refreshed
  • Loading branch information
P3pp3rF1y committed Jan 24, 2025
1 parent a37d4c5 commit 9edfef5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ loader_version_range=[4,)
mod_id=sophisticatedbackpacks
mod_name=Sophisticated Backpacks
mod_license=GNU General Public License v3.0
mod_version=3.22.7
mod_version=3.22.8
mod_group_id=sophisticatedbackpacks
mod_authors=P3pp3rF1y, Ridanisaurus
mod_description=Fancy and functional backpacks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import top.theillusivec4.curios.api.CuriosApi;
import top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.function.Function;

public class CuriosCompat implements ICompat {
Expand All @@ -25,14 +25,15 @@ private void addPlayerInventoryHandlers() {
false, true, true, true);
}

private Set<String> backpackCurioIdentifiers = new HashSet<>();
private final Set<String> backpackCurioIdentifiers = new CopyOnWriteArraySet<>();
private long lastTagsRefresh = -1;
private static final int TAGS_REFRESH_COOLDOWN = 100;

private Set<String> getCurioTags(long gameTime) {
if (lastTagsRefresh + TAGS_REFRESH_COOLDOWN < gameTime) {
lastTagsRefresh = gameTime;
backpackCurioIdentifiers = new HashSet<>( CuriosApi.getItemStackSlots(ModItems.BACKPACK.get().getDefaultInstance(), FMLLoader.getDist() == Dist.CLIENT).keySet());
backpackCurioIdentifiers.clear();
backpackCurioIdentifiers.addAll(CuriosApi.getItemStackSlots(ModItems.BACKPACK.get().getDefaultInstance(), FMLLoader.getDist() == Dist.CLIENT).keySet());
backpackCurioIdentifiers.add("curio");
}
return backpackCurioIdentifiers;
Expand Down

0 comments on commit 9edfef5

Please sign in to comment.