From b5ed9028710613c125ee72b5926747aa566658e2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Oct 2022 12:19:12 +0700 Subject: [PATCH] Allow to teleport under blocks Fixes #119 --- .../mc/otm/android/feature/EnderTeleporterFeature.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index d6b413d52..4d810fea2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -157,6 +157,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val testPositions = ply.genericPositions() if ( + !ply.isShiftKeyDown && result.direction == Direction.UP && isValidPosition(result.blockPos.above()) && shortestDistanceBetween(testPositions, result.blockPos.above().asVector()) <= ServerConfig.EnderTeleporter.MAX_DISTANCE @@ -167,6 +168,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val candidates = LinkedList() if ( + !ply.isShiftKeyDown && result.direction != Direction.UP && result.direction != Direction.DOWN && !isAirGap(result.blockPos) && @@ -196,7 +198,15 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv var phasedBlocks = 0 val phasedBlocksList = ArrayList() - for (y in (if (ply.level.getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level.maxBuildHeight - ply.level.minBuildHeight) { + val searchDirection: IntProgression + + if (ply.isShiftKeyDown) { + searchDirection = -1 downTo ply.level.minBuildHeight - ply.level.maxBuildHeight + } else { + searchDirection = (if (ply.level.getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level.maxBuildHeight - ply.level.minBuildHeight + } + + for (y in searchDirection) { val pos = BlockPos(result.blockPos.x, result.blockPos.y + y + 1, result.blockPos.z) val state = ply.level.getBlockState(pos)