From 1263d1adc74580857ec3943240118ad2b756940d Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Sat, 12 Jun 2021 23:38:12 +0200 Subject: [PATCH] set teleport position to highest solid block for rescue and entry deny --- .../github/flemmli97/flan/player/TeleportUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java b/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java index 88551bd..c92c6bb 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java @@ -8,6 +8,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.Heightmap; +import net.minecraft.world.chunk.ChunkStatus; import java.util.function.BiFunction; @@ -21,8 +23,13 @@ public class TeleportUtils { Pair pos = nearestOutside(dim, playerPos); bPos.set(pos.getRight().getX(), pos.getRight().getY(), pos.getRight().getZ()); Claim claim = storage.getClaimAt(bPos); - if (claim == null || check.apply(claim, bPos)) - return pos.getRight(); + if (claim == null || check.apply(claim, bPos)) { + Vec3d ret = pos.getRight(); + BlockPos rounded = roundedBlockPos(ret); + int y = player.getServerWorld().getChunk(rounded.getX() >> 4, rounded.getZ() >> 4, ChunkStatus.HEIGHTMAPS) + .sampleHeightmap(Heightmap.Type.MOTION_BLOCKING, rounded.getX() & 15, rounded.getZ() & 15); + return new Vec3d(ret.x, y + 1, ret.z); + } int[] newDim = claim.getDimensions(); switch (pos.getLeft()) { case NORTH: