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 2e4b3ff commit 58003be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.daemon=false

mod_id=sophisticatedbackpacks
mod_group_id=sophisticatedbackpacks
mod_version=3.22.4
mod_version=3.22.5
sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
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 @@ -49,15 +49,16 @@ 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.getCuriosHelper().getCurioTags(ModItems.BACKPACK.get()));
backpackCurioIdentifiers.add(SlotTypePreset.CURIO.getIdentifier());
backpackCurioIdentifiers.clear();
backpackCurioIdentifiers.addAll(CuriosApi.getItemStackSlots(ModItems.BACKPACK.get().getDefaultInstance()).keySet());
backpackCurioIdentifiers.add("curio");
}
return backpackCurioIdentifiers;
}
Expand Down

0 comments on commit 58003be

Please sign in to comment.