mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-03-07 13:48:00 +08:00
Added a brush for biomes (#1491)
* Added a brush for biomes * IntelliJ reformat * Move the warning * Update worldedit-core/src/main/resources/lang/strings.json Co-authored-by: Octavia Togami <octavia.togami@gmail.com> * Use BiomeFactory instead Co-authored-by: Octavia Togami <octavia.togami@gmail.com>
This commit is contained in:
parent
4a4c01cb18
commit
8d33672b23
@ -181,9 +181,11 @@ public void setBiome(Player player, LocalSession session, EditSession editSessio
|
||||
Operations.completeLegacy(visitor);
|
||||
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.setbiome.changed",
|
||||
TextComponent.of(visitor.getAffected())
|
||||
));
|
||||
"worldedit.setbiome.changed",
|
||||
TextComponent.of(visitor.getAffected())
|
||||
)
|
||||
.append(TextComponent.newline())
|
||||
.append(TranslatableComponent.of("worldedit.setbiome.warning")));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.factory.ApplyLayer;
|
||||
import com.sk89q.worldedit.function.factory.ApplyRegion;
|
||||
import com.sk89q.worldedit.function.factory.BiomeFactory;
|
||||
import com.sk89q.worldedit.function.factory.Deform;
|
||||
import com.sk89q.worldedit.function.factory.Paint;
|
||||
import com.sk89q.worldedit.function.factory.Snow;
|
||||
@ -62,6 +63,7 @@
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
@ -433,6 +435,24 @@ public void snow(Player player, LocalSession localSession,
|
||||
new ApplyLayer(new Snow(stack)), shape, "worldedit.brush.snow");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "biome",
|
||||
desc = "Biome brush, sets biomes in the area"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.biome")
|
||||
public void biome(Player player, LocalSession localSession,
|
||||
@Arg(desc = "The shape of the region")
|
||||
RegionFactory shape,
|
||||
@Arg(desc = "The size of the brush", def = "5")
|
||||
double radius,
|
||||
@Arg(desc = "The biome type")
|
||||
BiomeType biomeType) throws WorldEditException {
|
||||
|
||||
setOperationBasedBrush(player, localSession, radius,
|
||||
new ApplyRegion(new BiomeFactory(biomeType)), shape, "worldedit.brush.biome");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.setbiome.warning"));
|
||||
}
|
||||
|
||||
static void setOperationBasedBrush(Player player, LocalSession session, double radius,
|
||||
Contextual<? extends Operation> factory,
|
||||
RegionFactory shape,
|
||||
|
@ -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.function.factory;
|
||||
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.EditContext;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.biome.BiomeReplace;
|
||||
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||
|
||||
public class BiomeFactory implements Contextual<RegionFunction> {
|
||||
|
||||
private final BiomePattern biomeType;
|
||||
|
||||
public BiomeFactory(BiomePattern biomeType) {
|
||||
this.biomeType = biomeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionFunction createFromContext(EditContext context) {
|
||||
return new BiomeReplace(context.getDestination(), this.biomeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "set biome";
|
||||
}
|
||||
}
|
@ -29,7 +29,8 @@
|
||||
"worldedit.brush.operation.equip": "Set brush to {0}.",
|
||||
"worldedit.brush.none.equip": "Brush unbound from your current item.",
|
||||
|
||||
"worldedit.setbiome.changed": "Biomes were changed for approximately {0} blocks. You may have to rejoin your game (or close and reopen your world) to see a change.",
|
||||
"worldedit.setbiome.changed": "Biomes were changed for approximately {0} blocks.",
|
||||
"worldedit.setbiome.warning": "You may have to re-join your game (or close and re-open your world) to see changes.",
|
||||
|
||||
"worldedit.drawsel.disabled": "Server CUI disabled.",
|
||||
"worldedit.drawsel.enabled": "Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.",
|
||||
|
Loading…
Reference in New Issue
Block a user