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 6d7ed4b3b..20d101fd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.capability import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.model.PlayerModel @@ -98,7 +99,6 @@ import ru.dbotthepony.mc.otm.core.nbt.getIntList import ru.dbotthepony.mc.otm.core.nbt.getStringList import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.IntValueCodec -import ru.dbotthepony.mc.otm.core.util.ItemStackSorter import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.RGBCodec import ru.dbotthepony.mc.otm.core.util.Savetables @@ -302,9 +302,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial value.addFilterSynchronizer(synchronizer) field = value - _combinedInventory = CombinedContainer(wrappedInventory, exopackContainer) - _combinedInventory2 = CombinedContainer(wrappedItemInventory, exopackContainer) - _combinedInventory3 = CombinedContainer.Builder().add(wrappedItemInventory, 9 .. 35).add(exopackContainer).build() + _combinedInventory = null + _combinedInventory2 = null + _combinedInventory3 = null } private var _combinedInventory: CombinedContainer? = null @@ -351,7 +351,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val inventoryAndExopackNoHotbar: CombinedContainer get() { if (_combinedInventory3 == null) - _combinedInventory3 = CombinedContainer.Builder().add(wrappedItemInventory, 9 .. 35).add(exopackContainer).build() + _combinedInventory3 = CombinedContainer.Builder() + .add(wrappedItemInventory, 9 .. 35) + .add(exopackContainer).build() return _combinedInventory3!! } @@ -1375,9 +1377,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ fun inventoryAddImpl(stack: ItemStack): Boolean { if (hasExopack) { - inventoryAndExopack.consumeItem(stack, false, popTime = 5) + combinedInventory.consumeItem(stack, false, slots = IntSet.of(ply.inventory.selected), onlyIntoExisting = true, popTime = 5) + combinedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = true, popTime = 5) + inventoryAndExopack.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } else { - wrappedItemInventory.consumeItem(stack, false, popTime = 5) + wrappedInventory.consumeItem(stack, false, slots = IntSet.of(ply.inventory.selected), onlyIntoExisting = false, popTime = 5) + wrappedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = false, popTime = 5) + wrappedItemInventory.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this)) @@ -1412,6 +1418,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial @Suppress("unused") companion object { + private val offhandSlotRange = IntSet.of(40) + private fun setExoPack(players: Collection, hasExoPack: Boolean): Int { for (player in players) { player.matteryPlayer?.hasExopack = hasExoPack