Skip to content

Commit

Permalink
bump idofront
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Sep 30, 2023
1 parent 2b1550e commit 92e5d15
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
group=com.mineinabyss
version=1.9
idofrontVersion=0.18.10
idofrontVersion=0.18.26
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from("com.mineinabyss:catalog:$idofrontVersion")
version("modelengine", "R3.1.7")
}
}
}
Expand Down
24 changes: 23 additions & 1 deletion src/main/kotlin/org/cultofclang/bonehurtingjuice/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package org.cultofclang.bonehurtingjuice
import com.mineinabyss.idofront.typealiases.BukkitEntity
import com.ticxo.modelengine.api.ModelEngineAPI
import com.ticxo.modelengine.api.model.ModeledEntity
import com.ticxo.modelengine.api.model.bone.behavior.BoneBehavior
import com.ticxo.modelengine.api.model.bone.manager.BehaviorManager
import com.ticxo.modelengine.api.model.bone.manager.MountManager
import org.bukkit.Bukkit
import org.bukkit.Location
import org.bukkit.block.Block
Expand All @@ -14,6 +17,8 @@ import org.bukkit.event.vehicle.VehicleEvent
import org.cultofclang.bonehurtingjuice.events.BoneHurtDamageEvent
import org.cultofclang.bonehurtingjuice.listeners.MoveListener
import org.cultofclang.bonehurtingjuice.modules.bones
import java.util.*
import kotlin.jvm.optionals.getOrNull


internal fun VehicleEvent.forRidingPlayers(action: (Player) -> Unit) = vehicle.passengers
Expand Down Expand Up @@ -61,4 +66,21 @@ fun Player.hurtBones(fallDist: Float) {
}
}

internal fun BukkitEntity.toModelEntity(): ModeledEntity? = ModelEngineAPI.getModeledEntity(uniqueId)
fun BukkitEntity.toModelEntity(): ModeledEntity? = ModelEngineAPI.getModeledEntity(uniqueId)

class MountManagerWithBehavior<T: BoneBehavior>(
mountManager: MountManager,
behaviorManager: BehaviorManager<T>,
): MountManager by mountManager, BehaviorManager<T> by behaviorManager

fun BukkitEntity.getMountManager() : MountManagerWithBehavior<*>? {
val mountManager = (toModelEntity()
?.models?.values?.firstOrNull()
?.getMountManager<Nothing>() as Optional<*>?)
?.getOrNull() ?: return null

return MountManagerWithBehavior(
mountManager as MountManager,
mountManager as BehaviorManager<*>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import io.papermc.paper.event.entity.EntityMoveEvent
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.cultofclang.bonehurtingjuice.getMountManager
import org.cultofclang.bonehurtingjuice.hurtBones
import org.cultofclang.bonehurtingjuice.modules.bones
import org.cultofclang.bonehurtingjuice.toModelEntity

class ModelEngineListener : Listener {
@EventHandler
fun EntityMoveEvent.onRidableMobEnterWater() {
if (entity.fallDistance < bones.config.minFallDist) return
if (from.block.isLiquid) return
val mount = entity.toModelEntity()?.mountManager ?: return
val mount = entity.getMountManager() ?: return

if (mount.driver != null && mount.driver is Player) {
val driver = mount.driver as Player
driver.fallDistance = entity.fallDistance
driver.hurtBones(entity.fallDistance)
}
mount.passengers.keys.filterIsInstance<Player>().forEach { rider ->
/*mount.passengers.keys.filterIsInstance<Player>().forEach { rider ->
rider.fallDistance = entity.fallDistance
rider.hurtBones(entity.fallDistance)
}
}*/
}
}

0 comments on commit 92e5d15

Please sign in to comment.