Few fixes for feature brushes (#2371)

This commit is contained in:
Maddy Miller 2023-08-14 22:26:05 +10:00 committed by GitHub
parent 7f81aad028
commit d623488237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 7 deletions

View File

@ -567,7 +567,7 @@ public class BrushCommands {
@Arg(desc = "The type of feature to use")
ConfiguredFeatureType type) throws WorldEditException {
setOperationBasedBrush(player, localSession, radius,
new Paint(new FeatureGeneratorFactory(type), density / 100), shape, "worldedit.brush.feature");
new ApplyRegion(new FeatureGeneratorFactory(type, density / 100)), shape, "worldedit.brush.feature");
}
@Command(
@ -650,6 +650,7 @@ public class BrushCommands {
setOperationBasedBrush(player, localSession, radius,
new ApplyRegion(new BiomeFactory(biomeType)), shape, "worldedit.brush.biome");
player.printInfo(TranslatableComponent.of("worldedit.setbiome.warning"));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}
@Command(
@ -677,6 +678,7 @@ public class BrushCommands {
tool.setSize(brushSize);
player.printInfo(TranslatableComponent.of("worldedit.brush.morph.equip", TextComponent.of((int) brushSize)));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}
@Command(
@ -696,6 +698,7 @@ public class BrushCommands {
tool.setSize(brushSize);
player.printInfo(TranslatableComponent.of("worldedit.brush.morph.equip", TextComponent.of((int) brushSize)));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}
@Command(
@ -715,6 +718,7 @@ public class BrushCommands {
tool.setSize(brushSize);
player.printInfo(TranslatableComponent.of("worldedit.brush.morph.equip", TextComponent.of((int) brushSize)));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}
static void setOperationBasedBrush(Player player, LocalSession session, double radius,

View File

@ -22,19 +22,27 @@ package com.sk89q.worldedit.command.factory;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.function.Contextual;
import com.sk89q.worldedit.function.EditContext;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.generator.FeatureGenerator;
import com.sk89q.worldedit.function.mask.NoiseFilter;
import com.sk89q.worldedit.math.noise.RandomNoise;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
public final class FeatureGeneratorFactory implements Contextual<FeatureGenerator> {
public final class FeatureGeneratorFactory implements Contextual<RegionMaskingFilter> {
private final ConfiguredFeatureType type;
private final double density;
public FeatureGeneratorFactory(ConfiguredFeatureType type) {
public FeatureGeneratorFactory(ConfiguredFeatureType type, double density) {
this.type = type;
this.density = density;
}
@Override
public FeatureGenerator createFromContext(EditContext input) {
return new FeatureGenerator((EditSession) input.getDestination(), type);
public RegionMaskingFilter createFromContext(EditContext input) {
return new RegionMaskingFilter(
new NoiseFilter(new RandomNoise(), this.density),
new FeatureGenerator((EditSession) input.getDestination(), this.type)
);
}
@Override

View File

@ -26,8 +26,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
/**
* Generates forests by searching for the ground starting from the given upper Y
* coordinate for every column given.
* Attempt to generate features for every location in the given region.
*/
public class FeatureGenerator implements RegionFunction {