Get rid of top hook declaration

This commit is contained in:
DBotThePony 2022-10-10 23:18:18 +07:00
parent a4a965b33c
commit 6cee8e4acf
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 32 additions and 30 deletions

View File

@ -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<CompoundTag> {
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)
}
}
}

View File

@ -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