runelite-client: add debug/ground item plugins for labeling objects and tiles, and the apis for them
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
* (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;
|
||||
|
||||
import java.awt.Canvas;
|
||||
@@ -40,7 +39,9 @@ public class Client
|
||||
public Player getLocalPlayer()
|
||||
{
|
||||
if (client.getLocalPlayer() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Player(this, client.getLocalPlayer());
|
||||
}
|
||||
@@ -48,15 +49,15 @@ public class Client
|
||||
public NPC[] getNpcs()
|
||||
{
|
||||
return Arrays.stream(client.getCachedNPCs())
|
||||
.map(npc -> npc != null ? new NPC(this, npc) : null)
|
||||
.toArray(size -> new NPC[size]);
|
||||
.map(npc -> npc != null ? new NPC(this, npc) : null)
|
||||
.toArray(size -> new NPC[size]);
|
||||
}
|
||||
|
||||
public Player[] getPlayers()
|
||||
{
|
||||
return Arrays.stream(client.getCachedPlayers())
|
||||
.map(player -> player != null ? new Player(this, player) : null)
|
||||
.toArray(size -> new Player[size]);
|
||||
.map(player -> player != null ? new Player(this, player) : null)
|
||||
.toArray(size -> new Player[size]);
|
||||
}
|
||||
|
||||
public int[] getBoostedSkillLevels()
|
||||
@@ -158,4 +159,19 @@ public class Client
|
||||
{
|
||||
return client.getPlane();
|
||||
}
|
||||
|
||||
public Region getRegion()
|
||||
{
|
||||
return new Region(this, client.getRegion());
|
||||
}
|
||||
|
||||
public int getBaseX()
|
||||
{
|
||||
return client.getBaseX();
|
||||
}
|
||||
|
||||
public int getBaseY()
|
||||
{
|
||||
return client.getBaseY();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Decorative object, such as objects on walls
|
||||
*
|
||||
* @author Adam
|
||||
*/
|
||||
public class DecorativeObject extends TileObject
|
||||
{
|
||||
private final net.runelite.rs.api.DecorativeObject decorativeObject;
|
||||
|
||||
public DecorativeObject(Client client, net.runelite.rs.api.DecorativeObject decorativeObject)
|
||||
{
|
||||
super(client);
|
||||
this.decorativeObject = decorativeObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHash()
|
||||
{
|
||||
return decorativeObject.getHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalX()
|
||||
{
|
||||
return decorativeObject.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalY()
|
||||
{
|
||||
return decorativeObject.getY();
|
||||
}
|
||||
}
|
||||
58
runelite-api/src/main/java/net/runelite/api/GameObject.java
Normal file
58
runelite-api/src/main/java/net/runelite/api/GameObject.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adam
|
||||
*/
|
||||
public class GameObject extends TileObject
|
||||
{
|
||||
private final net.runelite.rs.api.GameObject gameObject;
|
||||
|
||||
public GameObject(Client client, net.runelite.rs.api.GameObject gameObject)
|
||||
{
|
||||
super(client);
|
||||
this.gameObject = gameObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHash()
|
||||
{
|
||||
return gameObject.getHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalX()
|
||||
{
|
||||
return gameObject.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalY()
|
||||
{
|
||||
return gameObject.getY();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class GroundObject extends TileObject
|
||||
{
|
||||
private final net.runelite.rs.api.GroundObject groundObject;
|
||||
|
||||
public GroundObject(Client client, net.runelite.rs.api.GroundObject groundObject)
|
||||
{
|
||||
super(client);
|
||||
this.groundObject = groundObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHash()
|
||||
{
|
||||
return groundObject.getHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalX()
|
||||
{
|
||||
return groundObject.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalY()
|
||||
{
|
||||
return groundObject.getY();
|
||||
}
|
||||
}
|
||||
46
runelite-api/src/main/java/net/runelite/api/Item.java
Normal file
46
runelite-api/src/main/java/net/runelite/api/Item.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
public class Item extends Renderable
|
||||
{
|
||||
private final net.runelite.rs.api.Item item;
|
||||
|
||||
public Item(net.runelite.rs.api.Item item)
|
||||
{
|
||||
super(item);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return item.getId();
|
||||
}
|
||||
|
||||
public int getQuantity()
|
||||
{
|
||||
return item.getQuantity();
|
||||
}
|
||||
}
|
||||
69
runelite-api/src/main/java/net/runelite/api/ItemLayer.java
Normal file
69
runelite-api/src/main/java/net/runelite/api/ItemLayer.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ItemLayer extends TileObject
|
||||
{
|
||||
private final net.runelite.rs.api.ItemLayer itemLayer;
|
||||
|
||||
public ItemLayer(Client client, net.runelite.rs.api.ItemLayer itemLayer)
|
||||
{
|
||||
super(client);
|
||||
this.itemLayer = itemLayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHash()
|
||||
{
|
||||
return itemLayer.getHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalX()
|
||||
{
|
||||
return itemLayer.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalY()
|
||||
{
|
||||
return itemLayer.getY();
|
||||
}
|
||||
|
||||
public Renderable getBottom()
|
||||
{
|
||||
return Renderable.of(itemLayer.getBottom());
|
||||
}
|
||||
|
||||
public Renderable getMiddle()
|
||||
{
|
||||
return Renderable.of(itemLayer.getMiddle());
|
||||
}
|
||||
|
||||
public Renderable getTop()
|
||||
{
|
||||
return Renderable.of(itemLayer.getTop());
|
||||
}
|
||||
}
|
||||
71
runelite-api/src/main/java/net/runelite/api/Node.java
Normal file
71
runelite-api/src/main/java/net/runelite/api/Node.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
public class Node
|
||||
{
|
||||
private final net.runelite.rs.api.Node node;
|
||||
|
||||
public Node(net.runelite.rs.api.Node node)
|
||||
{
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Node{" + "node=" + node + '}';
|
||||
}
|
||||
|
||||
public Node getNext()
|
||||
{
|
||||
return of(node.getNext());
|
||||
}
|
||||
|
||||
public Node getPrev()
|
||||
{
|
||||
return of(node.getPrevious());
|
||||
}
|
||||
|
||||
public static final Node of(net.runelite.rs.api.Node node)
|
||||
{
|
||||
if (node == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (node instanceof net.runelite.rs.api.Item)
|
||||
{
|
||||
return new Item((net.runelite.rs.api.Item) node);
|
||||
}
|
||||
|
||||
if (node instanceof net.runelite.rs.api.Renderable)
|
||||
{
|
||||
return new Renderable((net.runelite.rs.api.Renderable) node);
|
||||
}
|
||||
|
||||
return new Node(node);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,10 @@ package net.runelite.api;
|
||||
public class Perspective
|
||||
{
|
||||
private static final double UNIT = Math.PI / 1024d; // How much of the circle each unit of SINE/COSINE is
|
||||
|
||||
private static final int LOCAL_COORD_BITS = 7;
|
||||
private static final int LOCAL_TILE_SIZE = 1 << LOCAL_COORD_BITS; // 128 - size of a tile in local coordinates
|
||||
|
||||
public static final int[] SINE = new int[2048]; // sine angles for each of the 2048 units, * 65536 and stored as an int
|
||||
public static final int[] COSINE = new int[2048]; // cosine
|
||||
|
||||
@@ -119,4 +123,22 @@ public class Perspective
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static Point worldToLocal(Client client, Point point)
|
||||
{
|
||||
int baseX = client.getBaseX();
|
||||
int baseY = client.getBaseY();
|
||||
|
||||
int x = (point.getX() - baseX) << LOCAL_COORD_BITS;
|
||||
int y = (point.getY() - baseY) << LOCAL_COORD_BITS;
|
||||
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
public static Point localToWorld(Client client, Point point)
|
||||
{
|
||||
int x = (point.getX() >>> LOCAL_COORD_BITS) + client.getBaseX();
|
||||
int y = (point.getY() >>> LOCAL_COORD_BITS) + client.getBaseY();
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,19 @@ public class Point
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the distance from this point to another point
|
||||
*
|
||||
* @param other
|
||||
* @return
|
||||
*/
|
||||
public int distanceTo(Point other)
|
||||
{
|
||||
int dx = x - other.x;
|
||||
int dy = y - other.y;
|
||||
return (int) Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
||||
51
runelite-api/src/main/java/net/runelite/api/Region.java
Normal file
51
runelite-api/src/main/java/net/runelite/api/Region.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Region
|
||||
{
|
||||
private final Client client;
|
||||
private final net.runelite.rs.api.Region region;
|
||||
|
||||
public Region(Client client, net.runelite.rs.api.Region region)
|
||||
{
|
||||
this.client = client;
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public Tile[][][] getTiles()
|
||||
{
|
||||
return Arrays.stream(region.getTiles())
|
||||
.map(tile1 -> Arrays.stream(tile1)
|
||||
.map(tile2 -> Arrays.stream(tile2)
|
||||
.map(tile3 -> new Tile(client, tile3))
|
||||
.toArray(i -> new Tile[i])
|
||||
)
|
||||
.toArray(i -> new Tile[i][])
|
||||
).toArray(i -> new Tile[i][][]);
|
||||
}
|
||||
}
|
||||
@@ -22,15 +22,20 @@
|
||||
* (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;
|
||||
|
||||
public class Renderable
|
||||
public class Renderable extends Node
|
||||
{
|
||||
private net.runelite.rs.api.Renderable renderable;
|
||||
private final net.runelite.rs.api.Renderable renderable;
|
||||
|
||||
public Renderable(net.runelite.rs.api.Renderable renderable)
|
||||
{
|
||||
super(renderable);
|
||||
this.renderable = renderable;
|
||||
}
|
||||
|
||||
public static Renderable of(net.runelite.rs.api.Renderable renderable)
|
||||
{
|
||||
return (Renderable) Node.of(renderable);
|
||||
}
|
||||
}
|
||||
|
||||
106
runelite-api/src/main/java/net/runelite/api/Tile.java
Normal file
106
runelite-api/src/main/java/net/runelite/api/Tile.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Tile
|
||||
{
|
||||
private final Client client;
|
||||
private final net.runelite.rs.api.Tile tile;
|
||||
|
||||
public Tile(Client client, net.runelite.rs.api.Tile tile)
|
||||
{
|
||||
this.client = client;
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the decorative object for this tile.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DecorativeObject getDecorativeObject()
|
||||
{
|
||||
net.runelite.rs.api.DecorativeObject decorativeObject = tile.getDecorativeObject();
|
||||
|
||||
if (decorativeObject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DecorativeObject(client, decorativeObject);
|
||||
}
|
||||
|
||||
public GameObject[] getGameObjects()
|
||||
{
|
||||
net.runelite.rs.api.GameObject[] objects = tile.getObjects();
|
||||
|
||||
if (objects == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Arrays.stream(tile.getObjects())
|
||||
.map(go -> go != null ? new GameObject(client, go) : null)
|
||||
.toArray(i -> new GameObject[i]);
|
||||
}
|
||||
|
||||
public ItemLayer getItemLayer()
|
||||
{
|
||||
net.runelite.rs.api.ItemLayer itemLayer = tile.getItemLayer();
|
||||
|
||||
if (itemLayer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ItemLayer(client, itemLayer);
|
||||
}
|
||||
|
||||
public GroundObject getGroundObject()
|
||||
{
|
||||
net.runelite.rs.api.GroundObject groundObject = tile.getGroundObject();
|
||||
|
||||
if (groundObject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new GroundObject(client, groundObject);
|
||||
}
|
||||
|
||||
public WallObject getWallObject()
|
||||
{
|
||||
net.runelite.rs.api.WallObject wallObject = tile.getWallObject();
|
||||
|
||||
if (wallObject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new WallObject(client, wallObject);
|
||||
}
|
||||
}
|
||||
64
runelite-api/src/main/java/net/runelite/api/TileObject.java
Normal file
64
runelite-api/src/main/java/net/runelite/api/TileObject.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public abstract class TileObject
|
||||
{
|
||||
protected final Client client;
|
||||
|
||||
public TileObject(Client client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
protected abstract int getHash();
|
||||
|
||||
protected abstract int getLocalX();
|
||||
|
||||
protected abstract int getLocalY();
|
||||
|
||||
public int getId()
|
||||
{
|
||||
int hash = getHash();
|
||||
return hash >> 14 & 32767;
|
||||
}
|
||||
|
||||
public Point getWorldLocation()
|
||||
{
|
||||
Point localLocation = getLocalLocation();
|
||||
return Perspective.localToWorld(client, localLocation);
|
||||
}
|
||||
|
||||
public Point getLocalLocation()
|
||||
{
|
||||
return new Point(getLocalX(), getLocalY());
|
||||
}
|
||||
|
||||
public Point getCanvasLocation()
|
||||
{
|
||||
Point locaLocation = getLocalLocation();
|
||||
return Perspective.worldToCanvas(client, locaLocation.getX(), locaLocation.getY(), 0);
|
||||
}
|
||||
}
|
||||
59
runelite-api/src/main/java/net/runelite/api/WallObject.java
Normal file
59
runelite-api/src/main/java/net/runelite/api/WallObject.java
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* A wall object, which is a boundary you can't walk through.
|
||||
*
|
||||
* @author Adam
|
||||
*/
|
||||
public class WallObject extends TileObject
|
||||
{
|
||||
private final net.runelite.rs.api.WallObject wallObject;
|
||||
|
||||
public WallObject(Client client, net.runelite.rs.api.WallObject wallObject)
|
||||
{
|
||||
super(client);
|
||||
this.wallObject = wallObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHash()
|
||||
{
|
||||
return wallObject.getHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalX()
|
||||
{
|
||||
return wallObject.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalY()
|
||||
{
|
||||
return wallObject.getY();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user