project: Mixins

This commit is contained in:
Owain van Brakel
2021-10-30 10:16:51 +02:00
parent abf04a389f
commit 63309c2683
7 changed files with 41 additions and 38 deletions

View File

@@ -27,7 +27,7 @@ object ProjectVersions {
const val launcherVersion = "2.2.0"
const val rlVersion = "1.8.0"
const val openosrsVersion = "4.13.3"
const val openosrsVersion = "4.14.0"
const val rsversion = 200
const val cacheversion = 165

View File

@@ -77,7 +77,7 @@ public class Deob
Stopwatch stopwatch = Stopwatch.createStarted();
ClassGroup group = JarUtil.load(new File(args[0]));
ClassGroup group = JarUtil.load(new File(args[0]), true);
// remove except RuntimeException
run(group, new RuntimeExceptions());

View File

@@ -50,6 +50,11 @@ public class JarUtil
private static final Logger logger = LoggerFactory.getLogger(JarUtil.class);
public static ClassGroup load(File jarfile)
{
return load(jarfile, false);
}
public static ClassGroup load(File jarfile, boolean skip)
{
ClassGroup group = new ClassGroup();
@@ -59,7 +64,7 @@ public class JarUtil
{
JarEntry entry = it.nextElement();
if (!entry.getName().endsWith(".class"))
if (!entry.getName().endsWith(".class") || (skip && entry.getName().contains("bouncycastle")))
{
continue;
}
@@ -93,12 +98,17 @@ public class JarUtil
}
public static ClassGroup loadClasses(Collection<File> files) throws IOException
{
return loadClasses(files, false);
}
public static ClassGroup loadClasses(Collection<File> files, boolean skip) throws IOException
{
final ClassGroup group = new ClassGroup();
for (File file : files)
{
if (!file.getName().endsWith(".class"))
if (!file.getName().endsWith(".class") || (skip && file.getName().contains("bouncycastle")))
{
continue;
}

View File

@@ -1548,9 +1548,9 @@ public abstract class RSClientMixin implements RSClient
return WorldType.fromMask(flags);
}
@Inject
@MethodHook("openMenu")
public void menuOpened(int x, int y)
@Copy("openMenu")
@Replace("openMenu")
public void copy$openMenu(int x, int y)
{
final MenuOpened event = new MenuOpened();
event.setMenuEntries(getMenuEntries());
@@ -1560,6 +1560,10 @@ public abstract class RSClientMixin implements RSClient
{
setMenuEntries(event.getMenuEntries());
}
copy$openMenu(x, y);
client.getScene().menuOpen(client.getPlane(), x - client.getViewportXOffset(), y - client.getViewportYOffset(), false);
}
@Inject
@@ -2435,8 +2439,7 @@ public abstract class RSClientMixin implements RSClient
@Inject
public void setUnlockedFps(boolean unlocked)
{
// unlockedFps = unlocked;
unlockedFps = false;
unlockedFps = unlocked;
if (unlocked)
{

View File

@@ -48,15 +48,18 @@ public abstract class RSNanoClockMixin implements RSNanoClock
else
{
long nanoTime = System.nanoTime();
if (nanoTime < getLastTimeNano())
{
setLastTimeNano(nanoTime);
return 1;
}
else
{
long cycleDuration = (long) cycleDurationMillis * 1000000L;
long diff = nanoTime - getLastTimeNano();
int cycles = (int) (diff / cycleDuration);
setLastTimeNano(getLastTimeNano() + (long) cycles * cycleDuration);

View File

@@ -122,19 +122,14 @@ public abstract class RSSceneMixin implements RSScene
final boolean isGpu = client.isGpu();
final boolean checkClick = client.isCheckClick();
if (!client.isMenuOpen())
final boolean menuOpen = client.isMenuOpen();
if (!menuOpen && !checkClick)
{
// Force check click to update the selected tile
client.setCheckClick(true);
final int mouseX = client.getMouseX();
final int mouseY = client.getMouseY();
client.setMouseCanvasHoverPositionX(mouseX - client.getViewportXOffset());
client.setMouseCanvasHoverPositionY(mouseY - client.getViewportYOffset());
client.getScene().menuOpen(client.getPlane(), client.getMouseX() - client.getViewportXOffset(), client.getMouseY() - client.getViewportYOffset(), false);
}
if (!isGpu)
{
if (skyboxColor != 0)
if (!isGpu && skyboxColor != 0)
{
client.rasterizerFillRectangle(
client.getViewportXOffset(),
@@ -144,7 +139,6 @@ public abstract class RSSceneMixin implements RSScene
skyboxColor
);
}
}
final int maxX = getMaxX();
final int maxY = getMaxY();
@@ -305,7 +299,7 @@ public abstract class RSSceneMixin implements RSScene
}
}
if (!client.isMenuOpen())
if (!menuOpen)
{
rl$hoverY = -1;
rl$hoverX = -1;
@@ -408,10 +402,6 @@ public abstract class RSSceneMixin implements RSScene
client.setEntitiesAtMouseCount(0);
}
client.setCheckClick(false);
if (!checkClick)
{
client.setViewportWalking(false);
}
client.getCallbacks().drawScene();
if (client.getDrawCallbacks() != null)
@@ -497,12 +487,6 @@ public abstract class RSSceneMixin implements RSScene
client.setEntitiesAtMouseCount(0);
}
client.setCheckClick(false);
if (!checkClick)
{
// If checkClick was false, then the selected tile wouldn't have existed next tick,
// so clear viewport walking in order to prevent it triggering a walk
client.setViewportWalking(false);
}
client.getCallbacks().drawScene();
if (client.getDrawCallbacks() != null)
{

View File

@@ -85,4 +85,7 @@ public interface RSScene extends Scene
byte[][][] getTileShapes();
void setTileShapes(byte[][][] tileShapes);
@Import("menuOpen")
void menuOpen(int selectedPlane, int screenX, int screenY, boolean viewportWalking);
}