Skip to content

Commit

Permalink
Merge pull request #673 from P3pp3rF1y/1.20.4-dev
Browse files Browse the repository at this point in the history
fix: 🐛 Fix crash with mob charm code when there are multiple players …
  • Loading branch information
P3pp3rF1y authored Apr 7, 2024
2 parents 1ecc3c2 + 058a2f5 commit b3f4ca0
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
Expand Up @@ -13,7 +13,7 @@ loader_version_range=[2,)
mod_id=reliquary
mod_name=Reliquary
mod_license=GNU General Public License v3.0
mod_version=2.0.40
mod_version=2.0.41
mod_group_id=reliquary
mod_authors=x3n0ph0b3, TheMike, P3pp3rF1y
mod_description=Two words: magical swag. Oh, and a gun.
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 @@ -215,8 +215,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 @@ -240,9 +240,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);
}

public boolean damagePlayersMobCharm(ServerPlayer player, String entityRegistryName) {
Expand Down

0 comments on commit b3f4ca0

Please sign in to comment.