diff --git a/settings.gradle.kts b/settings.gradle.kts index f5db9315..b1bd4e52 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -26,7 +26,10 @@ dependencyResolutionManagement { } versionCatalogs { - create("libs").from("com.mineinabyss:catalog:$idofrontVersion") + create("libs"){ + from("com.mineinabyss:catalog:$idofrontVersion") + version("modelengine", "R4.0.3") + } create("blockyLibs").from(files("gradle/blockyLibs.versions.toml")) } } diff --git a/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockyFurnitureListener.kt b/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockyFurnitureListener.kt index 8d958d3e..df89dd6e 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockyFurnitureListener.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockyFurnitureListener.kt @@ -7,6 +7,7 @@ import com.github.shynixn.mccoroutine.bukkit.launch import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher import com.mineinabyss.blocky.api.BlockyFurnitures.getBlockySeat import com.mineinabyss.blocky.api.BlockyFurnitures.isBlockyFurniture +import com.mineinabyss.blocky.api.BlockyFurnitures.isModelEngineFurniture import com.mineinabyss.blocky.api.BlockyFurnitures.removeFurniture import com.mineinabyss.blocky.api.events.furniture.BlockyFurnitureInteractEvent import com.mineinabyss.blocky.api.events.furniture.BlockyFurniturePlaceEvent @@ -18,7 +19,7 @@ import com.mineinabyss.blocky.helpers.* import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull import com.mineinabyss.geary.prefabs.PrefabKey import com.mineinabyss.geary.prefabs.helpers.prefabs -import com.mineinabyss.idofront.messaging.broadcast +import com.ticxo.modelengine.api.events.BaseEntityInteractEvent import io.papermc.paper.event.packet.PlayerChunkLoadEvent import io.th0rgal.protectionlib.ProtectionLib import kotlinx.coroutines.delay @@ -97,7 +98,6 @@ class BlockyFurnitureListener : Listener { @EventHandler fun PlayerUseUnknownEntityEvent.onInteract() { - broadcast(this.entityId) val baseFurniture = FurniturePacketHelpers.getBaseFurnitureFromInteractionEntity(entityId) ?: return blocky.plugin.launch(blocky.plugin.minecraftDispatcher) { when { @@ -111,6 +111,20 @@ class BlockyFurnitureListener : Listener { } } + @EventHandler // ModelEngine-interaction check + fun BaseEntityInteractEvent.onModelEngineInteract() { + val baseEntity = baseEntity.original as? ItemDisplay ?: return + if (!baseEntity.isBlockyFurniture || !baseEntity.isModelEngineFurniture) return + when { + action == BaseEntityInteractEvent.Action.ATTACK -> removeFurniture(baseEntity, player) + else -> BlockyFurnitureInteractEvent( + baseEntity, player, + slot, player.inventory.itemInMainHand, + null, null + ).callEvent() + } + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) fun BlockyFurnitureInteractEvent.onSitting() { if (!ProtectionLib.canInteract(player, entity.location) || player.isSneaking) return