3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Restore ClickPlan double-simulation

This is used in some autocrafting situations. Oops.
Dieser Commit ist enthalten in:
Camotoy 2022-02-08 23:15:41 -05:00
Ursprung 0eed6025a6
Commit 0479af7cd3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -75,6 +75,11 @@ public final class ClickPlan {
gridSize = translator.getGridSize(); gridSize = translator.getGridSize();
} }
private void resetSimulation() {
this.simulatedItems.clear();
this.simulatedCursor = session.getPlayerInventory().getCursor().copy();
}
public void add(Click click, int slot) { public void add(Click click, int slot) {
add(click, slot, false); add(click, slot, false);
} }
@ -89,10 +94,14 @@ public final class ClickPlan {
ClickAction action = new ClickAction(click, slot, force); ClickAction action = new ClickAction(click, slot, force);
plan.add(action); plan.add(action);
// RUNNING THE SIMULATION HERE IS IMPORTANT. The contents of the simulation are used in complex, multi-stage tasks
// such as autocrafting.
simulateAction(action);
} }
public void execute(boolean refresh) { public void execute(boolean refresh) {
//update geyser inventory after simulation to avoid net id desync //update geyser inventory after simulation to avoid net id desync
resetSimulation();
ListIterator<ClickAction> planIter = plan.listIterator(); ListIterator<ClickAction> planIter = plan.listIterator();
while (planIter.hasNext()) { while (planIter.hasNext()) {
ClickAction action = planIter.next(); ClickAction action = planIter.next();
@ -190,7 +199,9 @@ public final class ClickPlan {
* Does not need to be called for the cursor * Does not need to be called for the cursor
*/ */
private void onSlotItemChange(int slot, GeyserItemStack itemStack) { private void onSlotItemChange(int slot, GeyserItemStack itemStack) {
changedItems.put(slot, itemStack.getItemStack()); if (changedItems != null) {
changedItems.put(slot, itemStack.getItemStack());
}
} }
private void simulateAction(ClickAction action) { private void simulateAction(ClickAction action) {