From 6cee8e4acf0a782431ad1188d916787f781c1f5f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 10 Oct 2022 23:18:18 +0700 Subject: [PATCH] Get rid of top hook declaration --- .../otm/capability/MatteryPlayerCapability.kt | 60 ++++++++++--------- src/main/resources/coremods/code_injector.js | 2 +- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 7a8f8a2a7..5e55e0048 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -61,35 +61,6 @@ import kotlin.collections.ArrayDeque import kotlin.collections.ArrayList import kotlin.collections.HashMap -/** - * this method is hooked through coremod transformer - */ -fun inventoryAddItemHook(inventory: Inventory, item: ItemStack) { - if (item.isEmpty) { - return - } - - val it = inventory.player.matteryPlayer ?: return - - if (!it.hasExoSuit) { - return - } - - val leftover = it.exoSuitContainer.addItem(item, false) - item.count = leftover.count -} - -/** - * this method is hooked through coremod transformer - */ -fun inventoryAddDamagedItemHook(determinedSlot: Int, inventory: Inventory, item: ItemStack) { - if (determinedSlot > 0) { - return - } - - inventoryAddItemHook(inventory, item) -} - @Suppress("unused") class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerializable { private inner class PlayerMatteryContainer(size: Int) : MatteryContainer(size) { @@ -914,5 +885,36 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } } + + /** + * this method is hooked through coremod transformer + */ + @JvmStatic + fun inventoryAddItemHook(inventory: Inventory, item: ItemStack) { + if (item.isEmpty) { + return + } + + val it = inventory.player.matteryPlayer ?: return + + if (!it.hasExoSuit) { + return + } + + val leftover = it.exoSuitContainer.addItem(item, false) + item.count = leftover.count + } + + /** + * this method is hooked through coremod transformer + */ + @JvmStatic + fun inventoryAddDamagedItemHook(determinedSlot: Int, inventory: Inventory, item: ItemStack) { + if (determinedSlot > 0) { + return + } + + inventoryAddItemHook(inventory, item) + } } } diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 7edb145e0..c16b73327 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -493,7 +493,7 @@ function injectInventoryInsertHook( // dispatching hook method next = new MethodInsnNode( opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapabilityKt', + 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', hookName, hookDesc, false