In non-building mode, construction objects that have not been built now no longer leave behind clipping flags

Added command ::drawclipping to visualize construction clipping flags
This commit is contained in:
Player Name 2024-03-31 14:11:46 +00:00 committed by Ryan
parent b1e6c9fe8c
commit 4ae1448800
4 changed files with 90 additions and 73 deletions

View file

@ -172,9 +172,11 @@ public final class Room {
if (object != null && object.getDefinition().hasAction("Build")) { if (object != null && object.getDefinition().hasAction("Build")) {
if (properties.isChamber() && BuildingUtils.isDoorHotspot(object)) { if (properties.isChamber() && BuildingUtils.isDoorHotspot(object)) {
if (!placeDoors(house, chunk, object, housePlane, x, y, rotation)) { if (!placeDoors(house, chunk, object, housePlane, x, y, rotation)) {
SceneryBuilder.remove(object);
chunk.remove(object); chunk.remove(object);
} }
} else { } else {
SceneryBuilder.remove(object);
chunk.remove(object); chunk.remove(object);
} }
} }

View file

@ -232,6 +232,10 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) {
setAttribute (player, "chunkdraw", !getAttribute(player, "chunkdraw", false)) setAttribute (player, "chunkdraw", !getAttribute(player, "chunkdraw", false))
} }
define("drawclipping", Privilege.ADMIN, "", "Draws the clipping flags of the region you're standing in") {player, _ ->
setAttribute (player, "clippingdraw", !getAttribute(player, "clippingdraw", false))
}
define("drawregions", Privilege.ADMIN, "", "DRaws the border of the region you're standing in") {player, _ -> define("drawregions", Privilege.ADMIN, "", "DRaws the border of the region you're standing in") {player, _ ->
setAttribute (player, "regiondraw", !getAttribute(player, "regiondraw", false)) setAttribute (player, "regiondraw", !getAttribute(player, "regiondraw", false))
} }

View file

@ -16,6 +16,7 @@ import core.net.packet.out.ConstructScenery;
import static core.api.ContentAPIKt.log; import static core.api.ContentAPIKt.log;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
/** /**
@ -75,14 +76,12 @@ public class BuildRegionChunk extends RegionChunk {
} }
} }
} }
if (items != null) { ArrayList<GroundItem> totalItems = drawItems(items, player);
for (Item item : items) { for (GroundItem item : totalItems) {
if (item != null && item.isActive() && item.getLocation() != null) { if (item != null && item.isActive() && item.getLocation() != null) {
GroundItem g = (GroundItem) item; if (!item.isPrivate() || item.droppedBy(player)) {
if (!g.isPrivate() || g.droppedBy(player)) { ConstructGroundItem.write(buffer, item);
ConstructGroundItem.write(buffer, item); updated = true;
updated = true;
}
} }
} }
} }

View file

@ -149,64 +149,76 @@ public class RegionChunk {
} }
} }
} }
ArrayList<GroundItem> totalItems = items != null ? new ArrayList(items) : new ArrayList(); ArrayList<GroundItem> totalItems = drawItems(items, player);
for (GroundItem item : totalItems) {
boolean drawChunks = player.getAttribute("chunkdraw", false); if (item != null && item.isActive() && item.getLocation() != null) {
boolean drawRegions = player.getAttribute("regiondraw", false); if (!item.isPrivate() || item.droppedBy(player)) {
ConstructGroundItem.write(buffer, item);
if (drawChunks) { updated = true;
Location l = currentBase;
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
boolean add = false;
if (y == 0 || y == SIZE - 1)
add = true;
else if (x == 0 || x == SIZE - 1)
add = true;
if (add)
totalItems.add(new GroundItem(new Item(13444), l.transform(x, y, 0), player));
}
}
}
if (drawRegions) {
Location l = currentBase;
int localX = l.getLocalX();
int localY = l.getLocalY();
for (int x = 0; x < SIZE; x++)
for (int y = 0; y < SIZE; y++) {
boolean add = false;
if (localY == 0 || localY == 56)
if (localY == 0 && y == 0)
add = true;
else if (localY == 56 && y == SIZE - 1)
add = true;
if (localX == 0 || localX == 56)
if (localX == 0 && x == 0)
add = true;
else if (localX == 56 && x == SIZE - 1)
add = true;
if (add)
totalItems.add(new GroundItem(new Item(13444), l.transform(x,y,0), player));
}
}
if (totalItems != null) {
for (Item item : totalItems) {
if (item != null && item.isActive() && item.getLocation() != null) {
GroundItem g = (GroundItem) item;
if (!g.isPrivate() || g.droppedBy(player)) {
ConstructGroundItem.write(buffer, item);
updated = true;
}
} }
} }
} }
return updated; return updated;
} }
public ArrayList<GroundItem> drawItems(List<GroundItem> items, Player player) {
ArrayList<GroundItem> totalItems = items != null ? new ArrayList<GroundItem>(items) : new ArrayList<GroundItem>();
if (player.getAttribute("chunkdraw", false)) {
Location l = currentBase;
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
boolean add = false;
if (y == 0 || y == SIZE - 1)
add = true;
else if (x == 0 || x == SIZE - 1)
add = true;
if (add)
totalItems.add(new GroundItem(new Item(13444), l.transform(x, y, 0), player));
}
}
}
if (player.getAttribute("regiondraw", false)) {
Location l = currentBase;
int localX = l.getLocalX();
int localY = l.getLocalY();
for (int x = 0; x < SIZE; x++)
for (int y = 0; y < SIZE; y++) {
boolean add = false;
if (localY == 0 || localY == 56)
if (localY == 0 && y == 0)
add = true;
else if (localY == 56 && y == SIZE - 1)
add = true;
if (localX == 0 || localX == 56)
if (localX == 0 && x == 0)
add = true;
else if (localX == 56 && x == SIZE - 1)
add = true;
if (add)
totalItems.add(new GroundItem(new Item(13444), l.transform(x,y,0), player));
}
}
if (player.getAttribute("clippingdraw", false)) {
Location l = currentBase;
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
int flag = RegionManager.getClippingFlag(l.getZ(), l.getX() + x, l.getY() + y);
if (flag > 0) {
totalItems.add(new GroundItem(new Item(flag), l.transform(x, y, 0), player));
}
}
}
}
return totalItems;
}
/** /**
* Sends all the update flags. * Sends all the update flags.
*/ */