Remove runescape-api and mixins

This code is used by internal tooling to build the client patch, which
is already closed source, and is not directly shipped as a dependency.

Outside contributions to it are rare due to the lack of build tools, and it is
primarily being abused by others. As such, I no longer wish to release
further changes to it under BSD-2.
This commit is contained in:
Adam
2019-07-07 18:22:06 -04:00
parent 83660849cb
commit 05c6743cb0
181 changed files with 0 additions and 17600 deletions

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Indicates a copy of the specified method should be copied into
* the target class.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface Copy
{
/**
* Method to copy
*
* @return
*/
String value();
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface FieldHook
{
String value();
boolean before() default false;
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
public @interface Inject
{
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface MethodHook
{
String value();
boolean end() default false;
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Repeatable(Mixins.class)
public @interface Mixin
{
/**
* Class to inject this mixin into
*
* @return
*/
Class<?> value();
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Mixins
{
Mixin[] value();
}

View File

@@ -1,47 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Replaces the existing method in the target class with the given method.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface Replace
{
/**
* Method to replace
*
* @return
*/
String value();
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Shadow
{
String value();
}

View File

@@ -1,112 +0,0 @@
/*
* Copyright (c) 2018 Abex
* 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.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
@Mixin(RSClient.class)
public abstract class CameraMixin implements RSClient
{
private static final int STANDARD_PITCH_MAX = 383;
private static final int NEW_PITCH_MAX = 512;
@Shadow("clientInstance")
static RSClient client;
@Inject
static boolean pitchRelaxEnabled = false;
@Inject
static int lastPitch = 128;
@Inject
static int lastPitchTarget = 128;
@Inject
public void setCameraPitchRelaxerEnabled(boolean enabled)
{
if (pitchRelaxEnabled == enabled)
{
return;
}
pitchRelaxEnabled = enabled;
if (!enabled)
{
int pitch = client.getCameraPitchTarget();
if (pitch > STANDARD_PITCH_MAX)
{
client.setCameraPitchTarget(STANDARD_PITCH_MAX);
}
}
}
@FieldHook("cameraPitchTarget")
@Inject
static void onCameraPitchTargetChanged(int idx)
{
int newPitch = client.getCameraPitchTarget();
int pitch = newPitch;
if (pitchRelaxEnabled)
{
// This works because the vanilla camera movement code only moves %2
if (lastPitchTarget > STANDARD_PITCH_MAX && newPitch == STANDARD_PITCH_MAX)
{
pitch = lastPitchTarget;
if (pitch > NEW_PITCH_MAX)
{
pitch = NEW_PITCH_MAX;
}
client.setCameraPitchTarget(pitch);
}
}
lastPitchTarget = pitch;
}
@FieldHook("cameraPitch")
@Inject
static void onCameraPitchChanged(int idx)
{
int newPitch = client.getCameraPitch();
int pitch = newPitch;
if (pitchRelaxEnabled)
{
// This works because the vanilla camera movement code only moves %2
if (lastPitch > STANDARD_PITCH_MAX && newPitch == STANDARD_PITCH_MAX)
{
pitch = lastPitch;
if (pitch > NEW_PITCH_MAX)
{
pitch = NEW_PITCH_MAX;
}
client.setCameraPitch(pitch);
}
}
lastPitch = pitch;
}
}

View File

@@ -1,320 +0,0 @@
package net.runelite.mixins;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSModel;
/**
* Class to check clickboxes of models. Mostly refactored code from the client.
*/
@Mixin(RSClient.class)
public abstract class ClickboxMixin implements RSClient
{
@Shadow("clientInstance")
private static RSClient client;
private static final int MAX_ENTITES_AT_MOUSE = 1000;
private static final int CLICKBOX_CLOSE = 50;
private static final int CLICKBOX_FAR = 3500;
private static final int OBJECT_INTERACTION_FAR = 35; // Max distance, in tiles, from camera
@Inject
private static final int[] rl$modelViewportXs = new int[4700];
@Inject
private static final int[] rl$modelViewportYs = new int[4700];
@Inject
public void checkClickbox(Model rlModel, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int _x, int _y, int _z, long hash)
{
RSModel model = (RSModel) rlModel;
boolean hasFlag = hash != 0L && (int) (hash >>> 16 & 1L) != 1;
boolean viewportContainsMouse = client.getViewportContainsMouse();
if (!hasFlag || !viewportContainsMouse || client.getOculusOrbState() != 0)
{
return;
}
boolean bb = boundingboxCheck(model, _x, _y, _z);
if (!bb)
{
return;
}
if (Math.sqrt(_x * _x + _z * _z) > OBJECT_INTERACTION_FAR * Perspective.LOCAL_TILE_SIZE)
{
return;
}
// only need a boundingbox check?
if (model.isClickable())
{
addHashAtMouse(hash);
return;
}
// otherwise we must check if the mouse is in a triangle
final int vertexCount = model.getVerticesCount();
final int triangleCount = model.getTrianglesCount();
final int[] vertexX = model.getVerticesX();
final int[] vertexY = model.getVerticesY();
final int[] vertexZ = model.getVerticesZ();
final int[] triangleX = model.getTrianglesX();
final int[] triangleY = model.getTrianglesY();
final int[] triangleZ = model.getTrianglesZ();
final int[] color3 = model.getFaceColors3();
final int zoom = client.get3dZoom();
final int centerX = client.getCenterX();
final int centerY = client.getCenterY();
int sin = 0;
int cos = 0;
if (orientation != 0)
{
sin = Perspective.SINE[orientation];
cos = Perspective.COSINE[orientation];
}
for (int i = 0; i < vertexCount; ++i)
{
int x = vertexX[i];
int y = vertexY[i];
int z = vertexZ[i];
int var42;
if (orientation != 0)
{
var42 = z * sin + x * cos >> 16;
z = z * cos - x * sin >> 16;
x = var42;
}
x += _x;
y += _y;
z += _z;
var42 = z * yawSin + yawCos * x >> 16;
z = yawCos * z - x * yawSin >> 16;
x = var42;
var42 = pitchCos * y - z * pitchSin >> 16;
z = y * pitchSin + pitchCos * z >> 16;
if (z >= 50)
{
rl$modelViewportYs[i] = x * zoom / z + centerX;
rl$modelViewportXs[i] = var42 * zoom / z + centerY;
}
else
{
rl$modelViewportYs[i] = -5000;
}
}
final int viewportMouseX = client.getViewportMouseX();
final int viewportMouseY = client.getViewportMouseY();
for (int i = 0; i < triangleCount; ++i)
{
if (color3[i] == -2)
{
continue;
}
final int vA = triangleX[i];
final int vB = triangleY[i];
final int vC = triangleZ[i];
int y1 = rl$modelViewportYs[vA];
int y2 = rl$modelViewportYs[vB];
int y3 = rl$modelViewportYs[vC];
int x1 = rl$modelViewportXs[vA];
int x2 = rl$modelViewportXs[vB];
int x3 = rl$modelViewportXs[vC];
if (y1 == -5000 || y2 == -5000 || y3 == -5000)
{
continue;
}
final int radius = model.isClickable() ? 20 : 5;
int var18 = radius + viewportMouseY;
boolean var34;
if (var18 < x1 && var18 < x2 && var18 < x3)
{
var34 = false;
}
else
{
var18 = viewportMouseY - radius;
if (var18 > x1 && var18 > x2 && var18 > x3)
{
var34 = false;
}
else
{
var18 = radius + viewportMouseX;
if (var18 < y1 && var18 < y2 && var18 < y3)
{
var34 = false;
}
else
{
var18 = viewportMouseX - radius;
if (var18 > y1 && var18 > y2 && var18 > y3)
{
var34 = false;
}
else
{
var34 = true;
}
}
}
}
if (var34)
{
addHashAtMouse(hash);
break;
}
}
}
@Inject
private void addHashAtMouse(long hash)
{
long[] entitiesAtMouse = client.getEntitiesAtMouse();
int count = client.getEntitiesAtMouseCount();
if (count < MAX_ENTITES_AT_MOUSE)
{
entitiesAtMouse[count] = hash;
client.setEntitiesAtMouseCount(count + 1);
}
}
@Inject
private boolean boundingboxCheck(Model model, int x, int y, int z)
{
final int cameraPitch = client.getCameraPitch();
final int cameraYaw = client.getCameraYaw();
final int pitchSin = Perspective.SINE[cameraPitch];
final int pitchCos = Perspective.COSINE[cameraPitch];
final int yawSin = Perspective.SINE[cameraYaw];
final int yawCos = Perspective.COSINE[cameraYaw];
final int centerX = client.getCenterX();
final int centerY = client.getCenterY();
final int viewportMouseX = client.getViewportMouseX();
final int viewportMouseY = client.getViewportMouseY();
final int Rasterizer3D_zoom = client.get3dZoom();
int var6 = (viewportMouseX - centerX) * CLICKBOX_CLOSE / Rasterizer3D_zoom;
int var7 = (viewportMouseY - centerY) * CLICKBOX_CLOSE / Rasterizer3D_zoom;
int var8 = (viewportMouseX - centerX) * CLICKBOX_FAR / Rasterizer3D_zoom;
int var9 = (viewportMouseY - centerY) * CLICKBOX_FAR / Rasterizer3D_zoom;
int var10 = rl$rot1(var7, CLICKBOX_CLOSE, pitchCos, pitchSin);
int var11 = rl$rot2(var7, CLICKBOX_CLOSE, pitchCos, pitchSin);
var7 = var10;
var10 = rl$rot1(var9, CLICKBOX_FAR, pitchCos, pitchSin);
int var12 = rl$rot2(var9, CLICKBOX_FAR, pitchCos, pitchSin);
var9 = var10;
var10 = rl$rot3(var6, var11, yawCos, yawSin);
var11 = rl$rot4(var6, var11, yawCos, yawSin);
var6 = var10;
var10 = rl$rot3(var8, var12, yawCos, yawSin);
var12 = rl$rot4(var8, var12, yawCos, yawSin);
int field1720 = (var10 - var6) / 2;
int field638 = (var9 - var7) / 2;
int field1846 = (var12 - var11) / 2;
int field1722 = Math.abs(field1720);
int field601 = Math.abs(field638);
int field38 = Math.abs(field1846);
int var38 = x + model.getCenterX();
int var39 = y + model.getCenterY();
int var40 = z + model.getCenterZ();
int var41 = model.getExtremeX();
int var42 = model.getExtremeY();
int var43 = model.getExtremeZ();
int field1861 = (var6 + var10) / 2;
int field2317 = (var7 + var9) / 2;
int field528 = (var12 + var11) / 2;
int var44 = field1861 - var38;
int var45 = field2317 - var39;
int var46 = field528 - var40;
boolean passes;
if (Math.abs(var44) > var41 + field1722)
{
passes = false;
}
else if (Math.abs(var45) > var42 + field601)
{
passes = false;
}
else if (Math.abs(var46) > var43 + field38)
{
passes = false;
}
else if (Math.abs(var46 * field638 - var45 * field1846) > var42 * field38 + var43 * field601)
{
passes = false;
}
else if (Math.abs(var44 * field1846 - var46 * field1720) > var43 * field1722 + var41 * field38)
{
passes = false;
}
else if (Math.abs(var45 * field1720 - var44 * field638) > var42 * field1722 + var41 * field601)
{
passes = false;
}
else
{
passes = true;
}
return passes;
}
@Inject
private static int rl$rot1(int var0, int var1, int var2, int var3)
{
return var0 * var2 + var3 * var1 >> 16;
}
@Inject
private static int rl$rot2(int var0, int var1, int var2, int var3)
{
return var2 * var1 - var3 * var0 >> 16;
}
@Inject
private static int rl$rot3(int var0, int var1, int var2, int var3)
{
return var0 * var2 - var3 * var1 >> 16;
}
@Inject
private static int rl$rot4(int var0, int var1, int var2, int var3)
{
return var3 * var0 + var2 * var1 >> 16;
}
}

View File

@@ -1,143 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
@Mixin(RSClient.class)
public abstract class EntityHiderBridgeMixin implements RSClient
{
@Inject
public static boolean isHidingEntities;
@Inject
public static boolean hidePlayers;
@Inject
public static boolean hidePlayers2D;
@Inject
public static boolean hideFriends;
@Inject
public static boolean hideClanMates;
@Inject
public static boolean hideLocalPlayer;
@Inject
public static boolean hideLocalPlayer2D;
@Inject
public static boolean hideNPCs;
@Inject
public static boolean hideNPCs2D;
@Inject
public static boolean hideAttackers;
@Inject
public static boolean hideProjectiles;
@Inject
@Override
public void setIsHidingEntities(boolean state)
{
isHidingEntities = state;
}
@Inject
@Override
public void setPlayersHidden(boolean state)
{
hidePlayers = state;
}
@Inject
@Override
public void setPlayersHidden2D(boolean state)
{
hidePlayers2D = state;
}
@Inject
@Override
public void setFriendsHidden(boolean state)
{
hideFriends = state;
}
@Inject
@Override
public void setClanMatesHidden(boolean state)
{
hideClanMates = state;
}
@Inject
@Override
public void setLocalPlayerHidden(boolean state)
{
hideLocalPlayer = state;
}
@Inject
@Override
public void setLocalPlayerHidden2D(boolean state)
{
hideLocalPlayer2D = state;
}
@Inject
@Override
public void setNPCsHidden(boolean state)
{
hideNPCs = state;
}
@Inject
@Override
public void setNPCsHidden2D(boolean state)
{
hideNPCs2D = state;
}
@Inject
@Override
public void setAttackersHidden(boolean state)
{
hideAttackers = state;
}
@Inject
@Override
public void setProjectilesHidden(boolean state)
{
hideProjectiles = state;
}
}

View File

@@ -1,172 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSActor;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSNPC;
import net.runelite.rs.api.RSPlayer;
import net.runelite.rs.api.RSProjectile;
import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSRenderable;
@Mixin(RSScene.class)
public abstract class EntityHiderMixin implements RSScene
{
@Shadow("clientInstance")
private static RSClient client;
@Shadow("isHidingEntities")
private static boolean isHidingEntities;
@Shadow("hidePlayers")
private static boolean hidePlayers;
@Shadow("hidePlayers2D")
private static boolean hidePlayers2D;
@Shadow("hideFriends")
private static boolean hideFriends;
@Shadow("hideClanMates")
private static boolean hideClanMates;
@Shadow("hideLocalPlayer")
private static boolean hideLocalPlayer;
@Shadow("hideLocalPlayer2D")
private static boolean hideLocalPlayer2D;
@Shadow("hideNPCs")
private static boolean hideNPCs;
@Shadow("hideNPCs2D")
private static boolean hideNPCs2D;
@Shadow("hideAttackers")
private static boolean hideAttackers;
@Shadow("hideProjectiles")
private static boolean hideProjectiles;
@Copy("addEntityMarker")
abstract boolean addEntityMarker(int var1, int var2, int var3, int var4, int var5, int x, int y, int var8, RSRenderable renderable, int var10, boolean var11, long var12, int var13);
@Replace("addEntityMarker")
boolean rl$addEntityMarker(int var1, int var2, int var3, int var4, int var5, int x, int y, int var8, RSRenderable renderable, int var10, boolean var11, long var12, int var13)
{
final boolean shouldDraw = shouldDraw(renderable, false);
if (!shouldDraw)
{
final int tileX = x >> 7;
final int tileY = y >> 7;
/*
* Set the 'occupied' tick to -1, to reset the tile being 'occupied',
* making the game think an entity hasn't been rendered at the location yet.
*/
client.getOccupiedTilesTick()[tileX][tileY] = -1;
}
return shouldDraw && addEntityMarker(var1, var2, var3, var4, var5, x, y, var8, renderable, var10, var11, var12, var13);
}
@Copy("draw2DExtras")
private static void draw2DExtras(RSActor actor, int var1, int var2, int var3, int var4, int var5)
{
throw new RuntimeException();
}
@Replace("draw2DExtras")
private static void rl$draw2DExtras(RSActor actor, int var1, int var2, int var3, int var4, int var5)
{
if (shouldDraw(actor, true))
{
draw2DExtras(actor, var1, var2, var3, var4, var5);
}
}
@Inject
private static boolean shouldDraw(Object renderable, boolean drawingUI)
{
if (!isHidingEntities)
{
return true;
}
if (renderable instanceof RSPlayer)
{
boolean local = drawingUI ? hideLocalPlayer2D : hideLocalPlayer;
boolean other = drawingUI ? hidePlayers2D : hidePlayers;
boolean isLocalPlayer = renderable == client.getLocalPlayer();
if (isLocalPlayer ? local : other)
{
RSPlayer player = (RSPlayer) renderable;
if (!hideAttackers)
{
if (player.getInteracting() == client.getLocalPlayer())
{
return true;
}
}
if (player.getName() == null)
{
// player.isFriend() and player.isClanMember() npe when the player has a null name
return false;
}
return (!hideFriends && player.isFriend()) || (!isLocalPlayer && !hideClanMates && player.isClanMember());
}
}
else if (renderable instanceof RSNPC)
{
RSNPC npc = (RSNPC) renderable;
if (!hideAttackers)
{
if (npc.getInteracting() == client.getLocalPlayer())
{
return true;
}
}
return drawingUI ? !hideNPCs2D : !hideNPCs;
}
else if (renderable instanceof RSProjectile)
{
return !hideProjectiles;
}
return true;
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) 2018, Woox <https://github.com/wooxsolo>
* 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.coords.LocalPoint;
import net.runelite.api.events.GraphicsObjectCreated;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSGraphicsObject;
@Mixin(RSGraphicsObject.class)
public abstract class GraphicsObjectMixin implements RSGraphicsObject
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
GraphicsObjectMixin()
{
final GraphicsObjectCreated event = new GraphicsObjectCreated(this);
client.getCallbacks().post(event);
}
@Override
@Inject
public LocalPoint getLocation()
{
return new LocalPoint(this.getX(), this.getY());
}
}

View File

@@ -1,112 +0,0 @@
/*
* Copyright (c) 2019, Ron Young <https://github.com/raiyni>
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSFont;
@Mixin(RSClient.class)
public abstract class MenuMixin implements RSClient
{
private static final int MENU_BORDER_OUTER_2010 = 0x6D6A5B;
private static final int MENU_BORDER_INNER_2010 = 0x524A3D;
private static final int MENU_PADDING_2010 = 0x2B2622;
private static final int MENU_BACKGROUND_2010 = 0x2B271C;
private static final int MENU_TEXT_2010 = 0xC6B895;
private static final int MENU_HEADER_GRADIENT_TOP_2010 = 0x322E22;
private static final int MENU_HEADER_GRADIENT_BOTTOM_2010 = 0x090A04;
@Inject
@Override
public void draw2010Menu()
{
int x = getMenuX();
int y = getMenuY();
int w = getMenuWidth();
int h = getMenuHeight();
// Outside border
RasterizerDrawHorizontalLine(x + 2, y, w - 4, MENU_BORDER_OUTER_2010);
RasterizerDrawHorizontalLine(x + 2, y + h - 1, w - 4, MENU_BORDER_OUTER_2010);
RasterizerDrawVerticalLine(x, y + 2, h - 4, MENU_BORDER_OUTER_2010);
RasterizerDrawVerticalLine(x + w - 1, y + 2, h - 4, MENU_BORDER_OUTER_2010);
// Padding
RasterizerDrawRectangle(x + 1, y + 5, w - 2, h - 6, MENU_PADDING_2010);
RasterizerDrawHorizontalLine(x + 1, y + 17, w - 2, MENU_PADDING_2010);
RasterizerDrawCircle(x + 2, y + h - 3, 0, MENU_PADDING_2010);
RasterizerDrawCircle(x + w - 3, y + h - 3, 0, MENU_PADDING_2010);
// Header
RasterizerDrawGradient(x + 2, y + 1, w - 4, 16, MENU_HEADER_GRADIENT_TOP_2010, MENU_HEADER_GRADIENT_BOTTOM_2010);
RasterizerFillRectangle(x + 1, y + 1, 2, 4, MENU_PADDING_2010);
RasterizerFillRectangle(x + w - 3, y + 1, 2, 4, MENU_PADDING_2010);
// Inside border
RasterizerDrawHorizontalLine(x + 2, y + 18, w - 4, MENU_BORDER_INNER_2010);
RasterizerDrawHorizontalLine(x + 3, y + h - 3, w - 6, MENU_BORDER_INNER_2010);
RasterizerDrawVerticalLine(x + 2, y + 18, h - 21, MENU_BORDER_INNER_2010);
RasterizerDrawVerticalLine(x + w - 3, y + 18, h - 21, MENU_BORDER_INNER_2010);
// Options background
RasterizerFillRectangle(x + 3, y + 19, w - 6, h - 22, MENU_BACKGROUND_2010);
// Corner insets
RasterizerDrawCircle(x + 1, y + 1, 0, MENU_BORDER_OUTER_2010);
RasterizerDrawCircle(x + w - 2, y + 1, 0, MENU_BORDER_OUTER_2010);
RasterizerDrawCircle(x + 1, y + h - 2, 0, MENU_BORDER_OUTER_2010);
RasterizerDrawCircle(x + w - 2, y + h - 2, 0, MENU_BORDER_OUTER_2010);
RSFont font = getFontBold12();
font.drawTextLeftAligned("Choose Option", x + 3, y + 14, MENU_TEXT_2010, -1);
int mouseX = getMouseX();
int mouseY = getMouseY();
int count = getMenuOptionCount();
String[] targets = getMenuTargets();
String[] options = getMenuOptions();
for (int i = 0; i < count; i++)
{
int rowY = y + (count - 1 - i) * 15 + 31;
String s = options[i];
if (!targets[i].isEmpty())
{
s += " " + targets[i];
}
font.drawTextLeftAligned(s, x + 3, rowY, MENU_TEXT_2010, -1);
// Highlight current option
if (mouseX > x && mouseX < w + x && mouseY > rowY - 13 && mouseY < rowY + 3)
{
RasterizerFillRectangleAlpha(x + 3, rowY - 12, w - 6, 15, 0xffffff, 80);
}
}
}
}

View File

@@ -1,101 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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 static net.runelite.api.Perspective.SCENE_SIZE;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSSpritePixels;
@Mixin(RSClient.class)
public abstract class MinimapMixin implements RSClient
{
@Inject
@Override
public RSSpritePixels drawInstanceMap(int z)
{
RSSpritePixels ourSprite = createSpritePixels(new int[512 * 512], 512, 512);
RSSpritePixels theirSprite = getMinimapSprite();
RSScene scene = getScene();
int[] pixels = ourSprite.getPixels();
byte[][][] tileSettings = getTileSettings();
try
{
setMinimapSprite(ourSprite);
int var4;
for (int x = 1; x < SCENE_SIZE - 1; ++x)
{
var4 = (103 - x) * 2048 + 24628;
for (int y = 1; y < SCENE_SIZE - 1; ++y)
{
if ((tileSettings[z][y][x] & 24) == 0)
{
scene.drawTile(pixels, var4, 512, z, y, x);
}
if (z < 3 && (tileSettings[z + 1][y][x] & 8) != 0)
{
scene.drawTile(pixels, var4, 512, z + 1, y, x);
}
var4 += 4;
}
}
int color1 = (238 + (int) (Math.random() * 20.0D) - 10 << 16) + (238 + (int) (Math.random() * 20.0D) - 10 << 8) + (238 + (int) (Math.random() * 20.0D) - 10);
int color2 = 238 + (int) (Math.random() * 20.0D) - 10 << 16;
ourSprite.setRaster();
for (int y = 1; y < SCENE_SIZE - 1; ++y)
{
for (int x = 1; x < SCENE_SIZE - 1; ++x)
{
if ((tileSettings[z][x][y] & 24) == 0)
{
drawObject(z, x, y, color1, color2);
}
if (z < 3 && (tileSettings[z + 1][x][y] & 8) != 0)
{
drawObject(z + 1, x, y, color1, color2);
}
}
}
}
finally
{
getBufferProvider().setRaster();
setMinimapSprite(theirSprite);
}
return ourSprite;
}
}

View File

@@ -1,74 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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.mixins.Copy;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSRunException;
@Mixin(RSClient.class)
public abstract class ProcessClientErrorMixin implements RSClient
{
@Shadow("clientInstance")
private static RSClient client;
@Copy("processClientError")
static void rs$processClientError(String string, Throwable throwable)
{
throw new RuntimeException();
}
@Replace("processClientError")
static void rl$processClientError(String string, Throwable throwable)
{
if (throwable != null)
{
Throwable throwableToScan = throwable;
if (throwable instanceof RSRunException)
{
throwableToScan = ((RSRunException) throwable).getParent();
}
client.getLogger().error("Game crash: {}", string, throwableToScan);
StackTraceElement[] stackTrace = throwableToScan.getStackTrace();
for (StackTraceElement stackTraceElement : stackTrace)
{
// If stack trace contains "runelite", don't send it
if (stackTraceElement.getClassName().contains("runelite"))
{
return;
}
}
}
rs$processClientError(string, throwable);
}
}

View File

@@ -1,286 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import net.runelite.api.Actor;
import net.runelite.api.Hitsplat;
import net.runelite.api.NPC;
import net.runelite.api.NPCComposition;
import net.runelite.api.Perspective;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.api.SpritePixels;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldArea;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.GraphicChanged;
import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.LocalPlayerDeath;
import net.runelite.api.events.OverheadTextChanged;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSActor;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSCombatInfo1;
import net.runelite.rs.api.RSHealthBar;
import net.runelite.rs.api.RSCombatInfoList;
import net.runelite.rs.api.RSCombatInfoListHolder;
import net.runelite.rs.api.RSNPC;
import net.runelite.rs.api.RSNode;
@Mixin(RSActor.class)
public abstract class RSActorMixin implements RSActor
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public Actor getInteracting()
{
int i = getRSInteracting();
if (i == -1 || i == 65535)
{
return null;
}
if (i < 0x8000)
{
NPC[] npcs = client.getCachedNPCs();
return npcs[i];
}
i -= 0x8000;
Player[] players = client.getCachedPlayers();
return players[i];
}
@Inject
@Override
public int getHealthRatio()
{
RSCombatInfoList combatInfoList = getCombatInfoList();
if (combatInfoList != null)
{
RSNode node = combatInfoList.getNode();
RSNode next = node.getNext();
if (next instanceof RSCombatInfoListHolder)
{
RSCombatInfoListHolder combatInfoListWrapper = (RSCombatInfoListHolder) next;
RSCombatInfoList combatInfoList1 = combatInfoListWrapper.getCombatInfo1();
RSNode node2 = combatInfoList1.getNode();
RSNode next2 = node2.getNext();
if (next2 instanceof RSCombatInfo1)
{
RSCombatInfo1 combatInfo = (RSCombatInfo1) next2;
return combatInfo.getHealthRatio();
}
}
}
return -1;
}
@Inject
@Override
public int getHealth()
{
RSCombatInfoList combatInfoList = getCombatInfoList();
if (combatInfoList != null)
{
RSNode node = combatInfoList.getNode();
RSNode next = node.getNext();
if (next instanceof RSCombatInfoListHolder)
{
RSCombatInfoListHolder combatInfoListWrapper = (RSCombatInfoListHolder) next;
RSHealthBar cf = combatInfoListWrapper.getHealthBar();
return cf.getHealthScale();
}
}
return -1;
}
@Override
@Inject
public WorldPoint getWorldLocation()
{
return WorldPoint.fromLocal(client,
this.getPathX()[0] * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2,
this.getPathY()[0] * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2,
client.getPlane());
}
@Inject
@Override
public LocalPoint getLocalLocation()
{
return new LocalPoint(getX(), getY());
}
@Inject
@Override
public Polygon getCanvasTilePoly()
{
return Perspective.getCanvasTilePoly(client, getLocalLocation());
}
@Inject
@Override
public Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset)
{
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
}
@Inject
@Override
public Point getCanvasImageLocation(BufferedImage image, int zOffset)
{
return Perspective.getCanvasImageLocation(client, getLocalLocation(), image, zOffset);
}
@Inject
@Override
public Point getCanvasSpriteLocation(SpritePixels sprite, int zOffset)
{
return Perspective.getCanvasSpriteLocation(client, getLocalLocation(), sprite, zOffset);
}
@Inject
@Override
public Point getMinimapLocation()
{
return Perspective.localToMinimap(client, getLocalLocation());
}
@FieldHook("animation")
@Inject
public void animationChanged(int idx)
{
AnimationChanged animationChange = new AnimationChanged();
animationChange.setActor(this);
client.getCallbacks().post(animationChange);
}
@FieldHook("graphic")
@Inject
public void graphicChanged(int idx)
{
GraphicChanged graphicChanged = new GraphicChanged();
graphicChanged.setActor(this);
client.getCallbacks().post(graphicChanged);
}
@FieldHook("interacting")
@Inject
public void interactingChanged(int idx)
{
InteractingChanged interactingChanged = new InteractingChanged(this, getInteracting());
client.getCallbacks().post(interactingChanged);
}
@FieldHook("overhead")
@Inject
public void overheadTextChanged(int idx)
{
String overheadText = getOverheadText();
if (overheadText != null)
{
OverheadTextChanged overheadTextChanged = new OverheadTextChanged(this, overheadText);
client.getCallbacks().post(overheadTextChanged);
}
}
@Inject
@Override
public WorldArea getWorldArea()
{
int size = 1;
if (this instanceof NPC)
{
NPCComposition composition = ((NPC)this).getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
if (composition != null)
{
size = composition.getSize();
}
}
return new WorldArea(this.getWorldLocation(), size, size);
}
@Inject
@MethodHook("setCombatInfo")
public void setCombatInfo(int combatInfoId, int gameCycle, int var3, int var4, int healthRatio, int health)
{
if (healthRatio == 0)
{
if (this == client.getLocalPlayer())
{
client.getLogger().debug("You died!");
LocalPlayerDeath event = new LocalPlayerDeath();
client.getCallbacks().post(event);
}
else if (this instanceof RSNPC)
{
((RSNPC) this).setDead(true);
}
}
}
/**
* Called after a hitsplat has been processed on an actor.
* Note that this event runs even if the hitsplat didn't show up,
* i.e. the actor already had 4 visible hitsplats.
*
* @param type The hitsplat type (i.e. color)
* @param value The value of the hitsplat (i.e. how high the hit was)
* @param var3 unknown
* @param var4 unknown
* @param gameCycle The gamecycle the hitsplat was applied on
* @param duration The amount of gamecycles the hitsplat will last for
*/
@Inject
@MethodHook(value = "applyActorHitsplat", end = true)
public void applyActorHitsplat(int type, int value, int var3, int var4, int gameCycle, int duration)
{
final Hitsplat hitsplat = new Hitsplat(Hitsplat.HitsplatType.fromInteger(type), value, gameCycle + duration);
final HitsplatApplied event = new HitsplatApplied();
event.setActor(this);
event.setHitsplat(hitsplat);
client.getCallbacks().post(event);
}
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright (c) 2018, trimbe <github.com/trimbe>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.MessageNode;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSCacheableNode;
import net.runelite.rs.api.RSChatLineBuffer;
@Mixin(RSChatLineBuffer.class)
public abstract class RSChatLineBufferMixin implements RSChatLineBuffer
{
@Inject
@Override
public void removeMessageNode(MessageNode node)
{
MessageNode[] lines = getLines();
final int length = getLength();
int found = -1;
// Find the index of the node
for (int idx = 0; idx < length; idx++)
{
if (lines[idx] == node)
{
found = idx;
break;
}
}
if (found == -1)
{
return;
}
// Shift down all other messages
for (int i = found; i < length - 1; i++)
{
lines[i] = lines[i + 1];
}
lines[length - 1] = null;
setLength(length - 1);
RSCacheableNode rsCacheableNode = (RSCacheableNode) node;
rsCacheableNode.unlink();
rsCacheableNode.unlinkDual();
}
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright (c) 2018, trimbe <github.com/trimbe>
* 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.ClanMember;
import net.runelite.api.events.ClanMemberJoined;
import net.runelite.api.events.ClanMemberLeft;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClanMemberManager;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSName;
import net.runelite.rs.api.RSNameable;
@Mixin(RSClanMemberManager.class)
public abstract class RSClanMemberManagerMixin implements RSClanMemberManager
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public void rl$add(RSName name, RSName prevName)
{
ClanMember member = findByName(name);
if (member == null)
{
return;
}
ClanMemberJoined event = new ClanMemberJoined(member);
client.getCallbacks().postDeferred(event);
}
@Inject
@Override
public void rl$remove(RSNameable nameable)
{
ClanMember member = findByName(nameable.getRsName());
if (member == null)
{
return;
}
ClanMemberLeft event = new ClanMemberLeft(member);
client.getCallbacks().postDeferred(event);
}
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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.ClanMemberRank;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClanMember;
@Mixin(RSClanMember.class)
public abstract class RSClanMemberMixin implements RSClanMember
{
@Override
@Inject
public String getUsername()
{
return getRsName().getName();
}
@Override
@Inject
public ClanMemberRank getRank()
{
return ClanMemberRank.valueOf(getRSRank());
}
}

View File

@@ -1,167 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Polygon;
import java.awt.geom.Area;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSDecorativeObject;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSRenderable;
@Mixin(RSDecorativeObject.class)
public abstract class RSDecorativeObjectMixin implements RSDecorativeObject
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int decorativeObjectPlane;
@Inject
@Override
public int getPlane()
{
return decorativeObjectPlane;
}
@Inject
@Override
public void setPlane(int plane)
{
this.decorativeObjectPlane = plane;
}
@Inject
private RSModel getModel()
{
RSRenderable renderable = getRenderable();
if (renderable == null)
{
return null;
}
RSModel model;
if (renderable instanceof Model)
{
model = (RSModel) renderable;
}
else
{
model = renderable.getModel();
}
return model;
}
@Inject
private RSModel getModel2()
{
RSRenderable renderable = getRenderable2();
if (renderable == null)
{
return null;
}
RSModel model;
if (renderable instanceof Model)
{
model = (RSModel) renderable;
}
else
{
model = renderable.getModel();
}
return model;
}
@Inject
@Override
public Area getClickbox()
{
Area clickbox = new Area();
LocalPoint lp = getLocalLocation();
Area clickboxA = Perspective.getClickbox(client, getModel(), 0,
new LocalPoint(lp.getX() + getXOffset(), lp.getY() + getYOffset()));
Area clickboxB = Perspective.getClickbox(client, getModel2(), 0, lp);
if (clickboxA == null && clickboxB == null)
{
return null;
}
if (clickboxA != null)
{
clickbox.add(clickboxA);
}
if (clickboxB != null)
{
clickbox.add(clickboxB);
}
return clickbox;
}
@Inject
@Override
public Polygon getConvexHull()
{
RSModel model = getModel();
if (model == null)
{
return null;
}
int tileHeight = Perspective.getTileHeight(client, new LocalPoint(getX(), getY()), client.getPlane());
return model.getConvexHull(getX() + getXOffset(), getY() + getYOffset(), 0, tileHeight);
}
@Inject
@Override
public Polygon getConvexHull2()
{
RSModel model = getModel2();
if (model == null)
{
return null;
}
int tileHeight = Perspective.getTileHeight(client, new LocalPoint(getX(), getY()), client.getPlane());
return model.getConvexHull(getX(), getY(), 0, tileHeight);
}
}

View File

@@ -1,81 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Copy;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSDynamicObject;
import net.runelite.rs.api.RSModel;
@Mixin(RSDynamicObject.class)
public abstract class RSDynamicObjectMixin implements RSDynamicObject
{
@Shadow("clientInstance")
private static RSClient client;
@Copy("getModel")
public abstract RSModel rs$getModel();
@Replace("getModel")
public RSModel rl$getModel()
{
try
{
// reset frame because it may have been set from the constructor
// it should be set again inside the getModel method
int animFrame = getAnimFrame();
if (animFrame < 0)
{
setAnimFrame((animFrame ^ Integer.MIN_VALUE) & 0xFFFF);
}
return rs$getModel();
}
finally
{
int animFrame = getAnimFrame();
if (animFrame < 0)
{
setAnimFrame((animFrame ^ Integer.MIN_VALUE) & 0xFFFF);
}
}
}
@FieldHook("animCycleCount")
@Inject
public void onAnimCycleCountChanged(int idx)
{
if (client.isInterpolateObjectAnimations())
{
// sets the packed anim frame with the frame cycle
int objectFrameCycle = client.getGameCycle() - getAnimCycleCount();
setAnimFrame(Integer.MIN_VALUE | objectFrameCycle << 16 | getAnimFrame());
}
}
}

View File

@@ -1,75 +0,0 @@
/*
* Copyright (c) 2019, Adam <Adam@sigterm.info>
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSEnum;
@Mixin(RSEnum.class)
public abstract class RSEnumMixin implements RSEnum
{
@Inject
@Override
public int getIntValue(int key)
{
final int[] keys = getKeys();
if (keys == null)
{
return getDefaultInt();
}
for (int i = 0; i < keys.length; ++i)
{
if (keys[i] == key)
{
final int[] values = getIntVals();
return values[i];
}
}
return getDefaultInt();
}
@Inject
@Override
public String getStringValue(int key)
{
final int[] keys = getKeys();
if (keys == null)
{
return getDefaultString();
}
for (int i = 0; i < keys.length; ++i)
{
if (keys[i] == key)
{
final String[] values = getStringVals();
return values[i];
}
}
return getDefaultString();
}
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.events.RemovedFriend;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSFriendManager;
@Mixin(RSFriendManager.class)
public abstract class RSFriendManagerMixin implements RSFriendManager
{
@Shadow("clientInstance")
private static RSClient client;
@MethodHook("removeFriend")
@Inject
public void rl$removeFriend(String friendName)
{
RemovedFriend removedFriend = new RemovedFriend(friendName);
client.getCallbacks().post(removedFriend);
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSFriend;
import net.runelite.rs.api.RSName;
@Mixin(RSFriend.class)
public abstract class RSFriendMixin implements RSFriend
{
@Override
@Inject
public String getName()
{
return getRsName().getName();
}
@Override
@Inject
public String getPrevName()
{
RSName prevName = getRsPrevName();
return prevName == null ? null : prevName.getName();
}
}

View File

@@ -1,93 +0,0 @@
/*
* Copyright (c) 2018 Abex
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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 java.awt.Canvas;
import java.awt.event.FocusListener;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSGameCanvas;
@Mixin(RSGameCanvas.class)
public abstract class RSGameCanvasMixin extends Canvas implements RSGameCanvas
{
@Shadow("clientInstance")
private static RSClient client;
// This is inverted because it is false initialized.
@Inject
private static boolean shouldNotHaveFocus;
@Inject
@Override
public void removeFocusListener(FocusListener l)
{
super.removeFocusListener(l);
shouldNotHaveFocus = !this.hasFocus();
}
@Inject
@Override
public void requestFocus()
{
// Runescape requests focus whenever the window is resized. Because of this, PluginPanels cannot have focus
// if they cause the sidebar to expand. This change prevents Runescape from requesting focus whenever it wants
if (!shouldNotHaveFocus)
{
this.requestFocusInWindow();
}
}
@Inject
@Override
public void setSize(int width, int height)
{
if (client.isStretchedEnabled())
{
super.setSize(client.getStretchedDimensions().width, client.getStretchedDimensions().height);
}
else
{
super.setSize(width, height);
}
}
@Inject
@Override
public void setLocation(int x, int y)
{
if (client.isStretchedEnabled())
{
super.setLocation((getParent().getWidth() - client.getStretchedDimensions().width) / 2, 0);
}
else
{
super.setLocation(x, y);
}
}
}

View File

@@ -1,100 +0,0 @@
/*
* Copyright (c) 2018 Abex
* 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 java.awt.event.FocusEvent;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.hooks.DrawCallbacks;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSGameEngine;
@Mixin(RSGameEngine.class)
public abstract class RSGameEngineMixin implements RSGameEngine
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private Thread thread;
@Inject
@Override
public Thread getClientThread()
{
return thread;
}
@Inject
@Override
public boolean isClientThread()
{
return thread == Thread.currentThread();
}
@Inject
@MethodHook("run")
public void onRun()
{
thread = Thread.currentThread();
thread.setName("Client");
}
@Inject
@MethodHook("focusGained")
public void onFocusGained(FocusEvent focusEvent)
{
final FocusChanged focusChanged = new FocusChanged();
focusChanged.setFocused(true);
client.getCallbacks().post(focusChanged);
}
@Inject
@MethodHook("post")
public void onPost(Object canvas)
{
DrawCallbacks drawCallbacks = client.getDrawCallbacks();
if (drawCallbacks != null)
{
drawCallbacks.draw();
}
}
@FieldHook("replaceCanvasNextFrame")
@Inject
public void onReplaceCanvasNextFrameChanged(int idx)
{
// when this is initially called the client instance doesn't exist yet
if (client != null && client.isGpu() && isReplaceCanvasNextFrame())
{
setReplaceCanvasNextFrame(false);
setResizeCanvasNextFrame(true);
}
}
}

View File

@@ -1,110 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Polygon;
import java.awt.geom.Area;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.coords.Angle;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSGameObject;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSRenderable;
@Mixin(RSGameObject.class)
public abstract class RSGameObjectMixin implements RSGameObject
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public Point getSceneMinLocation()
{
return new Point(getRelativeX(), getRelativeY());
}
@Inject
@Override
public Point getSceneMaxLocation()
{
return new Point(getOffsetX(), getOffsetY());
}
@Inject
private RSModel getModel()
{
RSRenderable renderable = getRenderable();
if (renderable == null)
{
return null;
}
if (renderable instanceof RSModel)
{
return (RSModel) renderable;
}
else
{
return renderable.getModel();
}
}
@Inject
@Override
public Area getClickbox()
{
return Perspective.getClickbox(client, getModel(), getRsOrientation(), getLocalLocation());
}
@Inject
@Override
public Polygon getConvexHull()
{
RSModel model = getModel();
if (model == null)
{
return null;
}
int tileHeight = Perspective.getTileHeight(client, new LocalPoint(getX(), getY()), client.getPlane());
return model.getConvexHull(getX(), getY(), getRsOrientation(), tileHeight);
}
@Override
@Inject
public Angle getOrientation()
{
int orientation = getRsOrientation();
int rotation = (getFlags() >> 6) & 3;
return new Angle(rotation * 512 + orientation);
}
}

View File

@@ -1,108 +0,0 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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.GrandExchangeOfferState;
import static net.runelite.api.GrandExchangeOfferState.BOUGHT;
import static net.runelite.api.GrandExchangeOfferState.BUYING;
import static net.runelite.api.GrandExchangeOfferState.CANCELLED_BUY;
import static net.runelite.api.GrandExchangeOfferState.CANCELLED_SELL;
import static net.runelite.api.GrandExchangeOfferState.EMPTY;
import static net.runelite.api.GrandExchangeOfferState.SELLING;
import static net.runelite.api.GrandExchangeOfferState.SOLD;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSGrandExchangeOffer;
@Mixin(RSGrandExchangeOffer.class)
public abstract class RSGrandExchangeOfferMixin implements RSGrandExchangeOffer
{
/*
Internally a GrandExchangeOffer's state is represented as 4 flags
packed into the lower half of a byte. They are:
*/
//Set for sell offers, unset for buy offers
private static final int IS_SELLING = 1 << 3; // 0b1000
/*
Set for offers that have finished, either because they've
been filled, or because they were cancelled
*/
private static final int COMPLETED = 1 << 2; // 0b0100
/*
Set for offers that are actually live
NB: Insta-buy/sell offers will be simultaneously LIVE and LOCAL
*/
private static final int LIVE = 1 << 1; // 0b0010
//True for just-made, just-cancelled, completely cancelled, and completed offers
private static final int LOCAL = 1;
@Inject
@Override
public GrandExchangeOfferState getState()
{
byte code = getRSState();
boolean isSelling = (code & IS_SELLING) == IS_SELLING;
boolean isFinished = (code & COMPLETED) == COMPLETED;
if (code == 0)
{
return EMPTY;
}
else if (isFinished && getQuantitySold() < getTotalQuantity())
{
return isSelling ? CANCELLED_SELL : CANCELLED_BUY;
}
else if (isSelling)
{
if (isFinished)
{
return SOLD;
}
else // if isUnfinished
{
return SELLING;
}
}
else // if isBuying
{
if (isFinished)
{
return BOUGHT;
}
else // if isUnfinished
{
return BUYING;
}
}
}
}

View File

@@ -1,85 +0,0 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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 java.awt.geom.Area;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Renderable;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSGroundObject;
@Mixin(RSGroundObject.class)
public abstract class RSGroundObjectMixin implements RSGroundObject
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int groundObjectPlane;
@Inject
@Override
public int getPlane()
{
return groundObjectPlane;
}
@Inject
@Override
public void setPlane(int plane)
{
this.groundObjectPlane = plane;
}
@Inject
private Model getModel()
{
Renderable renderable = getRenderable();
if (renderable == null)
{
return null;
}
if (renderable instanceof Model)
{
return (Model) renderable;
}
else
{
return renderable.getModel();
}
}
@Inject
@Override
public Area getClickbox()
{
return Perspective.getClickbox(client, getModel(), 0, getLocalLocation());
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.runelite.api.Node;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSHashTable;
import net.runelite.rs.api.RSNode;
@Mixin(RSHashTable.class)
public abstract class RSHashTableMixin implements RSHashTable
{
@Inject
@Override
public Collection<Node> getNodes()
{
// Copied in RSWidgetMixin.getParentId to reduce allocations
List<Node> nodes = new ArrayList<Node>();
RSNode[] buckets = getBuckets();
for (int i = 0; i < buckets.length; ++i)
{
Node node = buckets[i];
// It looks like the first node in the bucket is always
// a sentinel
Node cur = node.getNext();
while (cur != node)
{
nodes.add(cur);
cur = cur.getNext();
}
}
return nodes;
}
}

View File

@@ -1,50 +0,0 @@
/*
* Copyright (c) 2019, Lotto <https://github.com/devLotto>
* 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.events.PostHealthBar;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSBuffer;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSHealthBar;
@Mixin(RSHealthBar.class)
public abstract class RSHealthBarMixin implements RSHealthBar
{
@Shadow("clientInstance")
private static RSClient client;
@MethodHook(value = "read", end = true)
@Inject
public void onRead(RSBuffer buffer)
{
PostHealthBar postHealthBar = new PostHealthBar();
postHealthBar.setHealthBar(this);
client.getCallbacks().post(postHealthBar);
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSIgnore;
import net.runelite.rs.api.RSName;
@Mixin(RSIgnore.class)
public abstract class RSIgnoreMixin implements RSIgnore
{
@Override
@Inject
public String getName()
{
return getRsName().getName();
}
@Override
@Inject
public String getPrevName()
{
RSName prevName = getRsPrevName();
return prevName == null ? null : prevName.getName();
}
}

View File

@@ -1,139 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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 com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
import com.google.common.io.BaseEncoding;
import com.google.common.io.ByteStreams;
import com.google.common.io.CharStreams;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.api.overlay.OverlayIndex;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSIndexData;
import net.runelite.rs.api.RSIndexDataBase;
import org.slf4j.Logger;
@Mixin(RSIndexDataBase.class)
public abstract class RSIndexDataBaseMixin implements RSIndexDataBase
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private boolean overlayOutdated;
@Inject
@Override
public boolean isOverlayOutdated()
{
return overlayOutdated;
}
@Copy("getConfigData")
abstract byte[] rs$getConfigData(int archiveId, int fileId);
@Replace("getConfigData")
public byte[] rl$getConfigData(int archiveId, int fileId)
{
byte[] rsData = rs$getConfigData(archiveId, fileId);
RSIndexData indexData = (RSIndexData) this;
if (!OverlayIndex.hasOverlay(indexData.getIndex(), archiveId))
{
return rsData;
}
Logger log = client.getLogger();
InputStream in = getClass().getResourceAsStream("/runelite/" + indexData.getIndex() + "/" + archiveId);
if (in == null)
{
log.warn("Missing overlay data for {}/{}", indexData.getIndex(), archiveId);
return rsData;
}
InputStream in2 = getClass().getResourceAsStream("/runelite/" + indexData.getIndex() + "/" + archiveId + ".hash");
if (rsData == null)
{
if (in2 != null)
{
log.warn("Hash file for non existing archive {}/{}", indexData.getIndex(), archiveId);
return null;
}
log.debug("Adding archive {}/{}", indexData.getIndex(), archiveId);
try
{
return ByteStreams.toByteArray(in);
}
catch (IOException ex)
{
log.warn("error loading archive replacement", ex);
}
return null;
}
if (in2 == null)
{
log.warn("Missing hash file for {}/{}", indexData.getIndex(), archiveId);
return rsData;
}
HashCode rsDataHash = Hashing.sha256().hashBytes(rsData);
String rsHash = BaseEncoding.base16().encode(rsDataHash.asBytes());
try
{
String replaceHash = CharStreams.toString(new InputStreamReader(in2));
if (replaceHash.equals(rsHash))
{
log.debug("Replacing archive {}/{}",
indexData.getIndex(), archiveId);
return ByteStreams.toByteArray(in);
}
log.warn("Mismatch in overlaid cache archive hash for {}/{}: {} != {}",
indexData.getIndex(), archiveId, replaceHash, rsHash);
overlayOutdated = true;
}
catch (IOException ex)
{
log.warn("error checking hash", ex);
}
return rsData;
}
}

View File

@@ -1,92 +0,0 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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.events.PostItemComposition;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSItemComposition;
@Mixin(RSItemComposition.class)
public abstract class RSItemCompositionMixin implements RSItemComposition
{
private static final int DEFAULT_CUSTOM_SHIFT_CLICK_INDEX = -2;
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int shiftClickActionIndex = DEFAULT_CUSTOM_SHIFT_CLICK_INDEX;
@Inject
RSItemCompositionMixin()
{
}
@Inject
@Override
public boolean isStackable()
{
return getIsStackable() != 0;
}
@Inject
@Override
public void setShiftClickActionIndex(int shiftClickActionIndex)
{
this.shiftClickActionIndex = shiftClickActionIndex;
}
@Copy("getShiftClickActionIndex")
abstract int rs$getShiftClickActionIndex();
@Replace("getShiftClickActionIndex")
public int getShiftClickActionIndex()
{
return shiftClickActionIndex == DEFAULT_CUSTOM_SHIFT_CLICK_INDEX ? rs$getShiftClickActionIndex() : shiftClickActionIndex;
}
@Inject
@Override
public void resetShiftClickActionIndex()
{
shiftClickActionIndex = DEFAULT_CUSTOM_SHIFT_CLICK_INDEX;
}
@Inject
@MethodHook(value = "post", end = true)
public void post()
{
final PostItemComposition event = new PostItemComposition();
event.setItemComposition(this);
client.getCallbacks().post(event);
}
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright (c) 2016-2018, Adam <Adam@sigterm.info>
* 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.Item;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSItem;
import net.runelite.rs.api.RSItemContainer;
@Mixin(RSItemContainer.class)
public abstract class RSItemContainerMixin implements RSItemContainer
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int rl$lastCycle;
@Inject
@Override
public Item[] getItems()
{
int[] itemIds = getItemIds();
int[] stackSizes = getStackSizes();
Item[] items = new Item[itemIds.length];
for (int i = 0; i < itemIds.length; ++i)
{
RSItem item = client.createItem();
item.setId(itemIds[i]);
item.setQuantity(stackSizes[i]);
items[i] = item;
}
return items;
}
@FieldHook("stackSizes")
@Inject
public void stackSizesChanged(int idx)
{
int cycle = client.getGameCycle();
if (rl$lastCycle == cycle)
{
// Limit item container updates to one per cycle
return;
}
rl$lastCycle = cycle;
ItemContainerChanged event = new ItemContainerChanged(this);
client.getCallbacks().postDeferred(event);
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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 java.awt.geom.Area;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSItemLayer;
@Mixin(RSItemLayer.class)
public abstract class RSItemLayerMixin implements RSItemLayer
{
@Inject
private int itemLayerPlane;
@Inject
@Override
public int getPlane()
{
return itemLayerPlane;
}
@Inject
@Override
public void setPlane(int plane)
{
this.itemLayerPlane = plane;
}
@Inject
@Override
public Area getClickbox()
{
throw new UnsupportedOperationException();
}
}

View File

@@ -1,125 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.Tile;
import net.runelite.api.events.ItemQuantityChanged;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSItem;
@Mixin(RSItem.class)
public abstract class RSItemMixin implements RSItem
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int rl$sceneX = -1;
@Inject
private int rl$sceneY = -1;
@Inject
RSItemMixin()
{
}
@Inject
@Override
public Tile getTile()
{
int x = rl$sceneX;
int y = rl$sceneY;
if (x == -1 || y == -1)
{
return null;
}
Tile[][][] tiles = client.getScene().getTiles();
Tile tile = tiles[client.getPlane()][x][y];
return tile;
}
@Inject
@Override
public void onUnlink()
{
if (rl$sceneX != -1)
{
// on despawn, the first item unlinked is the item despawning. However on spawn
// items can be delinked in order to sort them, so we can't assume the item here is despawning
if (client.getLastItemDespawn() == null)
{
client.setLastItemDespawn(this);
}
}
}
@Inject
@FieldHook(value = "quantity", before = true)
public void quantityChanged(int quantity)
{
if (rl$sceneX != -1)
{
client.getLogger().debug("Item quantity changed: {} ({} -> {})", getId(), getQuantity(), quantity);
ItemQuantityChanged itemQuantityChanged = new ItemQuantityChanged(this, getTile(), getQuantity(), quantity);
client.getCallbacks().post(itemQuantityChanged);
}
}
@Inject
@Override
public int getX()
{
return rl$sceneX;
}
@Inject
@Override
public void setX(int x)
{
rl$sceneX = x;
}
@Inject
@Override
public int getY()
{
return rl$sceneY;
}
@Inject
@Override
public void setY(int y)
{
rl$sceneY = y;
}
}

View File

@@ -1,95 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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 java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSKeyFocusListener;
@Mixin(RSKeyFocusListener.class)
public abstract class RSKeyFocusListenerMixin implements RSKeyFocusListener
{
@Shadow("clientInstance")
private static RSClient client;
@Copy("keyPressed")
abstract void rs$keyPressed(KeyEvent keyEvent);
@Copy("keyReleased")
abstract void rs$keyReleased(KeyEvent keyEvent);
@Copy("keyTyped")
abstract void rs$keyTyped(KeyEvent keyEvent);
@Override
@Replace("keyPressed")
public final synchronized void keyPressed(KeyEvent keyEvent)
{
client.getCallbacks().keyPressed(keyEvent);
if (!keyEvent.isConsumed())
{
rs$keyPressed(keyEvent);
}
}
@Override
@Replace("keyReleased")
public final synchronized void keyReleased(KeyEvent keyEvent)
{
client.getCallbacks().keyReleased(keyEvent);
if (!keyEvent.isConsumed())
{
rs$keyReleased(keyEvent);
}
}
@Override
@Replace("keyTyped")
public final void keyTyped(KeyEvent keyEvent)
{
client.getCallbacks().keyTyped(keyEvent);
if (!keyEvent.isConsumed())
{
rs$keyTyped(keyEvent);
}
}
@Inject
@MethodHook("focusLost")
public void onFocusLost(FocusEvent focusEvent)
{
final FocusChanged focusChanged = new FocusChanged();
focusChanged.setFocused(false);
client.getCallbacks().post(focusChanged);
}
}

View File

@@ -1,89 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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 java.awt.Component;
import java.awt.Graphics;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.DirectColorModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.nio.IntBuffer;
import java.util.Hashtable;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSMainBufferProvider;
@Mixin(RSMainBufferProvider.class)
public abstract class RSMainBufferProviderMixin implements RSMainBufferProvider
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private IntBuffer buffer;
@MethodHook(value = "<init>", end = true)
@Inject
public void init(int width, int height, Component canvas)
{
if (!client.isGpu())
{
return;
}
final int[] pixels = getPixels();
// we need to make our own buffered image for the client with the alpha channel enabled in order to
// have alphas for the overlays applied correctly
DataBufferInt dataBufferInt = new DataBufferInt(pixels, pixels.length);
DirectColorModel directColorModel = new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
32, 0xff0000, 0xff00, 0xff, 0xff000000,
true, DataBuffer.TYPE_INT);
WritableRaster writableRaster = Raster.createWritableRaster(directColorModel.createCompatibleSampleModel(width, height), dataBufferInt, null);
BufferedImage bufferedImage = new BufferedImage(directColorModel, writableRaster, true, new Hashtable());
setImage(bufferedImage);
}
/**
* Replacing this method makes it so we can completely
* control when/what is drawn on the game's canvas,
* as the method that is replaced draws
* the game's image on the canvas.
*/
@Replace("draw")
final void draw(Graphics graphics, int x, int y)
{
client.getCallbacks().draw(this, graphics, x, y);
}
}

View File

@@ -1,97 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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.ChatMessageType;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSMessageNode;
@Mixin(RSMessageNode.class)
public abstract class RSMessageNodeMixin implements RSMessageNode
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private String runeLiteFormatMessage;
@Inject
private int rl$timestamp;
@Inject
RSMessageNodeMixin()
{
rl$timestamp = (int) (System.currentTimeMillis() / 1000L);
}
@Inject
@Override
public ChatMessageType getType()
{
return ChatMessageType.of(getRSType());
}
@Inject
@Override
public String getRuneLiteFormatMessage()
{
return runeLiteFormatMessage;
}
@Inject
@Override
public void setRuneLiteFormatMessage(String runeLiteFormatMessage)
{
this.runeLiteFormatMessage = runeLiteFormatMessage;
}
@Inject
@Override
public int getTimestamp()
{
return rl$timestamp;
}
@Inject
@Override
public void setTimestamp(int timestamp)
{
this.rl$timestamp = timestamp;
}
@Inject
@MethodHook(value = "setMessage", end = true)
public void setMessage(int type, String name, String sender, String value)
{
// Message nodes get reused after a time by calling setMessage.
// Clear the runelite formatted message then.
runeLiteFormatMessage = null;
rl$timestamp = (int) (System.currentTimeMillis() / 1000L);
}
}

View File

@@ -1,202 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.Model;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSModelData;
@Mixin(RSModelData.class)
public abstract class RSModelDataMixin implements RSModelData
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private float[][] faceTextureUCoordinates;
@Inject
private float[][] faceTextureVCoordinates;
@Copy("light")
public abstract Model rs$light(int ambient, int contrast, int var3, int var4, int var5);
@Replace("light")
public Model rl$light(int ambient, int contrast, int var3, int var4, int var5)
{
client.getLogger().trace("Lighting model {}", this);
Model model = rs$light(ambient, contrast, var3, var4, var5);
if (model == null)
{
return null;
}
if (faceTextureUCoordinates == null)
{
computeTextureUVCoordinates();
}
RSModel rsModel = (RSModel) model;
rsModel.setFaceTextureUCoordinates(faceTextureUCoordinates);
rsModel.setFaceTextureVCoordinates(faceTextureVCoordinates);
return model;
}
@Inject
public void computeTextureUVCoordinates()
{
final short[] faceTextures = getFaceTextures();
if (faceTextures == null)
{
return;
}
final int[] vertexPositionsX = getVertexX();
final int[] vertexPositionsY = getVertexY();
final int[] vertexPositionsZ = getVertexZ();
final int[] trianglePointsX = getTrianglePointsX();
final int[] trianglePointsY = getTrianglePointsY();
final int[] trianglePointsZ = getTrianglePointsZ();
final short[] texTriangleX = getTexTriangleX();
final short[] texTriangleY = getTexTriangleY();
final short[] texTriangleZ = getTexTriangleZ();
final byte[] textureCoords = getTextureCoords();
final byte[] textureRenderTypes = getTextureRenderTypes();
int faceCount = getTriangleFaceCount();
this.faceTextureUCoordinates = new float[faceCount][];
this.faceTextureVCoordinates = new float[faceCount][];
for (int i = 0; i < faceCount; i++)
{
int textureCoordinate;
if (textureCoords == null)
{
textureCoordinate = -1;
}
else
{
textureCoordinate = textureCoords[i];
}
short textureIdx;
textureIdx = faceTextures[i];
if (textureIdx != -1)
{
float[] u = new float[3];
float[] v = new float[3];
if (textureCoordinate == -1)
{
u[0] = 0.0F;
v[0] = 1.0F;
u[1] = 1.0F;
v[1] = 1.0F;
u[2] = 0.0F;
v[2] = 0.0F;
}
else
{
textureCoordinate &= 0xFF;
byte textureRenderType = 0;
if (textureRenderTypes != null)
{
textureRenderType = textureRenderTypes[textureCoordinate];
}
if (textureRenderType == 0)
{
int faceVertexIdx1 = trianglePointsX[i];
int faceVertexIdx2 = trianglePointsY[i];
int faceVertexIdx3 = trianglePointsZ[i];
int triangleVertexIdx1 = texTriangleX[textureCoordinate];
int triangleVertexIdx2 = texTriangleY[textureCoordinate];
int triangleVertexIdx3 = texTriangleZ[textureCoordinate];
float triangleX = (float) vertexPositionsX[triangleVertexIdx1];
float triangleY = (float) vertexPositionsY[triangleVertexIdx1];
float triangleZ = (float) vertexPositionsZ[triangleVertexIdx1];
float f_882_ = (float) vertexPositionsX[triangleVertexIdx2] - triangleX;
float f_883_ = (float) vertexPositionsY[triangleVertexIdx2] - triangleY;
float f_884_ = (float) vertexPositionsZ[triangleVertexIdx2] - triangleZ;
float f_885_ = (float) vertexPositionsX[triangleVertexIdx3] - triangleX;
float f_886_ = (float) vertexPositionsY[triangleVertexIdx3] - triangleY;
float f_887_ = (float) vertexPositionsZ[triangleVertexIdx3] - triangleZ;
float f_888_ = (float) vertexPositionsX[faceVertexIdx1] - triangleX;
float f_889_ = (float) vertexPositionsY[faceVertexIdx1] - triangleY;
float f_890_ = (float) vertexPositionsZ[faceVertexIdx1] - triangleZ;
float f_891_ = (float) vertexPositionsX[faceVertexIdx2] - triangleX;
float f_892_ = (float) vertexPositionsY[faceVertexIdx2] - triangleY;
float f_893_ = (float) vertexPositionsZ[faceVertexIdx2] - triangleZ;
float f_894_ = (float) vertexPositionsX[faceVertexIdx3] - triangleX;
float f_895_ = (float) vertexPositionsY[faceVertexIdx3] - triangleY;
float f_896_ = (float) vertexPositionsZ[faceVertexIdx3] - triangleZ;
float f_897_ = f_883_ * f_887_ - f_884_ * f_886_;
float f_898_ = f_884_ * f_885_ - f_882_ * f_887_;
float f_899_ = f_882_ * f_886_ - f_883_ * f_885_;
float f_900_ = f_886_ * f_899_ - f_887_ * f_898_;
float f_901_ = f_887_ * f_897_ - f_885_ * f_899_;
float f_902_ = f_885_ * f_898_ - f_886_ * f_897_;
float f_903_ = 1.0F / (f_900_ * f_882_ + f_901_ * f_883_ + f_902_ * f_884_);
u[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
u[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
u[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
f_900_ = f_883_ * f_899_ - f_884_ * f_898_;
f_901_ = f_884_ * f_897_ - f_882_ * f_899_;
f_902_ = f_882_ * f_898_ - f_883_ * f_897_;
f_903_ = 1.0F / (f_900_ * f_885_ + f_901_ * f_886_ + f_902_ * f_887_);
v[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
v[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
v[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
}
}
this.faceTextureUCoordinates[i] = u;
this.faceTextureVCoordinates[i] = v;
}
}
}
}

View File

@@ -1,437 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Polygon;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.api.model.Jarvis;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSFrame;
import net.runelite.rs.api.RSFrameMap;
import net.runelite.rs.api.RSFrames;
import net.runelite.rs.api.RSModel;
@Mixin(RSModel.class)
public abstract class RSModelMixin implements RSModel
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int rl$sceneId;
@Inject
private int rl$bufferOffset;
@Inject
private int rl$uvBufferOffset;
@Inject
private float[][] rl$faceTextureUCoordinates;
@Inject
private float[][] rl$faceTextureVCoordinates;
@MethodHook(value = "<init>", end = true)
@Inject
public void rl$init(RSModel[] models, int length)
{
int count = 0;
for (int i = 0; i < length; ++i)
{
RSModel model = models[i];
if (model != null)
{
count += model.getTrianglesCount();
}
}
float[][] u = new float[count][];
float[][] v = new float[count][];
int idx = 0;
for (int i = 0; i < length; ++i)
{
RSModel model = models[i];
if (model != null)
{
float[][] modelU = model.getFaceTextureUCoordinates();
float[][] modelV = model.getFaceTextureVCoordinates();
for (int j = 0; j < model.getTrianglesCount(); ++j)
{
if (modelU != null && modelV != null)
{
u[idx] = modelU[j];
v[idx] = modelV[j];
}
++idx;
}
}
}
setFaceTextureUCoordinates(u);
setFaceTextureVCoordinates(v);
}
@Override
@Inject
public List<Vertex> getVertices()
{
int[] verticesX = getVerticesX();
int[] verticesY = getVerticesY();
int[] verticesZ = getVerticesZ();
List<Vertex> vertices = new ArrayList<Vertex>(getVerticesCount());
for (int i = 0; i < getVerticesCount(); ++i)
{
Vertex v = new Vertex(
verticesX[i],
verticesY[i],
verticesZ[i]
);
vertices.add(v);
}
return vertices;
}
@Override
@Inject
public List<Triangle> getTriangles()
{
int[] trianglesX = getTrianglesX();
int[] trianglesY = getTrianglesY();
int[] trianglesZ = getTrianglesZ();
List<Vertex> vertices = getVertices();
List<Triangle> triangles = new ArrayList<Triangle>(getTrianglesCount());
for (int i = 0; i < getTrianglesCount(); ++i)
{
int triangleX = trianglesX[i];
int triangleY = trianglesY[i];
int triangleZ = trianglesZ[i];
Triangle triangle = new Triangle(
vertices.get(triangleX),
vertices.get(triangleY),
vertices.get(triangleZ)
);
triangles.add(triangle);
}
return triangles;
}
@Copy("contourGround")
public abstract Model rs$contourGround(int[][] tileHeights, int packedX, int height, int packedY, boolean copy, int contouredGround);
@Replace("contourGround")
public Model rl$contourGround(int[][] tileHeights, int packedX, int height, int packedY, boolean copy, int contouredGround)
{
// With contouredGround >= 0 lighted models are countoured, so we need to copy uvs
Model model = rs$contourGround(tileHeights, packedX, height, packedY, copy, contouredGround);
if (model != null && model != this)
{
RSModel rsModel = (RSModel) model;
rsModel.setFaceTextureUCoordinates(rl$faceTextureUCoordinates);
rsModel.setFaceTextureVCoordinates(rl$faceTextureVCoordinates);
}
return model;
}
@MethodHook("buildSharedModel")
@Inject
public void rl$buildSharedModel(boolean refTransparencies, Model sharedModel, byte[] transparencyBuffer)
{
// Animated models are usually a shared Model instance that is global
RSModel rsModel = (RSModel) sharedModel;
rsModel.setFaceTextureUCoordinates(rl$faceTextureUCoordinates);
rsModel.setFaceTextureVCoordinates(rl$faceTextureVCoordinates);
}
@Inject
public void interpolateFrames(RSFrames frames, int frameId, RSFrames nextFrames, int nextFrameId, int interval,
int intervalCount)
{
if (getVertexGroups() != null)
{
if (frameId != -1)
{
RSFrame frame = frames.getFrames()[frameId];
RSFrameMap skin = frame.getSkin();
RSFrame nextFrame = null;
if (nextFrames != null)
{
nextFrame = nextFrames.getFrames()[nextFrameId];
if (nextFrame.getSkin() != skin)
{
nextFrame = null;
}
}
client.setAnimOffsetX(0);
client.setAnimOffsetY(0);
client.setAnimOffsetZ(0);
interpolateFrames(skin, frame, nextFrame, interval, intervalCount);
resetBounds();
}
}
}
@Inject
public void interpolateFrames(RSFrameMap skin, RSFrame frame, RSFrame nextFrame, int interval, int intervalCount)
{
if (nextFrame == null || interval == 0)
{
// if there is no next frame or interval then animate the model as we normally would
for (int i = 0; i < frame.getTransformCount(); i++)
{
int type = frame.getTransformTypes()[i];
this.animate(skin.getTypes()[type], skin.getList()[type], frame.getTranslatorX()[i],
frame.getTranslatorY()[i], frame.getTranslatorZ()[i]);
}
}
else
{
int transformIndex = 0;
int nextTransformIndex = 0;
for (int i = 0; i < skin.getCount(); i++)
{
boolean frameValid = false;
if (transformIndex < frame.getTransformCount()
&& frame.getTransformTypes()[transformIndex] == i)
{
frameValid = true;
}
boolean nextFrameValid = false;
if (nextTransformIndex < nextFrame.getTransformCount()
&& nextFrame.getTransformTypes()[nextTransformIndex] == i)
{
nextFrameValid = true;
}
if (frameValid || nextFrameValid)
{
int staticFrame = 0;
int type = skin.getTypes()[i];
if (type == 3 || type == 10)
{
staticFrame = 128;
}
int currentTranslateX = staticFrame;
int currentTranslateY = staticFrame;
int currentTranslateZ = staticFrame;
if (frameValid)
{
currentTranslateX = frame.getTranslatorX()[transformIndex];
currentTranslateY = frame.getTranslatorY()[transformIndex];
currentTranslateZ = frame.getTranslatorZ()[transformIndex];
transformIndex++;
}
int nextTranslateX = staticFrame;
int nextTranslateY = staticFrame;
int nextTranslateZ = staticFrame;
if (nextFrameValid)
{
nextTranslateX = nextFrame.getTranslatorX()[nextTransformIndex];
nextTranslateY = nextFrame.getTranslatorY()[nextTransformIndex];
nextTranslateZ = nextFrame.getTranslatorZ()[nextTransformIndex];
nextTransformIndex++;
}
int translateX;
int translateY;
int translateZ;
if (type == 2)
{
int deltaX = nextTranslateX - currentTranslateX & 0xFF;
int deltaY = nextTranslateY - currentTranslateY & 0xFF;
int deltaZ = nextTranslateZ - currentTranslateZ & 0xFF;
if (deltaX >= 128)
{
deltaX -= 256;
}
if (deltaY >= 128)
{
deltaY -= 256;
}
if (deltaZ >= 128)
{
deltaZ -= 256;
}
translateX = currentTranslateX + deltaX * interval / intervalCount & 0xFF;
translateY = currentTranslateY + deltaY * interval / intervalCount & 0xFF;
translateZ = currentTranslateZ + deltaZ * interval / intervalCount & 0xFF;
}
else if (type == 5)
{
// don't interpolate alpha transformations
// alpha
translateX = currentTranslateX;
translateY = 0;
translateZ = 0;
}
else
{
translateX = currentTranslateX + (nextTranslateX - currentTranslateX) * interval / intervalCount;
translateY = currentTranslateY + (nextTranslateY - currentTranslateY) * interval / intervalCount;
translateZ = currentTranslateZ + (nextTranslateZ - currentTranslateZ) * interval / intervalCount;
}
// use interpolated translations to animate
animate(type, skin.getList()[i], translateX, translateY, translateZ);
}
}
}
}
@Override
@Inject
public Polygon getConvexHull(int localX, int localY, int orientation, int tileHeight)
{
List<Vertex> vertices = getVertices();
// rotate vertices
for (int i = 0; i < vertices.size(); ++i)
{
Vertex v = vertices.get(i);
vertices.set(i, v.rotate(orientation));
}
List<Point> points = new ArrayList<Point>();
for (Vertex v : vertices)
{
// Compute canvas location of vertex
Point p = Perspective.localToCanvas(client,
localX - v.getX(),
localY - v.getZ(),
tileHeight + v.getY());
if (p != null)
{
points.add(p);
}
}
// Run Jarvis march algorithm
points = Jarvis.convexHull(points);
if (points == null)
{
return null;
}
// Convert to a polygon
Polygon p = new Polygon();
for (Point point : points)
{
p.addPoint(point.getX(), point.getY());
}
return p;
}
@Inject
@Override
public int getSceneId()
{
return rl$sceneId;
}
@Inject
@Override
public void setSceneId(int sceneId)
{
this.rl$sceneId = sceneId;
}
@Inject
@Override
public int getBufferOffset()
{
return rl$bufferOffset;
}
@Inject
@Override
public void setBufferOffset(int bufferOffset)
{
rl$bufferOffset = bufferOffset;
}
@Inject
@Override
public int getUvBufferOffset()
{
return rl$uvBufferOffset;
}
@Inject
@Override
public void setUvBufferOffset(int bufferOffset)
{
rl$uvBufferOffset = bufferOffset;
}
@Inject
@Override
public float[][] getFaceTextureUCoordinates()
{
return rl$faceTextureUCoordinates;
}
@Inject
@Override
public void setFaceTextureUCoordinates(float[][] faceTextureUCoordinates)
{
this.rl$faceTextureUCoordinates = faceTextureUCoordinates;
}
@Inject
@Override
public float[][] getFaceTextureVCoordinates()
{
return rl$faceTextureVCoordinates;
}
@Inject
@Override
public void setFaceTextureVCoordinates(float[][] faceTextureVCoordinates)
{
this.rl$faceTextureVCoordinates = faceTextureVCoordinates;
}
}

View File

@@ -1,209 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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 java.awt.event.MouseEvent;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSMouseInput;
@Mixin(RSMouseInput.class)
public abstract class RSMouseInputMixin implements RSMouseInput
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int isInEvent;
@Copy("mousePressed")
abstract void rs$mousePressed(MouseEvent mouseEvent);
@Copy("mouseReleased")
abstract void rs$mouseReleased(MouseEvent mouseEvent);
@Copy("mouseClicked")
abstract void rs$mouseClicked(MouseEvent mouseEvent);
@Copy("mouseEntered")
abstract void rs$mouseEntered(MouseEvent mouseEvent);
@Copy("mouseExited")
abstract void rs$mouseExited(MouseEvent mouseEvent);
@Copy("mouseDragged")
abstract void rs$mouseDragged(MouseEvent mouseEvent);
@Copy("mouseMoved")
abstract void rs$mouseMoved(MouseEvent mouseEvent);
@Override
@Replace("mousePressed")
public synchronized void mousePressed(MouseEvent mouseEvent)
{
if (isInEvent == 0)
{
mouseEvent = client.getCallbacks().mousePressed(mouseEvent);
}
if (!mouseEvent.isConsumed())
{
isInEvent++;
try
{
rs$mousePressed(mouseEvent);
}
finally
{
isInEvent--;
}
}
}
@Override
@Replace("mouseReleased")
public synchronized void mouseReleased(MouseEvent mouseEvent)
{
if (isInEvent == 0)
{
mouseEvent = client.getCallbacks().mouseReleased(mouseEvent);
}
if (!mouseEvent.isConsumed())
{
isInEvent++;
try
{
rs$mouseReleased(mouseEvent);
}
finally
{
isInEvent--;
}
}
}
@Override
@Replace("mouseClicked")
public void mouseClicked(MouseEvent event)
{
event = client.getCallbacks().mouseClicked(event);
if (!event.isConsumed())
{
rs$mouseClicked(event);
}
}
@Override
@Replace("mouseEntered")
public synchronized void mouseEntered(MouseEvent mouseEvent)
{
if (isInEvent == 0)
{
mouseEvent = client.getCallbacks().mouseEntered(mouseEvent);
}
if (!mouseEvent.isConsumed())
{
isInEvent++;
try
{
rs$mouseEntered(mouseEvent);
}
finally
{
isInEvent--;
}
}
}
@Override
@Replace("mouseExited")
public synchronized void mouseExited(MouseEvent mouseEvent)
{
if (isInEvent == 0)
{
mouseEvent = client.getCallbacks().mouseExited(mouseEvent);
}
if (!mouseEvent.isConsumed())
{
isInEvent++;
try
{
rs$mouseExited(mouseEvent);
}
finally
{
isInEvent--;
}
}
}
@Override
@Replace("mouseDragged")
public synchronized void mouseDragged(MouseEvent mouseEvent)
{
if (isInEvent == 0)
{
mouseEvent = client.getCallbacks().mouseDragged(mouseEvent);
}
if (!mouseEvent.isConsumed())
{
isInEvent++;
try
{
rs$mouseDragged(mouseEvent);
}
finally
{
isInEvent--;
}
}
}
@Override
@Replace("mouseMoved")
public synchronized void mouseMoved(MouseEvent mouseEvent)
{
if (isInEvent == 0)
{
mouseEvent = client.getCallbacks().mouseMoved(mouseEvent);
}
if (!mouseEvent.isConsumed())
{
isInEvent++;
try
{
rs$mouseMoved(mouseEvent);
}
finally
{
isInEvent--;
}
}
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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 java.awt.event.MouseWheelEvent;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSMouseWheelHandler;
@Mixin(RSMouseWheelHandler.class)
public abstract class RSMouseWheelHandlerMixin implements RSMouseWheelHandler
{
@Shadow("clientInstance")
private static RSClient client;
@Copy("mouseWheelMoved")
abstract void rs$mouseWheelMoved(MouseWheelEvent event);
@Override
@Replace("mouseWheelMoved")
public void mouseWheelMoved(MouseWheelEvent event)
{
event = client.getCallbacks().mouseWheelMoved(event);
if (!event.isConsumed())
{
rs$mouseWheelMoved(event);
}
}
}

View File

@@ -1,192 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Polygon;
import net.runelite.api.AnimationID;
import net.runelite.api.NPCComposition;
import net.runelite.api.Perspective;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.events.NpcDespawned;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSNPC;
import net.runelite.rs.api.RSNPCComposition;
@Mixin(RSNPC.class)
public abstract class RSNPCMixin implements RSNPC
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int npcIndex;
@Inject
private boolean dead;
@Inject
@Override
public int getId()
{
RSNPCComposition composition = getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition == null ? -1 : composition.getId();
}
@Inject
@Override
public String getName()
{
RSNPCComposition composition = getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition == null ? null : composition.getName().replace('\u00A0', ' ');
}
@Inject
@Override
public int getCombatLevel()
{
RSNPCComposition composition = getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition == null ? -1 : composition.getCombatLevel();
}
@Inject
@Override
public int getIndex()
{
return npcIndex;
}
@Inject
@Override
public void setIndex(int id)
{
npcIndex = id;
}
@FieldHook(value = "composition", before = true)
@Inject
public void onCompositionChanged(RSNPCComposition composition)
{
if (composition == null)
{
client.getCallbacks().post(new NpcDespawned(this));
}
}
@Copy("getModel")
public abstract RSModel rs$getModel();
@Replace("getModel")
public RSModel rl$getModel()
{
if (!client.isInterpolateNpcAnimations()
|| getAnimation() == AnimationID.HELLHOUND_DEFENCE)
{
return rs$getModel();
}
int actionFrame = getActionFrame();
int poseFrame = getPoseFrame();
int spotAnimFrame = getSpotAnimFrame();
try
{
// combine the frames with the frame cycle so we can access this information in the sequence methods
// without having to change method calls
setActionFrame(Integer.MIN_VALUE | getActionFrameCycle() << 16 | actionFrame);
setPoseFrame(Integer.MIN_VALUE | getPoseFrameCycle() << 16 | poseFrame);
setSpotAnimFrame(Integer.MIN_VALUE | getSpotAnimFrameCycle() << 16 | spotAnimFrame);
return rs$getModel();
}
finally
{
// reset frames
setActionFrame(actionFrame);
setPoseFrame(poseFrame);
setSpotAnimFrame(spotAnimFrame);
}
}
@Inject
@Override
public NPCComposition getTransformedComposition()
{
RSNPCComposition composition = getComposition();
if (composition != null && composition.getConfigs() != null)
{
composition = composition.transform();
}
return composition;
}
@Inject
@Override
public boolean isDead()
{
return dead;
}
@Inject
@Override
public void setDead(boolean dead)
{
this.dead = dead;
}
@Inject
@Override
public Polygon getConvexHull()
{
RSModel model = getModel();
if (model == null)
{
return null;
}
int size = getComposition().getSize();
LocalPoint tileHeightPoint = new LocalPoint(
size * Perspective.LOCAL_HALF_TILE_SIZE - Perspective.LOCAL_HALF_TILE_SIZE + getX(),
size * Perspective.LOCAL_HALF_TILE_SIZE - Perspective.LOCAL_HALF_TILE_SIZE + getY());
int tileHeight = Perspective.getTileHeight(client, tileHeightPoint, client.getPlane());
return model.getConvexHull(getX(), getY(), getOrientation(), tileHeight);
}
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright (c) 2018, trimbe <github.com/trimbe>
* Copyright (c) 2019, Adam <Adam@sigterm.info>
* 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.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSName;
import net.runelite.rs.api.RSNameable;
import net.runelite.rs.api.RSNameableContainer;
@Mixin(RSNameableContainer.class)
public abstract class RSNameableContainerMixin implements RSNameableContainer
{
/**
* Default implementation of rl$add
* @param name
* @param prevName
*/
@Inject
@Override
public void rl$add(RSName name, RSName prevName)
{
}
/**
* Default implementation of rl$del
* @param nameable
*/
@Inject
@Override
public void rl$remove(RSNameable nameable)
{
}
@Inject
@MethodHook(value = "add", end = true)
public void add(RSName name, RSName prevName)
{
rl$add(name, prevName);
}
@Inject
@MethodHook("remove")
public void remove(RSNameable nameable)
{
rl$remove(nameable);
}
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.events.NameableNameChanged;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSNameable;
@Mixin(RSNameable.class)
public abstract class RSNameableMixin implements RSNameable
{
@Shadow("clientInstance")
private static RSClient client;
@FieldHook("prevName")
@Inject
public void onPrevNameChanged(int idx)
{
NameableNameChanged nameableNameChanged = new NameableNameChanged(this);
client.getCallbacks().post(nameableNameChanged);
}
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSNode;
@Mixin(RSNode.class)
public abstract class RSNodeMixin implements RSNode
{
@Inject
public void onUnlink()
{
}
@Inject
@MethodHook("unlink")
public void rl$unlink()
{
onUnlink();
}
}

View File

@@ -1,74 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.HeadIcon;
import static net.runelite.api.HeadIcon.MAGIC;
import static net.runelite.api.HeadIcon.MELEE;
import static net.runelite.api.HeadIcon.RANGED;
import static net.runelite.api.HeadIcon.RANGE_MAGE;
import net.runelite.api.events.NpcActionChanged;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSNPCComposition;
@Mixin(RSNPCComposition.class)
public abstract class RSNpcCompositionMixin implements RSNPCComposition
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public HeadIcon getOverheadIcon()
{
switch (getRsOverheadIcon())
{
case 0:
return MELEE;
case 1:
return RANGED;
case 2:
return MAGIC;
case 6:
return RANGE_MAGE;
default:
return null;
}
}
@FieldHook("actions")
@Inject
public void actionsHook(int idx)
{
NpcActionChanged npcActionChanged = new NpcActionChanged();
npcActionChanged.setNpcComposition(this);
npcActionChanged.setIdx(idx);
client.getCallbacks().post(npcActionChanged);
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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.kit.KitType;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSPlayerComposition;
@Mixin(RSPlayerComposition.class)
public abstract class RSPlayerCompositionMixin implements RSPlayerComposition
{
@Inject
@Override
public int getEquipmentId(KitType type)
{
int id = getEquipmentIds()[type.getIndex()];
if (id < 512)
{
return -1; // not an item
}
return id - 512;
}
@Inject
@Override
public int getKitId(KitType type)
{
int id = getEquipmentIds()[type.getIndex()];
if (id < 256 || id >= 512)
{
return -1; // not a kit
}
return id - 256;
}
}

View File

@@ -1,264 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Polygon;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.HeadIcon;
import static net.runelite.api.HeadIcon.MAGIC;
import static net.runelite.api.HeadIcon.MELEE;
import static net.runelite.api.HeadIcon.RANGED;
import static net.runelite.api.HeadIcon.REDEMPTION;
import static net.runelite.api.HeadIcon.RETRIBUTION;
import static net.runelite.api.HeadIcon.SMITE;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.SkullIcon;
import static net.runelite.api.SkullIcon.DEAD_MAN_FIVE;
import static net.runelite.api.SkullIcon.DEAD_MAN_FOUR;
import static net.runelite.api.SkullIcon.DEAD_MAN_ONE;
import static net.runelite.api.SkullIcon.DEAD_MAN_THREE;
import static net.runelite.api.SkullIcon.DEAD_MAN_TWO;
import static net.runelite.api.SkullIcon.SKULL;
import static net.runelite.api.SkullIcon.SKULL_FIGHT_PIT;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSName;
import net.runelite.rs.api.RSPlayer;
@Mixin(RSPlayer.class)
public abstract class RSPlayerMixin implements RSPlayer
{
@Shadow("clientInstance")
private static RSClient client;
@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', ' ');
}
@Inject
@Override
public HeadIcon getOverheadIcon()
{
switch (getRsOverheadIcon())
{
case 0:
return MELEE;
case 1:
return RANGED;
case 2:
return MAGIC;
case 3:
return RETRIBUTION;
case 4:
return SMITE;
case 5:
return REDEMPTION;
default:
return null;
}
}
@Inject
@Override
public SkullIcon getSkullIcon()
{
if (this != client.getLocalPlayer())
{
// prevent seeing skulls of other players.
return null;
}
switch (getRsSkullIcon())
{
case 0:
return SKULL;
case 1:
return SKULL_FIGHT_PIT;
case 8:
return DEAD_MAN_FIVE;
case 9:
return DEAD_MAN_FOUR;
case 10:
return DEAD_MAN_THREE;
case 11:
return DEAD_MAN_TWO;
case 12:
return DEAD_MAN_ONE;
default:
return null;
}
}
@Inject
@Override
public Polygon[] getPolygons()
{
Model model = getModel();
if (model == null)
{
return null;
}
int localX = getX();
int localY = getY();
int orientation = getOrientation();
final int tileHeight = Perspective.getTileHeight(client, new LocalPoint(localX, localY), client.getPlane());
List<Triangle> triangles = model.getTriangles();
triangles = rotate(triangles, orientation);
List<Polygon> polys = new ArrayList<Polygon>();
for (Triangle triangle : triangles)
{
Vertex vx = triangle.getA();
Vertex vy = triangle.getB();
Vertex vz = triangle.getC();
Point x = Perspective.localToCanvas(client,
localX - vx.getX(),
localY - vx.getZ(),
tileHeight + vx.getY());
Point y = Perspective.localToCanvas(client,
localX - vy.getX(),
localY - vy.getZ(),
tileHeight + vy.getY());
Point z = Perspective.localToCanvas(client,
localX - vz.getX(),
localY - vz.getZ(),
tileHeight + vz.getY());
int[] xx =
{
x.getX(), y.getX(), z.getX()
};
int[] yy =
{
x.getY(), y.getY(), z.getY()
};
polys.add(new Polygon(xx, yy, 3));
}
return polys.toArray(new Polygon[polys.size()]);
}
@Inject
@Override
public Polygon getConvexHull()
{
RSModel model = getModel();
if (model == null)
{
return null;
}
int tileHeight = Perspective.getTileHeight(client, new LocalPoint(getX(), getY()), client.getPlane());
return model.getConvexHull(getX(), getY(), getOrientation(), tileHeight);
}
@Inject
private List<Triangle> rotate(List<Triangle> triangles, int orientation)
{
List<Triangle> rotatedTriangles = new ArrayList<Triangle>();
for (Triangle triangle : triangles)
{
Vertex a = triangle.getA();
Vertex b = triangle.getB();
Vertex c = triangle.getC();
Triangle rotatedTriangle = new Triangle(
a.rotate(orientation),
b.rotate(orientation),
c.rotate(orientation)
);
rotatedTriangles.add(rotatedTriangle);
}
return rotatedTriangles;
}
@Copy("getModel")
public abstract RSModel rs$getModel();
@Replace("getModel")
public RSModel rl$getModel()
{
if (!client.isInterpolatePlayerAnimations())
{
return rs$getModel();
}
int actionFrame = getActionFrame();
int poseFrame = getPoseFrame();
int spotAnimFrame = getSpotAnimFrame();
try
{
// combine the frames with the frame cycle so we can access this information in the sequence methods
// without having to change method calls
setActionFrame(Integer.MIN_VALUE | getActionFrameCycle() << 16 | actionFrame);
setPoseFrame(Integer.MIN_VALUE | getPoseFrameCycle() << 16 | poseFrame);
setSpotAnimFrame(Integer.MIN_VALUE | getSpotAnimFrameCycle() << 16 | spotAnimFrame);
return rs$getModel();
}
finally
{
// reset frames
setActionFrame(actionFrame);
setPoseFrame(poseFrame);
setSpotAnimFrame(spotAnimFrame);
}
}
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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.coords.LocalPoint;
import net.runelite.api.events.ProjectileMoved;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSProjectile;
@Mixin(RSProjectile.class)
public abstract class RSProjectileMixin implements RSProjectile
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public int getRemainingCycles()
{
int currentGameCycle = client.getGameCycle();
return getEndCycle() - currentGameCycle;
}
/**
* Called when a projectile is set to move towards a point. For
* projectiles that target the ground, like AoE projectiles from
* Lizardman Shamans, this is only called once
*
* @param targetX X position of where the projectile is being moved to
* @param targetY Y position of where the projectile is being moved to
* @param targetZ Z position of where the projectile is being moved to
* @param cycle
*/
@Inject
@MethodHook("moveProjectile")
public void projectileMoved(int targetX, int targetY, int targetZ, int cycle)
{
final LocalPoint position = new LocalPoint(targetX, targetY);
final ProjectileMoved projectileMoved = new ProjectileMoved();
projectileMoved.setProjectile(this);
projectileMoved.setPosition(position);
projectileMoved.setZ(targetZ);
client.getCallbacks().post(projectileMoved);
}
}

View File

@@ -1,751 +0,0 @@
/*
* Copyright (c) 2018 Abex
* 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.Perspective;
import net.runelite.api.Renderable;
import net.runelite.api.SceneTileModel;
import net.runelite.api.SceneTilePaint;
import net.runelite.api.Tile;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.hooks.DrawCallbacks;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSDecorativeObject;
import net.runelite.rs.api.RSGroundObject;
import net.runelite.rs.api.RSItemLayer;
import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSSceneTileModel;
import net.runelite.rs.api.RSTile;
import net.runelite.rs.api.RSWallObject;
@Mixin(RSScene.class)
public abstract class RSSceneMixin implements RSScene
{
private static final int DEFAULT_DISTANCE = 25;
private static final int MAX_DISTANCE = 90;
private static final int PITCH_LOWER_LIMIT = 128;
private static final int PITCH_UPPER_LIMIT = 383;
private static final int MAX_TARGET_DISTANCE = 45;
@Shadow("clientInstance")
static RSClient client;
@Shadow("pitchRelaxEnabled")
private static boolean pitchRelaxEnabled;
@Inject
private static int[] tmpX = new int[6];
@Shadow("skyboxColor")
static int skyboxColor;
@Inject
private static int[] tmpY = new int[6];
@Inject
private static int rl$drawDistance;
@Replace("drawScene")
void rl$drawScene(int cameraX, int cameraY, int cameraZ, int cameraPitch, int cameraYaw, int plane)
{
final DrawCallbacks drawCallbacks = client.getDrawCallbacks();
if (drawCallbacks != null)
{
drawCallbacks.drawScene(cameraX, cameraY, cameraZ, cameraPitch, cameraYaw, plane);
}
final boolean isGpu = client.isGpu();
final boolean checkClick = client.isCheckClick();
if (!client.isMenuOpen())
{
// 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());
}
if (!isGpu)
{
if (skyboxColor != 0)
{
client.RasterizerFillRectangle(
client.getViewportXOffset(),
client.getViewportYOffset(),
client.getViewportWidth(),
client.getViewportHeight(),
skyboxColor
);
}
}
final int maxX = getMaxX();
final int maxY = getMaxY();
final int maxZ = getMaxZ();
final int minLevel = getMinLevel();
final RSTile[][][] tiles = getTiles();
final int distance = isGpu ? rl$drawDistance : DEFAULT_DISTANCE;
if (cameraX < 0)
{
cameraX = 0;
}
else if (cameraX >= maxX * Perspective.LOCAL_TILE_SIZE)
{
cameraX = maxX * Perspective.LOCAL_TILE_SIZE - 1;
}
if (cameraZ < 0)
{
cameraZ = 0;
}
else if (cameraZ >= maxZ * Perspective.LOCAL_TILE_SIZE)
{
cameraZ = maxZ * Perspective.LOCAL_TILE_SIZE - 1;
}
// we store the uncapped pitch for setting camera angle for the pitch relaxer
// we still have to cap the pitch in order to access the visibility map, though
int realPitch = cameraPitch;
if (cameraPitch < PITCH_LOWER_LIMIT)
{
cameraPitch = PITCH_LOWER_LIMIT;
}
else if (cameraPitch > PITCH_UPPER_LIMIT)
{
cameraPitch = PITCH_UPPER_LIMIT;
}
if (!pitchRelaxEnabled)
{
realPitch = cameraPitch;
}
client.setCycle(client.getCycle() + 1);
client.setPitchSin(Perspective.SINE[realPitch]);
client.setPitchCos(Perspective.COSINE[realPitch]);
client.setYawSin(Perspective.SINE[cameraYaw]);
client.setYawCos(Perspective.COSINE[cameraYaw]);
final int[][][] tileHeights = client.getTileHeights();
boolean[][] renderArea = client.getVisibilityMaps()[(cameraPitch - 128) / 32][cameraYaw / 64];
client.setRenderArea(renderArea);
client.setCameraX2(cameraX);
client.setCameraY2(cameraY);
client.setCameraZ2(cameraZ);
int screenCenterX = cameraX / Perspective.LOCAL_TILE_SIZE;
int screenCenterZ = cameraZ / Perspective.LOCAL_TILE_SIZE;
client.setScreenCenterX(screenCenterX);
client.setScreenCenterZ(screenCenterZ);
client.setScenePlane(plane);
int minTileX = screenCenterX - distance;
if (minTileX < 0)
{
minTileX = 0;
}
int minTileZ = screenCenterZ - distance;
if (minTileZ < 0)
{
minTileZ = 0;
}
int maxTileX = screenCenterX + distance;
if (maxTileX > maxX)
{
maxTileX = maxX;
}
int maxTileZ = screenCenterZ + distance;
if (maxTileZ > maxZ)
{
maxTileZ = maxZ;
}
client.setMinTileX(minTileX);
client.setMinTileZ(minTileZ);
client.setMaxTileX(maxTileX);
client.setMaxTileZ(maxTileZ);
updateOccluders();
client.setTileUpdateCount(0);
for (int z = minLevel; z < maxY; ++z)
{
RSTile[][] planeTiles = tiles[z];
for (int x = minTileX; x < maxTileX; ++x)
{
for (int y = minTileZ; y < maxTileZ; ++y)
{
RSTile tile = planeTiles[x][y];
if (tile != null)
{
if (tile.getPhysicalLevel() <= plane
&& (isGpu
|| renderArea[x - screenCenterX + DEFAULT_DISTANCE][y - screenCenterZ + DEFAULT_DISTANCE]
|| tileHeights[z][x][y] - cameraY >= 2000))
{
tile.setDraw(true);
tile.setVisible(true);
tile.setDrawEntities(true);
client.setTileUpdateCount(client.getTileUpdateCount() + 1);
}
else
{
tile.setDraw(false);
tile.setVisible(false);
tile.setWallCullDirection(0);
}
}
}
}
}
for (int z = minLevel; z < maxY; ++z)
{
RSTile[][] planeTiles = tiles[z];
for (int x = -distance; x <= 0; ++x)
{
int var10 = x + screenCenterX;
int var16 = screenCenterX - x;
if (var10 >= minTileX || var16 < maxTileX)
{
for (int y = -distance; y <= 0; ++y)
{
int var13 = y + screenCenterZ;
int var14 = screenCenterZ - y;
if (var10 >= minTileX)
{
if (var13 >= minTileZ)
{
RSTile tile = planeTiles[var10][var13];
if (tile != null && tile.isDraw())
{
draw(tile, true);
}
}
if (var14 < maxTileZ)
{
RSTile tile = planeTiles[var10][var14];
if (tile != null && tile.isDraw())
{
draw(tile, true);
}
}
}
if (var16 < maxTileX)
{
if (var13 >= minTileZ)
{
RSTile tile = planeTiles[var16][var13];
if (tile != null && tile.isDraw())
{
draw(tile, true);
}
}
if (var14 < maxTileZ)
{
RSTile tile = planeTiles[var16][var14];
if (tile != null && tile.isDraw())
{
draw(tile, true);
}
}
}
if (client.getTileUpdateCount() == 0)
{
if (!isGpu && client.getOculusOrbState() != 0)
{
client.setEntitiesAtMouseCount(0);
}
client.setCheckClick(false);
if (!checkClick)
{
client.setViewportWalking(false);
}
client.getCallbacks().drawScene();
return;
}
}
}
}
}
for (int z = minLevel; z < maxY; ++z)
{
RSTile[][] planeTiles = tiles[z];
for (int x = -distance; x <= 0; ++x)
{
int var10 = x + screenCenterX;
int var16 = screenCenterX - x;
if (var10 >= minTileX || var16 < maxTileX)
{
for (int y = -distance; y <= 0; ++y)
{
int var13 = y + screenCenterZ;
int var14 = screenCenterZ - y;
if (var10 >= minTileX)
{
if (var13 >= minTileZ)
{
RSTile tile = planeTiles[var10][var13];
if (tile != null && tile.isDraw())
{
draw(tile, false);
}
}
if (var14 < maxTileZ)
{
RSTile tile = planeTiles[var10][var14];
if (tile != null && tile.isDraw())
{
draw(tile, false);
}
}
}
if (var16 < maxTileX)
{
if (var13 >= minTileZ)
{
RSTile tile = planeTiles[var16][var13];
if (tile != null && tile.isDraw())
{
draw(tile, false);
}
}
if (var14 < maxTileZ)
{
RSTile tile = planeTiles[var16][var14];
if (tile != null && tile.isDraw())
{
draw(tile, false);
}
}
}
if (client.getTileUpdateCount() == 0)
{
if (!isGpu && client.getOculusOrbState() != 0)
{
client.setEntitiesAtMouseCount(0);
}
client.setCheckClick(false);
if (!checkClick)
{
client.setViewportWalking(false);
}
client.getCallbacks().drawScene();
return;
}
}
}
}
}
if (!isGpu && client.getOculusOrbState() != 0)
{
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();
}
@Copy("addBoundaryDecoration")
abstract public void rs$addBoundaryDecoration(int plane, int x, int y, int floor, Renderable var5, Renderable var6, int var7, int var8, int var9, int var10, long hash, int var12);
@Replace("addBoundaryDecoration")
public void rl$addBoundaryDecoration(int plane, int x, int y, int floor, Renderable var5, Renderable var6, int var7, int var8, int var9, int var10, long hash, int var12)
{
rs$addBoundaryDecoration(plane, x, y, floor, var5, var6, var7, var8, var9, var10, hash, var12);
Tile tile = getTiles()[plane][x][y];
if (tile != null)
{
RSDecorativeObject object = (RSDecorativeObject) tile.getDecorativeObject();
if (object != null)
{
object.setPlane(plane);
}
}
}
@Copy("addItemPile")
abstract public void rs$addItemPile(int plane, int x, int y, int hash, Renderable var5, long var6, Renderable var7, Renderable var8);
@Replace("addItemPile")
public void rl$addItemPile(int plane, int x, int y, int hash, Renderable var5, long var6, Renderable var7, Renderable var8)
{
rs$addItemPile(plane, x, y, hash, var5, var6, var7, var8);
Tile tile = getTiles()[plane][x][y];
if (tile != null)
{
RSItemLayer itemLayer = (RSItemLayer) tile.getItemLayer();
if (itemLayer != null)
{
itemLayer.setPlane(plane);
}
}
}
@Copy("groundObjectSpawned")
abstract public void rs$groundObjectSpawned(int plane, int x, int y, int floor, Renderable var5, long hash, int var7);
@Replace("groundObjectSpawned")
public void rl$groundObjectSpawned(int plane, int x, int y, int floor, Renderable var5, long hash, int var7)
{
rs$groundObjectSpawned(plane, x, y, floor, var5, hash, var7);
Tile tile = getTiles()[plane][x][y];
if (tile != null)
{
RSGroundObject groundObject = (RSGroundObject) tile.getGroundObject();
if (groundObject != null)
{
groundObject.setPlane(plane);
}
}
}
@Copy("addBoundary")
abstract public void rs$addBoundary(int plane, int x, int y, int floor, Renderable var5, Renderable var6, int var7, int var8, long hash, int var10);
@Replace("addBoundary")
public void rl$addBoundary(int plane, int x, int y, int floor, Renderable var5, Renderable var6, int var7, int var8, long hash, int var10)
{
rs$addBoundary(plane, x, y, floor, var5, var6, var7, var8, hash, var10);
Tile tile = getTiles()[plane][x][y];
if (tile != null)
{
RSWallObject wallObject = (RSWallObject) tile.getWallObject();
if (wallObject != null)
{
wallObject.setPlane(plane);
}
}
}
@Copy("drawTileUnderlay")
abstract public void rs$drawTileUnderlay(SceneTilePaint tile, int z, int pitchSin, int pitchCos, int yawSin, int yawCos, int x, int y);
@Replace("drawTileUnderlay")
public void rl$drawTileUnderlay(SceneTilePaint tile, int z, int pitchSin, int pitchCos, int yawSin, int yawCos, int x, int y)
{
if (!client.isGpu())
{
try
{
rs$drawTileUnderlay(tile, z, pitchSin, pitchCos, yawSin, yawCos, x, y);
}
catch (Exception ex)
{
client.getLogger().warn("error during tile underlay rendering", ex);
}
return;
}
final DrawCallbacks drawCallbacks = client.getDrawCallbacks();
if (drawCallbacks == null)
{
return;
}
try
{
final int[][][] tileHeights = getTileHeights();
final int cameraX2 = client.getCameraX2();
final int cameraY2 = client.getCameraY2();
final int cameraZ2 = client.getCameraZ2();
final int zoom = client.get3dZoom();
final int centerX = client.getCenterX();
final int centerY = client.getCenterY();
final int mouseX2 = client.getMouseX2();
final int mouseY2 = client.getMouseY2();
final boolean checkClick = client.isCheckClick();
int var9;
int var10 = var9 = (x << 7) - cameraX2;
int var11;
int var12 = var11 = (y << 7) - cameraZ2;
int var13;
int var14 = var13 = var10 + 128;
int var15;
int var16 = var15 = var12 + 128;
int var17 = tileHeights[z][x][y] - cameraY2;
int var18 = tileHeights[z][x + 1][y] - cameraY2;
int var19 = tileHeights[z][x + 1][y + 1] - cameraY2;
int var20 = tileHeights[z][x][y + 1] - cameraY2;
int var21 = var10 * yawCos + yawSin * var12 >> 16;
var12 = var12 * yawCos - yawSin * var10 >> 16;
var10 = var21;
var21 = var17 * pitchCos - pitchSin * var12 >> 16;
var12 = pitchSin * var17 + var12 * pitchCos >> 16;
var17 = var21;
if (var12 >= 50)
{
var21 = var14 * yawCos + yawSin * var11 >> 16;
var11 = var11 * yawCos - yawSin * var14 >> 16;
var14 = var21;
var21 = var18 * pitchCos - pitchSin * var11 >> 16;
var11 = pitchSin * var18 + var11 * pitchCos >> 16;
var18 = var21;
if (var11 >= 50)
{
var21 = var13 * yawCos + yawSin * var16 >> 16;
var16 = var16 * yawCos - yawSin * var13 >> 16;
var13 = var21;
var21 = var19 * pitchCos - pitchSin * var16 >> 16;
var16 = pitchSin * var19 + var16 * pitchCos >> 16;
var19 = var21;
if (var16 >= 50)
{
var21 = var9 * yawCos + yawSin * var15 >> 16;
var15 = var15 * yawCos - yawSin * var9 >> 16;
var9 = var21;
var21 = var20 * pitchCos - pitchSin * var15 >> 16;
var15 = pitchSin * var20 + var15 * pitchCos >> 16;
if (var15 >= 50)
{
int dy = var10 * zoom / var12 + centerX;
int dx = var17 * zoom / var12 + centerY;
int cy = var14 * zoom / var11 + centerX;
int cx = var18 * zoom / var11 + centerY;
int ay = var13 * zoom / var16 + centerX;
int ax = var19 * zoom / var16 + centerY;
int by = var9 * zoom / var15 + centerX;
int bx = var21 * zoom / var15 + centerY;
drawCallbacks.drawScenePaint(0, pitchSin, pitchCos, yawSin, yawCos,
-cameraX2, -cameraY2, -cameraZ2,
tile, z, x, y,
zoom, centerX, centerY);
if ((ay - by) * (cx - bx) - (ax - bx) * (cy - by) > 0)
{
if (checkClick && client.containsBounds(mouseX2, mouseY2, ax, bx, cx, ay, by, cy))
{
setTargetTile(x, y);
}
}
if ((dy - cy) * (bx - cx) - (dx - cx) * (by - cy) > 0)
{
if (checkClick && client.containsBounds(mouseX2, mouseY2, dx, cx, bx, dy, cy, by))
{
setTargetTile(x, y);
}
}
}
}
}
}
}
catch (Exception ex)
{
client.getLogger().warn("error during underlay rendering", ex);
}
}
@Copy("drawTileOverlay")
abstract public void rs$drawTileOverlay(SceneTileModel tile, int pitchSin, int pitchCos, int yawSin, int yawCos, int x, int y);
@Replace("drawTileOverlay")
public void rl$drawTileOverlay(SceneTileModel tile, int pitchSin, int pitchCos, int yawSin, int yawCos, int tileX, int tileY)
{
if (!client.isGpu())
{
rs$drawTileOverlay(tile, pitchSin, pitchCos, yawSin, yawCos, tileX, tileY);
return;
}
final DrawCallbacks drawCallbacks = client.getDrawCallbacks();
if (drawCallbacks == null)
{
return;
}
try
{
final int cameraX2 = client.getCameraX2();
final int cameraY2 = client.getCameraY2();
final int cameraZ2 = client.getCameraZ2();
final int zoom = client.get3dZoom();
final int centerX = client.getCenterX();
final int centerY = client.getCenterY();
drawCallbacks.drawSceneModel(0, pitchSin, pitchCos, yawSin, yawCos, -cameraX2, -cameraY2, -cameraZ2,
tile, client.getPlane(), tileX, tileY,
zoom, centerX, centerY);
final boolean checkClick = client.isCheckClick();
if (!checkClick)
{
return;
}
RSSceneTileModel sceneTileModel = (RSSceneTileModel) tile;
final int[] faceX = sceneTileModel.getFaceX();
final int[] faceY = sceneTileModel.getFaceY();
final int[] faceZ = sceneTileModel.getFaceZ();
final int[] vertexX = sceneTileModel.getVertexX();
final int[] vertexY = sceneTileModel.getVertexY();
final int[] vertexZ = sceneTileModel.getVertexZ();
final int vertexCount = vertexX.length;
final int faceCount = faceX.length;
final int mouseX2 = client.getMouseX2();
final int mouseY2 = client.getMouseY2();
for (int i = 0; i < vertexCount; ++i)
{
int vx = vertexX[i] - cameraX2;
int vy = vertexY[i] - cameraY2;
int vz = vertexZ[i] - cameraZ2;
int rotA = vz * yawSin + vx * yawCos >> 16;
int rotB = vz * yawCos - vx * yawSin >> 16;
int var13 = vy * pitchCos - rotB * pitchSin >> 16;
int var12 = vy * pitchSin + rotB * pitchCos >> 16;
if (var12 < 50)
{
return;
}
int ax = rotA * zoom / var12 + centerX;
int ay = var13 * zoom / var12 + centerY;
tmpX[i] = ax;
tmpY[i] = ay;
}
for (int i = 0; i < faceCount; ++i)
{
int va = faceX[i];
int vb = faceY[i];
int vc = faceZ[i];
int x1 = tmpX[va];
int x2 = tmpX[vb];
int x3 = tmpX[vc];
int y1 = tmpY[va];
int y2 = tmpY[vb];
int y3 = tmpY[vc];
if ((x1 - x2) * (y3 - y2) - (y1 - y2) * (x3 - x2) > 0)
{
if (client.containsBounds(mouseX2, mouseY2, y1, y2, y3, x1, x2, x3))
{
setTargetTile(tileX, tileY);
break;
}
}
}
}
catch (Exception ex)
{
client.getLogger().warn("error during overlay rendering", ex);
}
}
@Inject
@Override
public int getDrawDistance()
{
return rl$drawDistance;
}
@Inject
@Override
public void setDrawDistance(int drawDistance)
{
rl$drawDistance = drawDistance;
}
@Inject
static void setTargetTile(int targetX, int targetY)
{
final LocalPoint current = client.getLocalPlayer().getLocalLocation();
// Limit walk distance - https://math.stackexchange.com/a/85582
final int a = current.getSceneX();
final int b = current.getSceneY();
final int c = targetX;
final int d = targetY;
final int r = MAX_TARGET_DISTANCE;
final int t = (int) Math.hypot(a - c, b - d) - r;
int x = targetX;
int y = targetY;
if (t > 0)
{
x = (r * c + t * a) / (r + t);
y = (r * d + t * b) / (r + t);
}
client.setSelectedSceneTileX(x);
client.setSelectedSceneTileY(y);
}
}

View File

@@ -1,84 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSSceneTileModel;
@Mixin(RSSceneTileModel.class)
public abstract class RSSceneTileModelMixin implements RSSceneTileModel
{
@Inject
private int rl$modelBufferOffset;
@Inject
private int rl$modelUvBufferOffset;
@Inject
private int rl$modelBufferLen;
@Inject
@Override
public int getBufferOffset()
{
return rl$modelBufferOffset;
}
@Inject
@Override
public void setBufferOffset(int bufferOffset)
{
rl$modelBufferOffset = bufferOffset;
}
@Inject
@Override
public int getUvBufferOffset()
{
return rl$modelUvBufferOffset;
}
@Inject
@Override
public void setUvBufferOffset(int bufferOffset)
{
rl$modelUvBufferOffset = bufferOffset;
}
@Inject
@Override
public int getBufferLen()
{
return rl$modelBufferLen;
}
@Inject
@Override
public void setBufferLen(int bufferLen)
{
rl$modelBufferLen = bufferLen;
}
}

View File

@@ -1,84 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSSceneTilePaint;
@Mixin(RSSceneTilePaint.class)
public abstract class RSSceneTilePaintMixin implements RSSceneTilePaint
{
@Inject
private int rl$paintModelBufferOffset;
@Inject
private int rl$paintModelUvBufferOffset;
@Inject
private int rl$paintModelBufferLen;
@Inject
@Override
public int getBufferOffset()
{
return rl$paintModelBufferOffset;
}
@Inject
@Override
public void setBufferOffset(int bufferOffset)
{
rl$paintModelBufferOffset = bufferOffset;
}
@Inject
@Override
public int getUvBufferOffset()
{
return rl$paintModelUvBufferOffset;
}
@Inject
@Override
public void setUvBufferOffset(int bufferOffset)
{
rl$paintModelUvBufferOffset = bufferOffset;
}
@Inject
@Override
public int getBufferLen()
{
return rl$paintModelBufferLen;
}
@Inject
@Override
public void setBufferLen(int bufferLen)
{
rl$paintModelBufferLen = bufferLen;
}
}

View File

@@ -1,243 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Copy;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSFrames;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSSequence;
@Mixin(RSSequence.class)
public abstract class RSSequenceMixin implements RSSequence
{
@Shadow("clientInstance")
private static RSClient client;
@Copy("applyTransformations")
public abstract RSModel rs$applyTransformations(RSModel model, int actionFrame, RSSequence poseSeq, int poseFrame);
@Replace("applyTransformations")
public RSModel rl$applyTransformations(RSModel model, int actionFrame, RSSequence poseSeq, int poseFrame)
{
// reset frame ids because we're not interpolating this
if (actionFrame < 0)
{
int packed = actionFrame ^ Integer.MIN_VALUE;
actionFrame = packed & 0xFFFF;
}
if (poseFrame < 0)
{
int packed = poseFrame ^ Integer.MIN_VALUE;
poseFrame = packed & 0xFFFF;
}
return rs$applyTransformations(model, actionFrame, poseSeq, poseFrame);
}
@Copy("transformActorModel")
public abstract RSModel rs$transformActorModel(RSModel model, int frameIdx);
@Replace("transformActorModel")
public RSModel rl$transformActorModel(RSModel model, int frame)
{
// check if the frame has been modified
if (frame < 0)
{
// remove flag to check if the frame has been modified
int packed = frame ^ Integer.MIN_VALUE;
int interval = packed >> 16;
frame = packed & 0xFFFF;
int nextFrame = frame + 1;
if (nextFrame >= getFrameIDs().length)
{
// dont interpolate last frame
nextFrame = -1;
}
int[] frameIds = getFrameIDs();
int frameId = frameIds[frame];
RSFrames frames = client.getFrames(frameId >> 16);
int frameIdx = frameId & 0xFFFF;
int nextFrameIdx = -1;
RSFrames nextFrames = null;
if (nextFrame != -1)
{
int nextFrameId = frameIds[nextFrame];
nextFrames = client.getFrames(nextFrameId >> 16);
nextFrameIdx = nextFrameId & 0xFFFF;
}
if (frames == null)
{
// not sure what toSharedModel does but it is needed
return model.toSharedModel(true);
}
else
{
RSModel animatedModel = model.toSharedModel(!frames.getFrames()[frameIdx].isShowing());
animatedModel.interpolateFrames(frames, frameIdx, nextFrames, nextFrameIdx, interval,
getFrameLenths()[frame]);
return animatedModel;
}
}
else
{
return rs$transformActorModel(model, frame);
}
}
@Copy("transformObjectModel")
public abstract RSModel rs$transformObjectModel(RSModel model, int frame, int rotation);
@Replace("transformObjectModel")
public RSModel rl$transformObjectModel(RSModel model, int frame, int rotation)
{
// check if the frame has been modified
if (frame < 0)
{
// remove flag to check if the frame has been modified
int packed = frame ^ Integer.MIN_VALUE;
int interval = packed >> 16;
frame = packed & 0xFFFF;
int nextFrame = frame + 1;
if (nextFrame >= getFrameIDs().length)
{
// dont interpolate last frame
nextFrame = -1;
}
int[] frameIds = getFrameIDs();
int frameId = frameIds[frame];
RSFrames frames = client.getFrames(frameId >> 16);
int frameIdx = frameId & 0xFFFF;
int nextFrameIdx = -1;
RSFrames nextFrames = null;
if (nextFrame != -1)
{
int nextFrameId = frameIds[nextFrame];
nextFrames = client.getFrames(nextFrameId >> 16);
nextFrameIdx = nextFrameId & 0xFFFF;
}
if (frames == null)
{
return model.toSharedModel(true);
}
else
{
RSModel animatedModel = model.toSharedModel(!frames.getFrames()[frameIdx].isShowing());
// reset rotation before animating
rotation &= 3;
if (rotation == 1)
{
animatedModel.rotateY270Ccw();
}
else if (rotation == 2)
{
animatedModel.rotateY180Ccw();
}
else if (rotation == 3)
{
animatedModel.rotateY90Ccw();
}
animatedModel.interpolateFrames(frames, frameIdx, nextFrames, nextFrameIdx, interval,
getFrameLenths()[frame]);
// reapply rotation after animating
if (rotation == 1)
{
animatedModel.rotateY90Ccw();
}
else if (rotation == 2)
{
animatedModel.rotateY180Ccw();
}
else if (rotation == 3)
{
animatedModel.rotateY270Ccw();
}
return animatedModel;
}
}
else
{
return rs$transformObjectModel(model, frame, rotation);
}
}
@Copy("transformSpotAnimModel")
public abstract RSModel rs$transformSpotAnimModel(RSModel model, int frame);
@Replace("transformSpotAnimModel")
public RSModel rl$transformSpotAnimModel(RSModel model, int frame)
{
// check if the frame has been modified
if (frame < 0)
{
// remove flag to check if the frame has been modified
int packed = frame ^ Integer.MIN_VALUE;
int interval = packed >> 16;
frame = packed & 0xFFFF;
int nextFrame = frame + 1;
if (nextFrame >= getFrameIDs().length)
{
// dont interpolate last frame
nextFrame = -1;
}
int[] frameIds = getFrameIDs();
int frameId = frameIds[frame];
RSFrames frames = client.getFrames(frameId >> 16);
int frameIdx = frameId & 0xFFFF;
int nextFrameIdx = -1;
RSFrames nextFrames = null;
if (nextFrame != -1)
{
int nextFrameId = frameIds[nextFrame];
nextFrames = client.getFrames(nextFrameId >> 16);
nextFrameIdx = nextFrameId & 0xFFFF;
}
if (frames == null)
{
return model.toSharedSpotAnimModel(true);
}
else
{
RSModel animatedModel = model.toSharedSpotAnimModel(!frames.getFrames()[frameIdx].isShowing());
animatedModel.interpolateFrames(frames, frameIdx, nextFrames, nextFrameIdx, interval,
getFrameLenths()[frame]);
return animatedModel;
}
}
else
{
return rs$transformSpotAnimModel(model, frame);
}
}
}

View File

@@ -1,136 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Color;
import java.awt.image.BufferedImage;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSSpritePixels;
@Mixin(RSSpritePixels.class)
public abstract class RSSpritePixelsMixin implements RSSpritePixels
{
@Inject
@Override
public BufferedImage toBufferedImage()
{
BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
toBufferedImage(img);
return img;
}
@Inject
@Override
public void toBufferedImage(BufferedImage img)
{
int width = getWidth();
int height = getHeight();
if (img.getWidth() != width || img.getHeight() != height)
{
throw new IllegalArgumentException("Image bounds do not match SpritePixels");
}
int[] pixels = getPixels();
int[] transPixels = new int[pixels.length];
for (int i = 0; i < pixels.length; i++)
{
if (pixels[i] != 0)
{
transPixels[i] = pixels[i] | 0xff000000;
}
}
img.setRGB(0, 0, width, height, transPixels, 0, width);
}
@Inject
@Override
public BufferedImage toBufferedOutline(Color color)
{
BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
toBufferedOutline(img, color.getRGB());
return img;
}
@Inject
@Override
public void toBufferedOutline(BufferedImage img, int color)
{
int width = getWidth();
int height = getHeight();
if (img.getWidth() != width || img.getHeight() != height)
{
throw new IllegalArgumentException("Image bounds do not match SpritePixels");
}
int[] pixels = getPixels();
int[] newPixels = new int[width * height];
int pixelIndex = 0;
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
int pixel = pixels[pixelIndex];
if (pixel == 16777215 || pixel == 0)
{
// W
if (x > 0 && pixels[pixelIndex - 1] != 0)
{
pixel = color;
}
// N
else if (y > 0 && pixels[pixelIndex - width] != 0)
{
pixel = color;
}
// E
else if (x < width - 1 && pixels[pixelIndex + 1] != 0)
{
pixel = color;
}
// S
else if (y < height - 1 && pixels[pixelIndex + width] != 0)
{
pixel = color;
}
newPixels[pixelIndex] = pixel;
}
pixelIndex++;
}
}
img.setRGB(0, 0, width, height, newPixels, 0, width);
}
}

View File

@@ -1,92 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSTexture;
@Mixin(RSTexture.class)
public abstract class RSTextureMixin implements RSTexture
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private float rl$u;
@Inject
private float rl$v;
@Copy("animate")
public abstract void rs$animate(int diff);
@Replace("animate")
public void rl$animate(int diff)
{
// The client animates textures by cycling the backing pixels of the texture each fram
// based on how long it was since the last tick. On GPU we let the plugin manage this
// which will calculate uvs instead.
if (!client.isGpu())
{
rs$animate(diff);
return;
}
client.getDrawCallbacks().animate(this, diff);
}
@Inject
@Override
public float getU()
{
return rl$u;
}
@Inject
@Override
public void setU(float u)
{
this.rl$u = u;
}
@Inject
@Override
public float getV()
{
return rl$v;
}
@Inject
@Override
public void setV(float v)
{
this.rl$v = v;
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* 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.IndexDataBase;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSTextureProvider;
@Mixin(RSTextureProvider.class)
public abstract class RSTextureProviderMixin implements RSTextureProvider
{
@Shadow("clientInstance")
private static RSClient client;
@MethodHook(value = "<init>", end = true)
@Inject
public void rl$init(IndexDataBase indexTextures, IndexDataBase indexSprites, int maxSize, double brightness, int width)
{
// the client's max size is 20, however there are many scenes with >20 textures,
// which causes continuous alloc/free of textures with the gl. There are
// only ~57 textures in total.
setMaxSize(64);
setSize(64);
}
@MethodHook(value = "checkTextures", end = true)
@Inject
public void checkTextures(int diff)
{
client.getCallbacks().drawAboveOverheads();
}
}

View File

@@ -1,565 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.util.ArrayList;
import java.util.List;
import net.runelite.api.CollisionData;
import net.runelite.api.CollisionDataFlag;
import net.runelite.api.Constants;
import net.runelite.api.DecorativeObject;
import net.runelite.api.GroundObject;
import net.runelite.api.Item;
import net.runelite.api.ItemLayer;
import net.runelite.api.Node;
import net.runelite.api.Point;
import net.runelite.api.Tile;
import net.runelite.api.WallObject;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.DecorativeObjectChanged;
import net.runelite.api.events.DecorativeObjectDespawned;
import net.runelite.api.events.DecorativeObjectSpawned;
import net.runelite.api.events.GameObjectChanged;
import net.runelite.api.events.GameObjectDespawned;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GroundObjectChanged;
import net.runelite.api.events.GroundObjectDespawned;
import net.runelite.api.events.GroundObjectSpawned;
import net.runelite.api.events.ItemDespawned;
import net.runelite.api.events.ItemSpawned;
import net.runelite.api.events.WallObjectChanged;
import net.runelite.api.events.WallObjectDespawned;
import net.runelite.api.events.WallObjectSpawned;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSActor;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSDeque;
import net.runelite.rs.api.RSGameObject;
import net.runelite.rs.api.RSGraphicsObject;
import net.runelite.rs.api.RSItem;
import net.runelite.rs.api.RSItemLayer;
import net.runelite.rs.api.RSNode;
import net.runelite.rs.api.RSProjectile;
import net.runelite.rs.api.RSRenderable;
import net.runelite.rs.api.RSTile;
import org.slf4j.Logger;
@Mixin(RSTile.class)
public abstract class RSTileMixin implements RSTile
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private static RSGameObject lastGameObject;
@Inject
private static RSDeque[][][] lastGroundItems = new RSDeque[Constants.MAX_Z][Constants.SCENE_SIZE][Constants.SCENE_SIZE];
@Inject
private WallObject previousWallObject;
@Inject
private DecorativeObject previousDecorativeObject;
@Inject
private GroundObject previousGroundObject;
@Inject
private RSGameObject[] previousGameObjects;
@Inject
@Override
public WorldPoint getWorldLocation()
{
return WorldPoint.fromScene(client, getX(), getY(), getPlane());
}
@Inject
@Override
public Point getSceneLocation()
{
return new Point(getX(), getY());
}
@Inject
@Override
public LocalPoint getLocalLocation()
{
return LocalPoint.fromScene(getX(), getY());
}
@FieldHook("wallObject")
@Inject
public void wallObjectChanged(int idx)
{
WallObject previous = previousWallObject;
WallObject current = getWallObject();
previousWallObject = current;
if (current == null && previous != null)
{
WallObjectDespawned wallObjectDespawned = new WallObjectDespawned();
wallObjectDespawned.setTile(this);
wallObjectDespawned.setWallObject(previous);
client.getCallbacks().post(wallObjectDespawned);
}
else if (current != null && previous == null)
{
WallObjectSpawned wallObjectSpawned = new WallObjectSpawned();
wallObjectSpawned.setTile(this);
wallObjectSpawned.setWallObject(current);
client.getCallbacks().post(wallObjectSpawned);
}
else if (current != null && previous != null)
{
WallObjectChanged wallObjectChanged = new WallObjectChanged();
wallObjectChanged.setTile(this);
wallObjectChanged.setPrevious(previous);
wallObjectChanged.setWallObject(current);
client.getCallbacks().post(wallObjectChanged);
}
}
@FieldHook("decorativeObject")
@Inject
public void decorativeObjectChanged(int idx)
{
DecorativeObject previous = previousDecorativeObject;
DecorativeObject current = getDecorativeObject();
previousDecorativeObject = current;
if (current == null && previous != null)
{
DecorativeObjectDespawned decorativeObjectDespawned = new DecorativeObjectDespawned();
decorativeObjectDespawned.setTile(this);
decorativeObjectDespawned.setDecorativeObject(previous);
client.getCallbacks().post(decorativeObjectDespawned);
}
else if (current != null && previous == null)
{
DecorativeObjectSpawned decorativeObjectSpawned = new DecorativeObjectSpawned();
decorativeObjectSpawned.setTile(this);
decorativeObjectSpawned.setDecorativeObject(current);
client.getCallbacks().post(decorativeObjectSpawned);
}
else if (current != null && previous != null)
{
DecorativeObjectChanged decorativeObjectChanged = new DecorativeObjectChanged();
decorativeObjectChanged.setTile(this);
decorativeObjectChanged.setPrevious(previous);
decorativeObjectChanged.setDecorativeObject(current);
client.getCallbacks().post(decorativeObjectChanged);
}
}
@FieldHook("groundObject")
@Inject
public void groundObjectChanged(int idx)
{
GroundObject previous = previousGroundObject;
GroundObject current = getGroundObject();
previousGroundObject = current;
if (current == null && previous != null)
{
GroundObjectDespawned groundObjectDespawned = new GroundObjectDespawned();
groundObjectDespawned.setTile(this);
groundObjectDespawned.setGroundObject(previous);
client.getCallbacks().post(groundObjectDespawned);
}
else if (current != null && previous == null)
{
GroundObjectSpawned groundObjectSpawned = new GroundObjectSpawned();
groundObjectSpawned.setTile(this);
groundObjectSpawned.setGroundObject(current);
client.getCallbacks().post(groundObjectSpawned);
}
else if (current != null && previous != null)
{
GroundObjectChanged groundObjectChanged = new GroundObjectChanged();
groundObjectChanged.setTile(this);
groundObjectChanged.setPrevious(previous);
groundObjectChanged.setGroundObject(current);
client.getCallbacks().post(groundObjectChanged);
}
}
@FieldHook("objects")
@Inject
public void gameObjectsChanged(int idx)
{
if (idx == -1) // this happens from the field assignment
{
return;
}
if (previousGameObjects == null)
{
previousGameObjects = new RSGameObject[5];
}
// Previous game object
RSGameObject previous = previousGameObjects[idx];
// GameObject that was changed.
RSGameObject current = (RSGameObject) getGameObjects()[idx];
// Update previous object to current
previousGameObjects[idx] = current;
// Last game object
RSGameObject last = lastGameObject;
// Update last game object
lastGameObject = current;
// Duplicate event, return
if (current == previous)
{
return;
}
if (current != null && current == last)
{
// When >1 tile objects are added to the scene, the same GameObject is added to
// multiple tiles. We keep lastGameObject to prevent duplicate spawn events from
// firing for these objects.
return;
}
// actors, projectiles, and graphics objects are added and removed from the scene each frame as GameObjects,
// so ignore them.
boolean currentInvalid = false, prevInvalid = false;
if (current != null)
{
RSRenderable renderable = current.getRenderable();
currentInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject;
}
if (previous != null)
{
RSRenderable renderable = previous.getRenderable();
prevInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject;
}
Logger logger = client.getLogger();
if (current == null)
{
if (prevInvalid)
{
return;
}
logger.trace("Game object despawn: {}", previous.getId());
GameObjectDespawned gameObjectDespawned = new GameObjectDespawned();
gameObjectDespawned.setTile(this);
gameObjectDespawned.setGameObject(previous);
client.getCallbacks().post(gameObjectDespawned);
}
else if (previous == null)
{
if (currentInvalid)
{
return;
}
logger.trace("Game object spawn: {}", current.getId());
GameObjectSpawned gameObjectSpawned = new GameObjectSpawned();
gameObjectSpawned.setTile(this);
gameObjectSpawned.setGameObject(current);
client.getCallbacks().post(gameObjectSpawned);
}
else
{
if (currentInvalid && prevInvalid)
{
return;
}
logger.trace("Game object change: {} -> {}", previous.getId(), current.getId());
GameObjectChanged gameObjectsChanged = new GameObjectChanged();
gameObjectsChanged.setTile(this);
gameObjectsChanged.setPrevious(previous);
gameObjectsChanged.setGameObject(current);
client.getCallbacks().post(gameObjectsChanged);
}
}
@FieldHook("itemLayer")
@Inject
public void itemLayerChanged(int idx)
{
int x = getX();
int y = getY();
int z = client.getPlane();
RSDeque[][][] groundItemDeque = client.getGroundItemDeque();
RSDeque oldQueue = lastGroundItems[z][x][y];
RSDeque newQueue = groundItemDeque[z][x][y];
if (oldQueue != newQueue)
{
if (oldQueue != null)
{
// despawn everything in old ..
RSNode head = oldQueue.getHead();
for (RSNode cur = head.getNext(); cur != head; cur = cur.getNext())
{
RSItem item = (RSItem) cur;
ItemDespawned itemDespawned = new ItemDespawned(this, item);
client.getCallbacks().post(itemDespawned);
}
}
lastGroundItems[z][x][y] = newQueue;
}
RSItem lastUnlink = client.getLastItemDespawn();
if (lastUnlink != null)
{
client.setLastItemDespawn(null);
}
RSItemLayer itemLayer = (RSItemLayer) getItemLayer();
if (itemLayer == null)
{
if (lastUnlink != null)
{
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink);
client.getCallbacks().post(itemDespawned);
}
return;
}
RSDeque itemDeque = newQueue;
if (itemDeque == null)
{
if (lastUnlink != null)
{
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink);
client.getCallbacks().post(itemDespawned);
}
return;
}
// The new item gets added to either the head, or the tail, depending on its price
RSNode head = itemDeque.getHead();
RSNode current = null;
RSNode previous = head.getPrevious();
boolean forward = false;
if (head != previous)
{
RSItem prev = (RSItem) previous;
if (x != prev.getX() || y != prev.getY())
{
current = prev;
}
}
RSNode next = head.getNext();
if (current == null && head != next)
{
RSItem n = (RSItem) next;
if (x != n.getX() || y != n.getY())
{
current = n;
forward = true;
}
}
if (lastUnlink != null && lastUnlink != previous && lastUnlink != next)
{
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink);
client.getCallbacks().post(itemDespawned);
}
if (current == null)
{
return; // already seen this spawn, or no new item
}
do
{
RSItem item = (RSItem) current;
item.setX(x);
item.setY(y);
ItemSpawned itemSpawned = new ItemSpawned(this, item);
client.getCallbacks().post(itemSpawned);
current = forward ? current.getNext() : current.getPrevious();
// Send spawn events for anything on this tile which is at the wrong location, which happens
// when the scene base changes
} while (current != head && (((RSItem) current).getX() != x || ((RSItem) current).getY() != y));
}
@Inject
@Override
public boolean hasLineOfSightTo(Tile other)
{
// Thanks to Henke for this method :)
if (this.getPlane() != other.getPlane())
{
return false;
}
CollisionData[] collisionData = client.getCollisionMaps();
if (collisionData == null)
{
return false;
}
int z = this.getPlane();
int[][] collisionDataFlags = collisionData[z].getFlags();
Point p1 = this.getSceneLocation();
Point p2 = other.getSceneLocation();
if (p1.getX() == p2.getX() && p1.getY() == p2.getY())
{
return true;
}
int dx = p2.getX() - p1.getX();
int dy = p2.getY() - p1.getY();
int dxAbs = Math.abs(dx);
int dyAbs = Math.abs(dy);
int xFlags = CollisionDataFlag.BLOCK_LINE_OF_SIGHT_FULL;
int yFlags = CollisionDataFlag.BLOCK_LINE_OF_SIGHT_FULL;
if (dx < 0)
{
xFlags |= CollisionDataFlag.BLOCK_LINE_OF_SIGHT_EAST;
}
else
{
xFlags |= CollisionDataFlag.BLOCK_LINE_OF_SIGHT_WEST;
}
if (dy < 0)
{
yFlags |= CollisionDataFlag.BLOCK_LINE_OF_SIGHT_NORTH;
}
else
{
yFlags |= CollisionDataFlag.BLOCK_LINE_OF_SIGHT_SOUTH;
}
if (dxAbs > dyAbs)
{
int x = p1.getX();
int yBig = p1.getY() << 16; // The y position is represented as a bigger number to handle rounding
int slope = (dy << 16) / dxAbs;
yBig += 0x8000; // Add half of a tile
if (dy < 0)
{
yBig--; // For correct rounding
}
int direction = dx < 0 ? -1 : 1;
while (x != p2.getX())
{
x += direction;
int y = yBig >>> 16;
if ((collisionDataFlags[x][y] & xFlags) != 0)
{
// Collision while traveling on the x axis
return false;
}
yBig += slope;
int nextY = yBig >>> 16;
if (nextY != y && (collisionDataFlags[x][nextY] & yFlags) != 0)
{
// Collision while traveling on the y axis
return false;
}
}
}
else
{
int y = p1.getY();
int xBig = p1.getX() << 16; // The x position is represented as a bigger number to handle rounding
int slope = (dx << 16) / dyAbs;
xBig += 0x8000; // Add half of a tile
if (dx < 0)
{
xBig--; // For correct rounding
}
int direction = dy < 0 ? -1 : 1;
while (y != p2.getY())
{
y += direction;
int x = xBig >>> 16;
if ((collisionDataFlags[x][y] & yFlags) != 0)
{
// Collision while traveling on the y axis
return false;
}
xBig += slope;
int nextX = xBig >>> 16;
if (nextX != x && (collisionDataFlags[nextX][y] & xFlags) != 0)
{
// Collision while traveling on the x axis
return false;
}
}
}
// No collision
return true;
}
@Inject
@Override
public List<Item> getGroundItems()
{
ItemLayer layer = this.getItemLayer();
if (layer == null)
{
return null;
}
List<Item> result = new ArrayList<Item>();
Node node = layer.getBottom();
while (node instanceof Item)
{
result.add((Item) node);
node = node.getNext();
}
return result;
}
}

View File

@@ -1,31 +0,0 @@
package net.runelite.mixins;
import net.runelite.api.events.VarClientIntChanged;
import net.runelite.api.events.VarClientStrChanged;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSVarcs;
@Mixin(RSVarcs.class)
public abstract class RSVarcsMixin implements RSVarcs
{
@Shadow("clientInstance")
private static RSClient client;
@MethodHook(value = "putVarc", end = true)
@Inject
public void onVarCIntChanged(int id, int value)
{
client.getCallbacks().post(new VarClientIntChanged(id));
}
@MethodHook(value = "putVarcStringNew", end = true)
@Inject
public void onVarCStrChanged(int id, String value)
{
client.getCallbacks().post(new VarClientStrChanged(id));
}
}

View File

@@ -1,124 +0,0 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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 java.awt.geom.Area;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Renderable;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSWallObject;
@Mixin(RSWallObject.class)
public abstract class RSWallObjectMixin implements RSWallObject
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private int wallPlane;
@Inject
@Override
public int getPlane()
{
return wallPlane;
}
@Inject
@Override
public void setPlane(int plane)
{
this.wallPlane = plane;
}
@Inject
private Model getModelA()
{
Renderable renderable = getRenderable1();
if (renderable == null)
{
return null;
}
if (renderable instanceof Model)
{
return (Model) renderable;
}
else
{
return renderable.getModel();
}
}
@Inject
private Model getModelB()
{
Renderable renderable = getRenderable2();
if (renderable == null)
{
return null;
}
if (renderable instanceof Model)
{
return (Model) renderable;
}
else
{
return renderable.getModel();
}
}
@Inject
@Override
public Area getClickbox()
{
Area clickbox = new Area();
Area clickboxA = Perspective.getClickbox(client, getModelA(), 0, getLocalLocation());
Area clickboxB = Perspective.getClickbox(client, getModelB(), 0, getLocalLocation());
if (clickboxA == null && clickboxB == null)
{
return null;
}
if (clickboxA != null)
{
clickbox.add(clickboxA);
}
if (clickboxB != null)
{
clickbox.add(clickboxB);
}
return clickbox;
}
}

View File

@@ -1,584 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.runelite.api.HashTable;
import net.runelite.api.Node;
import net.runelite.api.Point;
import net.runelite.api.WidgetNode;
import net.runelite.api.events.WidgetHiddenChanged;
import net.runelite.api.events.WidgetPositioned;
import net.runelite.api.mixins.FieldHook;
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 static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSHashTable;
import net.runelite.rs.api.RSNode;
import net.runelite.rs.api.RSWidget;
@Mixin(RSWidget.class)
public abstract class RSWidgetMixin implements RSWidget
{
private static final int ITEM_SLOT_SIZE = 32;
@Shadow("clientInstance")
private static RSClient client;
@Inject
private static int rl$widgetLastPosChanged;
@Inject
private int rl$parentId;
@Inject
private int rl$x;
@Inject
private int rl$y;
@Inject
RSWidgetMixin()
{
rl$parentId = -1;
rl$x = -1;
rl$y = -1;
}
@Inject
@Override
public void setRenderParentId(int parentId)
{
rl$parentId = parentId;
}
@Inject
@Override
public void setRenderX(int x)
{
rl$x = x;
}
@Inject
@Override
public void setRenderY(int y)
{
rl$y = y;
}
@Inject
@Override
public Widget getParent()
{
int id = getParentId();
if (id == -1)
{
return null;
}
return client.getWidget(TO_GROUP(id), TO_CHILD(id));
}
@Inject
@Override
public int getParentId()
{
assert client.isClientThread();
int rsParentId = getRSParentId();
if (rsParentId != -1)
{
return rsParentId;
}
final int id = getId();
if (TO_GROUP(id) == client.getWidgetRoot())
{
// this is a root widget
return -1;
}
int parentId = rl$parentId;
if (parentId != -1)
{
// if this happens, the widget is or was nested.
// rl$parentId is updated when drawing, but will not be updated when
// the widget is no longer reachable in the tree, leaving
// parent id potentially incorrect
// check the parent in the component table
HashTable<WidgetNode> componentTable = client.getComponentTable();
WidgetNode widgetNode = componentTable.get(parentId);
if (widgetNode == null || widgetNode.getId() != TO_GROUP(id))
{
// invalidate parent
rl$parentId = -1;
}
else
{
return parentId;
}
}
// also the widget may not have been drawn, yet
int groupId = TO_GROUP(getId());
RSHashTable componentTable = client.getComponentTable();
RSNode[] buckets = componentTable.getBuckets();
for (RSNode node : buckets)
{
// It looks like the first node in the bucket is always
// a sentinel
Node cur = node.getNext();
while (cur != node)
{
WidgetNode wn = (WidgetNode) cur;
if (groupId == wn.getId())
{
return (int) wn.getHash();
}
cur = cur.getNext();
}
}
return -1;
}
@Inject
@Override
public String getText()
{
return getRSText().replace('\u00A0', ' ');
}
@Inject
@Override
public String getName()
{
return getRSName().replace('\u00A0', ' ');
}
@Inject
@Override
public void setName(String name)
{
setRSName(name.replace(' ', '\u00A0'));
}
@Inject
@Override
public boolean isHidden()
{
assert client.isClientThread();
if (isSelfHidden())
{
return true;
}
Widget parent = getParent();
if (parent == null)
{
if (TO_GROUP(getId()) != client.getWidgetRoot())
{
// Widget has no parent and is not the root widget (which is always visible),
// so it's not visible.
return true;
}
}
else if (parent.isHidden())
{
// If the parent is hidden, this widget is also hidden.
return true;
}
return false;
}
@Inject
@Override
public Point getCanvasLocation()
{
return new Point(rl$x, rl$y);
}
@Inject
@Override
public Rectangle getBounds()
{
Point canvasLocation = getCanvasLocation();
return new Rectangle(canvasLocation.getX(), canvasLocation.getY(), getWidth(), getHeight());
}
@Inject
@Override
public Collection<WidgetItem> getWidgetItems()
{
int[] itemIds = getItemIds();
if (itemIds == null)
{
return null;
}
List<WidgetItem> items = new ArrayList<WidgetItem>(itemIds.length);
for (int i = 0; i < itemIds.length; ++i)
{
if (itemIds[i] <= 0)
{
continue;
}
WidgetItem item = getWidgetItem(i);
if (item != null)
{
items.add(item);
}
}
return items;
}
@Inject
@Override
public WidgetItem getWidgetItem(int index)
{
int[] itemIds = getItemIds();
int[] itemQuantities = getItemQuantities();
if (itemIds == null || itemQuantities == null)
{
return null;
}
int columns = getWidth(); // the number of item slot columns is stored here
int xPitch = getXPitch();
int yPitch = getYPitch();
int itemId = itemIds[index];
int itemQuantity = itemQuantities[index];
if (columns <= 0)
{
return null;
}
int row = index / columns;
int col = index % columns;
int itemX = rl$x + ((ITEM_SLOT_SIZE + xPitch) * col);
int itemY = rl$y + ((ITEM_SLOT_SIZE + yPitch) * row);
Rectangle bounds = new Rectangle(itemX, itemY, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this);
}
@Inject
@Override
public Widget getChild(int index)
{
RSWidget[] widgets = getChildren();
if (widgets == null || widgets[index] == null)
{
return null;
}
return widgets[index];
}
@Inject
@Override
public Widget[] getDynamicChildren()
{
RSWidget[] children = getChildren();
if (children == null)
{
return new Widget[0];
}
List<Widget> widgets = new ArrayList<Widget>();
for (RSWidget widget : children)
{
if (widget != null && widget.getRSParentId() == getId())
{
widgets.add(widget);
}
}
return widgets.toArray(new Widget[widgets.size()]);
}
@Inject
@Override
public Widget[] getStaticChildren()
{
if (getRSParentId() == getId())
{
// This is a dynamic widget, so it can't have static children
return new Widget[0];
}
List<Widget> widgets = new ArrayList<Widget>();
for (RSWidget widget : client.getGroup(TO_GROUP(getId())))
{
if (widget != null && widget.getRSParentId() == getId())
{
widgets.add(widget);
}
}
return widgets.toArray(new RSWidget[widgets.size()]);
}
@Inject
@Override
public Widget[] getNestedChildren()
{
assert client.isClientThread();
if (getRSParentId() == getId())
{
// This is a dynamic widget, so it can't have nested children
return new Widget[0];
}
HashTable<WidgetNode> componentTable = client.getComponentTable();
WidgetNode wn = componentTable.get(getId());
if (wn == null)
{
return new RSWidget[0];
}
int group = wn.getId();
List<RSWidget> widgets = new ArrayList<RSWidget>();
for (RSWidget widget : client.getGroup(group))
{
if (widget != null && widget.getRSParentId() == -1)
{
widgets.add(widget);
}
}
return widgets.toArray(new RSWidget[widgets.size()]);
}
@Inject
@Override
public boolean contains(Point point)
{
Rectangle bounds = getBounds();
return bounds != null && bounds.contains(new java.awt.Point(point.getX(), point.getY()));
}
@Inject
@Override
public void broadcastHidden(boolean hidden)
{
WidgetHiddenChanged event = new WidgetHiddenChanged();
event.setWidget(this);
event.setHidden(hidden);
client.getCallbacks().post(event);
RSWidget[] children = getChildren();
if (children != null)
{
// recursive through children
for (RSWidget child : children)
{
// if the widget is hidden it will not magically unhide from its parent changing
if (child == null || child.isSelfHidden())
{
continue;
}
child.broadcastHidden(hidden);
}
}
// make sure we iterate nested children as well
// cannot be null
Widget[] nestedChildren = getNestedChildren();
for (Widget nestedChild : nestedChildren)
{
if (nestedChild == null || nestedChild.isSelfHidden())
{
continue;
}
((RSWidget) nestedChild).broadcastHidden(hidden);
}
}
@FieldHook("isHidden")
@Inject
public void onHiddenChanged(int idx)
{
int id = getId();
if (id == -1)
{
return;
}
Widget parent = getParent();
// if the parent is hidden then changes in this widget don't have any visual effect
// so ignore them
if (parent != null)
{
if (parent.isHidden())
{
return;
}
}
else if (TO_GROUP(id) != client.getWidgetRoot())
{
return;
}
broadcastHidden(isSelfHidden());
}
@FieldHook("relativeY")
@Inject
public void onPositionChanged(int idx)
{
int id = getId();
if (id == -1)
{
return;
}
int tick = client.getGameCycle();
if (tick == rl$widgetLastPosChanged)
{
return;
}
rl$widgetLastPosChanged = tick;
client.getLogger().trace("Posting widget position changed");
WidgetPositioned widgetPositioned = new WidgetPositioned();
client.getCallbacks().postDeferred(widgetPositioned);
}
@Inject
@Override
public Widget createChild(int index, int type)
{
assert client.isClientThread();
RSWidget w = client.createWidget();
w.setType(type);
w.setParentId(getId());
w.setId(getId());
w.setIsIf3(true);
RSWidget[] siblings = getChildren();
if (index < 0)
{
if (siblings == null)
{
index = 0;
}
else
{
index = 0;
for (int i = siblings.length - 1; i >= 0; i--)
{
if (siblings[i] != null)
{
index = i + 1;
break;
}
}
}
}
if (siblings == null)
{
siblings = new RSWidget[index + 1];
setChildren(siblings);
}
else if (siblings.length <= index)
{
RSWidget[] newSiblings = new RSWidget[index + 1];
System.arraycopy(siblings, 0, newSiblings, 0, siblings.length);
siblings = newSiblings;
setChildren(siblings);
}
siblings[index] = w;
w.setIndex(index);
return w;
}
@Inject
@Override
public void revalidate()
{
assert client.isClientThread();
client.revalidateWidget(this);
}
@Inject
@Override
public void revalidateScroll()
{
assert client.isClientThread();
client.revalidateWidget(this);
client.revalidateWidgetScroll(client.getWidgets()[TO_GROUP(this.getId())], this, false);
}
@Inject
@Override
public void deleteAllChildren()
{
if (getChildren() != null)
{
Arrays.fill(getChildren(), null);
}
}
}

View File

@@ -1,69 +0,0 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* 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 java.util.EnumSet;
import net.runelite.api.WorldType;
import net.runelite.api.events.WorldListLoad;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSWorld;
@Mixin(RSWorld.class)
public abstract class RSWorldMixin implements RSWorld
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public EnumSet<WorldType> getTypes()
{
return WorldType.fromMask(getMask());
}
@Inject
@Override
public void setTypes(final EnumSet<WorldType> types)
{
setMask(WorldType.toMask(types));
}
@Inject
@FieldHook("playerCount")
public void playerCountChanged(int idx)
{
RSWorld[] worlds = client.getWorldList();
if (worlds != null && worlds.length > 0 && worlds[worlds.length - 1] == this)
{
// this is the last world in the list.
WorldListLoad worldLoad = new WorldListLoad(worlds);
client.getCallbacks().post(worldLoad);
}
}
}

View File

@@ -1,244 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
@Mixin(RSClient.class)
public abstract class Rasterizer2DMixin implements RSClient
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private static void drawAlpha(int[] pixels, int index, int value, int alpha)
{
if (!client.isGpu() || pixels != client.getBufferProvider().getPixels())
{
pixels[index] = value;
return;
}
// (int) x * 0x8081 >>> 23 is equivalent to (short) x / 255
int outAlpha = alpha + ((pixels[index] >>> 24) * (255 - alpha) * 0x8081 >>> 23);
pixels[index] = value & 0x00FFFFFF | outAlpha << 24;
}
@Copy("drawGradientAlpha")
private static void rs$raster2d6(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7)
{
throw new RuntimeException();
}
@Replace("drawGradientAlpha")
private static void rl$drawGradientAlpha(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7)
{
final int width = client.getGraphicsPixelsWidth();
final int startX = client.getStartX();
final int startY = client.getStartY();
final int endX = client.getEndX();
final int endY = client.getEndY();
final int[] pixels = client.getGraphicsPixels();
if (!client.isGpu())
{
rs$raster2d6(var0, var1, var2, var3, var4, var5, var6, var7);
return;
}
if (var2 > 0 && var3 > 0)
{
int var8 = 0;
int var9 = 65536 / var3;
if (var0 < startX)
{
var2 -= startX - var0;
var0 = startX;
}
if (var1 < startY)
{
var8 += (startY - var1) * var9;
var3 -= startY - var1;
var1 = startY;
}
if (var0 + var2 > endX)
{
var2 = endX - var0;
}
if (var3 + var1 > endY)
{
var3 = endY - var1;
}
int var10 = width - var2;
int var11 = var0 + width * var1;
for (int var12 = -var3; var12 < 0; ++var12)
{
int var13 = 65536 - var8 >> 8;
int var14 = var8 >> 8;
int var15 = (var13 * var6 + var14 * var7 & 65280) >>> 8;
if (var15 == 0)
{
var11 += width;
var8 += var9;
}
else
{
int var16 = (var14 * (var5 & 16711935) + var13 * (var4 & 16711935) & -16711936) + (var14 * (var5 & 65280) + var13 * (var4 & 65280) & 16711680) >>> 8;
int var17 = 255 - var15;
int var18 = ((var16 & 16711935) * var15 >> 8 & 16711935) + (var15 * (var16 & 65280) >> 8 & 65280);
for (int var19 = -var2; var19 < 0; ++var19)
{
int var20 = pixels[var11];
var20 = ((var20 & 16711935) * var17 >> 8 & 16711935) + (var17 * (var20 & 65280) >> 8 & 65280);
drawAlpha(pixels, var11++, var18 + var20, var15);
}
var11 += var10;
var8 += var9;
}
}
}
}
@Copy("raster2d7")
public static void rs$raster2d7(int var0, int var1, int var2, int var3, int var4, int var5, byte[] var6, int var7)
{
throw new RuntimeException();
}
@Replace("raster2d7")
public static void rl$raster2d7(int var0, int var1, int var2, int var3, int var4, int var5, byte[] var6, int var7)
{
final int width = client.getGraphicsPixelsWidth();
final int height = client.getGraphicsPixelsHeight();
final int[] pixels = client.getGraphicsPixels();
if (!client.isGpu())
{
rs$raster2d7(var0, var1, var2, var3, var4, var5, var6, var7);
return;
}
if (var0 + var2 >= 0 && var3 + var1 >= 0)
{
if (var0 < width && var1 < height)
{
int var8 = 0;
int var9 = 0;
if (var0 < 0)
{
var8 -= var0;
var2 += var0;
}
if (var1 < 0)
{
var9 -= var1;
var3 += var1;
}
if (var0 + var2 > width)
{
var2 = width - var0;
}
if (var3 + var1 > height)
{
var3 = height - var1;
}
int var10 = var6.length / var7;
int var11 = width - var2;
int var12 = var4 >>> 24;
int var13 = var5 >>> 24;
int var14;
int var15;
int var16;
int var17;
int var18;
if (var12 == 255 && var13 == 255)
{
var14 = var0 + var8 + (var9 + var1) * width;
for (var15 = var9 + var1; var15 < var3 + var9 + var1; ++var15)
{
for (var16 = var0 + var8; var16 < var0 + var8 + var2; ++var16)
{
var17 = (var15 - var1) % var10;
var18 = (var16 - var0) % var7;
if (var6[var18 + var17 * var7] != 0)
{
pixels[var14++] = var5;
}
else
{
pixels[var14++] = var4;
}
}
var14 += var11;
}
}
else
{
var14 = var0 + var8 + (var9 + var1) * width;
for (var15 = var9 + var1; var15 < var3 + var9 + var1; ++var15)
{
for (var16 = var0 + var8; var16 < var0 + var8 + var2; ++var16)
{
var17 = (var15 - var1) % var10;
var18 = (var16 - var0) % var7;
int var19 = var4;
if (var6[var18 + var17 * var7] != 0)
{
var19 = var5;
}
int var20 = var19 >>> 24;
int var21 = 255 - var20;
int var22 = pixels[var14];
int var23 = ((var19 & 16711935) * var20 + (var22 & 16711935) * var21 & -16711936) + (var20 * (var19 & 65280) + var21 * (var22 & 65280) & 16711680) >> 8;
drawAlpha(pixels, var14++, var23, var20);
}
var14 += var11;
}
}
}
}
}
}

View File

@@ -1,156 +0,0 @@
/*
* Copyright (c) 2018 Abex
* 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 java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.runelite.api.Client;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.api.widgets.JavaScriptCallback;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSScript;
import net.runelite.rs.api.RSScriptEvent;
import static net.runelite.api.Opcodes.RUNELITE_EXECUTE;
@Mixin(RSClient.class)
public abstract class ScriptVMMixin implements RSClient
{
@Shadow("clientInstance")
private static Client client;
// This field is set by the ScriptVM raw injector
@Inject
private static RSScript currentScript;
// This field is set by the ScriptVM raw injector
@Inject
private static int currentScriptPC;
// 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);
client.getLogger().debug(out.toString());
client.setStringStackSize(stringStackSize);
client.setIntStackSize(intStackSize);
return true;
}
ScriptCallbackEvent event = new ScriptCallbackEvent();
event.setScript(currentScript);
event.setEventName(stringOp);
client.getCallbacks().post(event);
return true;
}
return false;
}
@Copy("runScript")
static void rs$runScript(RSScriptEvent event, int maxExecutionTime)
{
throw new RuntimeException();
}
@Replace("runScript")
static void rl$runScript(RSScriptEvent event, int maxExecutionTime)
{
Object[] arguments = event.getArguments();
if (arguments != null && arguments.length > 0 && arguments[0] instanceof JavaScriptCallback)
{
try
{
((JavaScriptCallback) arguments[0]).run(event);
}
catch (Exception e)
{
client.getLogger().error("Error in JavaScriptCallback", e);
}
return;
}
try
{
rs$runScript(event, maxExecutionTime);
}
finally
{
currentScript = null;
}
}
@Inject
@Override
public void runScript(int id, Object... args)
{
assert isClientThread();
assert currentScript == null;
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, 5000000);
}
}

View File

@@ -1,148 +0,0 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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.SoundEffectVolume;
import net.runelite.api.events.AreaSoundEffectPlayed;
import net.runelite.api.events.SoundEffectPlayed;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSAudioTaskNode;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSRawAudioNode;
import net.runelite.rs.api.RSSoundEffect;
import net.runelite.rs.api.RSTaskDataNode;
@Mixin(RSClient.class)
public abstract class SoundEffectMixin implements RSClient
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private static int lastSoundEffectCount;
@Inject
@Override
public void playSoundEffect(int id)
{
playSoundEffect(id, 0, 0, 0, 0);
}
@Inject
@Override
public void playSoundEffect(int id, int x, int y, int range)
{
playSoundEffect(id, x, y, range, 0);
}
@Inject
@Override
public void playSoundEffect(int id, int x, int y, int range, int delay)
{
int position = ((x & 255) << 16) + ((y & 255) << 8) + (range & 255);
int[] queuedSoundEffectIDs = getQueuedSoundEffectIDs();
int[] queuedSoundEffectLoops = getQueuedSoundEffectLoops();
int[] queuedSoundEffectDelays = getQueuedSoundEffectDelays();
RSSoundEffect[] audioEffects = getAudioEffects();
int[] soundLocations = getSoundLocations();
int queuedSoundEffectCount = getQueuedSoundEffectCount();
queuedSoundEffectIDs[queuedSoundEffectCount] = id;
queuedSoundEffectLoops[queuedSoundEffectCount] = 1;
queuedSoundEffectDelays[queuedSoundEffectCount] = delay;
audioEffects[queuedSoundEffectCount] = null;
soundLocations[queuedSoundEffectCount] = position;
setQueuedSoundEffectCount(queuedSoundEffectCount + 1);
}
@Inject
@Override
public void playSoundEffect(int id, int volume)
{
RSSoundEffect soundEffect = getTrack(getIndexCache4(), id, 0);
if (soundEffect == null)
{
return;
}
// If the current volume is not muted, use it instead
final int soundEffectVolume = getSoundEffectVolume();
if (soundEffectVolume != SoundEffectVolume.MUTED)
{
volume = soundEffectVolume;
}
RSRawAudioNode rawAudioNode = soundEffect.toRawAudioNode().applyResampler(getSoundEffectResampler());
RSAudioTaskNode audioTaskNode = createSoundEffectAudioTaskNode(rawAudioNode, 100, volume);
audioTaskNode.setNumLoops(1);
getSoundEffectAudioQueue().queueAudioTaskNode((RSTaskDataNode) audioTaskNode);
}
@FieldHook("queuedSoundEffectCount")
@Inject
public static void queuedSoundEffectCountChanged(int idx)
{
int soundCount = client.getQueuedSoundEffectCount();
if (soundCount == lastSoundEffectCount + 1)
{
int soundIndex = soundCount - 1;
int packedLocation = client.getSoundLocations()[soundIndex];
if (packedLocation == 0)
{
// Regular sound effect
SoundEffectPlayed event = new SoundEffectPlayed();
event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]);
event.setDelay(client.getQueuedSoundEffectDelays()[soundIndex]);
client.getCallbacks().post(event);
}
else
{
// Area sound effect
int x = (packedLocation >> 16) & 0xFF;
int y = (packedLocation >> 8) & 0xFF;
int range = (packedLocation) & 0xFF;
AreaSoundEffectPlayed event = new AreaSoundEffectPlayed();
event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]);
event.setSceneX(x);
event.setSceneY(y);
event.setRange(range);
event.setDelay(client.getQueuedSoundEffectDelays()[soundIndex]);
client.getCallbacks().post(event);
}
}
lastSoundEffectCount = soundCount;
}
}

View File

@@ -1,80 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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 HOLDER 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 java.util.HashMap;
import java.util.Map;
import net.runelite.api.SpritePixels;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSIndexDataBase;
import net.runelite.rs.api.RSSpritePixels;
@Mixin(RSClient.class)
public abstract class SpriteMixin implements RSClient
{
@Inject
private static final Map<Integer, SpritePixels> spriteOverrides = new HashMap<Integer, SpritePixels>();
@Inject
private static final Map<Integer, SpritePixels> widgetSpriteOverrides = new HashMap<Integer, SpritePixels>();
@Inject
@Override
public Map<Integer, SpritePixels> getSpriteOverrides()
{
return spriteOverrides;
}
@Inject
@Override
public Map<Integer, SpritePixels> getWidgetSpriteOverrides()
{
return widgetSpriteOverrides;
}
@Copy("getSpriteAsSpritePixels")
public static RSSpritePixels rs$loadSprite(RSIndexDataBase var0, int var1, int var2)
{
throw new RuntimeException();
}
@Replace("getSpriteAsSpritePixels")
public static RSSpritePixels rl$loadSprite(RSIndexDataBase var0, int var1, int var2)
{
SpritePixels sprite = spriteOverrides.get(var1);
if (sprite != null)
{
return (RSSpritePixels) sprite;
}
return rs$loadSprite(var0, var1, var2);
}
}

View File

@@ -1,76 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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 java.awt.Dimension;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSGameEngine;
@Mixin(RSGameEngine.class)
public abstract class StretchedModeMaxSizeMixin implements RSGameEngine
{
@Shadow("clientInstance")
private static RSClient client;
@Copy("resizeCanvas")
abstract void rs$resizeCanvas();
@Replace("resizeCanvas")
public void rl$resizeCanvas()
{
if (client.isStretchedEnabled())
{
client.invalidateStretching(false);
if (client.isResized())
{
Dimension realDimensions = client.getRealDimensions();
setMaxCanvasWidth(realDimensions.width);
setMaxCanvasHeight(realDimensions.height);
}
}
rs$resizeCanvas();
}
@Copy("setMaxCanvasSize")
abstract void rs$setMaxCanvasSize(int width, int height);
@Replace("setMaxCanvasSize")
public void rl$setMaxCanvasSize(int width, int height)
{
if (client.isStretchedEnabled() && client.isResized())
{
return;
}
rs$setMaxCanvasSize(width, height);
}
}

View File

@@ -1,216 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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 java.awt.Container;
import java.awt.Dimension;
import net.runelite.api.Constants;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
@Mixin(RSClient.class)
public abstract class StretchedModeMixin implements RSClient
{
@Inject
private static boolean stretchedEnabled;
@Inject
private static boolean stretchedFast;
@Inject
private static boolean stretchedIntegerScaling;
@Inject
private static boolean stretchedKeepAspectRatio;
@Inject
private static double scalingFactor;
@Inject
private static Dimension cachedStretchedDimensions;
@Inject
private static Dimension cachedRealDimensions;
@Inject
@Override
public boolean isStretchedEnabled()
{
return stretchedEnabled;
}
@Inject
@Override
public void setStretchedEnabled(boolean state)
{
stretchedEnabled = state;
}
@Inject
@Override
public boolean isStretchedFast()
{
return stretchedFast;
}
@Inject
@Override
public void setStretchedFast(boolean state)
{
stretchedFast = state;
}
@Inject
@Override
public void setStretchedIntegerScaling(boolean state)
{
stretchedIntegerScaling = state;
}
@Inject
@Override
public void setStretchedKeepAspectRatio(boolean state)
{
stretchedKeepAspectRatio = state;
}
@Inject
@Override
public void setScalingFactor(int factor)
{
scalingFactor = 1 + (factor / 100D);
}
@Inject
@Override
public Dimension getRealDimensions()
{
if (!isStretchedEnabled())
{
return getCanvas().getSize();
}
if (cachedRealDimensions == null)
{
if (isResized())
{
Container canvasParent = getCanvas().getParent();
int parentWidth = canvasParent.getWidth();
int parentHeight = canvasParent.getHeight();
int newWidth = (int) (parentWidth / scalingFactor);
int newHeight = (int) (parentHeight / scalingFactor);
if (newWidth < Constants.GAME_FIXED_WIDTH || newHeight < Constants.GAME_FIXED_HEIGHT)
{
double scalingFactorW = (double)parentWidth / Constants.GAME_FIXED_WIDTH;
double scalingFactorH = (double)parentHeight / Constants.GAME_FIXED_HEIGHT;
double scalingFactor = Math.min(scalingFactorW, scalingFactorH);
newWidth = (int) (parentWidth / scalingFactor);
newHeight = (int) (parentHeight / scalingFactor);
}
cachedRealDimensions = new Dimension(newWidth, newHeight);
}
else
{
cachedRealDimensions = Constants.GAME_FIXED_SIZE;
}
}
return cachedRealDimensions;
}
@Inject
@Override
public Dimension getStretchedDimensions()
{
if (cachedStretchedDimensions == null)
{
Container canvasParent = getCanvas().getParent();
int parentWidth = canvasParent.getWidth();
int parentHeight = canvasParent.getHeight();
Dimension realDimensions = getRealDimensions();
if (stretchedKeepAspectRatio)
{
double aspectRatio = realDimensions.getWidth() / realDimensions.getHeight();
int tempNewWidth = (int) (parentHeight * aspectRatio);
if (tempNewWidth > parentWidth)
{
parentHeight = (int) (parentWidth / aspectRatio);
}
else
{
parentWidth = tempNewWidth;
}
}
if (stretchedIntegerScaling)
{
if (parentWidth > realDimensions.width)
{
parentWidth = parentWidth - (parentWidth % realDimensions.width);
}
if (parentHeight > realDimensions.height)
{
parentHeight = parentHeight - (parentHeight % realDimensions.height);
}
}
cachedStretchedDimensions = new Dimension(parentWidth, parentHeight);
}
return cachedStretchedDimensions;
}
@Inject
@Override
public void invalidateStretching(boolean resize)
{
cachedRealDimensions = null;
cachedStretchedDimensions = null;
if (resize && isResized())
{
/*
Tells the game to run resizeCanvas the next frame.
This is useful when resizeCanvas wouldn't usually run,
for example when we've only changed the scaling factor
and we still want the game's canvas to resize
with regards to the new maximum bounds.
*/
setResizeCanvasNextFrame(true);
}
}
}

View File

@@ -1,113 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* 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 java.awt.Graphics2D;
import java.awt.Polygon;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.TileObject;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Mixins;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSDecorativeObject;
import net.runelite.rs.api.RSGameObject;
import net.runelite.rs.api.RSGroundObject;
import net.runelite.rs.api.RSItemLayer;
import net.runelite.rs.api.RSWallObject;
@Mixins({
@Mixin(RSDecorativeObject.class),
@Mixin(RSGameObject.class),
@Mixin(RSGroundObject.class),
@Mixin(RSItemLayer.class),
@Mixin(RSWallObject.class)
})
public abstract class TileObjectMixin implements TileObject
{
@Shadow("clientInstance")
private static RSClient client;
@Override
@Inject
public int getId()
{
long hash = getHash();
return (int) (hash >>> 17 & 4294967295L);
}
@Override
@Inject
public WorldPoint getWorldLocation()
{
return WorldPoint.fromLocal(client, getX(), getY(), getPlane());
}
@Override
@Inject
public LocalPoint getLocalLocation()
{
return new LocalPoint(getX(), getY());
}
@Override
@Inject
public Point getCanvasLocation()
{
return getCanvasLocation(0);
}
@Override
@Inject
public Point getCanvasLocation(int zOffset)
{
return Perspective.localToCanvas(client, getLocalLocation(), getPlane(), zOffset);
}
@Override
@Inject
public Polygon getCanvasTilePoly()
{
return Perspective.getCanvasTilePoly(client, getLocalLocation());
}
@Override
@Inject
public Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset)
{
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
}
@Override
@Inject
public Point getMinimapLocation()
{
return Perspective.localToMinimap(client, getLocalLocation());
}
}

View File

@@ -1,158 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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 com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.Map;
import net.runelite.api.VarClientInt;
import net.runelite.api.VarClientStr;
import net.runelite.api.Varbits;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSNodeCache;
import net.runelite.rs.api.RSVarbit;
@Mixin(RSClient.class)
public abstract class VarbitMixin implements RSClient
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
private Cache<Integer, RSVarbit> varbitCache = CacheBuilder.newBuilder()
.maximumSize(128)
.build();
@Inject
VarbitMixin()
{
}
@Inject
@Override
public int getVar(Varbits varbit)
{
int varbitId = varbit.getId();
return getVarbitValue(getVarps(), varbitId);
}
@Inject
@Override
public void setSetting(Varbits varbit, int value)
{
int varbitId = varbit.getId();
setVarbitValue(getVarps(), varbitId, value);
}
@Inject
@Override
public int getVarbitValue(int[] varps, int varbitId)
{
assert client.isClientThread();
RSVarbit v = varbitCache.getIfPresent(varbitId);
if (v == null)
{
client.getVarbit(varbitId); // load varbit into cache
RSNodeCache varbits = client.getVarbitCache();
v = (RSVarbit) varbits.get(varbitId); // get from cache
varbitCache.put(varbitId, v);
}
if (v.getIndex() == 0 && v.getLeastSignificantBit() == 0 && v.getMostSignificantBit() == 0)
{
throw new IndexOutOfBoundsException("Varbit " + varbitId + " does not exist");
}
int value = varps[v.getIndex()];
int lsb = v.getLeastSignificantBit();
int msb = v.getMostSignificantBit();
int mask = (1 << ((msb - lsb) + 1)) - 1;
return (value >> lsb) & mask;
}
@Inject
@Override
public void setVarbitValue(int[] varps, int varbitId, int value)
{
RSVarbit v = varbitCache.getIfPresent(varbitId);
if (v == null)
{
client.getVarbit(varbitId); // load varbit into cache
RSNodeCache varbits = client.getVarbitCache();
v = (RSVarbit) varbits.get(varbitId); // get from cache
varbitCache.put(varbitId, v);
}
int lsb = v.getLeastSignificantBit();
int msb = v.getMostSignificantBit();
int mask = (1 << ((msb - lsb) + 1)) - 1;
varps[v.getIndex()] = (varps[v.getIndex()] & ~(mask << lsb)) | ((value & mask) << lsb);
}
@Inject
@Override
public int getVar(VarClientInt varClientInt)
{
Map<Integer, Object> varcmap = getVarcMap();
Object object = varcmap.get(varClientInt.getIndex());
return object instanceof Integer ? (Integer) object : 0;
}
@Inject
@Override
public String getVar(VarClientStr varClientStr)
{
Map<Integer, Object> varcmap = getVarcMap();
Object var2 = varcmap.get(varClientStr.getIndex());
return var2 instanceof String ? (String) var2 : "";
}
@Inject
@Override
public void setVar(VarClientStr varClientStr, String value)
{
Map<Integer, Object> varcmap = getVarcMap();
varcmap.put(varClientStr.getIndex(), value);
}
@Inject
@Override
public void setVar(VarClientInt varClientInt, int value)
{
Map<Integer, Object> varcmap = getVarcMap();
varcmap.put(varClientInt.getIndex(), value);
}
@Inject
@Override
public Map<Integer, Object> getVarcMap()
{
return getVarcs().getVarcMap();
}
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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 HOLDER 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 java.util.Map;
import net.runelite.api.SpritePixels;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSSpritePixels;
import net.runelite.rs.api.RSWidget;
@Mixin(RSWidget.class)
public abstract class WidgetSpriteMixin implements RSWidget
{
@Shadow("widgetSpriteOverrides")
private static Map<Integer, SpritePixels> widgetSpriteOverrides;
@Copy("getWidgetSprite")
public RSSpritePixels rs$getWidgetSprite(boolean var1)
{
throw new RuntimeException();
}
@Replace("getWidgetSprite")
public RSSpritePixels rl$getWidgetSprite(boolean var1)
{
if (getSpriteId() != -1)
{
SpritePixels sprite = widgetSpriteOverrides.get(getId());
if (sprite != null)
{
return (RSSpritePixels) sprite;
}
}
return rs$getWidgetSprite(var1);
}
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* 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.World;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.rs.api.RSClient;
@Mixin(RSClient.class)
public abstract class WorldHoppingMixin implements RSClient
{
@Inject
@Override
public void openWorldHopper()
{
// The clicked x & y coordinates (the last arguments) are not processed in the game or sent to Jagex, so they don't have to be real.
menuAction(-1, WidgetInfo.WORLD_SWITCHER_BUTTON.getId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "World Switcher", "", 658, 384);
}
@Inject
@Override
public void hopToWorld(World world)
{
final int worldId = world.getId();
menuAction(worldId, WidgetInfo.WORLD_SWITCHER_LIST.getId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "Switch", "<col=ff9040>" + (worldId - 300) + "</col>", 683, 244);
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
* 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.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSWorldMapManager;
@Mixin(RSWorldMapManager.class)
public abstract class WorldMapManagerMixin implements RSWorldMapManager
{
@Shadow("clientInstance")
static RSClient client;
/*
The worldMapZoom is essentially pixels per tile. In most instances
getPixelsPerTile returns the same as worldMapZoom.
At some map widths when 100% zoomed in the Jagex version of this function
returns 7.89 instead of 8.0 (the worldMapZoom at this level).
This would cause both the x and y positions of the map to shift
slightly when the map was certain widths.
This mixin function replaces Jagex calculation with getWorldMapZoom.
This small change makes the world map tile sizing predictable.
*/
@Replace("getPixelsPerTile")
@Override
public float getPixelsPerTile(int graphicsDiff, int worldDiff)
{
return client.getRenderOverview().getWorldMapZoom();
}
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
* 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.Point;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSRenderOverview;
import net.runelite.rs.api.RSWorldMapManager;
@Mixin(RSRenderOverview.class)
public abstract class WorldMapMixin implements RSRenderOverview
{
@Override
@Inject
public Point getWorldMapPosition()
{
RSWorldMapManager worldMapManager = getWorldMapManager();
int worldX = getWorldMapX() + worldMapManager.getSurfaceOffsetX();
int worldY = getWorldMapY() + worldMapManager.getSurfaceOffsetY();
return new Point(worldX, worldY);
}
@Inject
public void setWorldMapPositionTarget(WorldPoint worldPoint)
{
setWorldMapPositionTarget(worldPoint.getX(), worldPoint.getY());
}
}