Quick move in item monitor
This commit is contained in:
parent
140042bbd4
commit
1510a68d5b
@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.menu
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.block.entity.ItemMonitorBlockEntity
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewSupplier
|
||||
import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE
|
||||
import ru.dbotthepony.mc.otm.storage.ItemStackWrapper
|
||||
import ru.dbotthepony.mc.otm.storage.PoweredVirtualComponent
|
||||
import ru.dbotthepony.mc.otm.storage.VirtualComponent
|
||||
@ -29,7 +29,7 @@ class ItemMonitorMenu @JvmOverloads constructor(
|
||||
|
||||
init {
|
||||
if (tile != null) {
|
||||
subscribed = tile.cell.storageGraph!!.getVirtualComponent(OverdriveThatMatters.INSTANCE.ITEM_STORAGE())
|
||||
subscribed = tile.cell.storageGraph!!.getVirtualComponent(ITEM_STORAGE)
|
||||
local = PoweredVirtualComponent(subscribed, tile.getCapability(MatteryCapability.ENERGY).resolve().get())
|
||||
view.setComponent(local)
|
||||
} else {
|
||||
@ -61,7 +61,25 @@ class ItemMonitorMenu @JvmOverloads constructor(
|
||||
|
||||
override fun quickMoveStack(ply: Player, slot_index: Int): ItemStack {
|
||||
if (slot_index in inventorySlotIndexStart..inventorySlotIndexEnd) {
|
||||
if (tile == null) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
val slot = slots[slot_index]
|
||||
|
||||
if (slot.item.isEmpty) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
val leftover = local!!.insertStack(ItemStackWrapper(slot.item), false).stack
|
||||
|
||||
if (leftover.count == slot.item.count) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
val old = slot.item.copy()
|
||||
slot.item.count = leftover.count
|
||||
return old
|
||||
}
|
||||
|
||||
return super.quickMoveStack(ply, slot_index)
|
||||
|
Loading…
Reference in New Issue
Block a user