Skip to content

Commit

Permalink
fix: use ItemStack#toSerializable instead of SerializableItemStack di…
Browse files Browse the repository at this point in the history
…rectly
  • Loading branch information
Boy0000 committed Jul 11, 2024
1 parent d943288 commit 85b5f9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/main/kotlin/com/mineinabyss/blocky/BlockyConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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 = "<gradient:gold:yellow>Block Menu".miniMsg()),
val wireButton: SerializableItemStack = SerializableItemStack(type = Material.PAPER, customModelData = 1, itemName = "<gradient:gold:yellow>Wire Menu".miniMsg()),
val furnitureButton: SerializableItemStack = SerializableItemStack(type = Material.PAPER, customModelData = 1, itemName = "<gradient:gold:yellow>Furniture Menu".miniMsg()),
val blockButton: SerializableItemStack = ItemStack(Material.PAPER).editItemMeta { setCustomModelData(1); itemName("<gradient:gold:yellow>Block Menu".miniMsg()) }.toSerializable(),
val wireButton: SerializableItemStack = ItemStack(Material.PAPER).editItemMeta { setCustomModelData(1); itemName("<gradient:gold:yellow>Wire Menu".miniMsg()) }.toSerializable(),
val furnitureButton: SerializableItemStack = ItemStack(Material.PAPER).editItemMeta { setCustomModelData(1); itemName("<gradient:gold:yellow>Furniture Menu".miniMsg()) }.toSerializable(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
)
Expand Down

0 comments on commit 85b5f9e

Please sign in to comment.