Compare commits
No commits in common. "46e00cea976e4ea1b3f1fa6cb413b3bfeba2aab2" and "7447c89394196f617771d60de34c1fcc69010636" have entirely different histories.
46e00cea97
...
7447c89394
|
@ -205,7 +205,7 @@ abstract class AbstractTerminalScreenHandler<T: AbstractTerminalBlockEntity>(
|
||||||
} else if (isPlayerSlot(slotId)) {
|
} else if (isPlayerSlot(slotId)) {
|
||||||
val slotsInsertedInto = tryInsertItem(slot.stack, bufferSlotsStart until playerSlotsStart) { terminal.internalBuffer.getMode(it - bufferSlotsStart) != TerminalBufferInventory.Mode.FROM_NETWORK }
|
val slotsInsertedInto = tryInsertItem(slot.stack, bufferSlotsStart until playerSlotsStart) { terminal.internalBuffer.getMode(it - bufferSlotsStart) != TerminalBufferInventory.Mode.FROM_NETWORK }
|
||||||
slotsInsertedInto.forEach { terminal.internalBuffer.markSlot(it - bufferSlotsStart, TerminalBufferInventory.Mode.TO_NETWORK) }
|
slotsInsertedInto.forEach { terminal.internalBuffer.markSlot(it - bufferSlotsStart, TerminalBufferInventory.Mode.TO_NETWORK) }
|
||||||
if (slotsInsertedInto.isEmpty()) {
|
if (slot.stack.isEmpty) {
|
||||||
return ItemStack.EMPTY
|
return ItemStack.EMPTY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.shadowfacts.phycon.block.terminal
|
package net.shadowfacts.phycon.block.terminal
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity
|
import alexiil.mc.lib.attributes.item.ItemStackCollections
|
||||||
import net.minecraft.entity.player.PlayerInventory
|
import net.minecraft.entity.player.PlayerInventory
|
||||||
import net.minecraft.inventory.CraftingInventory
|
import net.minecraft.inventory.CraftingInventory
|
||||||
import net.minecraft.inventory.CraftingResultInventory
|
import net.minecraft.inventory.CraftingResultInventory
|
||||||
|
@ -94,36 +94,6 @@ class CraftingTerminalScreenHandler(
|
||||||
terminal.requestItemsForCrafting(maxAmount)
|
terminal.requestItemsForCrafting(maxAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transferSlot(player: PlayerEntity, slotId: Int): ItemStack {
|
|
||||||
if (slotId == resultSlot.id && resultSlot.hasStack()) {
|
|
||||||
val craftingResult = resultSlot.stack
|
|
||||||
val originalResult = craftingResult.copy()
|
|
||||||
|
|
||||||
// todo: CraftingScreenHandler calls onCraft, but I don't think that's necessary because onStackChanged should handle it
|
|
||||||
craftingResult.item.onCraft(craftingResult, player.world, player)
|
|
||||||
|
|
||||||
if (!insertItem(craftingResult, playerSlotsStart, playerSlotsEnd, true)) {
|
|
||||||
return ItemStack.EMPTY
|
|
||||||
}
|
|
||||||
resultSlot.onStackChanged(craftingResult, originalResult)
|
|
||||||
|
|
||||||
if (craftingResult.isEmpty) {
|
|
||||||
resultSlot.stack = ItemStack.EMPTY
|
|
||||||
}
|
|
||||||
|
|
||||||
if (craftingResult.count == originalResult.count) {
|
|
||||||
return ItemStack.EMPTY
|
|
||||||
}
|
|
||||||
|
|
||||||
val taken = resultSlot.onTakeItem(player, craftingResult)
|
|
||||||
player.dropItem(taken, false)
|
|
||||||
|
|
||||||
return originalResult
|
|
||||||
} else {
|
|
||||||
return super.transferSlot(player, slotId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RecipeType.CRAFTING wants a CraftingInventory, but we can't store a CraftingInventory on the BE without a screen handler, so...
|
// RecipeType.CRAFTING wants a CraftingInventory, but we can't store a CraftingInventory on the BE without a screen handler, so...
|
||||||
class CraftingInv(val handler: CraftingTerminalScreenHandler): CraftingInventory(handler, 3, 3) {
|
class CraftingInv(val handler: CraftingTerminalScreenHandler): CraftingInventory(handler, 3, 3) {
|
||||||
private val backing = handler.terminal.craftingInv
|
private val backing = handler.terminal.craftingInv
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:block",
|
|
||||||
"pools": [
|
|
||||||
{
|
|
||||||
"rolls": 1,
|
|
||||||
"entries": [
|
|
||||||
{
|
|
||||||
"type": "minecraft:item",
|
|
||||||
"name": "phycon:crafting_terminal"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"condition": "minecraft:survives_explosion"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue