diff --git a/build.gradle.kts b/build.gradle.kts index f6eb383f..93b0140e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,7 +41,6 @@ dependencies { // Other plugins compileOnly(idofrontLibs.minecraft.plugin.modelengine) - compileOnly(idofrontLibs.minecraft.plugin.protocollib) compileOnly(idofrontLibs.minecraft.plugin.fawe.core) compileOnly(idofrontLibs.minecraft.plugin.fawe.bukkit) { isTransitive = false } compileOnly(idofrontLibs.minecraft.anvilgui) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 80396ca4..4210e164 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] gearyPaper = "0.29.12-dev.6" guiy="0.9.3" -protocolburrito="0.9.0" +protocolburrito="0.10.0-dev.0" [libraries] geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" } diff --git a/src/main/kotlin/com/mineinabyss/blocky/helpers/FurniturePacketHelpers.kt b/src/main/kotlin/com/mineinabyss/blocky/helpers/FurniturePacketHelpers.kt index d423385c..fc8e70df 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/helpers/FurniturePacketHelpers.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/helpers/FurniturePacketHelpers.kt @@ -3,6 +3,7 @@ package com.mineinabyss.blocky.helpers import com.comphenix.protocol.events.PacketContainer +import com.comphenix.protocol.wrappers.BlockPosition import com.mineinabyss.blocky.api.BlockyFurnitures import com.mineinabyss.blocky.api.BlockyFurnitures.isBlockyFurniture import com.mineinabyss.blocky.api.BlockyFurnitures.isModelEngineFurniture @@ -56,7 +57,7 @@ object FurniturePacketHelpers { const val INTERACTION_HEIGHT_ID = 9 const val ITEM_DISPLAY_ITEMSTACK_ID = 23 - private val collisionHitboxPosMap = mutableMapOf>() + private val collisionHitboxPosMap = mutableMapOf>() private val interactionHitboxIdMap = mutableSetOf() private val interactionHitboxPacketMap = mutableMapOf>() private val hitboxOutlineIdMap = mutableMapOf() @@ -65,7 +66,7 @@ object FurniturePacketHelpers { fun getBaseFurnitureFromInteractionEntity(id: Int) = interactionHitboxIdMap.firstOrNull { id in it.entityIds }?.furniture - fun getBaseFurnitureFromCollisionHitbox(pos: BlockPos) = + fun getBaseFurnitureFromCollisionHitbox(pos: BlockPosition) = collisionHitboxPosMap.entries.firstOrNull { pos in it.value }?.key?.toEntity() as? ItemDisplay internal fun registerPacketListeners() { @@ -86,7 +87,7 @@ object FurniturePacketHelpers { // Cancelled so client doesn't remove the "Ghost Block" onReceive { wrap -> Bukkit.getScheduler().callSyncMethod(blocky.plugin) { - getBaseFurnitureFromCollisionHitbox(wrap.blockHit.blockPos)?.let { baseFurniture -> + getBaseFurnitureFromCollisionHitbox(BlockPosition.getConverter().getSpecific(wrap.blockHit.blockPos))?.let { baseFurniture -> val clickedRelativePosition = Vector(wrap.blockHit.location.x, wrap.blockHit.location.y, wrap.blockHit.location.z) isCancelled = true @@ -221,8 +222,8 @@ object FurniturePacketHelpers { player.sendMultiBlockChange(positions) positions.map { it.key.toBlock() }.forEach { collisionHitboxPosMap.compute(baseEntity.uniqueId) { _, blockPos -> - blockPos?.plus(BlockPos(it.blockX(), it.blockY(), it.blockZ()))?.toMutableSet() - ?: mutableSetOf(BlockPos(it.blockX(), it.blockY(), it.blockZ())) + blockPos?.plus(BlockPosition(it.blockX(), it.blockY(), it.blockZ()))?.toMutableSet() + ?: mutableSetOf(BlockPosition(it.blockX(), it.blockY(), it.blockZ())) } } } diff --git a/src/main/kotlin/com/mineinabyss/blocky/helpers/GenericHelpers.kt b/src/main/kotlin/com/mineinabyss/blocky/helpers/GenericHelpers.kt index 08a09d97..80bc76f8 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/helpers/GenericHelpers.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/helpers/GenericHelpers.kt @@ -1,5 +1,6 @@ package com.mineinabyss.blocky.helpers +import com.comphenix.protocol.wrappers.BlockPosition import com.destroystokyo.paper.MaterialTags import com.jeff_media.customblockdata.CustomBlockData import com.mineinabyss.blocky.api.BlockyBlocks @@ -70,7 +71,7 @@ const val DEFAULT_FALL_PITCH = 0.75f val Block.persistentDataContainer get() = customBlockData as PersistentDataContainer val Block.customBlockData get() = CustomBlockData(this, blocky.plugin) -fun Block.toBlockPos() = BlockPos(this.x, this.y, this.z) +fun Block.toBlockPos() = BlockPosition(this.x, this.y, this.z) internal infix fun Pair.to(that: C): Triple = Triple(this.first, this.second, that) internal inline fun ItemStack.decode(): T? = this.itemMeta?.persistentDataContainer?.decode() diff --git a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetMEGModelOnFurnitureSystem.kt b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetMEGModelOnFurnitureSystem.kt index f20f2f5b..49938028 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetMEGModelOnFurnitureSystem.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetMEGModelOnFurnitureSystem.kt @@ -18,6 +18,10 @@ fun GearyModule.createFurnitureMEGModelSetter() = listener( val meg by source.get() } ).exec { + // Save for scheduled task + val display = display + val furniture = furniture + val meg = meg if (!Plugins.isEnabled("ModelEngine")) return@exec val activeModel = ModelEngineAPI.createActiveModel(meg.modelId) Bukkit.getScheduler().scheduleSyncDelayedTask(blocky.plugin, { diff --git a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetSeatOnFurnitureSystem.kt b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetSeatOnFurnitureSystem.kt index 491b3dd9..f51541d7 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetSeatOnFurnitureSystem.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetSeatOnFurnitureSystem.kt @@ -17,6 +17,11 @@ fun GearyModule.createFurnitureSeatSetter() = listener( val seat by source.get() } ).exec { + // Save for scheduled task + val display = display + val furniture = furniture + val seat = seat + val yaw = display.location.yaw FurnitureHelpers.clearFurnitureSeats(display) Bukkit.getScheduler().scheduleSyncDelayedTask(blocky.plugin, {