set teleport position to highest solid block for rescue and entry deny

This commit is contained in:
Flemmli97 2021-06-12 23:38:12 +02:00
parent 341aa9ebce
commit 1263d1adc7

View File

@ -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<Direction, Vec3d> 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: