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 (properties.isChamber() && BuildingUtils.isDoorHotspot(object)) {
if (!placeDoors(house, chunk, object, housePlane, x, y, rotation)) {
SceneryBuilder.remove(object);
chunk.remove(object);
}
} else {
SceneryBuilder.remove(object);
chunk.remove(object);
}
}

View file

@ -232,6 +232,10 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) {
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, _ ->
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 java.util.ArrayList;
import java.util.Arrays;
/**
@ -75,17 +76,15 @@ public class BuildRegionChunk extends RegionChunk {
}
}
}
if (items != null) {
for (Item item : items) {
ArrayList<GroundItem> totalItems = drawItems(items, player);
for (GroundItem item : totalItems) {
if (item != null && item.isActive() && item.getLocation() != null) {
GroundItem g = (GroundItem) item;
if (!g.isPrivate() || g.droppedBy(player)) {
if (!item.isPrivate() || item.droppedBy(player)) {
ConstructGroundItem.write(buffer, item);
updated = true;
}
}
}
}
return updated;
}

View file

@ -149,12 +149,23 @@ public class RegionChunk {
}
}
}
ArrayList<GroundItem> totalItems = items != null ? new ArrayList(items) : new ArrayList();
ArrayList<GroundItem> totalItems = drawItems(items, player);
for (GroundItem item : totalItems) {
if (item != null && item.isActive() && item.getLocation() != null) {
if (!item.isPrivate() || item.droppedBy(player)) {
ConstructGroundItem.write(buffer, item);
updated = true;
}
}
}
return updated;
}
boolean drawChunks = player.getAttribute("chunkdraw", false);
boolean drawRegions = player.getAttribute("regiondraw", false);
if (drawChunks) {
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++) {
@ -169,7 +180,7 @@ public class RegionChunk {
}
}
if (drawRegions) {
if (player.getAttribute("regiondraw", false)) {
Location l = currentBase;
int localX = l.getLocalX();
int localY = l.getLocalY();
@ -193,18 +204,19 @@ public class RegionChunk {
}
}
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;
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 updated;
return totalItems;
}
/**