Skip to content

Commit

Permalink
feat: add more FurnitureProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jan 22, 2024
1 parent 3e4502d commit 4125f17
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.mineinabyss.blocky

import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.blocky.api.BlockyFurnitures.isBlockyFurniture
import com.mineinabyss.blocky.components.core.BlockyFurniture
import com.mineinabyss.blocky.components.features.blocks.BlockyDirectional
import com.mineinabyss.blocky.helpers.FurniturePacketHelpers
import com.mineinabyss.blocky.helpers.gearyInventory
import com.mineinabyss.blocky.menus.BlockyMainMenu
import com.mineinabyss.blocky.systems.BlockyBlockQuery.prefabKey
Expand All @@ -22,12 +20,10 @@ import com.mineinabyss.idofront.commands.extensions.actions.playerAction
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.messaging.error
import com.mineinabyss.idofront.messaging.success
import com.mineinabyss.idofront.plugin.actions
import org.bukkit.Color
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
import org.bukkit.command.TabCompleter
import org.bukkit.entity.ItemDisplay
import org.bukkit.entity.Player
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.inventory.meta.LeatherArmorMeta
Expand All @@ -43,7 +39,7 @@ class BlockyCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
blocky.plugin.createBlockyContext()
blocky.plugin.runStartupFunctions()
blocky.plugin.launch {
BlockyQuery.forEach { prefabs.loader.reread(it.entity) }
BlockyQuery.forEach { prefabs.loader.reload(it.entity) }
}
sender.success("Blocky has been reloaded!")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
package com.mineinabyss.blocky.compatibility.worldedit

import ca.spottedleaf.dataconverter.converters.datatypes.DataType
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent
import com.mineinabyss.blocky.blocky
import com.mineinabyss.blocky.helpers.*
import com.mineinabyss.blocky.prefabMap
import com.mineinabyss.blocky.systems.BlockyBlockQuery
import com.mineinabyss.blocky.systems.BlockyBlockQuery.prefabKey
import com.mineinabyss.geary.papermc.datastore.decode
import com.mineinabyss.geary.papermc.datastore.decodePrefabs
import com.mineinabyss.geary.papermc.tracking.blocks.helpers.prefabKey
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.idofront.nms.nbt.WrappedPDC
import com.sk89q.worldedit.WorldEditException
import com.sk89q.worldedit.bukkit.BukkitAdapter
import com.sk89q.worldedit.entity.BaseEntity
import com.sk89q.worldedit.entity.Entity
import com.sk89q.worldedit.event.extent.EditSessionEvent
import com.sk89q.worldedit.extent.AbstractDelegateExtent
import com.sk89q.worldedit.math.BlockVector3
import com.sk89q.worldedit.util.eventbus.Subscribe
import com.sk89q.worldedit.world.block.BlockStateHolder
import net.minecraft.nbt.CompoundTag
import org.bukkit.*
import org.bukkit.entity.EntityType
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.persistence.PersistentDataAdapterContext
import org.bukkit.persistence.PersistentDataContainer

typealias WorldEditLocation = com.sk89q.worldedit.util.Location

