From 8be98e1a85fd2b0bbf9d39cae55930a993deb681 Mon Sep 17 00:00:00 2001 From: Boy0000 <62521371+Boy0000@users.noreply.github.com> Date: Tue, 2 Nov 2021 12:30:58 +0100 Subject: [PATCH] support for splitting sections into multiple regions of length-y (#86) * support for splitting sections into multiple regions of length-y * Updates * remove volume add length * remove length func Co-authored-by: Scyu_ --- gradle.properties | 4 +-- .../minecraft/deeperworld/world/Point.kt | 18 ---------- .../deeperworld/DeeperCommandExecutor.kt | 0 .../minecraft/deeperworld/DeeperContext.kt | 0 .../deeperworld/DeeperWorldPlugin.kt | 1 - .../derongan/minecraft/deeperworld/Helpers.kt | 0 .../deeperworld/MinecraftConstants.kt | 0 .../minecraft/deeperworld/Permissions.kt | 0 .../deeperworld/config/DeeperConfig.kt | 0 .../deeperworld/config/FallDamageConfig.kt | 1 - .../deeperworld/config/TimeConfig.kt | 1 - .../deeperworld/datastructures/Tree.kt | 0 .../deeperworld/event/BlockSyncEvent.kt | 0 .../deeperworld/event/PlayerAscendEvent.kt | 0 .../event/PlayerChangeSectionEvent.kt | 0 .../deeperworld/event/PlayerDescendEvent.kt | 0 .../extensions/DeeperWorldExtensions.kt | 0 .../deeperworld/listeners/MovementListener.kt | 0 .../deeperworld/listeners/PlayerListener.kt | 0 .../BedrockBlockingInvalidTeleportHandler.kt | 0 .../movement/InvalidTeleportHandler.kt | 0 .../deeperworld/movement/MovementHandler.kt | 0 .../movement/SectionTeleportPacketAdapter.kt | 0 .../deeperworld/movement/TeleportHandler.kt | 0 .../movement/TransitionTeleportHandler.kt | 0 .../UndoMovementInvalidTeleportHandler.kt | 0 .../transition/ConfigSectionChecker.kt | 0 .../movement/transition/SectionChecker.kt | 0 .../movement/transition/SectionTransition.kt | 0 .../player/FallingDamageManager.kt | 0 .../deeperworld/player/PlayerManagerImpl.kt | 0 .../deeperworld/services/PlayerManager.kt | 0 .../deeperworld/services/WorldManager.kt | 2 +- .../synchronization/ContainerSyncListener.kt | 0 .../ExploitPreventionListener.kt | 0 .../synchronization/SectionSyncListener.kt | 0 .../deeperworld/synchronization/Updaters.kt | 0 .../minecraft/deeperworld/world/Point.kt | 14 ++++++++ .../minecraft/deeperworld/world/Region.kt | 36 +++++++++++-------- .../deeperworld/world/WorldManagerImpl.kt | 6 ++-- .../world/section/AbstractSectionKey.kt | 0 .../deeperworld/world/section/Section.kt | 0 .../deeperworld/world/section/SectionKey.kt | 0 .../deeperworld/world/section/SectionUtils.kt | 0 .../deeperworld/world/RegionTestU.kt | 19 ---------- .../deeperworld/world/RegionTestU.kt | 19 ++++++++++ 46 files changed, 61 insertions(+), 60 deletions(-) delete mode 100644 src/main/java/com/derongan/minecraft/deeperworld/world/Point.kt rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/DeeperCommandExecutor.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/DeeperContext.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/DeeperWorldPlugin.kt (98%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/Helpers.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/MinecraftConstants.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/Permissions.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/config/DeeperConfig.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/config/FallDamageConfig.kt (88%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/config/TimeConfig.kt (90%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/datastructures/Tree.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/event/BlockSyncEvent.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/event/PlayerAscendEvent.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/event/PlayerChangeSectionEvent.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/event/PlayerDescendEvent.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/extensions/DeeperWorldExtensions.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/listeners/PlayerListener.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/BedrockBlockingInvalidTeleportHandler.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/InvalidTeleportHandler.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/MovementHandler.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/SectionTeleportPacketAdapter.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/TeleportHandler.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/TransitionTeleportHandler.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/UndoMovementInvalidTeleportHandler.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/transition/ConfigSectionChecker.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/transition/SectionChecker.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/movement/transition/SectionTransition.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/player/FallingDamageManager.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/player/PlayerManagerImpl.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/services/PlayerManager.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/services/WorldManager.kt (96%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/synchronization/ContainerSyncListener.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/synchronization/ExploitPreventionListener.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/synchronization/Updaters.kt (100%) create mode 100644 src/main/kotlin/com/derongan/minecraft/deeperworld/world/Point.kt rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/world/Region.kt (51%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/world/WorldManagerImpl.kt (86%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/world/section/AbstractSectionKey.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/world/section/Section.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/world/section/SectionKey.kt (100%) rename src/main/{java => kotlin}/com/derongan/minecraft/deeperworld/world/section/SectionUtils.kt (100%) delete mode 100644 src/test/java/com/derongan/minecraft/deeperworld/world/RegionTestU.kt create mode 100644 src/test/kotlin/com/derongan/minecraft/deeperworld/world/RegionTestU.kt diff --git a/gradle.properties b/gradle.properties index 7613a43..1ff0d76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,5 +2,5 @@ group=com.derongan.minecraft version=0.3 kotlinVersion=1.5.31 serverVersion=1.17.1-R0.1-SNAPSHOT -idofrontVersion=0.7.35 -idofrontConventions=1.5.31-35 +idofrontVersion=0.7.38 +idofrontConventions=1.5.31-38 diff --git a/src/main/java/com/derongan/minecraft/deeperworld/world/Point.kt b/src/main/java/com/derongan/minecraft/deeperworld/world/Point.kt deleted file mode 100644 index e8674db..0000000 --- a/src/main/java/com/derongan/minecraft/deeperworld/world/Point.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.derongan.minecraft.deeperworld.world - -import kotlin.math.sqrt - -/** - * Represents a single X/Z column in a minecraft world. - */ -data class Point(val x: Int, val z: Int) { - operator fun plus(other: Point) = Point(x + other.x, z + other.z) - - operator fun minus(other: Point) = Point(x - other.x, z - other.z) - - operator fun div(o: Float) = Point((x / o).toInt(), (z / o).toInt()) - - operator fun div(o: Int) = Point(x / o, z / o) - - val length get() = sqrt((x * x + z * z).toDouble()) -} \ No newline at end of file diff --git a/src/main/java/com/derongan/minecraft/deeperworld/DeeperCommandExecutor.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/DeeperCommandExecutor.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/DeeperCommandExecutor.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/DeeperCommandExecutor.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/DeeperContext.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/DeeperContext.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/DeeperContext.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/DeeperContext.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/DeeperWorldPlugin.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/DeeperWorldPlugin.kt similarity index 98% rename from src/main/java/com/derongan/minecraft/deeperworld/DeeperWorldPlugin.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/DeeperWorldPlugin.kt index e632879..dc8b183 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/DeeperWorldPlugin.kt +++ b/src/main/kotlin/com/derongan/minecraft/deeperworld/DeeperWorldPlugin.kt @@ -18,7 +18,6 @@ import com.mineinabyss.idofront.commands.execution.ExperimentalCommandDSL import com.mineinabyss.idofront.plugin.registerEvents import com.mineinabyss.idofront.plugin.registerService import com.mineinabyss.idofront.slimjar.IdofrontSlimjar -import com.mineinabyss.idofront.slimjar.LibraryLoaderInjector import com.okkero.skedule.schedule import org.bukkit.Material import org.bukkit.plugin.java.JavaPlugin diff --git a/src/main/java/com/derongan/minecraft/deeperworld/Helpers.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/Helpers.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/Helpers.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/Helpers.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/MinecraftConstants.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/MinecraftConstants.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/MinecraftConstants.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/MinecraftConstants.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/Permissions.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/Permissions.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/Permissions.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/Permissions.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/config/DeeperConfig.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/config/DeeperConfig.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/config/DeeperConfig.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/config/DeeperConfig.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/config/FallDamageConfig.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/config/FallDamageConfig.kt similarity index 88% rename from src/main/java/com/derongan/minecraft/deeperworld/config/FallDamageConfig.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/config/FallDamageConfig.kt index 2365d4f..f392d2d 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/config/FallDamageConfig.kt +++ b/src/main/kotlin/com/derongan/minecraft/deeperworld/config/FallDamageConfig.kt @@ -1,7 +1,6 @@ package com.derongan.minecraft.deeperworld.config import com.mineinabyss.idofront.time.TimeSpan -import com.mineinabyss.idofront.time.TimeSpanSerializer import com.mineinabyss.idofront.time.ticks import kotlinx.serialization.Serializable diff --git a/src/main/java/com/derongan/minecraft/deeperworld/config/TimeConfig.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/config/TimeConfig.kt similarity index 90% rename from src/main/java/com/derongan/minecraft/deeperworld/config/TimeConfig.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/config/TimeConfig.kt index dc98b7f..f3d4e9f 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/config/TimeConfig.kt +++ b/src/main/kotlin/com/derongan/minecraft/deeperworld/config/TimeConfig.kt @@ -4,7 +4,6 @@ package com.derongan.minecraft.deeperworld.config import com.mineinabyss.idofront.serialization.WorldSerializer import com.mineinabyss.idofront.time.TimeSpan -import com.mineinabyss.idofront.time.TimeSpanSerializer import com.mineinabyss.idofront.time.seconds import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers diff --git a/src/main/java/com/derongan/minecraft/deeperworld/datastructures/Tree.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/datastructures/Tree.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/datastructures/Tree.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/datastructures/Tree.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/event/BlockSyncEvent.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/event/BlockSyncEvent.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/event/BlockSyncEvent.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/event/BlockSyncEvent.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/event/PlayerAscendEvent.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/event/PlayerAscendEvent.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/event/PlayerAscendEvent.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/event/PlayerAscendEvent.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/event/PlayerChangeSectionEvent.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/event/PlayerChangeSectionEvent.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/event/PlayerChangeSectionEvent.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/event/PlayerChangeSectionEvent.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/event/PlayerDescendEvent.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/event/PlayerDescendEvent.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/event/PlayerDescendEvent.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/event/PlayerDescendEvent.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/extensions/DeeperWorldExtensions.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/extensions/DeeperWorldExtensions.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/extensions/DeeperWorldExtensions.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/extensions/DeeperWorldExtensions.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/listeners/PlayerListener.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/listeners/PlayerListener.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/listeners/PlayerListener.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/listeners/PlayerListener.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/BedrockBlockingInvalidTeleportHandler.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/BedrockBlockingInvalidTeleportHandler.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/BedrockBlockingInvalidTeleportHandler.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/BedrockBlockingInvalidTeleportHandler.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/InvalidTeleportHandler.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/InvalidTeleportHandler.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/InvalidTeleportHandler.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/InvalidTeleportHandler.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/MovementHandler.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/MovementHandler.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/MovementHandler.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/MovementHandler.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/SectionTeleportPacketAdapter.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/SectionTeleportPacketAdapter.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/SectionTeleportPacketAdapter.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/SectionTeleportPacketAdapter.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/TeleportHandler.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/TeleportHandler.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/TeleportHandler.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/TeleportHandler.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/TransitionTeleportHandler.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/TransitionTeleportHandler.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/TransitionTeleportHandler.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/TransitionTeleportHandler.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/UndoMovementInvalidTeleportHandler.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/UndoMovementInvalidTeleportHandler.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/UndoMovementInvalidTeleportHandler.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/UndoMovementInvalidTeleportHandler.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/transition/ConfigSectionChecker.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/transition/ConfigSectionChecker.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/transition/ConfigSectionChecker.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/transition/ConfigSectionChecker.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/transition/SectionChecker.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/transition/SectionChecker.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/transition/SectionChecker.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/transition/SectionChecker.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/movement/transition/SectionTransition.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/movement/transition/SectionTransition.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/movement/transition/SectionTransition.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/movement/transition/SectionTransition.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/player/FallingDamageManager.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/player/FallingDamageManager.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/player/FallingDamageManager.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/player/FallingDamageManager.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/player/PlayerManagerImpl.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/player/PlayerManagerImpl.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/player/PlayerManagerImpl.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/player/PlayerManagerImpl.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/services/PlayerManager.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/services/PlayerManager.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/services/PlayerManager.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/services/PlayerManager.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/services/WorldManager.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/services/WorldManager.kt similarity index 96% rename from src/main/java/com/derongan/minecraft/deeperworld/services/WorldManager.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/services/WorldManager.kt index d25a73e..cd5ffb2 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/services/WorldManager.kt +++ b/src/main/kotlin/com/derongan/minecraft/deeperworld/services/WorldManager.kt @@ -28,7 +28,7 @@ interface WorldManager { * @param world The world * @return The section or null if the location is not within a section. */ - fun getSectionFor(x: Int, z: Int, world: World): Section? + fun getSectionFor(x: Int, y: Int, z: Int, world: World): Section? /** * Gets the section associated with the provided key diff --git a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/ContainerSyncListener.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/ContainerSyncListener.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/synchronization/ContainerSyncListener.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/ContainerSyncListener.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/ExploitPreventionListener.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/ExploitPreventionListener.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/synchronization/ExploitPreventionListener.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/ExploitPreventionListener.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/Updaters.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/Updaters.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/synchronization/Updaters.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/synchronization/Updaters.kt diff --git a/src/main/kotlin/com/derongan/minecraft/deeperworld/world/Point.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/Point.kt new file mode 100644 index 0000000..453bf30 --- /dev/null +++ b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/Point.kt @@ -0,0 +1,14 @@ +package com.derongan.minecraft.deeperworld.world + +/** + * Represents a single X/Y/Z cube in a minecraft world. + */ +data class CubePoint(val x: Int, val y: Int, val z: Int) { + operator fun plus(other: CubePoint) = CubePoint(x + other.x, y + other.y, z + other.z) + + operator fun minus(other: CubePoint) = CubePoint(x - other.x, y - other.y, z - other.z) + + operator fun div(o: Float) = CubePoint((x / o).toInt(), (y / o).toInt(), (z / o).toInt()) + + operator fun div(o: Int) = CubePoint(x / o, y / o, z / o) +} \ No newline at end of file diff --git a/src/main/java/com/derongan/minecraft/deeperworld/world/Region.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/Region.kt similarity index 51% rename from src/main/java/com/derongan/minecraft/deeperworld/world/Region.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/world/Region.kt index 6f3634a..df7970a 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/world/Region.kt +++ b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/Region.kt @@ -4,8 +4,6 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -13,17 +11,23 @@ import kotlin.math.max import kotlin.math.min /** - * Represents a region of the world. Contains all Y values. + * Represents a region of the world. */ @Serializable(with = RegionSerializer::class) -class Region(val a: Point, val b: Point) { - constructor(ax: Int, az: Int, bx: Int, bz: Int) : this(Point(ax, az), Point(bx, bz)) +class Region(val a: CubePoint, val b: CubePoint) { + constructor(ax: Int, ay: Int, az: Int, bx: Int, by: Int, bz: Int) : this( + CubePoint(ax, ay, az), + CubePoint(bx, by, bz) + ) - val center: Point get() = a.plus(b).div(2) + val center: CubePoint get() = a.plus(b).div(2) - fun contains(x: Int, z: Int): Boolean = x in min(a.x, b.x)..max(a.x, b.x) && z in min(a.z, b.z)..max(a.z, b.z) + fun contains(x: Int, y: Int, z: Int): Boolean = + x in min(a.x, b.x)..max(a.x, b.x) && + y in min(a.y, b.y)..max(a.y, b.y) && + z in min(a.z, b.z)..max(a.z, b.z) - operator fun contains(p: Point) = contains(p.x, p.z) + operator fun contains(p: CubePoint) = contains(p.x, p.y, p.z) } object RegionSerializer : KSerializer { @@ -31,13 +35,17 @@ object RegionSerializer : KSerializer { override val descriptor: SerialDescriptor = serializer.descriptor override fun serialize(encoder: Encoder, value: Region) { - val (x, y) = value.a - val (x2, y2) = value.b - encoder.encodeSerializableValue(serializer, listOf(x, y, x2, y2)) + val (x, y, z) = value.a + val (x2, y2, z2) = value.b + encoder.encodeSerializableValue(serializer, listOf(x, y, z, x2, y2, z2)) } override fun deserialize(decoder: Decoder): Region { - val (x, y, x2, y2) = decoder.decodeSerializableValue(serializer) - return Region(x, y, x2, y2) + val (x, y, z, x2, y2, z2) = decoder.decodeSerializableValue(serializer) + return Region(x, y, z, x2, y2, z2) } -} \ No newline at end of file +} + +private operator fun List.component6(): E = this[5] + + diff --git a/src/main/java/com/derongan/minecraft/deeperworld/world/WorldManagerImpl.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/WorldManagerImpl.kt similarity index 86% rename from src/main/java/com/derongan/minecraft/deeperworld/world/WorldManagerImpl.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/world/WorldManagerImpl.kt index 5548f05..00eb5da 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/world/WorldManagerImpl.kt +++ b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/WorldManagerImpl.kt @@ -29,11 +29,11 @@ class WorldManagerImpl(config: FileConfiguration) : WorldManager { override fun unregisterSection(key: SectionKey) = TODO() override fun getSectionFor(location: Location): Section? { - return getSectionFor(location.blockX, location.blockZ, location.world!!) + return getSectionFor(location.blockX, location.blockY, location.blockZ, location.world!!) } - override fun getSectionFor(x: Int, z: Int, world: World): Section? = //TODO consider performance - sectionMap.values.firstOrNull { it.world == world && it.region.contains(x, z) } + override fun getSectionFor(x: Int, y: Int, z: Int, world: World): Section? = //TODO consider performance + sectionMap.values.firstOrNull { it.world == world && it.region.contains(x, y, z) } override fun getSectionFor(key: SectionKey) = sectionMap[key] override fun getSectionFor(key: String) = sectionMap[CustomSectionKey(key)] diff --git a/src/main/java/com/derongan/minecraft/deeperworld/world/section/AbstractSectionKey.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/AbstractSectionKey.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/world/section/AbstractSectionKey.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/AbstractSectionKey.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/world/section/Section.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/Section.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/world/section/Section.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/Section.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/world/section/SectionKey.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/SectionKey.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/world/section/SectionKey.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/SectionKey.kt diff --git a/src/main/java/com/derongan/minecraft/deeperworld/world/section/SectionUtils.kt b/src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/SectionUtils.kt similarity index 100% rename from src/main/java/com/derongan/minecraft/deeperworld/world/section/SectionUtils.kt rename to src/main/kotlin/com/derongan/minecraft/deeperworld/world/section/SectionUtils.kt diff --git a/src/test/java/com/derongan/minecraft/deeperworld/world/RegionTestU.kt b/src/test/java/com/derongan/minecraft/deeperworld/world/RegionTestU.kt deleted file mode 100644 index 9ef42bd..0000000 --- a/src/test/java/com/derongan/minecraft/deeperworld/world/RegionTestU.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.derongan.minecraft.deeperworld.world - -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Test - -class RegionTestU { - @Test - fun contains() { - val region = Region(-1, -1, 10, 10) - assertTrue(region.contains(-1, -1)) - assertTrue(region.contains(10, 10)) - assertTrue(region.contains(8, 5)) - assertFalse(region.contains(-2, 5)) - assertFalse(region.contains(11, 5)) - assertFalse(region.contains(5, -2)) - assertFalse(region.contains(5, 11)) - } -} diff --git a/src/test/kotlin/com/derongan/minecraft/deeperworld/world/RegionTestU.kt b/src/test/kotlin/com/derongan/minecraft/deeperworld/world/RegionTestU.kt new file mode 100644 index 0000000..8bca6b4 --- /dev/null +++ b/src/test/kotlin/com/derongan/minecraft/deeperworld/world/RegionTestU.kt @@ -0,0 +1,19 @@ +package com.derongan.minecraft.deeperworld.world + +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test + +class RegionTestU { + @Test + fun contains() { + val region = Region(-1, 0, -1, 10, 10, 10) + assertTrue(region.contains(-1, 0, -1)) + assertTrue(region.contains(10, 0, 10)) + assertTrue(region.contains(8, 2, 5)) + assertFalse(region.contains(-2, 5, 5)) + assertFalse(region.contains(11, -3, 5)) + assertFalse(region.contains(5, 5, -2)) + assertFalse(region.contains(5, -7, 11)) + } +}