Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix action sync #94

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/main/java/org/rev317/min/api/methods/Menu.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.rev317.min.api.methods;

import org.parabot.core.Context;
import org.parabot.core.GameSync;
import org.rev317.min.Loader;
import org.rev317.min.accessors.Client;
import org.rev317.min.api.methods.utils.Settings;
Expand All @@ -10,7 +11,7 @@
import java.util.HashMap;

/**
* @author JKetelaar, Everel
* @author JKetelaar, Everel, Matt123337
*/
public class Menu {

Expand Down Expand Up @@ -316,15 +317,22 @@ public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int inde
*/
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) {
Client client = Loader.getClient();
//TODO Just a heads up, by doing this only one action can be sent per-tick, so you might want to convert all the sendAction methods to vararg methods or something
// On the bright side no-more de-syncing the client :)
GameSync.lock();
try{

client.getMenuAction1()[index] = cmd1;
client.getMenuAction2()[index] = cmd2;
client.getMenuAction3()[index] = cmd3;
if (Game.hasAction4()) {
client.getMenuAction4()[index] = cmd4;
}
client.getMenuActionId()[index] = action;

client.getMenuAction1()[index] = cmd1;
client.getMenuAction2()[index] = cmd2;
client.getMenuAction3()[index] = cmd3;
if (Game.hasAction4()) {
client.getMenuAction4()[index] = cmd4;
client.doAction(index);
}finally{
GameSync.unlock();
}
client.getMenuActionId()[index] = action;

client.doAction(index);
}
}