Improve vinesweeper hole restoration

This commit is contained in:
Player Name 2026-06-27 15:44:46 +02:00
parent fb7f569445
commit c794cb9fee
2 changed files with 27 additions and 6 deletions

View file

@ -665,7 +665,14 @@ class VinesweeperNPC : AbstractNPC {
1 -> {
animate(Animation(Animations.GNOME_FARMER_SPADE_SMACK_8732))
sendChat(FARMER_FLAG_LINES.DEAD_PLANT.line)
SceneryBuilder.replace(scenery, scenery.transform(HOLES[0]))
var originalHoleId = HOLES[0]
for (obj in scenery.location.chunk.getStatObjects(scenery.location.chunkOffsetX, scenery.location.chunkOffsetY)) {
if (obj?.id != null) {
originalHoleId = obj.id
break
}
}
SceneryBuilder.replace(scenery, scenery.transform(originalHoleId))
}
2 -> {
animate(Animation(Animations.GNOME_FARMER_CLEAR_HOLES_8724))

View file

@ -509,15 +509,29 @@ public class RegionChunk {
}
/**
* Gets the sceneries located on the coordinates in this chunk.
* @param chunkX The chunk x-coordinate (0-7).
* @param chunkY The chunk y-coordinate (0-7).
* Gets the dynamic sceneries located on the coordinates in this chunk.
* @param chunkOffsetX The x coordinate within the chunk (0-7).
* @param chunkOffsetY The y coordinate within the chunk (0-7).
* @return The objects.
*/
public Scenery[] getObjects(int chunkX, int chunkY) {
public Scenery[] getObjects(int chunkOffsetX, int chunkOffsetY) {
Scenery[] result = new Scenery[ARRAY_SIZE];
for (int i = 0; i < objects.length; i++) {
result[i] = objects[i][chunkX][chunkY];
result[i] = objects[i][chunkOffsetX][chunkOffsetY];
}
return result;
}
/**
* Gets the static sceneries located on the coordinates in this chunk.
* @param chunkOffsetX The x coordinate within the chunk (0-7).
* @param chunkOffsetY The y coordinate within the chunk (0-7).
* @return The objects.
*/
public Scenery[] getStatObjects(int chunkOffsetX, int chunkOffsetY) {
Scenery[] result = new Scenery[ARRAY_SIZE];
for (int i = 0; i < statObjects.length; i++) {
result[i] = statObjects[i][chunkOffsetX][chunkOffsetY];
}
return result;
}