Use World.isHeightInvalid() instead for determining where to place particles.

This commit is contained in:
Giraffe1966 2021-03-25 10:18:37 -04:00
parent 0b0dc5b262
commit 7516505bda

View File

@ -11,6 +11,7 @@ import net.minecraft.particle.DustParticleEffect;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -69,16 +70,12 @@ public class ClaimDisplay {
}; };
} }
for (int[] pos : this.poss) { for (int[] pos : this.poss) {
if (pos[2] == -1)
continue;
if (pos[1] != pos[2]) 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[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)); 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) if (this.middlePoss != null)
for (int[] pos : this.middlePoss) { for (int[] pos : this.middlePoss) {
if (pos[2] == -1)
continue;
if (pos[1] != pos[2]) 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[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)); 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()) { if (state.getMaterial().isReplaceable()) {
pos = pos.down(); pos = pos.down();
state = world.getBlockState(pos); state = world.getBlockState(pos);
while (state.getMaterial().isReplaceable()) { while (state.getMaterial().isReplaceable() && !World.isHeightInvalid(pos)) {
pos = pos.down(); pos = pos.down();
state = world.getBlockState(pos); 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(); pos = pos.up();
state = world.getBlockState(pos); state = world.getBlockState(pos);