diff --git a/src/main/kotlin/com/mineinabyss/blocky/helpers/FurnitureHelpers.kt b/src/main/kotlin/com/mineinabyss/blocky/helpers/FurnitureHelpers.kt index daf4f24e..c31b8415 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/helpers/FurnitureHelpers.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/helpers/FurnitureHelpers.kt @@ -94,7 +94,7 @@ object FurnitureHelpers { val color = item?.itemMeta?.asColorable()?.color return spawnLoc.spawnFromPrefab(prefabKey) { if (color != null) set(BlockyFurniture.Color(color)) - }.getOrNull() as? ItemDisplay + }.getOrThrow() as? ItemDisplay } //TODO Fix seat breaking below 0.0 offset and remove max() check here diff --git a/src/main/kotlin/com/mineinabyss/blocky/systems/AttemptSpawnFurnitureSystem.kt b/src/main/kotlin/com/mineinabyss/blocky/systems/AttemptSpawnFurnitureSystem.kt index 6fca45b4..8d0cb3eb 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/systems/AttemptSpawnFurnitureSystem.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/systems/AttemptSpawnFurnitureSystem.kt @@ -14,8 +14,7 @@ import org.bukkit.entity.ItemDisplay @OptIn(DangerousComponentOperation::class) fun GearyModule.createFurnitureSpawner() = observeWithData() - .involving(query()) - .exec { (furniture, color) -> + .exec(query()) { (furniture/*, color*/) -> val spawnLoc = event.location spawnLoc.spawn { @@ -32,7 +31,7 @@ fun GearyModule.createFurnitureSpawner() = observeWithData() props.shadowStrength?.let { shadowStrength = it } transformation = transformation.apply { scale.set(props.scale) } - color.let { entity.setPersisting(it) } + //color.let { entity.setPersisting(it) } entity.set(this) } } diff --git a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetItemOnFurnitureSystem.kt b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetItemOnFurnitureSystem.kt index 62671bc0..d3808d77 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetItemOnFurnitureSystem.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetItemOnFurnitureSystem.kt @@ -2,20 +2,23 @@ package com.mineinabyss.blocky.systems.actions import com.mineinabyss.blocky.components.core.BlockyFurniture import com.mineinabyss.geary.modules.GearyModule +import com.mineinabyss.geary.observers.events.OnSet import com.mineinabyss.geary.papermc.tracking.items.components.SetItem import com.mineinabyss.geary.systems.builders.observeWithData import com.mineinabyss.geary.systems.query.query import com.mineinabyss.idofront.items.asColorable import com.mineinabyss.idofront.items.editItemMeta +import com.mineinabyss.idofront.typealiases.BukkitEntity import net.kyori.adventure.text.Component import org.bukkit.entity.ItemDisplay -fun GearyModule.createFurnitureItemSetter() = observeWithData() - .exec(query()) { (furniture/*, color*/, entity) -> - val itemStack = furniture.properties.itemStack?.toItemStackOrNull() ?: event.item.toItemStack() +fun GearyModule.createFurnitureItemSetter() = observeWithData() + .exec(query()) { (entity, item, furniture/*, color*/) -> + val itemDisplay = entity as? ItemDisplay ?: return@exec + val itemStack = furniture.properties.itemStack?.toItemStackOrNull() ?: item.item.toItemStack() val furnitureItem = itemStack.clone().editItemMeta { displayName(Component.empty()) //color.color?.let { asColorable()?.color = it } } - entity.itemStack = furnitureItem + itemDisplay.itemStack = furnitureItem } 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 8e562adf..0caed341 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetMEGModelOnFurnitureSystem.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetMEGModelOnFurnitureSystem.kt @@ -4,20 +4,22 @@ import com.mineinabyss.blocky.blocky import com.mineinabyss.blocky.components.core.BlockyFurniture import com.mineinabyss.blocky.components.features.furniture.BlockyModelEngine import com.mineinabyss.geary.modules.GearyModule +import com.mineinabyss.geary.observers.events.OnSet import com.mineinabyss.geary.systems.builders.observeWithData import com.mineinabyss.geary.systems.query.query import com.mineinabyss.idofront.plugin.Plugins +import com.mineinabyss.idofront.typealiases.BukkitEntity import com.ticxo.modelengine.api.ModelEngineAPI import org.bukkit.Bukkit import org.bukkit.entity.ItemDisplay -fun GearyModule.createFurnitureMEGModelSetter() = observeWithData() - .exec(query { has() } ) { (itemDisplay) -> +fun GearyModule.createFurnitureMEGModelSetter() = observeWithData() + .exec(query()) { (entity, furniture, modelengine) -> // Save for scheduled task if (!Plugins.isEnabled("ModelEngine")) return@exec - val activeModel = ModelEngineAPI.createActiveModel(event.modelId) + val activeModel = ModelEngineAPI.createActiveModel(modelengine.modelId) Bukkit.getScheduler().scheduleSyncDelayedTask(blocky.plugin, { - ModelEngineAPI.getOrCreateModeledEntity(itemDisplay).apply { + ModelEngineAPI.getOrCreateModeledEntity(entity).apply { models.forEach { removeModel(it.key) it.value.destroy() 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 15a29323..237ae654 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetSeatOnFurnitureSystem.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/systems/actions/SetSeatOnFurnitureSystem.kt @@ -5,17 +5,18 @@ import com.mineinabyss.blocky.components.core.BlockyFurniture import com.mineinabyss.blocky.components.features.furniture.BlockySeat import com.mineinabyss.blocky.helpers.FurnitureHelpers import com.mineinabyss.geary.modules.GearyModule +import com.mineinabyss.geary.observers.events.OnSet import com.mineinabyss.geary.systems.builders.observeWithData import com.mineinabyss.geary.systems.query.query +import com.mineinabyss.idofront.typealiases.BukkitEntity import org.bukkit.Bukkit import org.bukkit.entity.ItemDisplay -fun GearyModule.createFurnitureSeatSetter() = observeWithData() - .involving(query()) - .exec { (entity, furniture) -> - val display = entity +fun GearyModule.createFurnitureSeatSetter() = observeWithData() + .exec(query()) { (entity, furniture, seat) -> + val display = entity as? ItemDisplay ?: return@exec val furniture = furniture - val seat = event + val seat = seat val yaw = display.location.yaw FurnitureHelpers.clearFurnitureSeats(display)