Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
#	gradle/mobzyLibs.versions.toml
  • Loading branch information
Boy0000 committed Aug 19, 2022
2 parents 66ddf65 + 633dfb3 commit 63b65a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group=com.mineinabyss
version=0.18
useNMS=true
idofrontVersion=0.12.104
idofrontVersion=0.12.106
kotlinVersion=1.6.10
serverVersion=1.19.2-R0.1-SNAPSHOT
# Workaround for dokka builds failing on CI, see https://github.com/Kotlin/dokka/issues/1405
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import com.mineinabyss.mobzy.ecs.components.interaction.Rideable
import com.mineinabyss.mobzy.systems.systems.ModelEngineSystem.toModelEntity
import io.papermc.paper.event.entity.EntityMoveEvent
import org.bukkit.Material
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityDamageEvent
import org.bukkit.event.player.PlayerInteractEntityEvent

object RidableListener : Listener {
Expand Down Expand Up @@ -53,4 +55,27 @@ object RidableListener : Listener {
isCancelled = true
}
}

/** Apply remaining damage to driver and passengers of a [Rideable] entity when it dies */
@EventHandler
fun EntityDamageEvent.onMountFallDamage() {
val mount = entity.toModelEntity()?.mountHandler ?: return
val health = (entity as LivingEntity).health

if (entity.toGearyOrNull() == null) return
if (cause != EntityDamageEvent.DamageCause.FALL) return
if (health - finalDamage > 0) return

if (mount.hasDriver() && mount.driver is Player) {
val driver = mount.driver as Player
driver.damage(damage - health)
driver.lastDamageCause = this
driver.noDamageTicks = 0
}
mount.passengers["mount"]?.passengers?.filterIsInstance<Player>()?.forEach {
it.damage(damage - health)
it.lastDamageCause = this
it.noDamageTicks = 0
}
}
}

0 comments on commit 63b65a9

Please sign in to comment.