mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
This commit is contained in:
parent
02d5f3e8d5
commit
7967ef4db4
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe;
|
package com.boydti.fawe;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.implementation.QueueHandler;
|
import com.boydti.fawe.beta.implementation.QueueHandler;
|
||||||
|
import com.boydti.fawe.command.CFICommand;
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
@ -18,6 +19,7 @@ import com.boydti.fawe.util.WEManager;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
|
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -71,13 +71,14 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
import org.enginehub.piston.annotation.param.Arg;
|
||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
import org.enginehub.piston.exception.StopExecutionException;
|
import org.enginehub.piston.exception.StopExecutionException;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
public class CFICommands {
|
public class CFICommands {
|
||||||
@ -154,7 +155,7 @@ public class CFICommands {
|
|||||||
public void brush(FawePlayer fp) {
|
public void brush(FawePlayer fp) {
|
||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.popMessages(fp);
|
settings.popMessages(fp);
|
||||||
@NonNull Builder msg;
|
@NotNull Builder msg;
|
||||||
if (settings.getGenerator().getImageViewer() != null) {
|
if (settings.getGenerator().getImageViewer() != null) {
|
||||||
msg = TextComponent.builder("CFI supports using brushes during creation").append(newline())
|
msg = TextComponent.builder("CFI supports using brushes during creation").append(newline())
|
||||||
.append(" - Place the map on a wall of item frames").append(newline())
|
.append(" - Place the map on a wall of item frames").append(newline())
|
||||||
@ -811,7 +812,7 @@ public class CFICommands {
|
|||||||
int biomePriority = gen.getBiomePriority();
|
int biomePriority = gen.getBiomePriority();
|
||||||
|
|
||||||
//TODO fix this so it can execute commands and show tooltips.
|
//TODO fix this so it can execute commands and show tooltips.
|
||||||
@NonNull Builder builder = TextComponent.builder(">> Current Settings <<").append(newline())
|
@NotNull Builder builder = TextComponent.builder(">> Current Settings <<").append(newline())
|
||||||
.append("Randomization ").append("[" + Boolean.toString(rand).toUpperCase() + "]")//.cmdTip("/cfi randomization " + (!rand))
|
.append("Randomization ").append("[" + Boolean.toString(rand).toUpperCase() + "]")//.cmdTip("/cfi randomization " + (!rand))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append("Mask ").append("[" + mask + "]")//.cmdTip("/cfi mask")
|
.append("Mask ").append("[" + mask + "]")//.cmdTip("/cfi mask")
|
||||||
@ -1020,7 +1021,7 @@ public class CFICommands {
|
|||||||
String snow = "/cfi snow";
|
String snow = "/cfi snow";
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
@NonNull Builder msg = TextComponent.builder(">> Current Settings <<").append(newline())
|
@NotNull Builder msg = TextComponent.builder(">> Current Settings <<").append(newline())
|
||||||
.append("Mask ").append(TextComponent.of("[" + mask + "]")
|
.append("Mask ").append(TextComponent.of("[" + mask + "]")
|
||||||
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi mask")))
|
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi mask")))
|
||||||
.clickEvent(ClickEvent.runCommand("/cfi mask")))
|
.clickEvent(ClickEvent.runCommand("/cfi mask")))
|
||||||
|
@ -5,7 +5,6 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -23,8 +22,6 @@ public abstract class FaweParser<T> extends InputParser<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Dispatcher getDispatcher();
|
|
||||||
|
|
||||||
protected static class ParseEntry {
|
protected static class ParseEntry {
|
||||||
public boolean and;
|
public boolean and;
|
||||||
public String input;
|
public String input;
|
||||||
|
@ -41,7 +41,6 @@ public class SplatterBrush extends ScatterBrush {
|
|||||||
}
|
}
|
||||||
final int size2 = (int) (size * size);
|
final int size2 = (int) (size * size);
|
||||||
SurfaceMask surface = new SurfaceMask(editSession);
|
SurfaceMask surface = new SurfaceMask(editSession);
|
||||||
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
|
||||||
|
|
||||||
RecursiveVisitor visitor = new RecursiveVisitor(vector -> {
|
RecursiveVisitor visitor = new RecursiveVisitor(vector -> {
|
||||||
double dist = vector.distanceSq(position);
|
double dist = vector.distanceSq(position);
|
||||||
@ -51,6 +50,7 @@ public class SplatterBrush extends ScatterBrush {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}, vector -> editSession.setBlock(vector, finalPattern), recursion);
|
}, vector -> editSession.setBlock(vector, finalPattern), recursion);
|
||||||
|
visitor.setMaxBranch(2);
|
||||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
|
@ -16,7 +16,7 @@ public class VisualQueue extends SingleThreadIntervalQueue<FawePlayer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operate(FawePlayer fp) {
|
public void operate(FawePlayer fp) {
|
||||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(fp.toWorldEditPlayer());
|
LocalSession session = fp.getSession();
|
||||||
Player player = fp.getPlayer();
|
Player player = fp.getPlayer();
|
||||||
Tool tool = session.getTool(player);
|
Tool tool = session.getTool(player);
|
||||||
if (tool instanceof BrushTool) {
|
if (tool instanceof BrushTool) {
|
||||||
|
@ -168,14 +168,16 @@ public class Schematic {
|
|||||||
return editSession;
|
return editSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paste(Extent extent, BlockVector3 to, boolean pasteAir, Transform transform) {
|
public void paste(Extent extent, BlockVector3 to, boolean pasteAir, @Nullable Transform transform) {
|
||||||
checkNotNull(transform);
|
Extent source = clipboard;
|
||||||
Extent source = new BlockTransformExtent(clipboard, transform);
|
if (transform != null && !transform.isIdentity()) {
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(source, clipboard.getRegion(),
|
source = new BlockTransformExtent(clipboard, transform);
|
||||||
clipboard.getOrigin(), extent, to);
|
}
|
||||||
|
ForwardExtentCopy copy = new ForwardExtentCopy(source, clipboard.getRegion(), clipboard.getOrigin(), extent, to);
|
||||||
|
if (transform != null) {
|
||||||
copy.setTransform(transform);
|
copy.setTransform(transform);
|
||||||
copy.setCopyingBiomes(
|
}
|
||||||
!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP
|
copy.setCopyingBiomes(!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP
|
||||||
.hasBiomes());
|
.hasBiomes());
|
||||||
if (extent instanceof EditSession) {
|
if (extent instanceof EditSession) {
|
||||||
EditSession editSession = (EditSession) extent;
|
EditSession editSession = (EditSession) extent;
|
||||||
|
@ -48,8 +48,8 @@ public class ListFilters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "private",
|
name = "local",
|
||||||
aliases = {"me", "mine", "local"},
|
aliases = {"me", "mine", "private"},
|
||||||
desc = "List your personal schematics"
|
desc = "List your personal schematics"
|
||||||
)
|
)
|
||||||
public Filter local() {
|
public Filter local() {
|
||||||
@ -57,8 +57,8 @@ public class ListFilters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "public",
|
name = "global",
|
||||||
aliases = {"global"},
|
aliases = {"public"},
|
||||||
desc = "List public schematics"
|
desc = "List public schematics"
|
||||||
)
|
)
|
||||||
public Filter global() {
|
public Filter global() {
|
||||||
@ -76,7 +76,7 @@ public class ListFilters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "*", //TODO originally this was left blank but doing so causes a major compilation error
|
name = "*", //TODO NOT IMPLEMENTED originally this was left blank but doing so causes a major compilation error
|
||||||
desc = "wildcard"
|
desc = "wildcard"
|
||||||
)
|
)
|
||||||
public Filter wildcard(Actor actor, File root, String arg) {
|
public Filter wildcard(Actor actor, File root, String arg) {
|
||||||
|
@ -88,8 +88,8 @@ public class MaskCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "false",
|
name = "#false",
|
||||||
aliases = {"#false"},
|
aliases = {"false"},
|
||||||
desc = "Always false"
|
desc = "Always false"
|
||||||
)
|
)
|
||||||
public Mask falseMask(Extent extent) {
|
public Mask falseMask(Extent extent) {
|
||||||
@ -97,8 +97,8 @@ public class MaskCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "true",
|
name = "#true",
|
||||||
aliases = {"#true"},
|
aliases = {"true"},
|
||||||
desc = "Always true"
|
desc = "Always true"
|
||||||
)
|
)
|
||||||
public Mask trueMask(Extent extent) {
|
public Mask trueMask(Extent extent) {
|
||||||
|
@ -428,7 +428,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
if (typeId.hasBlockType()) {
|
if (typeId.hasBlockType()) {
|
||||||
return typeId.getBlockType().getDefaultState().toBaseBlock();
|
return typeId.getBlockType().getDefaultState().toBaseBlock();
|
||||||
} else {
|
} else {
|
||||||
|
return BlockTypes.AIR.getDefaultState().toBaseBlock(); // FAWE returns air here
|
||||||
|
/*
|
||||||
throw new NotABlockException();
|
throw new NotABlockException();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ import com.sk89q.worldedit.command.ToolCommandsRegistration;
|
|||||||
import com.sk89q.worldedit.command.ToolUtilCommands;
|
import com.sk89q.worldedit.command.ToolUtilCommands;
|
||||||
import com.sk89q.worldedit.command.ToolUtilCommandsRegistration;
|
import com.sk89q.worldedit.command.ToolUtilCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.TransformCommands;
|
import com.sk89q.worldedit.command.TransformCommands;
|
||||||
|
import com.sk89q.worldedit.command.TransformCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.UtilityCommands;
|
import com.sk89q.worldedit.command.UtilityCommands;
|
||||||
import com.sk89q.worldedit.command.UtilityCommandsRegistration;
|
import com.sk89q.worldedit.command.UtilityCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.WorldEditCommands;
|
import com.sk89q.worldedit.command.WorldEditCommands;
|
||||||
@ -690,7 +691,7 @@ public final class PlatformCommandManager {
|
|||||||
// exceptions without writing a hook into every dispatcher, we need to unwrap these
|
// exceptions without writing a hook into every dispatcher, we need to unwrap these
|
||||||
// exceptions and rethrow their converted form, if their is one.
|
// exceptions and rethrow their converted form, if their is one.
|
||||||
try {
|
try {
|
||||||
task.get();
|
Object result = task.get();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// Use the exception converter to convert the exception if any of its causes
|
// Use the exception converter to convert the exception if any of its causes
|
||||||
// can be converted, otherwise throw the original exception
|
// can be converted, otherwise throw the original exception
|
||||||
|
@ -72,27 +72,13 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
||||||
throw new IOException("This format does not support saving");
|
throw new IOException("This format does not support saving, use `schem` or `sponge` as format"); // Is more helpful
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFormat(File file) {
|
public boolean isFormat(File file) {
|
||||||
try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) {
|
String name = file.getName().toLowerCase();
|
||||||
NamedTag rootTag = str.readNamedTag();
|
return name.endsWith(".schematic") || name.endsWith(".mcedit") || name.endsWith(".mce");
|
||||||
if (!rootTag.getName().equals("Schematic")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
|
|
||||||
|
|
||||||
// Check
|
|
||||||
Map<String, Tag> schematic = schematicTag.getValue();
|
|
||||||
if (!schematic.containsKey("Materials")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SPONGE_SCHEMATIC("sponge", "schem") {
|
SPONGE_SCHEMATIC("sponge", "schem") {
|
||||||
@ -127,23 +113,8 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFormat(File file) {
|
public boolean isFormat(File file) {
|
||||||
try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) {
|
String name = file.getName().toLowerCase();
|
||||||
NamedTag rootTag = str.readNamedTag();
|
return name.endsWith(".schem") || name.endsWith(".sponge");
|
||||||
if (!rootTag.getName().equals("Schematic")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
|
|
||||||
|
|
||||||
// Check
|
|
||||||
Map<String, Tag> schematic = schematicTag.getValue();
|
|
||||||
if (!schematic.containsKey("Version")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -175,20 +146,8 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFormat(File file) {
|
public boolean isFormat(File file) {
|
||||||
try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) {
|
String name = file.getName().toLowerCase();
|
||||||
NamedTag rootTag = str.readNamedTag();
|
return name.endsWith(".nbt");
|
||||||
CompoundTag structureTag = (CompoundTag) rootTag.getTag();
|
|
||||||
|
|
||||||
// Check
|
|
||||||
Map<String, Tag> structure = structureTag.getValue();
|
|
||||||
if (!structure.containsKey("DataVersion")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -280,6 +280,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private Clipboard readVersion2(BlockArrayClipboard version1, CompoundTag schematicTag) throws IOException {
|
private Clipboard readVersion2(BlockArrayClipboard version1, CompoundTag schematicTag) throws IOException {
|
||||||
Map<String, Tag> schematic = schematicTag.getValue();
|
Map<String, Tag> schematic = schematicTag.getValue();
|
||||||
if (schematic.containsKey("BiomeData")) {
|
if (schematic.containsKey("BiomeData")) {
|
||||||
@ -290,6 +291,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
}
|
}
|
||||||
return version1;
|
return version1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private void readBiomes(BlockArrayClipboard clipboard, Map<String, Tag> schematic) throws IOException {
|
private void readBiomes(BlockArrayClipboard clipboard, Map<String, Tag> schematic) throws IOException {
|
||||||
ByteArrayTag dataTag = requireTag(schematic, "BiomeData", ByteArrayTag.class);
|
ByteArrayTag dataTag = requireTag(schematic, "BiomeData", ByteArrayTag.class);
|
||||||
@ -349,6 +351,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private void readEntities(BlockArrayClipboard clipboard, Map<String, Tag> schematic) throws IOException {
|
private void readEntities(BlockArrayClipboard clipboard, Map<String, Tag> schematic) throws IOException {
|
||||||
List<Tag> entList = requireTag(schematic, "Entities", ListTag.class).getValue();
|
List<Tag> entList = requireTag(schematic, "Entities", ListTag.class).getValue();
|
||||||
if (entList.isEmpty()) {
|
if (entList.isEmpty()) {
|
||||||
@ -379,6 +382,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
|
@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
return extent.setBlock(position, pattern.apply(position));
|
return pattern.apply(extent, position, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
return !vector.getBlock(getExtent()).getMaterial().isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -31,13 +31,6 @@ public class SolidBlockMask extends BlockMask {
|
|||||||
add(state -> state.getMaterial().isMovementBlocker());
|
add(state -> state.getMaterial().isMovementBlocker());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
Extent extent = getExtent();
|
|
||||||
BlockState block = extent.getBlock(vector);
|
|
||||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Mask2D toMask2D() {
|
public Mask2D toMask2D() {
|
||||||
|
@ -66,11 +66,13 @@ public class ChangeSetExecutor implements Operation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(RunContext run) throws WorldEditException {
|
public Operation resume(RunContext run) throws WorldEditException {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Change change = iterator.next();
|
Change change = iterator.next();
|
||||||
if (type == Type.UNDO) {
|
if (type == Type.UNDO) {
|
||||||
|
while (iterator.hasNext()) {
|
||||||
change.undo(context);
|
change.undo(context);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
while (iterator.hasNext()) {
|
||||||
change.redo(context);
|
change.redo(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public class BlockVector2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BlockVector2 at(int x, int z) {
|
public static BlockVector2 at(int x, int z) {
|
||||||
|
/* unnecessary
|
||||||
switch (x) {
|
switch (x) {
|
||||||
case 0:
|
case 0:
|
||||||
if (z == 0) {
|
if (z == 0) {
|
||||||
@ -66,11 +67,14 @@ public class BlockVector2 {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return new BlockVector2(x, z);
|
return new BlockVector2(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int x, z;
|
protected int x, z;
|
||||||
|
|
||||||
|
protected BlockVector2(){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance.
|
* Construct an instance.
|
||||||
*
|
*
|
||||||
|
@ -48,6 +48,7 @@ public abstract class BlockVector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BlockVector3 at(int x, int y, int z) {
|
public static BlockVector3 at(int x, int y, int z) {
|
||||||
|
/* unnecessary
|
||||||
// switch for efficiency on typical cases
|
// switch for efficiency on typical cases
|
||||||
// in MC y is rarely 0/1 on selections
|
// in MC y is rarely 0/1 on selections
|
||||||
switch (y) {
|
switch (y) {
|
||||||
@ -62,6 +63,7 @@ public abstract class BlockVector3 {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return new BlockVector3Imp(x, y, z);
|
return new BlockVector3Imp(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ public class Vector2 {
|
|||||||
public static final Vector2 ONE = new Vector2(1, 1);
|
public static final Vector2 ONE = new Vector2(1, 1);
|
||||||
|
|
||||||
public static Vector2 at(double x, double z) {
|
public static Vector2 at(double x, double z) {
|
||||||
|
/* Unnecessary
|
||||||
int xTrunc = (int) x;
|
int xTrunc = (int) x;
|
||||||
switch (xTrunc) {
|
switch (xTrunc) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -46,6 +47,7 @@ public class Vector2 {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return new Vector2(x, z);
|
return new Vector2(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ public abstract class Vector3 {
|
|||||||
public static final Vector3 ONE = Vector3.at(1, 1, 1);
|
public static final Vector3 ONE = Vector3.at(1, 1, 1);
|
||||||
|
|
||||||
public static Vector3 at(double x, double y, double z) {
|
public static Vector3 at(double x, double y, double z) {
|
||||||
|
/* Unnecessary
|
||||||
// switch for efficiency on typical cases
|
// switch for efficiency on typical cases
|
||||||
// in MC y is rarely 0/1 on selections
|
// in MC y is rarely 0/1 on selections
|
||||||
int yTrunc = (int) y;
|
int yTrunc = (int) y;
|
||||||
@ -54,6 +55,7 @@ public abstract class Vector3 {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return new Vector3Impl(x, y, z);
|
return new Vector3Impl(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +392,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Slow and unnecessary
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(BlockVector3 position) {
|
public boolean contains(BlockVector3 position) {
|
||||||
BlockVector3 min = getMinimumPoint();
|
BlockVector3 min = getMinimumPoint();
|
||||||
@ -399,6 +400,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
return position.containedWithin(min, max);
|
return position.containedWithin(min, max);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
|
@ -296,6 +296,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if a point is inside this region.
|
* Checks to see if a point is inside this region.
|
||||||
*/
|
*/
|
||||||
|
/* Slow and unnecessary
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(BlockVector3 position) {
|
public boolean contains(BlockVector3 position) {
|
||||||
final int blockY = position.getBlockY();
|
final int blockY = position.getBlockY();
|
||||||
@ -305,6 +306,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1;
|
return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if a point is inside this region.
|
* Checks to see if a point is inside this region.
|
||||||
|
@ -26,7 +26,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class EnumProperty extends AbstractProperty<String> {
|
public class EnumProperty extends AbstractProperty<String> {
|
||||||
|
|
||||||
private Map<String, Integer> offsets = new HashMap<>();
|
private Map<CharSequence, Integer> offsets = new HashMap<>();
|
||||||
|
|
||||||
public EnumProperty(final String name, final List<String> values) {
|
public EnumProperty(final String name, final List<String> values) {
|
||||||
this(name, values, 0);
|
this(name, values, 0);
|
||||||
@ -48,7 +48,7 @@ public class EnumProperty extends AbstractProperty<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndexFor(CharSequence string) throws IllegalArgumentException {
|
public int getIndexFor(CharSequence string) throws IllegalArgumentException {
|
||||||
Integer value = offsets.get(string.toString());
|
Integer value = offsets.get(string);
|
||||||
return value == null ? -1 : value;
|
return value == null ? -1 : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,10 +67,16 @@ public class IntegerProperty extends AbstractProperty<Integer> {
|
|||||||
public Integer getValueFor(String string) {
|
public Integer getValueFor(String string) {
|
||||||
try {
|
try {
|
||||||
int val = Integer.parseInt(string);
|
int val = Integer.parseInt(string);
|
||||||
|
/*
|
||||||
//It shouldn't matter if this check is slow. It's an important check
|
//It shouldn't matter if this check is slow. It's an important check
|
||||||
if (!getValues().contains(val)) {
|
if (!getValues().contains(val)) {
|
||||||
throw new IllegalArgumentException("Invalid int value: " + string + ". Must be in " + getValues().toString());
|
throw new IllegalArgumentException("Invalid int value: " + string + ". Must be in " + getValues().toString());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
// An exception will get thrown anyway if the property doesn't exist, so it's not really that important. Anyway, we can check the array instead of the string list
|
||||||
|
if (val > 0 && val >= map.length) {
|
||||||
|
throw new IllegalArgumentException("Invalid int value: " + string + ". Must be in " + getValues().toString());
|
||||||
|
}
|
||||||
return val;
|
return val;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException("Invalid int value: " + string + ". Not an int.");
|
throw new IllegalArgumentException("Invalid int value: " + string + ". Not an int.");
|
||||||
|
@ -151,7 +151,7 @@ public class PasteBuilder {
|
|||||||
copy.setFilterFunction(this.canApply);
|
copy.setFilterFunction(this.canApply);
|
||||||
}
|
}
|
||||||
if (ignoreAirBlocks) {
|
if (ignoreAirBlocks) {
|
||||||
sourceMask = new MaskIntersection(sourceMask, new ExistingBlockMask(clipboard));
|
sourceMask = MaskIntersection.of(sourceMask, new ExistingBlockMask(clipboard));
|
||||||
}
|
}
|
||||||
if (targetExtent instanceof EditSession) {
|
if (targetExtent instanceof EditSession) {
|
||||||
Mask esSourceMask = ((EditSession) targetExtent).getSourceMask();
|
Mask esSourceMask = ((EditSession) targetExtent).getSourceMask();
|
||||||
|
Loading…
Reference in New Issue
Block a user