3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-03 08:21:06 +02:00

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.
Dieser Commit ist enthalten in:
RednedEpic 2023-06-13 23:26:43 -05:00
Ursprung d43a862491
Commit bf5e08403c

Datei anzeigen

@ -525,10 +525,28 @@ public abstract class InventoryTranslator {
int remainder = transferAction.getCount() % resultSize; int remainder = transferAction.getCount() % resultSize;
int timesToCraft = transferAction.getCount() / resultSize; int timesToCraft = transferAction.getCount() / resultSize;
if (plan.getCursor().isEmpty()) {
// No carried items - move to destination
for (int i = 0; i < timesToCraft; i++) { for (int i = 0; i < timesToCraft; i++) {
plan.add(Click.LEFT, sourceSlot); plan.add(Click.LEFT, sourceSlot);
plan.add(Click.LEFT, destSlot); 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) { if (remainder > 0) {
plan.add(Click.LEFT, 0); plan.add(Click.LEFT, 0);
for (int i = 0; i < remainder; i++) { for (int i = 0; i < remainder; i++) {