rl-api, groundmarkers: handle instance plane conversion correctly
This commit is contained in:
@@ -234,8 +234,9 @@ public class WorldPoint
|
|||||||
|
|
||||||
// find instance chunks using the template point. there might be more than one.
|
// find instance chunks using the template point. there might be more than one.
|
||||||
List<WorldPoint> worldPoints = new ArrayList<>();
|
List<WorldPoint> worldPoints = new ArrayList<>();
|
||||||
final int z = worldPoint.getPlane();
|
|
||||||
int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks();
|
int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks();
|
||||||
|
for (int z = 0; z < instanceTemplateChunks.length; z++)
|
||||||
|
{
|
||||||
for (int x = 0; x < instanceTemplateChunks[z].length; ++x)
|
for (int x = 0; x < instanceTemplateChunks[z].length; ++x)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < instanceTemplateChunks[z][x].length; ++y)
|
for (int y = 0; y < instanceTemplateChunks[z][x].length; ++y)
|
||||||
@@ -244,17 +245,20 @@ public class WorldPoint
|
|||||||
int rotation = chunkData >> 1 & 0x3;
|
int rotation = chunkData >> 1 & 0x3;
|
||||||
int templateChunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE;
|
int templateChunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE;
|
||||||
int templateChunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE;
|
int templateChunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE;
|
||||||
|
int plane = chunkData >> 24 & 0x3;
|
||||||
if (worldPoint.getX() >= templateChunkX && worldPoint.getX() < templateChunkX + CHUNK_SIZE
|
if (worldPoint.getX() >= templateChunkX && worldPoint.getX() < templateChunkX + CHUNK_SIZE
|
||||||
&& worldPoint.getY() >= templateChunkY && worldPoint.getY() < templateChunkY + CHUNK_SIZE)
|
&& worldPoint.getY() >= templateChunkY && worldPoint.getY() < templateChunkY + CHUNK_SIZE
|
||||||
|
&& plane == worldPoint.getPlane())
|
||||||
{
|
{
|
||||||
WorldPoint p = new WorldPoint(client.getBaseX() + x * CHUNK_SIZE + (worldPoint.getX() & (CHUNK_SIZE - 1)),
|
WorldPoint p = new WorldPoint(client.getBaseX() + x * CHUNK_SIZE + (worldPoint.getX() & (CHUNK_SIZE - 1)),
|
||||||
client.getBaseY() + y * CHUNK_SIZE + (worldPoint.getY() & (CHUNK_SIZE - 1)),
|
client.getBaseY() + y * CHUNK_SIZE + (worldPoint.getY() & (CHUNK_SIZE - 1)),
|
||||||
worldPoint.getPlane());
|
z);
|
||||||
p = rotate(p, rotation);
|
p = rotate(p, rotation);
|
||||||
worldPoints.add(p);
|
worldPoints.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return worldPoints;
|
return worldPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public class GroundMarkerPlugin extends Plugin
|
|||||||
|
|
||||||
final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, selectedSceneTile.getLocalLocation());
|
final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, selectedSceneTile.getLocalLocation());
|
||||||
final int regionId = worldPoint.getRegionID();
|
final int regionId = worldPoint.getRegionID();
|
||||||
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane(), null, null);
|
||||||
final boolean exists = getPoints(regionId).contains(point);
|
final boolean exists = getPoints(regionId).contains(point);
|
||||||
|
|
||||||
client.createMenuEntry(-1)
|
client.createMenuEntry(-1)
|
||||||
@@ -302,7 +302,7 @@ public class GroundMarkerPlugin extends Plugin
|
|||||||
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
||||||
|
|
||||||
int regionId = worldPoint.getRegionID();
|
int regionId = worldPoint.getRegionID();
|
||||||
GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor(), null);
|
GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane(), config.markerColor(), null);
|
||||||
log.debug("Updating point: {} - {}", point, worldPoint);
|
log.debug("Updating point: {} - {}", point, worldPoint);
|
||||||
|
|
||||||
List<GroundMarkerPoint> groundMarkerPoints = new ArrayList<>(getPoints(regionId));
|
List<GroundMarkerPoint> groundMarkerPoints = new ArrayList<>(getPoints(regionId));
|
||||||
@@ -326,7 +326,7 @@ public class GroundMarkerPlugin extends Plugin
|
|||||||
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
||||||
final int regionId = worldPoint.getRegionID();
|
final int regionId = worldPoint.getRegionID();
|
||||||
|
|
||||||
GroundMarkerPoint searchPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
GroundMarkerPoint searchPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane(), null, null);
|
||||||
Collection<GroundMarkerPoint> points = getPoints(regionId);
|
Collection<GroundMarkerPoint> points = getPoints(regionId);
|
||||||
GroundMarkerPoint existing = points.stream()
|
GroundMarkerPoint existing = points.stream()
|
||||||
.filter(p -> p.equals(searchPoint))
|
.filter(p -> p.equals(searchPoint))
|
||||||
@@ -342,7 +342,7 @@ public class GroundMarkerPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
input = Strings.emptyToNull(input);
|
input = Strings.emptyToNull(input);
|
||||||
|
|
||||||
GroundMarkerPoint newPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), existing.getColor(), input);
|
GroundMarkerPoint newPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane(), existing.getColor(), input);
|
||||||
points.remove(searchPoint);
|
points.remove(searchPoint);
|
||||||
points.add(newPoint);
|
points.add(newPoint);
|
||||||
savePoints(regionId, points);
|
savePoints(regionId, points);
|
||||||
|
|||||||
Reference in New Issue
Block a user