Skip to content

Commit

Permalink
feat: add component to prevent furniture itemstack updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jan 27, 2024
1 parent ff63d5d commit 5a4aabb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ data class BlockyFurniture(
)

val hasStrictRotation get() = rotationType != RotationType.NONE

@Serializable
@SerialName("blocky:prevent_itemstack_update")
class PreventItemStackUpdate
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.mineinabyss.blocky.systems

import com.mineinabyss.blocky.api.BlockyFurnitures.prefabKey
import com.mineinabyss.blocky.components.core.BlockyFurniture
import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull
import com.mineinabyss.geary.papermc.tracking.items.gearyItems
import com.mineinabyss.geary.systems.RepeatingSystem
import com.mineinabyss.geary.systems.accessors.Pointer
Expand All @@ -15,6 +17,7 @@ class FurnitureTrackerSystem : RepeatingSystem(interval = 1.ticks) {
private val Pointer.furniture by get<ItemDisplay>()

override fun Pointer.tick() {
if (furniture.toGearyOrNull()?.has<BlockyFurniture.PreventItemStackUpdate>() != false) return
val freshItem = furniture.prefabKey?.let { gearyItems.createItem(it, furniture.itemStack) } ?: return
furniture.itemStack = freshItem.toSerializable().toItemStack(furniture.itemStack ?: ItemStack.empty(), EnumSet.of(BaseSerializableItemStack.Properties.COLOR))
}
Expand Down

0 comments on commit 5a4aabb

Please sign in to comment.