Fix shift-click crafting with item in hand

When shift-clicking the result item in a crafting table while holding an item in your hand, items would bug out completely and cause weird inventory desyncs.
This commit is contained in:
RednedEpic 2023-06-13 23:26:43 -05:00
parent d43a862491
commit bf5e08403c

View file

@ -525,10 +525,28 @@ public abstract class InventoryTranslator {
int remainder = transferAction.getCount() % resultSize;
int timesToCraft = transferAction.getCount() / resultSize;
for (int i = 0; i < timesToCraft; i++) {
plan.add(Click.LEFT, sourceSlot);
plan.add(Click.LEFT, destSlot);
if (plan.getCursor().isEmpty()) {
// No carried items - move to destination
for (int i = 0; i < timesToCraft; i++) {
plan.add(Click.LEFT, sourceSlot);
plan.add(Click.LEFT, destSlot);
}
} else {
GeyserItemStack cursor = session.getPlayerInventory().getCursor();
int tempSlot = findTempSlot(inventory, cursor, true, sourceSlot, destSlot);
if (tempSlot == -1) {
return rejectRequest(request);
}
plan.add(Click.LEFT, tempSlot); //place cursor into temp slot
for (int i = 0; i < timesToCraft; i++) {
plan.add(Click.LEFT, sourceSlot); //pick up source item
plan.add(Click.LEFT, destSlot); //place source item into dest slot
}
plan.add(Click.LEFT, tempSlot); //pick up original item
}
if (remainder > 0) {
plan.add(Click.LEFT, 0);
for (int i = 0; i < remainder; i++) {