diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-10-13 19:14:20 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-10-13 19:14:20 +0200 |
| commit | 631ad8812627c6cb9f7bafed4abbd6c7c27f822d (patch) | |
| tree | 4db05808b12078565df972b6935e7bf1707f7710 /src/main/kotlin | |
| parent | f73a0e4e8e7c4306cdaf0ed163d312c6a0b2c1d5 (diff) | |
| download | Firmament-631ad8812627c6cb9f7bafed4abbd6c7c27f822d.tar.gz Firmament-631ad8812627c6cb9f7bafed4abbd6c7c27f822d.tar.bz2 Firmament-631ad8812627c6cb9f7bafed4abbd6c7c27f822d.zip | |
fix: improve accuracy of etherwarp distance estimate
Diffstat (limited to 'src/main/kotlin')
| -rw-r--r-- | src/main/kotlin/features/items/EtherwarpOverlay.kt | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/kotlin/features/items/EtherwarpOverlay.kt b/src/main/kotlin/features/items/EtherwarpOverlay.kt index 51bc252..650b315 100644 --- a/src/main/kotlin/features/items/EtherwarpOverlay.kt +++ b/src/main/kotlin/features/items/EtherwarpOverlay.kt @@ -10,6 +10,7 @@ import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.HitResult import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d +import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.BlockView import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.WorldRenderLastEvent @@ -139,7 +140,7 @@ object EtherwarpOverlay { } sealed interface EtherwarpBlockHit { - data class BlockHit(val blockPos: BlockPos) : EtherwarpBlockHit + data class BlockHit(val blockPos: BlockPos, val accuratePos: Vec3d?) : EtherwarpBlockHit data object Miss : EtherwarpBlockHit } @@ -159,7 +160,8 @@ object EtherwarpOverlay { // if (world.raycastBlock(start, end, blockPos, hitShape, defaultedState) == null) { // return@raycast null // } - return@raycast EtherwarpBlockHit.BlockHit(blockPos) + val partialResult = world.raycastBlock(start, end, blockPos, VoxelShapes.fullCube(), world.getBlockState(blockPos).block.defaultState) + return@raycast EtherwarpBlockHit.BlockHit(blockPos, partialResult?.pos) }, { EtherwarpBlockHit.Miss }) } @@ -190,7 +192,7 @@ object EtherwarpOverlay { else 1.62 val playerEyePos = player.pos.add(0.0, playerEyeHeight, 0.0) val start = playerEyePos - val end = player.getRotationVec(0F).multiply(120.0).add(playerEyePos) + val end = player.getRotationVec(0F).multiply(160.0).add(playerEyePos) val hitResult = raycastWithEtherwarpTransparency( world, start, @@ -203,7 +205,7 @@ object EtherwarpOverlay { EtherwarpResult.OCCUPIED else if (!isEtherwarpTransparent(world, blockPos.up(2))) EtherwarpResult.OCCUPIED - else if (player.squaredDistanceTo(blockPos.toCenterPos()) > 61 * 61) + else if (playerEyePos.squaredDistanceTo(hitResult.accuratePos ?: blockPos.toCenterPos()) > 61 * 61) EtherwarpResult.TOO_DISTANT else if ((MC.instance.crosshairTarget as? BlockHitResult) ?.takeIf { it.type == HitResult.Type.BLOCK } |
