From c831bfe82eaf9744d9d31572718bbe029dba2d44 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 1 Feb 2026 05:51:27 +0100 Subject: [PATCH] Make non-legacy blocks' type/data values -1, to allow overriding non-legacy blocks with air in //generate (#2901) * In //g, allow overriding non-legacy blocks with air Previously, it was impossible to override a non-legacy block (i.e. one that was introduced after the switch to string IDs) with air. This was due to the fact that non-legacy blocks and air had the same type id (0). This change gives them separate type ids, making it possible to override non-legacy blocks with air. * Make query functions return type/data values of -1 for non-legacy blocks This matches the new behaviour of the type/data variables in //generate --- .../src/main/java/com/sk89q/worldedit/EditSession.java | 4 ++-- .../regions/shape/WorldEditExpressionEnvironment.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index c25bf8fee3..10bb926f56 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2481,8 +2481,8 @@ protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) try { int[] legacy = LegacyMapper.getInstance().getLegacyFromBlock(defaultMaterial.toImmutableState()); - int typeVar = 0; - int dataVar = 0; + int typeVar = -1; + int dataVar = -1; if (legacy != null) { typeVar = legacy[0]; if (legacy.length > 1) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java index 9f146e426c..1a77953aa7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java @@ -60,7 +60,7 @@ public Vector3 toWorldRel(double x, double y, double z) { private int getLegacy(BlockVector3 position, int index) { final int[] legacy = LegacyMapper.getInstance().getLegacyFromBlock(extent.getBlock(position).toImmutableState()); - return legacy == null ? 0 : legacy[index]; + return legacy == null ? -1 : legacy[index]; } @Override