|
6 | 6 | import generations.gg.generations.core.generationscore.common.world.level.block.entities.CookingPotBlockEntity; |
7 | 7 | import generations.gg.generations.core.generationscore.common.world.container.slots.CurryResultSlot; |
8 | 8 | import generations.gg.generations.core.generationscore.common.world.container.slots.PredicateSlotItemHandler; |
| 9 | +import net.minecraft.nbt.CompoundTag; |
9 | 10 | import net.minecraft.tags.ItemTags; |
10 | 11 | import net.minecraft.world.entity.player.Inventory; |
11 | 12 | import net.minecraft.world.entity.player.Player; |
@@ -67,36 +68,62 @@ public boolean stillValid(@NotNull Player playerIn) { |
67 | 68 |
|
68 | 69 | @Override |
69 | 70 | public @NotNull ItemStack quickMoveStack(@NotNull Player playerIn, int index) { |
70 | | - ItemStack stack = ItemStack.EMPTY; |
71 | 71 | Slot slot = this.slots.get(index); |
| 72 | + if (!slot.hasItem()) return ItemStack.EMPTY; |
72 | 73 |
|
73 | | - if (slot.hasItem()) { |
74 | | - ItemStack slotStack = slot.getItem(); |
75 | | - stack = slotStack.copy(); |
76 | | - |
77 | | - if (index < 14) { |
78 | | - if (!this.moveItemStackTo(slotStack, 14, 49, false)) return ItemStack.EMPTY; |
79 | | - if (index == 13) slot.onQuickCraft(slotStack, stack); |
80 | | - } else if (index < 50) { |
81 | | - if (isBerryOrMaxMushrooms(stack)) { |
82 | | - if (!this.moveItemStackTo(slotStack, 0, 10, false)) return ItemStack.EMPTY; |
83 | | - } else if (isBowl(stack)) { |
84 | | - if (!this.moveItemStackTo(slotStack, 10, 11, false)) return ItemStack.EMPTY; |
85 | | - } else if (isCurryIngredientOrMaxHoney(stack)) { |
86 | | - if (!this.moveItemStackTo(slotStack, 11, 12, false)) return ItemStack.EMPTY; |
87 | | - } else if (isLog(stack)) { |
88 | | - if (!this.moveItemStackTo(slotStack, 12, 13, false)) return ItemStack.EMPTY; |
89 | | - } |
| 74 | + ItemStack slotStack = slot.getItem(); |
| 75 | + ItemStack originalStack = slotStack.copy(); // Copy to retain original data |
| 76 | + |
| 77 | + // Store NBT for debugging before we move it |
| 78 | + CompoundTag originalNBT = slotStack.hasTag() ? slotStack.getTag().copy() : null; |
| 79 | + |
| 80 | + // Debug Log: Initial State |
| 81 | + System.out.println("[DEBUG] Shift-Click Event:"); |
| 82 | + System.out.println(" - Clicked Slot Index: " + index); |
| 83 | + System.out.println(" - Original Stack: " + originalStack); |
| 84 | + System.out.println(" - Original NBT: " + (originalNBT != null ? originalNBT : "None")); |
| 85 | + |
| 86 | + boolean moved = false; |
| 87 | + |
| 88 | + // If the slot is the crafting output (slot 13), ensure crafting logic is applied before moving |
| 89 | + if (index == 13) { |
| 90 | + System.out.println(" - Crafting Slot Detected! Running `onTake()` before moving."); |
| 91 | + slot.onTake(playerIn, slotStack); |
| 92 | + } |
| 93 | + |
| 94 | + if (index < 14) { |
| 95 | + this.moveItemStackTo(slotStack, 14, 49, false); |
| 96 | + } else if (index < 50) { |
| 97 | + if (isBerryOrMaxMushrooms(originalStack)) { |
| 98 | + this.moveItemStackTo(slotStack, 0, 10, false); |
| 99 | + } else if (isBowl(originalStack)) { |
| 100 | + this.moveItemStackTo(slotStack, 10, 11, false); |
| 101 | + } else if (isCurryIngredientOrMaxHoney(originalStack)) { |
| 102 | + this.moveItemStackTo(slotStack, 11, 12, false); |
| 103 | + } else if (isLog(originalStack)) { |
| 104 | + this.moveItemStackTo(slotStack, 12, 13, false); |
90 | 105 | } |
| 106 | + } |
| 107 | + |
| 108 | + if (!ItemStack.matches(slotStack, originalStack)) { |
| 109 | + slotStack.setTag(originalNBT); |
| 110 | + } |
91 | 111 |
|
92 | | - if (slotStack.getCount() == 0) slot.safeInsert(ItemStack.EMPTY); |
93 | | - else slot.setChanged(); |
| 112 | + if (slotStack.getCount() == 0) { |
| 113 | + slot.safeInsert(ItemStack.EMPTY); |
| 114 | + } else { |
| 115 | + slot.setChanged(); |
| 116 | + } |
| 117 | + |
| 118 | + if (slotStack.getCount() == originalStack.getCount()) { |
| 119 | + return ItemStack.EMPTY; |
| 120 | + } |
94 | 121 |
|
95 | | - if (slotStack.getCount() == stack.getCount()) return ItemStack.EMPTY; |
96 | | - slot.onTake(playerIn, stack); |
| 122 | + if (index == 13) { |
| 123 | + slot.onTake(playerIn, originalStack); |
97 | 124 | } |
98 | 125 |
|
99 | | - return stack; |
| 126 | + return originalStack; |
100 | 127 | } |
101 | 128 |
|
102 | 129 | public static boolean isLog(ItemStack stack) { |
|
0 commit comments