Skip to content

Commit

Permalink
chore: bump idofront
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jun 28, 2024
1 parent 35fdd09 commit 6709d7c
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.mineinabyss.geary.papermc.datastore.decode
import com.mineinabyss.geary.papermc.datastore.decodePrefabs
import com.mineinabyss.geary.papermc.datastore.encode
import com.mineinabyss.geary.papermc.datastore.hasComponentsEncoded
import com.mineinabyss.geary.papermc.tracking.items.components.SetItemIgnoredProperties
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.nms.nbt.fastPDC
import com.mineinabyss.idofront.serialization.BaseSerializableItemStack
Expand Down Expand Up @@ -60,21 +59,9 @@ class RecipeCraftingListener : Listener {
it.template.test(template) && it.addition.test(mineral) && it.base.itemStack.itemMeta?.persistentDataContainer?.decodePrefabs()
?.firstOrNull() == inputGearyEntity
}.firstOrNull()?.result
var recipeResultItem = (customRecipeResult ?: ItemStack.empty()).let {
result?.toSerializable()?.toItemStack(it, EnumSet.of(BaseSerializableItemStack.Properties.DISPLAY_NAME))
}

recipeResultItem = recipeResultItem?.editItemMeta {
displayName(
equipment.fastPDC?.decode<SetItemIgnoredProperties>()?.let { properties ->
persistentDataContainer.encode(properties)
if (BaseSerializableItemStack.Properties.DISPLAY_NAME in properties.ignore && result?.itemMeta?.hasDisplayName() == true)
result?.itemMeta?.displayName()?.compact()
else displayName()?.compact()
} ?: displayName()?.compact()
)
result = (customRecipeResult ?: ItemStack.empty()).let {
result?.toSerializable()?.toItemStack(it)
}

result = recipeResultItem
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mineinabyss.geary.papermc.plugin.commands

import com.mineinabyss.geary.papermc.tracking.items.gearyItems
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.idofront.commands.Command
import com.mineinabyss.idofront.commands.arguments.intArg
import com.mineinabyss.idofront.commands.arguments.optionArg
Expand All @@ -15,13 +16,9 @@ fun Command.items() {
}
val amount by intArg { default = 1 }
playerAction {
val item = gearyItems.createItem(
com.mineinabyss.geary.prefabs.PrefabKey.of(prefabKey)
) ?: run {
sender.error("Failed to create $prefabKey")
return@playerAction
}
item.amount = amount.coerceIn(1, 64)
val item = gearyItems.createItem(PrefabKey.of(prefabKey))
?: return@playerAction sender.error("Failed to create $prefabKey")
item.amount = amount.coerceIn(1, item.maxStackSize)
player.inventory.addItem(item)
}
}
Expand Down
2 changes: 1 addition & 1 deletion geary-papermc-plugin/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: ${plugin_version}
author: Offz
load: STARTUP
main: com.mineinabyss.geary.papermc.plugin.GearyPluginImpl
api-version: '1.20'
api-version: '1.21'

prefix: Geary
description: An Entity Component System written for Spigot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import com.mineinabyss.geary.papermc.datastore.encodeComponentsTo
import com.mineinabyss.geary.papermc.datastore.encodePrefabs
import com.mineinabyss.geary.papermc.datastore.loadComponentsFrom
import com.mineinabyss.geary.papermc.tracking.items.components.SetItem
import com.mineinabyss.geary.papermc.tracking.items.components.SetItemIgnoredProperties
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.serialization.BaseSerializableItemStack
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
Expand All @@ -27,15 +27,9 @@ class GearyItemProvider {
fun serializePrefabToItemStack(prefabKey: PrefabKey, existing: ItemStack? = null): ItemStack? {
val prefab = prefabKey.toEntityOrNull() ?: return null

val item = prefab.get<SetItem>()?.item?.toItemStack(
applyTo = existing ?: ItemStack(Material.AIR),
ignoreProperties = prefab.get<SetItemIgnoredProperties>()?.ignoreAsEnumSet()
?: EnumSet.noneOf(BaseSerializableItemStack.Properties::class.java)
) ?: ItemStack(Material.AIR)
item.editMeta {
it.persistentDataContainer.encodePrefabs(listOf(prefabKey))
return prefab.get<SetItem>()?.item?.toItemStackOrNull(existing ?: ItemStack(Material.AIR))?.editItemMeta {
persistentDataContainer.encodePrefabs(listOf(prefabKey))
}
return item.takeUnless { it.isEmpty }
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@ package com.mineinabyss.geary.papermc.tracking.items.migration
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.papermc.tracking.items.components.SetItemIgnoredProperties
import com.mineinabyss.geary.systems.builders.observe
import com.mineinabyss.geary.systems.query.query
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.serialization.BaseSerializableItemStack
import org.bukkit.inventory.ItemStack
import java.util.*

fun GearyModule.createItemMigrationListener() = observe<OnSet>()
.involving(query<SetItem, ItemStack>())
.exec { (setItem, item) ->
val overrides = entity.get<SetItemIgnoredProperties>()
val ignoredProperties =
overrides?.ignoreAsEnumSet() ?: EnumSet.noneOf(BaseSerializableItemStack.Properties::class.java)
val newItem = setItem.item.toItemStack(applyTo = item, ignoredProperties)
item.type = newItem.type
item.itemMeta = newItem.itemMeta
setItem.item.toItemStack(applyTo = item)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class EntityTrackingTests: MockedServerTest() {
val pig = world.spawn(world.spawnLocation, Pig::class.java)

// act
EntityAddToWorldEvent(pig).callEvent() // Not called by MockBukkit
EntityAddToWorldEvent(pig, world).callEvent() // Not called by MockBukkit

// assert
val gearyPig = pig.toGearyOrNull().shouldNotBeNull()
Expand Down Expand Up @@ -106,7 +106,7 @@ class EntityTrackingTests: MockedServerTest() {
@Test
fun `should persist components on entities when chunk unloaded`() {
val pig = world.spawn(world.spawnLocation, Pig::class.java)
EntityAddToWorldEvent(pig).callEvent()
EntityAddToWorldEvent(pig, world).callEvent()

testPersistence(
pig.toGeary(),
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlin.code.style=official
group=com.mineinabyss
version=0.30
idofrontVersion=0.24.0
idofrontVersion=0.24.10
gearyVersion=0.26.0
5 changes: 1 addition & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ dependencyResolutionManagement {
}

versionCatalogs {
create("idofrontLibs") {
from("com.mineinabyss:catalog:$idofrontVersion")
version("mockbukkit", "3.9.0")
}
create("idofrontLibs").from("com.mineinabyss:catalog:$idofrontVersion")
create("gearyLibs").from("com.mineinabyss:geary-catalog:$gearyVersion")
}
}
Expand Down

0 comments on commit 6709d7c

Please sign in to comment.