diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index ca497bbfe..37d98e6fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -25,7 +25,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.event.network.CustomPayloadEvent -import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType @@ -298,6 +297,11 @@ abstract class MatteryMenu( open inner class EquipmentSlot(container: Container, index: Int, val type: net.minecraft.world.entity.EquipmentSlot) : InventorySlot(container, index) { constructor(type: net.minecraft.world.entity.EquipmentSlot) : this(inventory, 34 + type.ordinal, type) + override fun setByPlayer(newItem: ItemStack, oldItem: ItemStack) { + inventory.player.onEquipItem(type, oldItem, newItem) + super.setByPlayer(newItem, oldItem) + } + override fun mayPlace(itemStack: ItemStack): Boolean { return super.mayPlace(itemStack) && itemStack.canEquip(type, inventory.player) } @@ -322,6 +326,11 @@ abstract class MatteryMenu( autoCreateInventoryFrame = autoFrame offhandSlot = object : InventorySlot(inventory, 40) { + override fun setByPlayer(newItem: ItemStack, oldItem: ItemStack) { + inventory.player.onEquipItem(net.minecraft.world.entity.EquipmentSlot.OFFHAND, oldItem, newItem) + super.setByPlayer(newItem, oldItem) + } + override fun getNoItemIcon(): Pair { return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD) }