Skip to content

Commit

Permalink
Fix ConcurrentModificationException
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaCartes committed Nov 21, 2023
1 parent 48b5e71 commit 30546b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ Purple = End
This mod utilizes vanilla scoreboard teams to color nicknames.
To opt-out of detection you can join any other team.

[CurseForge](https://legacy.curseforge.com/minecraft/mc-mods/dimensional-tracker), [Modrinth](https://modrinth.com/mod/dimensionaltracker)
## [CurseForge](https://legacy.curseforge.com/minecraft/mc-mods/dimensional-tracker), [Modrinth](https://modrinth.com/mod/dimensionaltracker)

[Discord](https://discord.gg/UY4nhvUzaK)

### Why this mod instead of datapacks?
Because of how datapacks work they should check dimensions every tick. It's okay for singleplayer, but on servers it can cause lag.
In testing, I saw that it can take up to 30% of MSPT for 10 players:
![img.png](datapack.webp)

### Example of how it works using Immersive Portals

![image.webp](image.webp)
Binary file added datapack.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.1
loader_version=0.14.22

# Mod Properties
mod_version=1.0.0
mod_version=1.1.0
maven_group=xyz.nikitacartes
archives_base_name=dimensionalTracker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ private void onServerTick(MinecraftServer server) {
if (playerCache.isEmpty()) {
return;
}
playerCache.forEach(playerName -> {
LinkedHashSet<String> temp = new LinkedHashSet<>(playerCache);
playerCache.clear();
temp.forEach(playerName -> {
ServerPlayerEntity player = server.getPlayerManager().getPlayer(playerName);
if (player != null) {
if (server.getScoreboard().getTeam(player.getEntityName()) == null) {
Expand All @@ -54,7 +56,6 @@ private void onServerTick(MinecraftServer server) {
}
}
});
playerCache.clear();
}

private void onServerStarted(MinecraftServer minecraftServer) {
Expand Down

0 comments on commit 30546b7

Please sign in to comment.