Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 02:50:05 +01:00
Begin fixing layer brush
- Required new argument parser, which should ultimately be made into a singe blockstate parser for best results, and proper tab-completion - The layer brush itself is broken because of the changes to internal block retrieval from legacy
Dieser Commit ist enthalten in:
Ursprung
7ef8b2f95e
Commit
1fa5f4d725
@ -25,8 +25,8 @@ public class LayerBrush implements Brush {
|
||||
private final BlockState[] layers;
|
||||
private RecursiveVisitor visitor;
|
||||
|
||||
public LayerBrush(BlockState[] layers) {
|
||||
this.layers = layers;
|
||||
public LayerBrush(Pattern[] layers) {
|
||||
this.layers = Arrays.stream(layers).map(p -> p.applyBlock(BlockVector3.ZERO).toBlockState()).toArray(BlockState[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +41,7 @@ public class LayerBrush implements Brush {
|
||||
BlockVectorSet visited = visitor.getVisited();
|
||||
visitor = new RecursiveVisitor(new LayerBrushMask(editSession, visitor, layers, adjacent), pos -> {
|
||||
int depth = visitor.getDepth();
|
||||
BlockState currentPattern = layers[depth];
|
||||
Pattern currentPattern = layers[depth];
|
||||
return currentPattern.apply(editSession, pos, pos);
|
||||
}, layers.length - 1);
|
||||
for (BlockVector3 pos : visited) {
|
||||
@ -50,4 +50,5 @@ public class LayerBrush implements Brush {
|
||||
Operations.completeBlindly(visitor);
|
||||
visitor = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,12 +4,15 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LayerBrushMask extends AbstractExtentMask {
|
||||
|
||||
private final EditSession editSession;
|
||||
@ -33,7 +36,7 @@ public class LayerBrushMask extends AbstractExtentMask {
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 pos) {
|
||||
int depth = visitor.getDepth() + 1;
|
||||
int depth = (visitor.getDepth() + 1) % layers.length;
|
||||
if (depth > 1) {
|
||||
boolean found = false;
|
||||
BlockState previous = layers[depth - 1];
|
||||
|
@ -96,6 +96,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.PatternList;
|
||||
import com.sk89q.worldedit.internal.annotation.ClipboardMask;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -108,7 +109,6 @@ import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -632,10 +632,13 @@ public class BrushCommands {
|
||||
@CommandPermissions("worldedit.brush.layer")
|
||||
public void surfaceLayer(InjectedValueAccess context,
|
||||
@Arg(desc = "Expression")
|
||||
Expression radius, List<BlockState> blockLayers)
|
||||
Expression radius,
|
||||
@Arg(desc = "List of comma-separated patterns")
|
||||
@PatternList()
|
||||
List<Pattern> patternLayers)
|
||||
throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius);
|
||||
set(context, new LayerBrush(patternLayers.toArray(new Pattern[0]))).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -683,7 +686,9 @@ public class BrushCommands {
|
||||
@Arg(desc = "double", def = "1")
|
||||
double points,
|
||||
@Arg(desc = "double", def = "1")
|
||||
double distance, List<String> commandStr)
|
||||
double distance,
|
||||
@Arg(desc = "List of comma-separated commands")
|
||||
List<String> commandStr)
|
||||
throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(context,
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.google.auto.value.AutoAnnotation;
|
||||
import com.sk89q.worldedit.internal.annotation.PatternList;
|
||||
import com.sk89q.worldedit.internal.annotation.Radii;
|
||||
|
||||
/**
|
||||
@ -32,6 +33,11 @@ class Annotations {
|
||||
return new AutoAnnotation_Annotations_radii(value);
|
||||
}
|
||||
|
||||
@AutoAnnotation
|
||||
static PatternList patternList() {
|
||||
return new AutoAnnotation_Annotations_patternList();
|
||||
}
|
||||
|
||||
private Annotations() {
|
||||
}
|
||||
|
||||
|
@ -261,6 +261,9 @@ public final class PlatformCommandManager {
|
||||
SideEffectConverter.register(commandManager);
|
||||
HeightConverter.register(commandManager);
|
||||
OffsetConverter.register(worldEdit, commandManager);
|
||||
commandManager.registerConverter(Key.of(com.sk89q.worldedit.function.pattern.Pattern.class, Annotations.patternList()),
|
||||
CommaSeparatedValuesConverter.wrap(commandManager.getConverter(Key.of(
|
||||
com.sk89q.worldedit.function.pattern.Pattern.class)).get()));
|
||||
|
||||
registerBindings(new ConsumeBindings(worldEdit, this));
|
||||
registerBindings(new PrimitiveBindings(worldEdit));
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.internal.annotation;
|
||||
|
||||
import org.enginehub.piston.inject.InjectAnnotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotates a {@code List<BlockState>} parameter to inject a list of BlockStates.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@InjectAnnotation
|
||||
public @interface PatternList {
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren