Merge pull request #3194 from open-osrs/edging-with-the-injector
This commit is contained in:
@@ -457,17 +457,22 @@ public class MixinInjector extends AbstractInjector
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
Method copy = new Method(targetClass, mixinMethod.getName(), mixinMethod.getDescriptor());
|
Method method = targetClass.findMethod(mixinMethod.getName(), mixinMethod.getDescriptor());
|
||||||
moveCode(copy, mixinMethod.getCode());
|
|
||||||
copy.setAccessFlags(mixinMethod.getAccessFlags());
|
if (method == null)
|
||||||
copy.setPublic();
|
{
|
||||||
|
method = new Method(targetClass, mixinMethod.getName(), mixinMethod.getDescriptor());
|
||||||
|
targetClass.addMethod(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
moveCode(method, mixinMethod.getCode());
|
||||||
|
method.setAccessFlags(mixinMethod.getAccessFlags());
|
||||||
|
method.setPublic();
|
||||||
assert mixinMethod.getExceptions().getExceptions().isEmpty();
|
assert mixinMethod.getExceptions().getExceptions().isEmpty();
|
||||||
|
|
||||||
setOwnersToTargetClass(mixinClass, targetClass, copy, copiedMethods);
|
setOwnersToTargetClass(mixinClass, targetClass, method, copiedMethods);
|
||||||
|
|
||||||
targetClass.addMethod(copy);
|
log.debug("[DEBUG] Injected mixin method {} to {}", method, targetClass);
|
||||||
|
|
||||||
log.debug("[DEBUG] Injected mixin method {} to {}", copy, targetClass);
|
|
||||||
++injected;
|
++injected;
|
||||||
}
|
}
|
||||||
else if (mixinMethod.findAnnotation(REPLACE) != null)
|
else if (mixinMethod.findAnnotation(REPLACE) != null)
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ package com.openosrs.injector.injectors.raw;
|
|||||||
import com.openosrs.injector.InjectUtil;
|
import com.openosrs.injector.InjectUtil;
|
||||||
import com.openosrs.injector.injection.InjectData;
|
import com.openosrs.injector.injection.InjectData;
|
||||||
import com.openosrs.injector.injectors.AbstractInjector;
|
import com.openosrs.injector.injectors.AbstractInjector;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
import java.util.Set;
|
||||||
import net.runelite.asm.ClassFile;
|
import net.runelite.asm.ClassFile;
|
||||||
import net.runelite.asm.Field;
|
import net.runelite.asm.Field;
|
||||||
import net.runelite.asm.Method;
|
import net.runelite.asm.Method;
|
||||||
@@ -43,6 +45,9 @@ public class CopyRuneLiteClasses extends AbstractInjector
|
|||||||
"RuneLiteObject"
|
"RuneLiteObject"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
private final Set<Type> shadowFields = new HashSet<>();
|
||||||
|
|
||||||
public CopyRuneLiteClasses(InjectData inject)
|
public CopyRuneLiteClasses(InjectData inject)
|
||||||
{
|
{
|
||||||
super(inject);
|
super(inject);
|
||||||
@@ -52,6 +57,8 @@ public class CopyRuneLiteClasses extends AbstractInjector
|
|||||||
{
|
{
|
||||||
for (String className : RUNELITE_OBJECTS)
|
for (String className : RUNELITE_OBJECTS)
|
||||||
{
|
{
|
||||||
|
shadowFields.clear();
|
||||||
|
|
||||||
ClassFile runeliteObjectVanilla = inject.vanilla.findClass(className);
|
ClassFile runeliteObjectVanilla = inject.vanilla.findClass(className);
|
||||||
|
|
||||||
final ClassFile runeLiteDeob = inject.getDeobfuscated()
|
final ClassFile runeLiteDeob = inject.getDeobfuscated()
|
||||||
@@ -85,21 +92,21 @@ public class CopyRuneLiteClasses extends AbstractInjector
|
|||||||
runeliteObjectVanilla.getInterfaces().addInterface(interfaze);
|
runeliteObjectVanilla.getInterfaces().addInterface(interfaze);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Field field : runeLiteDeob.getFields())
|
|
||||||
{
|
|
||||||
field.setType(InjectUtil.deobToVanilla(inject, field.getType()));
|
|
||||||
runeliteObjectVanilla.addField(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Method method : runeLiteDeob.getMethods())
|
for (Method method : runeLiteDeob.getMethods())
|
||||||
{
|
{
|
||||||
if (className.equals("RuneLiteMenuEntry") && (method.getName().equals("getItemId") || method.getName().equals("getWidget") || method.getName().equals("getItemOp")))
|
transformMethod(method);
|
||||||
|
runeliteObjectVanilla.addMethod(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Field field : runeLiteDeob.getFields())
|
||||||
|
{
|
||||||
|
if (shadowFields.contains(field.getType()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
transformMethod(method);
|
field.setType(InjectUtil.deobToVanilla(inject, field.getType()));
|
||||||
runeliteObjectVanilla.addMethod(method);
|
runeliteObjectVanilla.addField(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
inject.vanilla.addClass(runeliteObjectVanilla);
|
inject.vanilla.addClass(runeliteObjectVanilla);
|
||||||
@@ -170,7 +177,16 @@ public class CopyRuneLiteClasses extends AbstractInjector
|
|||||||
net.runelite.asm.pool.Field field = ((GetStatic) i).getField();
|
net.runelite.asm.pool.Field field = ((GetStatic) i).getField();
|
||||||
Field vanilla = findField(field);
|
Field vanilla = findField(field);
|
||||||
|
|
||||||
if (vanilla != null)
|
if (method.getClassFile().getName().equals(field.getClazz().getName()) && field.getType().toString().contains("Lnet/runelite/rs/api/RS"))
|
||||||
|
{
|
||||||
|
shadowFields.add(field.getType());
|
||||||
|
|
||||||
|
String fieldName = field.getType().toString().replace("Lnet/runelite/rs/api/RS", "").replace(";", "");
|
||||||
|
final Field deobTargetField = InjectUtil.findStaticField(inject, fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1), null, InjectUtil.apiToDeob(inject, field.getType()));
|
||||||
|
|
||||||
|
iterator.set(new GetStatic(ins, inject.toVanilla(deobTargetField)));
|
||||||
|
}
|
||||||
|
else if (vanilla != null)
|
||||||
{
|
{
|
||||||
iterator.set(new GetStatic(ins, vanilla));
|
iterator.set(new GetStatic(ins, vanilla));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,142 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, OpenOSRS
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.mixins;
|
|
||||||
|
|
||||||
import net.runelite.api.MenuAction;
|
|
||||||
import net.runelite.api.mixins.Inject;
|
|
||||||
import net.runelite.api.mixins.Mixin;
|
|
||||||
import net.runelite.api.mixins.Shadow;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
|
||||||
import net.runelite.rs.api.RSClient;
|
|
||||||
import net.runelite.rs.api.RSRuneLiteMenuEntry;
|
|
||||||
|
|
||||||
@Mixin(RSRuneLiteMenuEntry.class)
|
|
||||||
public abstract class RuneLiteMenuEntryMixin implements RSRuneLiteMenuEntry
|
|
||||||
{
|
|
||||||
@Shadow("client")
|
|
||||||
private static RSClient client;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
@Override
|
|
||||||
public int getItemOp()
|
|
||||||
{
|
|
||||||
MenuAction var1 = this.getType();
|
|
||||||
if (var1 == MenuAction.CC_OP || var1 == MenuAction.CC_OP_LOW_PRIORITY)
|
|
||||||
{
|
|
||||||
int identifier = this.getIdentifier();
|
|
||||||
int param0 = this.getParam0();
|
|
||||||
int param1 = this.getParam1();
|
|
||||||
|
|
||||||
if (param1 == 9764864)
|
|
||||||
{
|
|
||||||
switch (identifier)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
Widget widget = client.getWidget(param1);
|
|
||||||
if (widget != null && param0 != -1)
|
|
||||||
{
|
|
||||||
widget = widget.getChild(param0);
|
|
||||||
if (widget != null && widget.getItemId() > -1)
|
|
||||||
{
|
|
||||||
int shiftClickActionIndex = client.getItemComposition(widget.getItemId()).getShiftClickActionIndex();
|
|
||||||
|
|
||||||
if (shiftClickActionIndex >= 0)
|
|
||||||
{
|
|
||||||
return shiftClickActionIndex + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
return 1;
|
|
||||||
case 3:
|
|
||||||
return 2;
|
|
||||||
case 4:
|
|
||||||
return 3;
|
|
||||||
case 5:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
return 4;
|
|
||||||
case 7:
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
@Override
|
|
||||||
public int getItemId()
|
|
||||||
{
|
|
||||||
MenuAction menuAction = this.getType();
|
|
||||||
if (menuAction == MenuAction.CC_OP || menuAction == MenuAction.CC_OP_LOW_PRIORITY)
|
|
||||||
{
|
|
||||||
int param1 = this.getParam1();
|
|
||||||
int param0 = this.getParam0();
|
|
||||||
|
|
||||||
if (param1 == 9764864)
|
|
||||||
{
|
|
||||||
Widget widget = client.getWidget(param1);
|
|
||||||
if (param0 != -1)
|
|
||||||
{
|
|
||||||
widget = widget.getChild(param0);
|
|
||||||
return widget.getItemId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
@Override
|
|
||||||
public Widget getWidget()
|
|
||||||
{
|
|
||||||
int param1 = this.getParam1();
|
|
||||||
int param0 = this.getParam0();
|
|
||||||
|
|
||||||
Widget widget = client.getWidget(param1);
|
|
||||||
|
|
||||||
if (widget == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (param0 != -1)
|
|
||||||
{
|
|
||||||
Widget child = widget.getChild(param0);
|
|
||||||
|
|
||||||
if (child != null)
|
|
||||||
{
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,6 +27,7 @@ group = "com.openosrs.rs"
|
|||||||
description = "RuneScape Client"
|
description = "RuneScape Client"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
api(project(":runescape-api"))
|
||||||
api(project(":runelite-api"))
|
api(project(":runelite-api"))
|
||||||
|
|
||||||
implementation(project(":injection-annotations"))
|
implementation(project(":injection-annotations"))
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ import java.util.function.Consumer;
|
|||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
|
import net.runelite.rs.api.RSClient;
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
|
|
||||||
public class RuneLiteMenuEntry implements MenuEntry
|
public class RuneLiteMenuEntry implements MenuEntry
|
||||||
{
|
{
|
||||||
|
private static RSClient client;
|
||||||
|
|
||||||
public Consumer consumer;
|
public Consumer consumer;
|
||||||
public int idx;
|
public int idx;
|
||||||
|
|
||||||
@@ -328,14 +331,15 @@ public class RuneLiteMenuEntry implements MenuEntry
|
|||||||
@Override
|
@Override
|
||||||
public boolean isItemOp()
|
public boolean isItemOp()
|
||||||
{
|
{
|
||||||
MenuAction var1 = this.getType();
|
MenuAction menuAction = this.getType();
|
||||||
if (var1 == MenuAction.CC_OP || var1 == MenuAction.CC_OP_LOW_PRIORITY)
|
if (menuAction == MenuAction.CC_OP || menuAction == MenuAction.CC_OP_LOW_PRIORITY)
|
||||||
{
|
{
|
||||||
int var2 = this.getIdentifier();
|
int identifier = this.getIdentifier();
|
||||||
int var3 = this.getParam1();
|
int param1 = this.getParam1();
|
||||||
if (var3 == 9764864)
|
|
||||||
|
if (param1 == 9764864)
|
||||||
{
|
{
|
||||||
switch (var2)
|
switch (identifier)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@@ -355,19 +359,100 @@ public class RuneLiteMenuEntry implements MenuEntry
|
|||||||
@Override
|
@Override
|
||||||
public int getItemOp()
|
public int getItemOp()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
MenuAction menuAction = this.getType();
|
||||||
|
if (menuAction == MenuAction.CC_OP || menuAction == MenuAction.CC_OP_LOW_PRIORITY)
|
||||||
|
{
|
||||||
|
int identifier = this.getIdentifier();
|
||||||
|
int param0 = this.getParam0();
|
||||||
|
int param1 = this.getParam1();
|
||||||
|
|
||||||
|
if (param1 == 9764864)
|
||||||
|
{
|
||||||
|
switch (identifier)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
Widget widget = client.getWidget(param1);
|
||||||
|
if (widget != null && param0 != -1)
|
||||||
|
{
|
||||||
|
widget = widget.getChild(param0);
|
||||||
|
if (widget != null && widget.getItemId() > -1)
|
||||||
|
{
|
||||||
|
int shiftClickActionIndex = client.getItemComposition(widget.getItemId()).getShiftClickActionIndex();
|
||||||
|
|
||||||
|
if (shiftClickActionIndex >= 0)
|
||||||
|
{
|
||||||
|
return shiftClickActionIndex + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return 1;
|
||||||
|
case 3:
|
||||||
|
return 2;
|
||||||
|
case 4:
|
||||||
|
return 3;
|
||||||
|
case 5:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
return 4;
|
||||||
|
case 7:
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemId()
|
public int getItemId()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
MenuAction menuAction = this.getType();
|
||||||
|
if (menuAction == MenuAction.CC_OP || menuAction == MenuAction.CC_OP_LOW_PRIORITY)
|
||||||
|
{
|
||||||
|
int param1 = this.getParam1();
|
||||||
|
int param0 = this.getParam0();
|
||||||
|
|
||||||
|
if (param1 == 9764864)
|
||||||
|
{
|
||||||
|
Widget widget = client.getWidget(param1);
|
||||||
|
if (param0 != -1)
|
||||||
|
{
|
||||||
|
widget = widget.getChild(param0);
|
||||||
|
return widget.getItemId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Widget getWidget()
|
public Widget getWidget()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
int param1 = this.getParam1();
|
||||||
|
int param0 = this.getParam0();
|
||||||
|
|
||||||
|
Widget widget = client.getWidget(param1);
|
||||||
|
|
||||||
|
if (widget == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param0 != -1)
|
||||||
|
{
|
||||||
|
Widget child = widget.getChild(param0);
|
||||||
|
|
||||||
|
if (child != null)
|
||||||
|
{
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user