project: Injector and mixins

This commit is contained in:
Owain van Brakel
2021-12-15 05:39:57 +01:00
parent 62a5942180
commit 6b133497df
30 changed files with 530 additions and 168 deletions

View File

@@ -59,15 +59,15 @@ public abstract class ClickboxMixin implements RSClient
// otherwise we must check if the mouse is in a triangle
final int vertexCount = model.getVerticesCount();
final int triangleCount = model.getTrianglesCount();
final int triangleCount = model.getFaceCount();
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[] triangleX = model.getFaceIndices1();
final int[] triangleY = model.getFaceIndices2();
final int[] triangleZ = model.getFaceIndices3();
final int[] color3 = model.getFaceColors3();

View File

@@ -39,9 +39,10 @@ import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.runelite.api.Animation;
import net.runelite.api.ChatMessageType;
import net.runelite.api.EnumComposition;
import net.runelite.api.Friend;
import net.runelite.api.FriendContainer;
import net.runelite.api.GameState;
import net.runelite.api.GrandExchangeOffer;
import net.runelite.api.GraphicsObject;
@@ -79,7 +80,6 @@ import net.runelite.api.Point;
import net.runelite.api.Prayer;
import net.runelite.api.Projectile;
import net.runelite.api.ScriptEvent;
import net.runelite.api.Sequence;
import net.runelite.api.Skill;
import net.runelite.api.SpritePixels;
import net.runelite.api.StructComposition;
@@ -789,6 +789,15 @@ public abstract class RSClientMixin implements RSClient
setChatCycle(getCycleCntr());
}
@Inject
@Override
public MenuEntry createMenuEntry(int idx)
{
// TODO: Implement this
return new MenuEntry();
}
@Inject
@Override
public MenuEntry[] getMenuEntries()
@@ -887,9 +896,9 @@ public abstract class RSClientMixin implements RSClient
options[oldCount] = event.getOption();
targets[oldCount] = event.getTarget();
identifiers[oldCount] = event.getIdentifier();
opcodes[oldCount] = event.getOpcode();
arguments1[oldCount] = event.getParam0();
arguments2[oldCount] = event.getParam1();
opcodes[oldCount] = event.getType();
arguments1[oldCount] = event.getActionParam0();
arguments2[oldCount] = event.getActionParam1();
forceLeftClick[oldCount] = event.isForceLeftClick();
}
}
@@ -999,7 +1008,7 @@ public abstract class RSClientMixin implements RSClient
@Inject
@Override
public NameableContainer<Friend> getFriendContainer()
public FriendContainer getFriendContainer()
{
return getFriendManager().getFriendContainer();
}
@@ -2427,7 +2436,7 @@ public abstract class RSClientMixin implements RSClient
}
@Inject
public Sequence loadAnimation(int id)
public Animation loadAnimation(int id)
{
return client.getSequenceDefinition(id);
}

View File

@@ -0,0 +1,55 @@
/*
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSFriendLoginUpdate;
import net.runelite.rs.api.RSUsername;
@Mixin(RSFriendLoginUpdate.class)
public abstract class RSFriendLoginUpdatesMixin implements RSFriendLoginUpdate
{
@Inject
@Override
public String getName()
{
final RSUsername rsName = getRsName();
if (rsName == null)
{
return null;
}
String name = rsName.getName();
if (name == null)
{
return null;
}
return name.replace('\u00A0', ' ');
}
}

View File

@@ -0,0 +1,51 @@
/*
* 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.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSLink;
import net.runelite.rs.api.RSLinkDeque;
@Mixin(RSLinkDeque.class)
public abstract class RSLinkDequeMixin implements RSLinkDeque
{
@Inject
@Override
public void clear()
{
while (true)
{
RSLink rsLink = getSentinel().getPrevious();
if (rsLink == getSentinel())
{
setCurrent(null);
return;
}
rsLink.remove();
}
}
}

View File

@@ -78,7 +78,7 @@ public abstract class RSModelMixin implements RSModel
{
if (getFaceTextures() != null)
{
int count = getTrianglesCount();
int count = getFaceCount();
float[] uv = new float[count * 6];
int idx = 0;
@@ -91,10 +91,10 @@ public abstract class RSModelMixin implements RSModel
if (modelUV != null)
{
System.arraycopy(modelUV, 0, uv, idx, model.getTrianglesCount() * 6);
System.arraycopy(modelUV, 0, uv, idx, model.getFaceCount() * 6);
}
idx += model.getTrianglesCount() * 6;
idx += model.getFaceCount() * 6;
}
}
@@ -131,14 +131,14 @@ public abstract class RSModelMixin implements RSModel
@Inject
public List<Triangle> getTriangles()
{
int[] trianglesX = getTrianglesX();
int[] trianglesY = getTrianglesY();
int[] trianglesZ = getTrianglesZ();
int[] trianglesX = getFaceIndices1();
int[] trianglesY = getFaceIndices2();
int[] trianglesZ = getFaceIndices3();
List<Vertex> vertices = getVertices();
List<Triangle> triangles = new ArrayList<>(getTrianglesCount());
List<Triangle> triangles = new ArrayList<>(getFaceCount());
for (int i = 0; i < getTrianglesCount(); ++i)
for (int i = 0; i < getFaceCount(); ++i)
{
int triangleX = trianglesX[i];
int triangleY = trianglesY[i];
@@ -408,14 +408,14 @@ public abstract class RSModelMixin implements RSModel
rl$vertexNormalsY = new int[verticesCount];
rl$vertexNormalsZ = new int[verticesCount];
int[] trianglesX = getTrianglesX();
int[] trianglesY = getTrianglesY();
int[] trianglesZ = getTrianglesZ();
int[] trianglesX = getFaceIndices1();
int[] trianglesY = getFaceIndices2();
int[] trianglesZ = getFaceIndices3();
int[] verticesX = getVerticesX();
int[] verticesY = getVerticesY();
int[] verticesZ = getVerticesZ();
for (int i = 0; i < getTrianglesCount(); ++i)
for (int i = 0; i < getFaceCount(); ++i)
{
int var9 = trianglesX[i];
int var10 = trianglesY[i];

View File

@@ -181,13 +181,13 @@ public abstract class RSPlayerMixin implements RSPlayer
final int tileHeight = Perspective.getTileHeight(client, new LocalPoint(localX, localY), client.getPlane());
Perspective.modelToCanvas(client, model.getVerticesCount(), localX, localY, tileHeight, getOrientation(), model.getVerticesX(), model.getVerticesZ(), model.getVerticesY(), x2d, y2d);
ArrayList polys = new ArrayList(model.getTrianglesCount());
ArrayList polys = new ArrayList(model.getFaceCount());
int[] trianglesX = model.getTrianglesX();
int[] trianglesY = model.getTrianglesY();
int[] trianglesZ = model.getTrianglesZ();
int[] trianglesX = model.getFaceIndices1();
int[] trianglesY = model.getFaceIndices2();
int[] trianglesZ = model.getFaceIndices3();
for (int triangle = 0; triangle < model.getTrianglesCount(); ++triangle)
for (int triangle = 0; triangle < model.getFaceCount(); ++triangle)
{
int[] xx =
{

View File

@@ -24,9 +24,9 @@
*/
package net.runelite.mixins;
import net.runelite.api.Animation;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Sequence;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
@@ -55,7 +55,7 @@ public abstract class RuneLiteObjectMixin implements RSRuneLiteObject
}
@Inject
public void setAnimation(Sequence var1)
public void setAnimation(Animation var1)
{
setFrame(0);
setFrameCycle(0);