Add //placement, which sets either pos1 or player explicitly

This commit is contained in:
TomyLobo 2023-03-06 17:54:05 +01:00 committed by Maddy Miller
parent 21a465b902
commit d28fadb842
3 changed files with 22 additions and 0 deletions

View File

@ -38,6 +38,7 @@
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.internal.annotation.Offset;
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
import com.sk89q.worldedit.internal.command.CommandUtil; import com.sk89q.worldedit.internal.command.CommandUtil;
import com.sk89q.worldedit.internal.cui.ServerCUIHandler; import com.sk89q.worldedit.internal.cui.ServerCUIHandler;
@ -445,6 +446,23 @@ public void togglePlace(Actor actor, LocalSession session) {
} }
} }
@Command(
name = "placement",
aliases = {"/placement"},
desc = "Select which placement to use"
)
public void placement(Actor actor, LocalSession session,
@Arg(desc = "Which placement type to use")
PlacementType placementType,
@Arg(desc = "number of times to apply the offset", def = "1")
int multiplier,
@Arg(desc = "How much to offset from it placement to use", def = Offset.ZERO)
@Offset
BlockVector3 offset) {
offset = offset.multiply(multiplier);
placementImpl(actor, session, new Placement(placementType, offset));
}
@Command( @Command(
name = "searchitem", name = "searchitem",
aliases = {"/searchitem", "/l", "/search"}, aliases = {"/searchitem", "/l", "/search"},

View File

@ -23,6 +23,7 @@
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.command.util.HookMode; import com.sk89q.worldedit.command.util.HookMode;
import com.sk89q.worldedit.extent.TracingExtent; import com.sk89q.worldedit.extent.TracingExtent;
import com.sk89q.worldedit.session.PlacementType;
import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
@ -57,6 +58,8 @@ public static void register(CommandManager commandManager) {
basic(HookMode.class)); basic(HookMode.class));
commandManager.registerConverter(Key.of(TracingExtent.Action.class), commandManager.registerConverter(Key.of(TracingExtent.Action.class),
basic(TracingExtent.Action.class)); basic(TracingExtent.Action.class));
commandManager.registerConverter(Key.of(PlacementType.class),
basic(PlacementType.class));
} }
private static <E extends Enum<E>> ArgumentConverter<E> basic(Class<E> enumClass) { private static <E extends Enum<E>> ArgumentConverter<E> basic(Class<E> enumClass) {

View File

@ -35,4 +35,5 @@
@InjectAnnotation @InjectAnnotation
public @interface Offset { public @interface Offset {
String FORWARD = "forward"; String FORWARD = "forward";
String ZERO = "0,0,0";
} }