From 4d77771ea191502cbe3713cbe157ef0211c70dba Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 7 Apr 2021 19:54:44 +0200 Subject: [PATCH] Increase cui limit based on game limits --- .../internal/cui/ServerCUIHandler.java | 29 +++++++++++++++---- .../src/main/resources/lang/strings.json | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java index 591dcca39..69f9ea5da 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java @@ -28,6 +28,7 @@ import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.RegionSelector; @@ -63,6 +64,8 @@ public class ServerCUIHandler { LocalSession session = WorldEdit.getInstance().getSessionManager().get(player); RegionSelector regionSelector = session.getRegionSelector(player.getWorld()); + int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion(); + int posX; int posY; int posZ; @@ -112,9 +115,16 @@ public class ServerCUIHandler { return null; } - if (width > 32 || length > 32 || height > 32) { - // Structure blocks have a limit of 32x32x32 - return null; + if (dataVersion >= 2526) { + if (width > 48 || length > 48 || height > 48) { + // 20w16a+ allows structure blocks up to 48 per axis + return null; + } else { + if (width > 32 || length > 32 || height > 32) { + // Structure blocks on versions <= 20w16a have a limit of 32x32x32 + return null; + } + } } // Borrowed this math from FAWE @@ -132,9 +142,16 @@ public class ServerCUIHandler { posY -= y; posZ -= z; - if (Math.abs(posX) > 32 || Math.abs(posY) > 32 || Math.abs(posZ) > 32) { - // Structure blocks have a limit - return null; + if (dataVersion >= 2526) { + if (Math.abs(posX) > 48 || Math.abs(posY) > 48 || Math.abs(posZ) > 48) { + // 20w16a+ allows structure blocks up to 48 per axis + return null; + } else { + if (Math.abs(posX) > 32 || Math.abs(posY) > 32 || Math.abs(posZ) > 32) { + // Structure blocks on versions <= 20w16a have a limit of 32x32x32 + return null; + } + } } structureTag.put("name", new StringTag("worldedit:" + player.getName())); diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 2c57c27e6..9b73326da 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -274,7 +274,7 @@ "worldedit.setbiome.changed": "Biomes were changed in {0} columns. You may have to rejoin your game (or close and reopen your world) to see a change.", "worldedit.drawsel.disabled": "Server CUI disabled.", - "worldedit.drawsel.enabled": "Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.", + "worldedit.drawsel.enabled": "Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32 on versions lower than 1.16, otherwise 48x48x48.", "worldedit.drawsel.disabled.already": "Server CUI already disabled.", "worldedit.drawsel.enabled.already": "Server CUI already enabled.", "worldedit.limit.too-high": "Your maximum allowable limit is {0}.",