use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class ScriptVMMixin method runScript.
@Inject
@Override
public void runScript(int id, Object... args) {
assert isClientThread();
Object[] cargs = new Object[args.length + 1];
cargs[0] = id;
System.arraycopy(args, 0, cargs, 1, args.length);
RSScriptEvent se = createScriptEvent();
se.setArguments(cargs);
runScript(se, 200000);
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class ScriptVMMixin method vmExecuteOpcode.
// Call is injected into runScript by the ScriptVM raw injector
@Inject
static boolean vmExecuteOpcode(int opcode) {
if (opcode == RUNELITE_EXECUTE) {
assert currentScript.getInstructions()[currentScriptPC] == RUNELITE_EXECUTE;
int stringStackSize = client.getStringStackSize();
String stringOp = client.getStringStack()[--stringStackSize];
client.setStringStackSize(stringStackSize);
if ("debug".equals(stringOp)) {
int intStackSize = client.getIntStackSize();
String fmt = client.getStringStack()[--stringStackSize];
StringBuffer out = new StringBuffer();
Matcher m = Pattern.compile("%(.)").matcher(fmt);
for (; m.find(); ) {
m.appendReplacement(out, "");
switch(m.group(1).charAt(0)) {
case 'i':
case 'd':
out.append(client.getIntStack()[--intStackSize]);
break;
case 's':
out.append(client.getStringStack()[--stringStackSize]);
break;
default:
out.append(m.group(0)).append("=unknown");
}
}
m.appendTail(out);
Hooks.log.debug(out.toString());
client.setStringStackSize(stringStackSize);
client.setIntStackSize(intStackSize);
return true;
}
ScriptCallbackEvent event = new ScriptCallbackEvent();
event.setScript(currentScript);
event.setEventName(stringOp);
Hooks.eventBus.post(event);
return true;
}
return false;
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSActorMixin method getInteracting.
@Inject
@Override
public Actor getInteracting() {
int i = getRSInteracting();
if (i == -1) {
return null;
}
if (i < 0x8000) {
NPC[] npcs = client.getCachedNPCs();
return npcs[i];
}
i -= 0x8000;
Player[] players = client.getCachedPlayers();
return players[i];
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSActorMixin method graphicChanged.
@FieldHook("graphic")
@Inject
public void graphicChanged(int idx) {
GraphicChanged graphicChanged = new GraphicChanged();
graphicChanged.setActor(this);
eventBus.post(graphicChanged);
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSPlayerMixin method getName.
@Inject
@Override
public String getName() {
final RSName rsName = getRsName();
if (rsName == null) {
return null;
}
String name = rsName.getName();
if (name == null) {
return null;
}
return name.replace('\u00A0', ' ');
}
Aggregations