runelite-api: fix Tile location methods
This commit is contained in:
@@ -218,6 +218,22 @@ public class Perspective
|
|||||||
return new Point(x, y);
|
return new Point(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Point regionToWorld(Client client, Point point)
|
||||||
|
{
|
||||||
|
int baseX = client.getBaseX();
|
||||||
|
int baseY = client.getBaseY();
|
||||||
|
int x = point.getX() + baseX;
|
||||||
|
int y = point.getY() + baseY;
|
||||||
|
return new Point(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point regionToLocal(Client client, Point point)
|
||||||
|
{
|
||||||
|
int x = point.getX() << LOCAL_COORD_BITS;
|
||||||
|
int y = point.getY() << LOCAL_COORD_BITS;
|
||||||
|
return new Point(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates a tile polygon from offset worldToScreen() points.
|
* Calculates a tile polygon from offset worldToScreen() points.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -47,5 +47,7 @@ public interface Tile
|
|||||||
|
|
||||||
Point getWorldLocation();
|
Point getWorldLocation();
|
||||||
|
|
||||||
|
Point getRegionLocation();
|
||||||
|
|
||||||
Point getLocalLocation();
|
Point getLocalLocation();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,26 +24,40 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.mixins;
|
package net.runelite.mixins;
|
||||||
|
|
||||||
import static net.runelite.api.Perspective.LOCAL_COORD_BITS;
|
import net.runelite.api.Perspective;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.mixins.Inject;
|
import net.runelite.api.mixins.Inject;
|
||||||
import net.runelite.api.mixins.Mixin;
|
import net.runelite.api.mixins.Mixin;
|
||||||
|
import net.runelite.api.mixins.Shadow;
|
||||||
|
import net.runelite.rs.api.RSClient;
|
||||||
import net.runelite.rs.api.RSTile;
|
import net.runelite.rs.api.RSTile;
|
||||||
|
|
||||||
@Mixin(RSTile.class)
|
@Mixin(RSTile.class)
|
||||||
public abstract class RSTileMixin implements RSTile
|
public abstract class RSTileMixin implements RSTile
|
||||||
{
|
{
|
||||||
|
@Shadow("clientInstance")
|
||||||
|
private static RSClient client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Override
|
@Override
|
||||||
public Point getWorldLocation()
|
public Point getWorldLocation()
|
||||||
{
|
{
|
||||||
return new Point(getLocalLocation().getX() << LOCAL_COORD_BITS, getLocalLocation().getX() << LOCAL_COORD_BITS);
|
Point regionLocation = getRegionLocation();
|
||||||
|
return Perspective.regionToWorld(client, regionLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Override
|
||||||
|
public Point getRegionLocation()
|
||||||
|
{
|
||||||
|
return new Point(getX(), getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Override
|
@Override
|
||||||
public Point getLocalLocation()
|
public Point getLocalLocation()
|
||||||
{
|
{
|
||||||
return new Point(getX(), getY());
|
Point regionLocation = getRegionLocation();
|
||||||
|
return Perspective.regionToLocal(client, regionLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user