3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 02:20:07 +01:00

Make inset/outset use varargs contract/expand, so they can be used with cylinders and ellipses.

Dieser Commit ist enthalten in:
aumgn 2012-03-13 10:02:00 +01:00 committet von TomyLobo
Ursprung 8506bb437e
Commit 760f77e681

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.commands;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
@ -438,31 +439,11 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.outset")
public void outset(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld());
try {
if (!args.hasFlag('h')) {
region.expand((new Vector(0, 1, 0)).multiply(change));
region.expand((new Vector(0, -1, 0)).multiply(change));
}
if (!args.hasFlag('v')) {
region.expand((new Vector(1, 0, 0)).multiply(change));
region.expand((new Vector(-1, 0, 0)).multiply(change));
region.expand((new Vector(0, 0, 1)).multiply(change));
region.expand((new Vector(0, 0, -1)).multiply(change));
}
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region outset.");
} catch (RegionOperationException e) {
player.printError(e.getMessage());
}
region.expand(getChangesForEachDir(args));
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region outset.");
}
@Command(
@ -481,27 +462,30 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.inset")
public void inset(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Region region = session.getSelection(player.getWorld());
region.contract(getChangesForEachDir(args));
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region inset.");
}
private Vector[] getChangesForEachDir(CommandContext args) {
List<Vector> changes = new ArrayList<Vector>(6);
int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld());
if (!args.hasFlag('h')) {
region.contract((new Vector(0, 1, 0)).multiply(change));
region.contract((new Vector(0, -1, 0)).multiply(change));
changes.add((new Vector(0, 1, 0)).multiply(change));
changes.add((new Vector(0, -1, 0)).multiply(change));
}
if (!args.hasFlag('v')) {
region.contract((new Vector(1, 0, 0)).multiply(change));
region.contract((new Vector(-1, 0, 0)).multiply(change));
region.contract((new Vector(0, 0, 1)).multiply(change));
region.contract((new Vector(0, 0, -1)).multiply(change));
changes.add((new Vector(1, 0, 0)).multiply(change));
changes.add((new Vector(-1, 0, 0)).multiply(change));
changes.add((new Vector(0, 0, 1)).multiply(change));
changes.add((new Vector(0, 0, -1)).multiply(change));
}
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region inset.");
return changes.toArray(new Vector[0]);
}
@Command(