Fix spilling crafting grid on ground if regular (not exosuit) slots are full

This commit is contained in:
DBotThePony 2022-09-11 20:57:18 +07:00
parent 199b22dad5
commit e5d41bf456
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -10,6 +10,7 @@ import net.minecraft.world.entity.player.Player
import net.minecraft.world.inventory.*
import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.container.iterator
import ru.dbotthepony.mc.otm.network.ExoSuitCarriedPacket
import ru.dbotthepony.mc.otm.network.ExoSuitMenuInitPacket
import ru.dbotthepony.mc.otm.network.ExoSuitSlotPacket
@ -88,7 +89,17 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
craftingResultContainer.clearContent()
if (!player.level.isClientSide) {
clearContainer(player, craftingGrid)
val iterator = craftingGrid.iterator()
for (itemStack in iterator) {
val leftover = moveItemStackToSlots(itemStack, playerInventorySlots)
if (!leftover.isEmpty) {
player.drop(leftover, true)
}
iterator.remove()
}
}
}