Disallow to phase through bedrock

This commit is contained in:
DBotThePony 2022-10-13 15:46:20 +07:00
parent a76d07ecc2
commit c3784f8043
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -15,6 +15,7 @@ import net.minecraft.sounds.SoundSource
import net.minecraft.tags.BlockTags
import net.minecraft.world.level.ClipContext
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.phys.HitResult
import net.minecraft.world.phys.shapes.BooleanOp
import net.minecraft.world.phys.shapes.CollisionContext
@ -148,6 +149,11 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
for (y in (if (ply.level.getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ServerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
val pos = BlockPos(result.blockPos.x, result.blockPos.y + y + 1, result.blockPos.z)
if (ply.level.getBlockState(pos).`is`(Blocks.BEDROCK)) {
// Can't phase through bedrock
break
}
if (isValidPosition(pos) && shortestDistanceBetween(testPositions, pos.asVector()) <= ServerConfig.EnderTeleporter.MAX_DISTANCE) {
return TraceResult(pos, if (y != 0) ImmutableList(y + 1) { result.blockPos + BlockPos(0, it, 0) } else listOf())
}
@ -159,6 +165,11 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
for (y in 0 downTo -ServerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
val pos = BlockPos(result.blockPos.x, result.blockPos.y + y, result.blockPos.z)
if (ply.level.getBlockState(pos).`is`(Blocks.BEDROCK)) {
// Can't phase through bedrock
break
}
if (isValidPosition(pos) && shortestDistanceBetween(testPositions, pos.asVector()) <= ServerConfig.EnderTeleporter.MAX_DISTANCE) {
return TraceResult(pos, if (y != 0) ImmutableList(-y + 1) { result.blockPos - BlockPos(0, it, 0) } else listOf())
}