Increase cui limit based on game limits

This commit is contained in:
NotMyFault 2021-04-07 19:54:44 +02:00
parent 6e8cc06637
commit 4d77771ea1
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
2 changed files with 24 additions and 7 deletions

View File

@ -28,6 +28,7 @@ import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
@ -63,6 +64,8 @@ public class ServerCUIHandler {
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player); LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
RegionSelector regionSelector = session.getRegionSelector(player.getWorld()); RegionSelector regionSelector = session.getRegionSelector(player.getWorld());
int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
int posX; int posX;
int posY; int posY;
int posZ; int posZ;
@ -112,9 +115,16 @@ public class ServerCUIHandler {
return null; return null;
} }
if (width > 32 || length > 32 || height > 32) { if (dataVersion >= 2526) {
// Structure blocks have a limit of 32x32x32 if (width > 48 || length > 48 || height > 48) {
// 20w16a+ allows structure blocks up to 48 per axis
return null; 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 // Borrowed this math from FAWE
@ -132,9 +142,16 @@ public class ServerCUIHandler {
posY -= y; posY -= y;
posZ -= z; posZ -= z;
if (Math.abs(posX) > 32 || Math.abs(posY) > 32 || Math.abs(posZ) > 32) { if (dataVersion >= 2526) {
// Structure blocks have a limit if (Math.abs(posX) > 48 || Math.abs(posY) > 48 || Math.abs(posZ) > 48) {
// 20w16a+ allows structure blocks up to 48 per axis
return null; 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())); structureTag.put("name", new StringTag("worldedit:" + player.getName()));

View File

@ -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.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.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.disabled.already": "Server CUI already disabled.",
"worldedit.drawsel.enabled.already": "Server CUI already enabled.", "worldedit.drawsel.enabled.already": "Server CUI already enabled.",
"worldedit.limit.too-high": "Your maximum allowable limit is {0}.", "worldedit.limit.too-high": "Your maximum allowable limit is {0}.",