From 597aea7176a497167e5d385b04bb8115eb66d412 Mon Sep 17 00:00:00 2001 From: Callum Seabrook Date: Tue, 21 Jun 2022 21:31:16 +0100 Subject: [PATCH] Forgot Git files are case insensitive --- .../krypton/entity/player/KryptonPlayer.kt | 2 -- .../org/kryptonmc/krypton/util/positions.kt | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 server/src/main/kotlin/org/kryptonmc/krypton/util/positions.kt diff --git a/server/src/main/kotlin/org/kryptonmc/krypton/entity/player/KryptonPlayer.kt b/server/src/main/kotlin/org/kryptonmc/krypton/entity/player/KryptonPlayer.kt index ad2543b5e0b..e134591f66d 100644 --- a/server/src/main/kotlin/org/kryptonmc/krypton/entity/player/KryptonPlayer.kt +++ b/server/src/main/kotlin/org/kryptonmc/krypton/entity/player/KryptonPlayer.kt @@ -465,7 +465,6 @@ class KryptonPlayer( fun hasCorrectTool(block: Block): Boolean = !block.requiresCorrectTool || inventory.heldItem(Hand.MAIN).type.handler().isCorrectTool(block) - /* fun interactOn(entity: KryptonEntity, hand: Hand): InteractionResult { if (isSpectator) { // TODO: Open spectator menu @@ -491,7 +490,6 @@ class KryptonPlayer( */ return InteractionResult.PASS } - */ override fun addViewer(player: KryptonPlayer): Boolean { if (player === this) return false diff --git a/server/src/main/kotlin/org/kryptonmc/krypton/util/positions.kt b/server/src/main/kotlin/org/kryptonmc/krypton/util/positions.kt new file mode 100644 index 00000000000..6320064e431 --- /dev/null +++ b/server/src/main/kotlin/org/kryptonmc/krypton/util/positions.kt @@ -0,0 +1,32 @@ +/* + * This file is part of the Krypton project, licensed under the GNU General Public License v3.0 + * + * Copyright (C) 2021-2022 KryptonMC and the contributors of the Krypton project + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.kryptonmc.krypton.util + +import org.spongepowered.math.vector.Vector3d +import org.spongepowered.math.vector.Vector3i + +fun Vector3d.chunkX(): Int = floorX().toChunk() + +fun Vector3d.chunkZ(): Int = floorZ().toChunk() + +fun Vector3i.chunkX(): Int = x().toChunk() + +fun Vector3i.chunkZ(): Int = z().toChunk() + +private fun Int.toChunk(): Int = this shr 4