Skip to content

Commit

Permalink
Merge pull request #81 from MineInAbyss/riding-fix
Browse files Browse the repository at this point in the history
Update physics and movement
  • Loading branch information
0ffz authored Aug 15, 2021
2 parents beb24dd + df2b1cb commit d2274e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,6 +56,14 @@ object MovementListener : Listener {
}
}

@EventHandler
fun EntityMoveEvent.entityMove() {
if (entity.getPassengersRecursive().isEmpty()) return
entity.getPassengersRecursive().filterIsInstance<Player>()
.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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d2274e2

Please sign in to comment.