mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-01-18 12:34:20 +08:00
Add a -c flag to the biome brush to set entire column (#2235)
* Add a -c flag to the biome brush to set entire column * Use new region factories that take fixed positions * Rename to FixedHeight from just Fixed
This commit is contained in:
parent
4fc62d98cb
commit
856aaa6267
@ -63,8 +63,12 @@
|
||||
import com.sk89q.worldedit.internal.annotation.ClipboardMask;
|
||||
import com.sk89q.worldedit.internal.annotation.VertHeight;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.factory.CuboidRegionFactory;
|
||||
import com.sk89q.worldedit.regions.factory.CylinderRegionFactory;
|
||||
import com.sk89q.worldedit.regions.factory.FixedHeightCuboidRegionFactory;
|
||||
import com.sk89q.worldedit.regions.factory.FixedHeightCylinderRegionFactory;
|
||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||
import com.sk89q.worldedit.regions.factory.SphereRegionFactory;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.session.request.RequestExtent;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
@ -626,7 +630,22 @@ public void biome(Player player, LocalSession localSession,
|
||||
@Arg(desc = "The size of the brush", def = "5")
|
||||
double radius,
|
||||
@Arg(desc = "The biome type")
|
||||
BiomeType biomeType) throws WorldEditException {
|
||||
BiomeType biomeType,
|
||||
@Switch(name = 'c', desc = "Whether to set the full column")
|
||||
boolean column) throws WorldEditException {
|
||||
|
||||
if (column) {
|
||||
// Convert this shape factory to a column-based one, if possible
|
||||
if (shape instanceof CylinderRegionFactory || shape instanceof SphereRegionFactory) {
|
||||
// Sphere regions that are Y-expended are just cylinders
|
||||
shape = new FixedHeightCylinderRegionFactory(player.getWorld().getMinY(), player.getWorld().getMaxY());
|
||||
} else if (shape instanceof CuboidRegionFactory) {
|
||||
shape = new FixedHeightCuboidRegionFactory(player.getWorld().getMinY(), player.getWorld().getMaxY());
|
||||
} else {
|
||||
player.printError(TranslatableComponent.of("worldedit.brush.biome.column-supported-types"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setOperationBasedBrush(player, localSession, radius,
|
||||
new ApplyRegion(new BiomeFactory(biomeType)), shape, "worldedit.brush.biome");
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.factory;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
* A factory for a cuboid region, with a fixed minimum and maximum Y position.
|
||||
*/
|
||||
public class FixedHeightCuboidRegionFactory implements RegionFactory {
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
|
||||
public FixedHeightCuboidRegionFactory(int minY, int maxY) {
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region createCenteredAt(BlockVector3 position, double size) {
|
||||
CuboidRegion region = CuboidRegion.fromCenter(position, (int) size);
|
||||
region.setPos1(region.getPos1().withY(minY));
|
||||
region.setPos2(region.getPos2().withY(maxY));
|
||||
return region;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.factory;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
* A factory for a cylinder region, with a fixed minimum and maximum Y position.
|
||||
*/
|
||||
public class FixedHeightCylinderRegionFactory implements RegionFactory {
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
|
||||
public FixedHeightCylinderRegionFactory(int minY, int maxY) {
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region createCenteredAt(BlockVector3 position, double size) {
|
||||
return new CylinderRegion(position, Vector2.at(size, size), minY, maxY);
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@
|
||||
"worldedit.brush.heightmap.equip": "Heightmap brush equipped ({0}).",
|
||||
"worldedit.brush.heightmap.unknown": "Unknown heightmap brush: {0}.",
|
||||
"worldedit.brush.morph.equip": "Morph brush shape equipped: {0}.",
|
||||
"worldedit.brush.biome.column-supported-types": "This brush shape is not supported with whole-column brushing, try the cylinder shape.",
|
||||
"worldedit.brush.none.equip": "Brush unbound from your current item.",
|
||||
"worldedit.brush.none.equipped": "You have no brush bound to your current item. Try /brush sphere for a basic brush.",
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user