Skip to content

Commit

Permalink
fix: 🐛 Fix crash with mob charm code when there are multiple players …
Browse files Browse the repository at this point in the history
…in the world
  • Loading branch information
P3pp3rF1y committed Apr 7, 2024
1 parent f634670 commit 1c0e4c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx2048m
minecraft_version=1.20.1
forge_version=47.1.5
mod_version=2.0.39
mod_version=2.0.40
jei_mc_version=1.20.1-forge
jei_version=15.1.0.19
curios_version=5.2.0-beta.3+1.20.1
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/reliquary/items/MobCharmItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ public void setCharmInventoryHandler(CharmInventoryHandler charmInventoryHandler
}

public static class CharmInventoryHandler {
private static long lastCharmCacheTime = -1;
private static final Map<UUID, Set<String>> charmsInInventoryCache = new HashMap<>();
private long lastCharmCacheTime = -1;
private final Map<UUID, Set<String>> charmsInInventoryCache = new HashMap<>();

protected Set<String> getCharmRegistryNames(Player player) {
Set<String> ret = new HashSet<>();
Expand All @@ -249,9 +249,8 @@ public boolean playerHasMobCharm(Player player, MobCharmDefinition charmDefiniti
if (lastCharmCacheTime != player.level().getGameTime()) {
lastCharmCacheTime = player.level().getGameTime();
charmsInInventoryCache.clear();
charmsInInventoryCache.put(player.getUUID(), getCharmRegistryNames(player));
}
return charmsInInventoryCache.get(player.getUUID()).contains(registryName);
return charmsInInventoryCache.computeIfAbsent(player.getUUID(), u -> getCharmRegistryNames(player)).contains(registryName);
}


Expand Down

0 comments on commit 1c0e4c5

Please sign in to comment.