From df2b1cb923ca42bef8d6a669f860055858edf2c8 Mon Sep 17 00:00:00 2001 From: Scyu_ Date: Sat, 14 Aug 2021 21:12:32 +0100 Subject: [PATCH] Update physics and movement --- .../deeperworld/listeners/MovementListener.kt | 9 +++++++++ .../synchronization/SectionSyncListener.kt | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt b/src/main/java/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt index 964a7a2..7e02951 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt +++ b/src/main/java/com/derongan/minecraft/deeperworld/listeners/MovementListener.kt @@ -22,6 +22,7 @@ import com.mineinabyss.idofront.events.call import com.mineinabyss.idofront.location.up import com.mineinabyss.idofront.messaging.color import com.okkero.skedule.schedule +import io.papermc.paper.event.entity.EntityMoveEvent import org.bukkit.GameMode import org.bukkit.Location import org.bukkit.Material @@ -55,6 +56,14 @@ object MovementListener : Listener { } } + @EventHandler + fun EntityMoveEvent.entityMove() { + if (entity.getPassengersRecursive().isEmpty()) return + entity.getPassengersRecursive().filterIsInstance() + .filter { rider -> rider.hasPermission(Permissions.CHANGE_SECTION_PERMISSION) && rider.canMoveSections } + .forEach { onPlayerMoveInternal(it, from, to) } + } + private fun onPlayerMoveInternal(player: Player, from: Location, to: Location) { val current = WorldManager.getSectionFor(player.location) ?: let { //damage players outside of sections diff --git a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt b/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt index 95f0582..0dba317 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt +++ b/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt @@ -1,7 +1,10 @@ package com.derongan.minecraft.deeperworld.synchronization import com.derongan.minecraft.deeperworld.DeeperContext +import com.derongan.minecraft.deeperworld.world.section.correspondingSection import com.derongan.minecraft.deeperworld.world.section.inSectionOverlap +import com.derongan.minecraft.deeperworld.world.section.isOnTopOf +import com.derongan.minecraft.deeperworld.world.section.section import com.mineinabyss.idofront.messaging.error import nl.rutgerkok.blocklocker.SearchMode import org.bukkit.Material @@ -105,10 +108,18 @@ object SectionSyncListener : Listener { @EventHandler fun BlockPhysicsEvent.sync() { + val section = block.location.section ?: return + val section2 = block.location.correspondingSection ?: return + if( block.location.inSectionOverlap + && section.isOnTopOf(section2) && block.blockData !is Levelled // Water / Lava ) isCancelled = true + + if(!section.isOnTopOf(section2)) { + block.sync() + } } @EventHandler