From 85b5f9e98e9d8100aa2b7f6303fff7ece6903794 Mon Sep 17 00:00:00 2001 From: Boy Date: Thu, 11 Jul 2024 19:27:11 +0200 Subject: [PATCH] fix: use ItemStack#toSerializable instead of SerializableItemStack directly --- .../kotlin/com/mineinabyss/blocky/BlockyConfig.kt | 11 +++++++---- .../mineinabyss/blocky/helpers/NoteBlockHelpers.kt | 14 ++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/mineinabyss/blocky/BlockyConfig.kt b/src/main/kotlin/com/mineinabyss/blocky/BlockyConfig.kt index 5254e1c..939753d 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/BlockyConfig.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/BlockyConfig.kt @@ -2,8 +2,10 @@ package com.mineinabyss.blocky import com.charleskorn.kaml.YamlComment import com.mineinabyss.blocky.helpers.FurnitureOutlineType +import com.mineinabyss.idofront.items.editItemMeta import com.mineinabyss.idofront.serialization.MiniMessageSerializer import com.mineinabyss.idofront.serialization.SerializableItemStack +import com.mineinabyss.idofront.serialization.toSerializable import com.mineinabyss.idofront.textcomponents.miniMsg import kotlinx.serialization.Serializable import kotlinx.serialization.Transient @@ -13,6 +15,7 @@ import net.minecraft.network.syncher.SynchedEntityData import net.minecraft.world.level.block.Block import org.bukkit.Material import org.bukkit.craftbukkit.inventory.CraftItemStack +import org.bukkit.inventory.ItemStack @Suppress("UnstableApiUsage") @Serializable @@ -60,7 +63,7 @@ data class BlockyConfig( data class HitboxOutline( @YamlComment("Valid typed are ITEM, BLOCK, NONE") val type: FurnitureOutlineType = FurnitureOutlineType.ITEM, - val item: SerializableItemStack = SerializableItemStack(type = Material.PAPER) + val item: SerializableItemStack = ItemStack(Material.PAPER).toSerializable() ) { fun entityType(): net.minecraft.world.entity.EntityType<*>? { return when (type) { @@ -83,8 +86,8 @@ data class BlockyConfig( @Serializable data class DefaultBlockyMenu( val title: @Serializable(MiniMessageSerializer::class) Component = Component.empty(), val height: Int = 5, - val blockButton: SerializableItemStack = SerializableItemStack(type = Material.PAPER, customModelData = 1, itemName = "Block Menu".miniMsg()), - val wireButton: SerializableItemStack = SerializableItemStack(type = Material.PAPER, customModelData = 1, itemName = "Wire Menu".miniMsg()), - val furnitureButton: SerializableItemStack = SerializableItemStack(type = Material.PAPER, customModelData = 1, itemName = "Furniture Menu".miniMsg()), + val blockButton: SerializableItemStack = ItemStack(Material.PAPER).editItemMeta { setCustomModelData(1); itemName("Block Menu".miniMsg()) }.toSerializable(), + val wireButton: SerializableItemStack = ItemStack(Material.PAPER).editItemMeta { setCustomModelData(1); itemName("Wire Menu".miniMsg()) }.toSerializable(), + val furnitureButton: SerializableItemStack = ItemStack(Material.PAPER).editItemMeta { setCustomModelData(1); itemName("Furniture Menu".miniMsg()) }.toSerializable(), ) } diff --git a/src/main/kotlin/com/mineinabyss/blocky/helpers/NoteBlockHelpers.kt b/src/main/kotlin/com/mineinabyss/blocky/helpers/NoteBlockHelpers.kt index 7425e24..b932b77 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/helpers/NoteBlockHelpers.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/helpers/NoteBlockHelpers.kt @@ -12,12 +12,14 @@ import com.mineinabyss.geary.papermc.tracking.blocks.components.SetBlock import com.mineinabyss.geary.papermc.tracking.blocks.gearyBlocks import com.mineinabyss.geary.prefabs.PrefabKey import com.mineinabyss.idofront.serialization.SerializableItemStack +import com.mineinabyss.idofront.serialization.toSerializable import org.bukkit.Material import org.bukkit.block.Block import org.bukkit.block.BlockFace import org.bukkit.block.data.BlockData import org.bukkit.block.data.type.NoteBlock import org.bukkit.entity.Player +import org.bukkit.inventory.ItemStack /** * Gets the blockdata of a given Blocky-block from a GearyEntity @@ -54,27 +56,27 @@ object NoteBlockHelpers { heldTypes = setOf(BlockyBreaking.BlockyModifiers.BlockyToolModifier(toolType = ToolType.AXE, value = 0.3)), heldItems = setOf( BlockyBreaking.BlockyModifiers.BlockySerializableItemModifier( - item = SerializableItemStack(type = Material.NETHERITE_AXE), + item = ItemStack(Material.NETHERITE_AXE).toSerializable(), value = 9.0 ), BlockyBreaking.BlockyModifiers.BlockySerializableItemModifier( - item = SerializableItemStack(type = Material.DIAMOND_AXE), + item = ItemStack(Material.DIAMOND_AXE).toSerializable(), value = 8.0 ), BlockyBreaking.BlockyModifiers.BlockySerializableItemModifier( - item = SerializableItemStack(type = Material.GOLDEN_AXE), + item = ItemStack(Material.GOLDEN_AXE).toSerializable(), value = 12.0 ), BlockyBreaking.BlockyModifiers.BlockySerializableItemModifier( - item = SerializableItemStack(type = Material.IRON_AXE), + item = ItemStack(Material.IRON_AXE).toSerializable(), value = 6.0 ), BlockyBreaking.BlockyModifiers.BlockySerializableItemModifier( - item = SerializableItemStack(type = Material.STONE_AXE), + item = ItemStack(Material.STONE_AXE).toSerializable(), value = 4.0 ), BlockyBreaking.BlockyModifiers.BlockySerializableItemModifier( - item = SerializableItemStack(type = Material.WOODEN_AXE), + item = ItemStack(Material.WOODEN_AXE).toSerializable(), value = 2.0 ) )