From 959cdd70d374cb3a59df0d7080f0dadd8150c1cb Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Sun, 18 Dec 2022 20:37:36 +0100 Subject: [PATCH] fix claim display keep getting added for same claim causing lots of particles --- Changelog.md | 4 +++ .../io/github/flemmli97/flan/claim/Claim.java | 5 +-- .../flemmli97/flan/claim/ClaimStorage.java | 4 +-- .../flemmli97/flan/commands/CommandClaim.java | 2 +- .../flan/event/BlockInteractEvents.java | 2 +- .../flan/event/ItemInteractEvents.java | 2 +- .../integration/claiming/FTBChunks.java | 2 +- .../claiming/OtherClaimingModCheck.java | 2 +- .../flan/player/PlayerClaimData.java | 3 ++ .../player/{ => display}/ClaimDisplay.java | 2 +- .../flan/player/display/ClaimDisplayBox.java | 36 +++++++++++++++++++ .../flan/player/{ => display}/DisplayBox.java | 26 +++++++++----- .../player/{ => display}/EnumDisplayType.java | 2 +- .../claiming/OtherClaimingModCheckImpl.java | 2 +- .../claiming/OtherClaimingModCheckImpl.java | 2 +- gradle.properties | 2 +- 16 files changed, 76 insertions(+), 22 deletions(-) rename common/src/main/java/io/github/flemmli97/flan/player/{ => display}/ClaimDisplay.java (99%) create mode 100644 common/src/main/java/io/github/flemmli97/flan/player/display/ClaimDisplayBox.java rename common/src/main/java/io/github/flemmli97/flan/player/{ => display}/DisplayBox.java (78%) rename common/src/main/java/io/github/flemmli97/flan/player/{ => display}/EnumDisplayType.java (60%) diff --git a/Changelog.md b/Changelog.md index 6aa2c33..7ebdcb1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +Flan 1.8.3 +================ +- Fix claim display keep getting added for same claim causing lots of particles + Flan 1.8.2 ================ - Some QOL changes diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java b/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java index f36cd19..52faa82 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java @@ -15,9 +15,10 @@ import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.platform.ClaimPermissionCheck; import io.github.flemmli97.flan.platform.CrossPlatformStuff; import io.github.flemmli97.flan.platform.integration.webmap.WebmapCalls; -import io.github.flemmli97.flan.player.DisplayBox; import io.github.flemmli97.flan.player.LogoutTracker; import io.github.flemmli97.flan.player.PlayerClaimData; +import io.github.flemmli97.flan.player.display.ClaimDisplayBox; +import io.github.flemmli97.flan.player.display.DisplayBox; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -855,7 +856,7 @@ public class Claim implements IPermissionContainer { } public DisplayBox display() { - return new DisplayBox(() -> new DisplayBox.Box(this.minX, this.minY, this.minZ, this.maxX, this.world.getMaxBuildHeight(), this.maxZ), this::isRemoved); + return new ClaimDisplayBox(this, () -> new DisplayBox.Box(this.minX, this.minY, this.minZ, this.maxX, this.world.getMaxBuildHeight(), this.maxZ), this::isRemoved); } public enum InfoType { diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java index 5f59854..93e36e4 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java @@ -17,12 +17,12 @@ import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.platform.integration.claiming.OtherClaimingModCheck; import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler; import io.github.flemmli97.flan.platform.integration.webmap.WebmapCalls; -import io.github.flemmli97.flan.player.DisplayBox; -import io.github.flemmli97.flan.player.EnumDisplayType; import io.github.flemmli97.flan.player.EnumEditMode; import io.github.flemmli97.flan.player.OfflinePlayerData; import io.github.flemmli97.flan.player.PlayerClaimData; import io.github.flemmli97.flan.player.PlayerDataHandler; +import io.github.flemmli97.flan.player.display.DisplayBox; +import io.github.flemmli97.flan.player.display.EnumDisplayType; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.ChatFormatting; diff --git a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java index 9c0310a..66b58eb 100644 --- a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java +++ b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java @@ -20,10 +20,10 @@ import io.github.flemmli97.flan.event.ItemInteractEvents; import io.github.flemmli97.flan.gui.ClaimMenuScreenHandler; import io.github.flemmli97.flan.gui.PersonalGroupScreenHandler; import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler; -import io.github.flemmli97.flan.player.EnumDisplayType; import io.github.flemmli97.flan.player.EnumEditMode; import io.github.flemmli97.flan.player.OfflinePlayerData; import io.github.flemmli97.flan.player.PlayerClaimData; +import io.github.flemmli97.flan.player.display.EnumDisplayType; import net.minecraft.ChatFormatting; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; diff --git a/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java index 3b5386c..29979ef 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java @@ -8,8 +8,8 @@ import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.LockedLecternScreenHandler; import io.github.flemmli97.flan.platform.CrossPlatformStuff; -import io.github.flemmli97.flan.player.EnumDisplayType; import io.github.flemmli97.flan.player.PlayerClaimData; +import io.github.flemmli97.flan.player.display.EnumDisplayType; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; diff --git a/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java index 6dbc38c..e0d33f1 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java @@ -11,9 +11,9 @@ import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler; -import io.github.flemmli97.flan.player.EnumDisplayType; import io.github.flemmli97.flan.player.EnumEditMode; import io.github.flemmli97.flan.player.PlayerClaimData; +import io.github.flemmli97.flan.player.display.EnumDisplayType; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; diff --git a/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/FTBChunks.java b/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/FTBChunks.java index a7584c7..5caf90e 100644 --- a/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/FTBChunks.java +++ b/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/FTBChunks.java @@ -8,7 +8,7 @@ import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.config.ConfigHandler; -import io.github.flemmli97.flan.player.DisplayBox; +import io.github.flemmli97.flan.player.display.DisplayBox; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; diff --git a/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/OtherClaimingModCheck.java b/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/OtherClaimingModCheck.java index 6679eec..dd9e463 100644 --- a/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/OtherClaimingModCheck.java +++ b/common/src/main/java/io/github/flemmli97/flan/platform/integration/claiming/OtherClaimingModCheck.java @@ -2,7 +2,7 @@ package io.github.flemmli97.flan.platform.integration.claiming; import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.claim.Claim; -import io.github.flemmli97.flan.player.DisplayBox; +import io.github.flemmli97.flan.player.display.DisplayBox; import java.util.Set; diff --git a/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java b/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java index 24b3a30..73b82c9 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java @@ -15,6 +15,9 @@ import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.event.EntityInteractEvents; import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler; +import io.github.flemmli97.flan.player.display.ClaimDisplay; +import io.github.flemmli97.flan.player.display.DisplayBox; +import io.github.flemmli97.flan.player.display.EnumDisplayType; import io.github.flemmli97.flan.scoreboard.ClaimCriterias; import net.minecraft.ChatFormatting; import net.minecraft.commands.CommandSourceStack; diff --git a/common/src/main/java/io/github/flemmli97/flan/player/ClaimDisplay.java b/common/src/main/java/io/github/flemmli97/flan/player/display/ClaimDisplay.java similarity index 99% rename from common/src/main/java/io/github/flemmli97/flan/player/ClaimDisplay.java rename to common/src/main/java/io/github/flemmli97/flan/player/display/ClaimDisplay.java index 755fd54..a1e4a46 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/ClaimDisplay.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/display/ClaimDisplay.java @@ -1,4 +1,4 @@ -package io.github.flemmli97.flan.player; +package io.github.flemmli97.flan.player.display; import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.ParticleIndicators; diff --git a/common/src/main/java/io/github/flemmli97/flan/player/display/ClaimDisplayBox.java b/common/src/main/java/io/github/flemmli97/flan/player/display/ClaimDisplayBox.java new file mode 100644 index 0000000..60e0c21 --- /dev/null +++ b/common/src/main/java/io/github/flemmli97/flan/player/display/ClaimDisplayBox.java @@ -0,0 +1,36 @@ +package io.github.flemmli97.flan.player.display; + +import io.github.flemmli97.flan.claim.Claim; + +import java.util.function.Supplier; + +public class ClaimDisplayBox extends DisplayBox { + + private final Claim claim; + private final Supplier boxSup; + + public ClaimDisplayBox(Claim claim, Supplier sup, Supplier removed) { + super(sup.get(), removed); + this.claim = claim; + this.boxSup = sup; + } + + @Override + public Box box() { + return this.boxSup.get(); + } + + @Override + public int hashCode() { + return super.hashCode() >> this.claim.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + if (obj instanceof ClaimDisplayBox box) + return this.claim == box.claim; + return false; + } +} diff --git a/common/src/main/java/io/github/flemmli97/flan/player/DisplayBox.java b/common/src/main/java/io/github/flemmli97/flan/player/display/DisplayBox.java similarity index 78% rename from common/src/main/java/io/github/flemmli97/flan/player/DisplayBox.java rename to common/src/main/java/io/github/flemmli97/flan/player/display/DisplayBox.java index 2282c0d..b7cd137 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/DisplayBox.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/display/DisplayBox.java @@ -1,4 +1,4 @@ -package io.github.flemmli97.flan.player; +package io.github.flemmli97.flan.player.display; import net.minecraft.core.Direction; @@ -10,7 +10,6 @@ import java.util.function.Supplier; public class DisplayBox { private final Box box; - private final Supplier boxSup; private final Supplier removed; private final EnumSet excludedSides = EnumSet.noneOf(Direction.class); @@ -21,7 +20,6 @@ public class DisplayBox { public DisplayBox(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Supplier removed, Direction... exclude) { this.box = new Box(minX, minY, minZ, Math.max(minX + 1, maxX), maxY, Math.max(minZ + 1, maxZ)); - this.boxSup = null; this.removed = removed; this.excludedSides.addAll(Arrays.asList(exclude)); } @@ -29,9 +27,8 @@ public class DisplayBox { /** * For claims with dynamic size (atm only from this mod) */ - public DisplayBox(Supplier sup, Supplier removed, Direction... exclude) { - this.box = sup.get(); - this.boxSup = sup; + public DisplayBox(Box box, Supplier removed, Direction... exclude) { + this.box = box; this.removed = removed; this.excludedSides.addAll(Arrays.asList(exclude)); } @@ -41,8 +38,6 @@ public class DisplayBox { } public Box box() { - if (this.boxSup != null) - return this.boxSup.get(); return this.box; } @@ -50,6 +45,21 @@ public class DisplayBox { return this.excludedSides; } + @Override + public int hashCode() { + return this.box.hashCode(); + } + + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + if (obj instanceof DisplayBox other) + return this.box.equals(other.box); + return false; + } + public record Box(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { @Override diff --git a/common/src/main/java/io/github/flemmli97/flan/player/EnumDisplayType.java b/common/src/main/java/io/github/flemmli97/flan/player/display/EnumDisplayType.java similarity index 60% rename from common/src/main/java/io/github/flemmli97/flan/player/EnumDisplayType.java rename to common/src/main/java/io/github/flemmli97/flan/player/display/EnumDisplayType.java index 2f25627..7fcde1b 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/EnumDisplayType.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/display/EnumDisplayType.java @@ -1,4 +1,4 @@ -package io.github.flemmli97.flan.player; +package io.github.flemmli97.flan.player.display; public enum EnumDisplayType { MAIN, diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/claiming/OtherClaimingModCheckImpl.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/claiming/OtherClaimingModCheckImpl.java index dd4f94e..a48a321 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/claiming/OtherClaimingModCheckImpl.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/claiming/OtherClaimingModCheckImpl.java @@ -7,7 +7,7 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.platform.integration.claiming.FTBChunks; import io.github.flemmli97.flan.platform.integration.claiming.OtherClaimingModCheck; -import io.github.flemmli97.flan.player.DisplayBox; +import io.github.flemmli97.flan.player.display.DisplayBox; import java.util.Set; diff --git a/forge/src/main/java/io/github/flemmli97/flan/forge/platform/integration/claiming/OtherClaimingModCheckImpl.java b/forge/src/main/java/io/github/flemmli97/flan/forge/platform/integration/claiming/OtherClaimingModCheckImpl.java index df36b9b..fe7e369 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forge/platform/integration/claiming/OtherClaimingModCheckImpl.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forge/platform/integration/claiming/OtherClaimingModCheckImpl.java @@ -9,7 +9,7 @@ import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.platform.integration.claiming.FTBChunks; import io.github.flemmli97.flan.platform.integration.claiming.OtherClaimingModCheck; -import io.github.flemmli97.flan.player.DisplayBox; +import io.github.flemmli97.flan.player.display.DisplayBox; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; diff --git a/gradle.properties b/gradle.properties index 7047394..333bc76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ forge_version=1.19.2-43.1.57 # check these on https://fabricmc.net/use loader_version=0.14.8 # Mod Properties -mod_version=1.8.2 +mod_version=1.8.3 maven_group=io.github.flemmli97 archives_base_name=flan