From 0b0dc5b2626eb02768f0c17bc5347dbf9d301e9c Mon Sep 17 00:00:00 2001 From: Giraffe1966 <35208168+Giraffe1966@users.noreply.github.com> Date: Sat, 20 Feb 2021 01:48:24 -0500 Subject: [PATCH 1/2] Fix issue where the sever would freeze if a particle marking a claim boundary was over the void. This bug could have caused crashes if a claim was created between islands in the End. --- .../java/com/flemmli97/flan/player/ClaimDisplay.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java b/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java index 307b583..e258f7d 100644 --- a/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java +++ b/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java @@ -69,12 +69,16 @@ public class ClaimDisplay { }; } for (int[] pos : this.poss) { + if (pos[2] == -1) + continue; if (pos[1] != pos[2]) player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); } if (this.middlePoss != null) for (int[] pos : this.middlePoss) { + if (pos[2] == -1) + continue; if (pos[1] != pos[2]) player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); @@ -144,6 +148,11 @@ public class ClaimDisplay { while (state.getMaterial().isReplaceable()) { pos = pos.down(); state = world.getBlockState(pos); + // check if void is reached + if(pos.getY() == -1 && !world.getBlockState(pos.up()).getMaterial().isLiquid()) + return new int[]{-1, -1}; + else if(pos.getY() == -1) + break; } pos = pos.up(); state = world.getBlockState(pos); From 7516505bda120b11e24f65de71266b96e2dd29cd Mon Sep 17 00:00:00 2001 From: Giraffe1966 <35208168+Giraffe1966@users.noreply.github.com> Date: Thu, 25 Mar 2021 10:18:37 -0400 Subject: [PATCH 2/2] Use World.isHeightInvalid() instead for determining where to place particles. --- .../java/com/flemmli97/flan/player/ClaimDisplay.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java b/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java index e258f7d..dfdc79d 100644 --- a/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java +++ b/src/main/java/com/flemmli97/flan/player/ClaimDisplay.java @@ -11,6 +11,7 @@ import net.minecraft.particle.DustParticleEffect; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import java.util.List; import java.util.Set; @@ -69,16 +70,12 @@ public class ClaimDisplay { }; } for (int[] pos : this.poss) { - if (pos[2] == -1) - continue; if (pos[1] != pos[2]) player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); } if (this.middlePoss != null) for (int[] pos : this.middlePoss) { - if (pos[2] == -1) - continue; if (pos[1] != pos[2]) player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); @@ -145,14 +142,9 @@ public class ClaimDisplay { if (state.getMaterial().isReplaceable()) { pos = pos.down(); state = world.getBlockState(pos); - while (state.getMaterial().isReplaceable()) { + while (state.getMaterial().isReplaceable() && !World.isHeightInvalid(pos)) { pos = pos.down(); state = world.getBlockState(pos); - // check if void is reached - if(pos.getY() == -1 && !world.getBlockState(pos.up()).getMaterial().isLiquid()) - return new int[]{-1, -1}; - else if(pos.getY() == -1) - break; } pos = pos.up(); state = world.getBlockState(pos);