Merge remote-tracking branch 'upstream/master' into 2310-merge
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
description = 'RuneLite Mixins'
|
||||
|
||||
dependencies {
|
||||
compileOnly group: 'com.google.guava', name: 'guava', version: guava
|
||||
compileOnly group: 'javax.inject', name: 'javax.inject', version: javaxInject
|
||||
compileOnly group: 'org.slf4j', name: 'slf4j-api', version: slf4j
|
||||
|
||||
implementation project(':runescape-api')
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile){
|
||||
options.compilerArgs.addAll('-source', '7', '-Xlint:-unchecked')
|
||||
}
|
||||
38
runelite-mixins/runelite-mixins.gradle.kts
Normal file
38
runelite-mixins/runelite-mixins.gradle.kts
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
description = "RuneLite Mixins"
|
||||
|
||||
dependencies {
|
||||
compileOnly(Libraries.guava)
|
||||
compileOnly(Libraries.javaxInject)
|
||||
compileOnly(Libraries.slf4jApi)
|
||||
|
||||
implementation(project(":runescape-api"))
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.compilerArgs.addAll(arrayOf("-source", "7", "-Xlint:-unchecked"))
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import net.runelite.api.mixins.Replace;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSItemDefinition;
|
||||
import net.runelite.rs.api.RSModel;
|
||||
|
||||
@Mixin(RSItemDefinition.class)
|
||||
public abstract class RSItemDefinitionMixin implements RSItemDefinition
|
||||
@@ -21,6 +22,16 @@ public abstract class RSItemDefinitionMixin implements RSItemDefinition
|
||||
@Inject
|
||||
private int shiftClickActionIndex = DEFAULT_CUSTOM_SHIFT_CLICK_INDEX;
|
||||
|
||||
@Inject
|
||||
private int modelOverride = -1;
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
public void setModelOverride(int id)
|
||||
{
|
||||
modelOverride = id;
|
||||
}
|
||||
|
||||
@Inject
|
||||
RSItemDefinitionMixin()
|
||||
{
|
||||
@@ -64,4 +75,18 @@ public abstract class RSItemDefinitionMixin implements RSItemDefinition
|
||||
event.setItemDefinition(this);
|
||||
client.getCallbacks().post(PostItemDefinition.class, event);
|
||||
}
|
||||
|
||||
@Copy("getModel")
|
||||
public abstract RSModel rs$getModel(int quantity);
|
||||
|
||||
@Replace("getModel")
|
||||
public RSModel getModel(int quantity)
|
||||
{
|
||||
if (modelOverride == -1)
|
||||
{
|
||||
return rs$getModel(quantity);
|
||||
}
|
||||
|
||||
return client.getItemDefinition(modelOverride).getModel(quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.runelite.api.Perspective;
|
||||
import net.runelite.api.TileModel;
|
||||
import net.runelite.api.TilePaint;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.hooks.DrawCallbacks;
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
@@ -38,6 +39,8 @@ import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.rs.api.RSBoundaryObject;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSFloorDecoration;
|
||||
import net.runelite.rs.api.RSNodeDeque;
|
||||
import net.runelite.rs.api.RSTileItem;
|
||||
import net.runelite.rs.api.RSTileItemPile;
|
||||
import net.runelite.rs.api.RSScene;
|
||||
import net.runelite.rs.api.RSTile;
|
||||
@@ -716,4 +719,72 @@ public abstract class RSSceneMixin implements RSScene
|
||||
client.setSelectedSceneTileX(targetX);
|
||||
client.setSelectedSceneTileY(targetY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
public void addItem(int id, int quantity, WorldPoint point)
|
||||
{
|
||||
final int sceneX = point.getX() - client.getBaseX();
|
||||
final int sceneY = point.getY() - client.getBaseY();
|
||||
final int plane = point.getPlane();
|
||||
|
||||
if (sceneX < 0 || sceneY < 0 || sceneX >= 104 || sceneY >= 104)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RSTileItem item = client.newTileItem();
|
||||
item.setId(id);
|
||||
item.setQuantity(quantity);
|
||||
RSNodeDeque[][][] groundItems = client.getGroundItemDeque();
|
||||
|
||||
if (groundItems[plane][sceneX][sceneY] == null)
|
||||
{
|
||||
groundItems[plane][sceneX][sceneY] = client.newNodeDeque();
|
||||
}
|
||||
|
||||
groundItems[plane][sceneX][sceneY].addFirst(item);
|
||||
|
||||
if (plane == client.getPlane())
|
||||
{
|
||||
client.updateItemPile(sceneX, sceneY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
public void removeItem(int id, int quantity, WorldPoint point)
|
||||
{
|
||||
final int sceneX = point.getX() - client.getBaseX();
|
||||
final int sceneY = point.getY() - client.getBaseY();
|
||||
final int plane = point.getPlane();
|
||||
|
||||
if (sceneX < 0 || sceneY < 0 || sceneX >= 104 || sceneY >= 104)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RSNodeDeque items = client.getGroundItemDeque()[plane][sceneX][sceneY];
|
||||
|
||||
if (items == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (RSTileItem item = (RSTileItem) items.last(); item != null; item = (RSTileItem) items.previous())
|
||||
{
|
||||
if (item.getId() == id && quantity == 1)
|
||||
{
|
||||
item.unlink();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (items.last() == null)
|
||||
{
|
||||
client.getGroundItemDeque()[plane][sceneX][sceneY] = null;
|
||||
}
|
||||
|
||||
client.updateItemPile(sceneX, sceneY);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user