Restore vanilla behavior regarding picking up items
This commit is contained in:
parent
967b8c71d8
commit
9bebe74282
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.capability
|
|||||||
import com.mojang.blaze3d.systems.RenderSystem
|
import com.mojang.blaze3d.systems.RenderSystem
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import it.unimi.dsi.fastutil.ints.IntAVLTreeSet
|
import it.unimi.dsi.fastutil.ints.IntAVLTreeSet
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntSet
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
|
||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.client.model.PlayerModel
|
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.getStringList
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
import ru.dbotthepony.mc.otm.core.util.IntValueCodec
|
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.ItemValueCodec
|
||||||
import ru.dbotthepony.mc.otm.core.util.RGBCodec
|
import ru.dbotthepony.mc.otm.core.util.RGBCodec
|
||||||
import ru.dbotthepony.mc.otm.core.util.Savetables
|
import ru.dbotthepony.mc.otm.core.util.Savetables
|
||||||
@ -302,9 +302,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
value.addFilterSynchronizer(synchronizer)
|
value.addFilterSynchronizer(synchronizer)
|
||||||
field = value
|
field = value
|
||||||
|
|
||||||
_combinedInventory = CombinedContainer(wrappedInventory, exopackContainer)
|
_combinedInventory = null
|
||||||
_combinedInventory2 = CombinedContainer(wrappedItemInventory, exopackContainer)
|
_combinedInventory2 = null
|
||||||
_combinedInventory3 = CombinedContainer.Builder().add(wrappedItemInventory, 9 .. 35).add(exopackContainer).build()
|
_combinedInventory3 = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private var _combinedInventory: CombinedContainer? = null
|
private var _combinedInventory: CombinedContainer? = null
|
||||||
@ -351,7 +351,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
val inventoryAndExopackNoHotbar: CombinedContainer
|
val inventoryAndExopackNoHotbar: CombinedContainer
|
||||||
get() {
|
get() {
|
||||||
if (_combinedInventory3 == null)
|
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!!
|
return _combinedInventory3!!
|
||||||
}
|
}
|
||||||
@ -1375,9 +1377,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
*/
|
*/
|
||||||
fun inventoryAddImpl(stack: ItemStack): Boolean {
|
fun inventoryAddImpl(stack: ItemStack): Boolean {
|
||||||
if (hasExopack) {
|
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 {
|
} 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))
|
MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this))
|
||||||
@ -1412,6 +1418,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
companion object {
|
companion object {
|
||||||
|
private val offhandSlotRange = IntSet.of(40)
|
||||||
|
|
||||||
private fun setExoPack(players: Collection<Player>, hasExoPack: Boolean): Int {
|
private fun setExoPack(players: Collection<Player>, hasExoPack: Boolean): Int {
|
||||||
for (player in players) {
|
for (player in players) {
|
||||||
player.matteryPlayer?.hasExopack = hasExoPack
|
player.matteryPlayer?.hasExopack = hasExoPack
|
||||||
|
Loading…
Reference in New Issue
Block a user