Expand All @@ -39,7 +27,8 @@ class WorldEditListener : Listener {

extent = object : AbstractDelegateExtent(extent) {

override fun createEntity(location: WorldEditLocation?, baseEntity: BaseEntity?): Entity? {
//TODO Implement this fully
/*override fun createEntity(location: WorldEditLocation?, baseEntity: BaseEntity?): Entity? {
val superEntity by lazy { super.createEntity(location, baseEntity) }
val world = world?.name?.let { Bukkit.getWorld(it) } ?: return superEntity
val bukkitLoc = BukkitAdapter.adapt(world, location) ?: return superEntity
Expand All @@ -50,7 +39,7 @@ class WorldEditListener : Listener {
if (baseEntity.type != BukkitAdapter.adapt(EntityType.ITEM_DISPLAY)) return superEntity
return superEntity
}
}*/

@Deprecated("Deprecated in Java")
@Throws(WorldEditException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ data class BlockyFurniture(
@Serializable
@SerialName("blocky:furniture_properties")
data class FurnitureProperties(
val persistent: Boolean = true,
val itemStack: SerializableItemStack? = null,
val displayTransform: ItemDisplayTransform = ItemDisplayTransform.NONE,
val scale: @Serializable(Vector3fSerializer::class) Vector3f = Vector3f(1f, 1f, 1f),
val displayWidth: Float = 0f,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mineinabyss.blocky.helpers

import com.destroystokyo.paper.MaterialSetTag
import net.minecraft.core.Direction
import net.minecraft.util.Mth
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
Expand All @@ -11,12 +10,8 @@ import net.minecraft.world.item.context.DirectionalPlaceContext
import net.minecraft.world.item.context.UseOnContext
import net.minecraft.world.level.ClipContext
import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.Vec3
import org.bukkit.GameMode
import org.bukkit.block.Block
import org.bukkit.block.BlockFace
import org.bukkit.block.Sign
import org.bukkit.block.data.BlockData
import org.bukkit.block.sign.Side
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack
Expand Down Expand Up @@ -60,7 +55,7 @@ object BlockStateCorrection {
val l = i * j
val n = h * j
val d = 5.0
val vec32 = vec3.add(l.toDouble() * 5.0, k.toDouble() * 5.0, n.toDouble() * 5.0)
val vec32 = vec3.add(l.toDouble() * d, k.toDouble() * d, n.toDouble() * d)
return player.level().clip(ClipContext(vec3, vec32, ClipContext.Block.OUTLINE, fluidHandling, player))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ object FurnitureHelpers {
item: ItemStack?
): ItemDisplay? {
val gearyEntity = prefabKey.toEntityOrNull() ?: return null
val itemStack = item ?: gearyEntity.get<SetItem>()?.item?.toItemStack() ?: return null
val furniture = gearyEntity.get<BlockyFurniture>() ?: return null
val itemStack = furniture.properties.itemStack?.toItemStackOrNull() ?: item ?: gearyEntity.get<SetItem>()?.item?.toItemStack() ?: return null
val furnitureItem = itemStack.clone().editItemMeta {
displayName(Component.empty())
(this as? LeatherArmorMeta)?.setColor((itemStack.itemMeta as? LeatherArmorMeta)?.color)
Expand All @@ -95,7 +95,7 @@ object FurnitureHelpers {
}

val newFurniture = spawnLoc.spawn<ItemDisplay> {
isPersistent = true
isPersistent = furniture.properties.persistent

furniture.properties.let { properties ->
itemDisplayTransform = properties.displayTransform
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mineinabyss.blocky.listeners

import com.destroystokyo.paper.MaterialTags
import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.blocky.api.BlockyBlocks.isBlockyBlock
import com.mineinabyss.blocky.api.events.block.BlockyBlockDamageAbortEvent
Expand All @@ -9,9 +8,10 @@ import com.mineinabyss.blocky.api.events.block.BlockyBlockInteractEvent
import com.mineinabyss.blocky.blocky
import com.mineinabyss.blocky.components.features.BlockyBreaking
import com.mineinabyss.blocky.components.features.mining.PlayerIsMining
import com.mineinabyss.blocky.helpers.*
import com.mineinabyss.blocky.helpers.GenericHelpers.isInteractable
import com.mineinabyss.blocky.helpers.GenericHelpers.toBlockCenterLocation
import com.mineinabyss.blocky.helpers.CopperHelpers
import com.mineinabyss.blocky.helpers.attemptBreakBlockyBlock
import com.mineinabyss.blocky.helpers.gearyInventory
import com.mineinabyss.blocky.helpers.to
import com.mineinabyss.geary.papermc.tracking.blocks.components.SetBlock
import com.mineinabyss.geary.papermc.tracking.blocks.helpers.toGearyOrNull
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
Expand All @@ -20,13 +20,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.job
import org.bukkit.GameMode
import org.bukkit.Material
import org.bukkit.Sound
import org.bukkit.Tag
import org.bukkit.block.Block
import org.bukkit.block.BlockFace
import org.bukkit.block.data.Directional
import org.bukkit.block.data.type.Slab
import org.bukkit.entity.EntityType
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
Expand Down

0 comments on commit 4125f17

Please sign in to comment.