forked from open-osrs/runelite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.openosrs.injector.injectors.raw; | ||
|
||
import com.openosrs.injector.InjectUtil; | ||
import com.openosrs.injector.injection.InjectData; | ||
import com.openosrs.injector.injectors.AbstractInjector; | ||
import java.util.ListIterator; | ||
import net.runelite.asm.ClassFile; | ||
import net.runelite.asm.Method; | ||
import net.runelite.asm.attributes.code.Instruction; | ||
import net.runelite.asm.attributes.code.Instructions; | ||
import net.runelite.asm.attributes.code.instructions.LDC; | ||
import net.runelite.asm.attributes.code.instructions.PutStatic; | ||
import net.runelite.asm.pool.Field; | ||
|
||
public class GameDrawingMode extends AbstractInjector | ||
{ | ||
public GameDrawingMode(InjectData inject) | ||
{ | ||
super(inject); | ||
} | ||
|
||
public void inject() | ||
{ | ||
final ClassFile clientVanilla = inject.toVanilla( | ||
inject.getDeobfuscated() | ||
.findClass("Client") | ||
); | ||
final Field gameDrawingMode = InjectUtil.findField(inject, "gameDrawingMode", "Client").getPoolField(); | ||
|
||
Method clinit = clientVanilla.findMethod("<clinit>"); | ||
|
||
Instructions ins = clinit.getCode().getInstructions(); | ||
ListIterator<Instruction> iterator = ins.getInstructions().listIterator(); | ||
while (iterator.hasNext()) | ||
{ | ||
Instruction i = iterator.next(); | ||
|
||
if (i instanceof PutStatic) | ||
{ | ||
Field field = ((PutStatic) i).getField(); | ||
|
||
if (field.getName().equals(gameDrawingMode.getName())) | ||
{ | ||
iterator.add(new LDC(ins, 2)); | ||
iterator.add(new PutStatic(ins, gameDrawingMode)); | ||
} | ||
} | ||
} | ||
} | ||
} |