Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-09 21:10:05 +01:00
resolve issues with 2e67425d8131a2b1eb7ff752335bccf371801b8b
Dieser Commit ist enthalten in:
Ursprung
1bc35eb59a
Commit
6e13b44f84
@ -38,9 +38,10 @@ println """
|
|||||||
*******************************************
|
*******************************************
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
allprojects {
|
||||||
group = 'com.boydti.fawe'
|
group = 'com.boydti.fawe'
|
||||||
|
|
||||||
def rootVersion = "1.14"
|
def rootVersion = "1.13"
|
||||||
def revision = ""
|
def revision = ""
|
||||||
def buildNumber = ""
|
def buildNumber = ""
|
||||||
def date = ""
|
def date = ""
|
||||||
@ -56,6 +57,8 @@ ext {
|
|||||||
for (; parents != null && !parents.isEmpty(); index++) {
|
for (; parents != null && !parents.isEmpty(); index++) {
|
||||||
parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
|
parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
|
||||||
}
|
}
|
||||||
|
buildNumber = "${index}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version = String.format("%s.%s", rootVersion, buildNumber)
|
version = String.format("%s.%s", rootVersion, buildNumber)
|
||||||
|
@ -23,7 +23,7 @@ public class VoxelList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(BlockMask mask) {
|
public void add(BlockMask mask) {
|
||||||
this.mask = (BlockMask) mask.and(mask);
|
this.mask = (BlockMask) mask.tryCombine(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +37,7 @@ public class VoxelList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeValue(final BlockMask state) {
|
public boolean removeValue(final BlockMask state) {
|
||||||
this.mask = (BlockMask) mask.and(state.inverse());
|
this.mask = (BlockMask) mask.tryCombine(state.inverse());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ configurations.all { Configuration it ->
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile ('net.milkbowl.vault:VaultAPI:1.7')
|
compile ('net.milkbowl.vault:VaultAPI:1.7')
|
||||||
api project(':worldedit-core')
|
api project(':worldedit-core')
|
||||||
|
api project(':worldedit-libs:core') // TODO remove once core can compile
|
||||||
api project(':worldedit-libs:bukkit')
|
api project(':worldedit-libs:bukkit')
|
||||||
compileOnly 'com.sk89q:dummypermscompat:1.10'
|
compileOnly 'com.sk89q:dummypermscompat:1.10'
|
||||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||||
|
@ -318,13 +318,14 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (worldRef.get() == null) {
|
World ref = worldRef.get();
|
||||||
|
if (ref == null) {
|
||||||
return false;
|
return false;
|
||||||
} else if (other == null) {
|
} else if (other == null) {
|
||||||
return false;
|
return false;
|
||||||
} else if ((other instanceof BukkitWorld)) {
|
} else if ((other instanceof BukkitWorld)) {
|
||||||
World otherWorld = ((BukkitWorld) other).worldRef.get();
|
World otherWorld = ((BukkitWorld) other).worldRef.get();
|
||||||
return otherWorld != null && otherWorld.equals(getWorld());
|
return ref.equals(otherWorld);
|
||||||
} else if (other instanceof com.sk89q.worldedit.world.World) {
|
} else if (other instanceof com.sk89q.worldedit.world.World) {
|
||||||
return ((com.sk89q.worldedit.world.World) other).getName().equals(getName());
|
return ((com.sk89q.worldedit.world.World) other).getName().equals(getName());
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import com.bekvon.bukkit.residence.commands.command;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -36,12 +37,15 @@ import org.bukkit.event.player.PlayerCommandSendEvent;
|
|||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.inject.InjectedValueStore;
|
import org.enginehub.piston.inject.InjectedValueStore;
|
||||||
import org.enginehub.piston.inject.Key;
|
import org.enginehub.piston.inject.Key;
|
||||||
import org.enginehub.piston.inject.MapBackedValueStore;
|
import org.enginehub.piston.inject.MapBackedValueStore;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all events thrown in relation to a Player
|
* Handles all events thrown in relation to a Player
|
||||||
@ -71,16 +75,22 @@ public class WorldEditListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||||
InjectedValueStore store = MapBackedValueStore.create();
|
InjectedValueStore store = null;
|
||||||
store.injectValue(Key.of(Actor.class), context ->
|
|
||||||
Optional.of(plugin.wrapCommandSender(event.getPlayer())));
|
|
||||||
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager();
|
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager();
|
||||||
event.getCommands().removeIf(name ->
|
Iterator<String> iter = event.getCommands().iterator();
|
||||||
// remove if in the manager and not satisfied
|
while (iter.hasNext()) {
|
||||||
commandManager.getCommand(name)
|
String name = iter.next();
|
||||||
.filter(command -> !command.getCondition().satisfied(store))
|
Optional<Command> optional = commandManager.getCommand(name);
|
||||||
.isPresent()
|
if (optional.isPresent()) {
|
||||||
);
|
if (store == null) {
|
||||||
|
store = MapBackedValueStore.create();
|
||||||
|
store.injectValue(Key.of(Actor.class), context -> Optional.of(plugin.wrapCommandSender(event.getPlayer())));
|
||||||
|
}
|
||||||
|
if (!optional.get().getCondition().satisfied(store)) {
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||||
@ -150,18 +151,22 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConfirmTask(@NotNull Runnable task, CommandContext context) {
|
private void setConfirmTask(@NotNull Runnable task, CommandContext context, String command) {
|
||||||
|
if (task != null) {
|
||||||
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
|
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
|
||||||
task.run();
|
task.run();
|
||||||
return null;
|
return null;
|
||||||
}, context.getLocals());
|
}, context.getLocals());
|
||||||
setMeta("cmdConfirm", newTask);
|
setMeta("cmdConfirm", newTask);
|
||||||
|
} else {
|
||||||
|
setMeta("cmdConfirm", new CommandEvent(getPlayer(), command));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkConfirmation(@NotNull Runnable task, String command, int times, int limit, CommandContext context) throws RegionOperationException {
|
public void checkConfirmation(@NotNull Runnable task, String command, int times, int limit, CommandContext context) throws RegionOperationException {
|
||||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
if (times > limit) {
|
if (times > limit) {
|
||||||
setConfirmTask(task, context);
|
setConfirmTask(task, context, command);
|
||||||
String volume = "<unspecified>";
|
String volume = "<unspecified>";
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
||||||
}
|
}
|
||||||
@ -173,7 +178,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
if (radius > 0) {
|
if (radius > 0) {
|
||||||
if (radius > 448) {
|
if (radius > 448) {
|
||||||
setConfirmTask(task, context);
|
setConfirmTask(task, context, command);
|
||||||
long volume = (long) (Math.PI * ((double) radius * radius));
|
long volume = (long) (Math.PI * ((double) radius * radius));
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command, NumberFormat.getNumberInstance().format(volume)));
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command, NumberFormat.getNumberInstance().format(volume)));
|
||||||
}
|
}
|
||||||
@ -189,7 +194,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
||||||
if (area > 2 << 18) {
|
if (area > 2 << 18) {
|
||||||
setConfirmTask(task, context);
|
setConfirmTask(task, context, command);
|
||||||
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
||||||
long volume = (long) base.getX() * base.getZ() * base.getY() * times;
|
long volume = (long) base.getX() * base.getZ() * base.getY() * times;
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||||
@ -206,7 +211,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1);
|
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1);
|
||||||
if (area > 2 << 18) {
|
if (area > 2 << 18) {
|
||||||
setConfirmTask(task, context);
|
setConfirmTask(task, context, command);
|
||||||
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
||||||
long volume = (long) base.getX() * base.getZ() * base.getY();
|
long volume = (long) base.getX() * base.getZ() * base.getY();
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||||
|
@ -25,41 +25,18 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
|||||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
|
||||||
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.example.MappedFaweQueue;
|
|
||||||
import com.boydti.fawe.jnbt.anvil.MCAQueue;
|
|
||||||
import com.boydti.fawe.jnbt.anvil.MCAWorld;
|
|
||||||
import com.boydti.fawe.logging.LoggingChangeSet;
|
|
||||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.HistoryExtent;
|
import com.boydti.fawe.object.HistoryExtent;
|
||||||
import com.boydti.fawe.object.NullChangeSet;
|
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
|
||||||
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
|
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
|
||||||
import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet;
|
|
||||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
|
||||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
|
||||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.object.extent.FastWorldEditExtent;
|
|
||||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
|
||||||
import com.boydti.fawe.object.extent.HeightBoundExtent;
|
|
||||||
import com.boydti.fawe.object.extent.MultiRegionExtent;
|
|
||||||
import com.boydti.fawe.object.extent.NullExtent;
|
|
||||||
import com.boydti.fawe.object.extent.ProcessedWEExtent;
|
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
|
||||||
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
|
||||||
import com.boydti.fawe.object.extent.SlowExtent;
|
|
||||||
import com.boydti.fawe.object.extent.SourceMaskExtent;
|
|
||||||
import com.boydti.fawe.object.extent.StripNBTExtent;
|
|
||||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
||||||
import com.boydti.fawe.object.extent.NullExtent;
|
import com.boydti.fawe.object.extent.NullExtent;
|
||||||
import com.boydti.fawe.object.extent.ProcessedWEExtent;
|
import com.boydti.fawe.object.extent.ProcessedWEExtent;
|
||||||
@ -68,24 +45,17 @@ import com.boydti.fawe.object.extent.SourceMaskExtent;
|
|||||||
import com.boydti.fawe.object.function.SurfaceRegionFunction;
|
import com.boydti.fawe.object.function.SurfaceRegionFunction;
|
||||||
import com.boydti.fawe.object.mask.ResettableMask;
|
import com.boydti.fawe.object.mask.ResettableMask;
|
||||||
import com.boydti.fawe.object.pattern.ExistingPattern;
|
import com.boydti.fawe.object.pattern.ExistingPattern;
|
||||||
import com.boydti.fawe.object.progress.ChatProgressTracker;
|
|
||||||
import com.boydti.fawe.object.progress.DefaultProgressTracker;
|
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
import com.boydti.fawe.util.ExtentTraverser;
|
import com.boydti.fawe.util.ExtentTraverser;
|
||||||
import com.boydti.fawe.util.MaskTraverser;
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.MemUtil;
|
|
||||||
import com.boydti.fawe.util.Perm;
|
|
||||||
import com.boydti.fawe.util.SetQueue;
|
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -95,12 +65,10 @@ import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
|
|||||||
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
||||||
import com.sk89q.worldedit.function.GroundFunction;
|
import com.sk89q.worldedit.function.GroundFunction;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
|
||||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||||
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
||||||
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
|
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
|
||||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||||
@ -116,7 +84,6 @@ import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
|||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
|
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
|
||||||
import com.sk89q.worldedit.function.util.RegionOffset;
|
import com.sk89q.worldedit.function.util.RegionOffset;
|
||||||
@ -137,7 +104,6 @@ import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutExceptio
|
|||||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MathUtils;
|
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector2;
|
import com.sk89q.worldedit.math.Vector2;
|
||||||
@ -161,7 +127,6 @@ import com.sk89q.worldedit.util.Direction;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
import com.sk89q.worldedit.world.SimpleWorld;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -185,15 +150,12 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
|
||||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
|
||||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
|
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
|
||||||
@ -559,9 +521,6 @@ public class EditSession extends AbstractDelegateExtent SimpleWorld, AutoCloseab
|
|||||||
new MaskTraverser(mask).reset(this);
|
new MaskTraverser(mask).reset(this);
|
||||||
}
|
}
|
||||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
|
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
|
||||||
=======
|
|
||||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
|
|
||||||
>>>>>>> filter-pipeline
|
|
||||||
if (maskingExtent != null && maskingExtent.get() != null) {
|
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||||
Mask oldMask = maskingExtent.get().getMask();
|
Mask oldMask = maskingExtent.get().getMask();
|
||||||
if (oldMask instanceof ResettableMask) {
|
if (oldMask instanceof ResettableMask) {
|
||||||
@ -2580,7 +2539,7 @@ public class EditSession extends AbstractDelegateExtent SimpleWorld, AutoCloseab
|
|||||||
final Vector3 scaled = current.subtract(zero).divide(unit);
|
final Vector3 scaled = current.subtract(zero).divide(unit);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getInternalId(), defaultMaterial.getInternalPropertiesId()}, timeout) <= 0) {
|
if (expression.evaluateTimeout(timeout, scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getInternalId(), defaultMaterial.getInternalPropertiesId()) <= 0) {
|
||||||
// TODO data
|
// TODO data
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -2632,7 +2591,7 @@ public class EditSession extends AbstractDelegateExtent SimpleWorld, AutoCloseab
|
|||||||
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
|
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
|
||||||
|
|
||||||
// transform
|
// transform
|
||||||
expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout);
|
expression.evaluateTimeout(timeout, scaled.getX(), scaled.getY(), scaled.getZ());
|
||||||
int xv = (int) (x.getValue() * unit.getX() + zero2.getX());
|
int xv = (int) (x.getValue() * unit.getX() + zero2.getX());
|
||||||
int yv = (int) (y.getValue() * unit.getY() + zero2.getY());
|
int yv = (int) (y.getValue() * unit.getY() + zero2.getY());
|
||||||
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ());
|
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ());
|
||||||
@ -2993,7 +2952,7 @@ public class EditSession extends AbstractDelegateExtent SimpleWorld, AutoCloseab
|
|||||||
double scaledZ = (z - zero2D.getZ()) / unit2D.getZ();
|
double scaledZ = (z - zero2D.getZ()) / unit2D.getZ();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (expression.evaluate(new double[]{scaledX, scaledZ}, timeout) <= 0) {
|
if (expression.evaluateTimeout(timeout, scaledX, scaledZ, timeout) <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,8 +660,7 @@ public class UtilityCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
||||||
double result = expression.evaluate(
|
double result = expression.evaluateTimeout(WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
||||||
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
|
||||||
String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result);
|
String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result);
|
||||||
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
|
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
|
||||||
}, null);
|
}, null);
|
||||||
|
@ -20,19 +20,8 @@
|
|||||||
package com.sk89q.worldedit.extension.factory;
|
package com.sk89q.worldedit.extension.factory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
|
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.DefaultMaskParser;
|
import com.sk89q.worldedit.extension.factory.parser.mask.DefaultMaskParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
|
@ -62,7 +62,7 @@ public class ExpressionMaskParser extends InputParser<Mask> {
|
|||||||
exp.setEnvironment(env);
|
exp.setEnvironment(env);
|
||||||
if (context.getActor() != null) {
|
if (context.getActor() != null) {
|
||||||
SessionOwner owner = context.getActor();
|
SessionOwner owner = context.getActor();
|
||||||
IntSupplier timeout = () -> WorldEdit.getInstance().getSessionManager().get(owner).getTimeout();
|
int timeout = WorldEdit.getInstance().getSessionManager().get(owner).getTimeout();
|
||||||
return new ExpressionMask(exp, timeout);
|
return new ExpressionMask(exp, timeout);
|
||||||
}
|
}
|
||||||
return new ExpressionMask(exp);
|
return new ExpressionMask(exp);
|
||||||
|
@ -209,7 +209,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
public boolean descendLevel() {
|
public boolean descendLevel() {
|
||||||
final Location pos = getBlockIn();
|
final Location pos = getBlockIn();
|
||||||
final int x = pos.getBlockX();
|
final int x = pos.getBlockX();
|
||||||
int y = Math.max(0, pos.getBlockY() - 1);
|
int y = Math.max(0, pos.getBlockY());
|
||||||
final int z = pos.getBlockZ();
|
final int z = pos.getBlockZ();
|
||||||
final Extent world = pos.getExtent();
|
final Extent world = pos.getExtent();
|
||||||
|
|
||||||
|
@ -2,14 +2,12 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public abstract class ABlockMask extends AbstractExtentMask {
|
public abstract class ABlockMask extends AbstractExtentMask {
|
||||||
public ABlockMask(Extent extent) {
|
public ABlockMask(Extent extent) {
|
||||||
@ -45,7 +43,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask and(Mask mask) {
|
public Mask tryCombine(Mask mask) {
|
||||||
if (mask instanceof ABlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
ABlockMask other = (ABlockMask) mask;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
BlockMask newMask = new BlockMask(getExtent());
|
BlockMask newMask = new BlockMask(getExtent());
|
||||||
@ -56,7 +54,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mask tmp = newMask.optimize();
|
Mask tmp = newMask.tryOptimize();
|
||||||
if (tmp == null) tmp = newMask;
|
if (tmp == null) tmp = newMask;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -64,7 +62,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask or(Mask mask) {
|
public Mask tryOr(Mask mask) {
|
||||||
if (mask instanceof ABlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
ABlockMask other = (ABlockMask) mask;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
BlockMask newMask = new BlockMask(getExtent());
|
BlockMask newMask = new BlockMask(getExtent());
|
||||||
@ -75,7 +73,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mask tmp = newMask.optimize();
|
Mask tmp = newMask.tryOptimize();
|
||||||
if (tmp == null) tmp = newMask;
|
if (tmp == null) tmp = newMask;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class BlockMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask and(Mask mask) {
|
public Mask tryCombine(Mask mask) {
|
||||||
if (mask instanceof ABlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
ABlockMask other = (ABlockMask) mask;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
for (int i = 0; i < ordinals.length; i++) {
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
@ -143,7 +143,7 @@ public class BlockMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask or(Mask mask) {
|
public Mask tryOr(Mask mask) {
|
||||||
if (mask instanceof ABlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
ABlockMask other = (ABlockMask) mask;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
for (int i = 0; i < ordinals.length; i++) {
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
@ -157,7 +157,7 @@ public class BlockMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask optimize() {
|
public Mask tryOptimize() {
|
||||||
int setStates = 0;
|
int setStates = 0;
|
||||||
BlockState setState = null;
|
BlockState setState = null;
|
||||||
BlockState unsetState = null;
|
BlockState unsetState = null;
|
||||||
|
@ -248,7 +248,10 @@ public class BlockMaskBuilder {
|
|||||||
private boolean optimizedStates = true;
|
private boolean optimizedStates = true;
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return Arrays.stream(bitSets).noneMatch(Objects::nonNull);
|
for (long[] bitSet : bitSets) {
|
||||||
|
if (bitSet != null) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder() {
|
public BlockMaskBuilder() {
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||||
@ -39,7 +40,7 @@ import java.util.function.IntSupplier;
|
|||||||
public class ExpressionMask extends AbstractMask {
|
public class ExpressionMask extends AbstractMask {
|
||||||
|
|
||||||
private final Expression expression;
|
private final Expression expression;
|
||||||
private final IntSupplier timeout;
|
private final int timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -57,10 +58,10 @@ public class ExpressionMask extends AbstractMask {
|
|||||||
* @param expression the expression
|
* @param expression the expression
|
||||||
*/
|
*/
|
||||||
public ExpressionMask(Expression expression) {
|
public ExpressionMask(Expression expression) {
|
||||||
this(expression, null);
|
this(expression, WorldEdit.getInstance().getConfiguration().calculationTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionMask(Expression expression, @Nullable IntSupplier timeout) {
|
public ExpressionMask(Expression expression, int timeout) {
|
||||||
checkNotNull(expression);
|
checkNotNull(expression);
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@ -72,12 +73,7 @@ public class ExpressionMask extends AbstractMask {
|
|||||||
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
||||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
||||||
}
|
}
|
||||||
if (timeout == null) {
|
return expression.evaluateTimeout(timeout, vector.getX(), vector.getY(), vector.getZ()) > 0;
|
||||||
return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0;
|
|
||||||
} else {
|
|
||||||
return expression.evaluate(new double[]{vector.getX(), vector.getY(), vector.getZ()},
|
|
||||||
timeout.getAsInt()) > 0;
|
|
||||||
}
|
|
||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||||
@ -32,7 +33,7 @@ import java.util.function.IntSupplier;
|
|||||||
public class ExpressionMask2D extends AbstractMask2D {
|
public class ExpressionMask2D extends AbstractMask2D {
|
||||||
|
|
||||||
private final Expression expression;
|
private final Expression expression;
|
||||||
private final IntSupplier timeout;
|
private final int timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -50,10 +51,10 @@ public class ExpressionMask2D extends AbstractMask2D {
|
|||||||
* @param expression the expression
|
* @param expression the expression
|
||||||
*/
|
*/
|
||||||
public ExpressionMask2D(Expression expression) {
|
public ExpressionMask2D(Expression expression) {
|
||||||
this(expression, null);
|
this(expression, WorldEdit.getInstance().getConfiguration().calculationTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionMask2D(Expression expression, @Nullable IntSupplier timeout) {
|
public ExpressionMask2D(Expression expression, int timeout) {
|
||||||
checkNotNull(expression);
|
checkNotNull(expression);
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@ -62,11 +63,7 @@ public class ExpressionMask2D extends AbstractMask2D {
|
|||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
try {
|
try {
|
||||||
if (timeout != null) {
|
return expression.evaluateTimeout(timeout, vector.getX(), 0, vector.getZ()) > 0;
|
||||||
return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0;
|
|
||||||
} else {
|
|
||||||
return expression.evaluate(new double[]{vector.getX(), 0, vector.getZ()}, timeout.getAsInt()) > 0;
|
|
||||||
}
|
|
||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -75,16 +75,36 @@ public interface Mask {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
default Mask optimize() {
|
/**
|
||||||
|
* Returns null if no optimization took place
|
||||||
|
* otherwise a new/same mask
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default Mask tryOptimize() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Mask tryCombine(Mask other) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default Mask tryOr(Mask other) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default Mask optimize() {
|
||||||
|
Mask value = tryOptimize();
|
||||||
|
return value == null ? this : value;
|
||||||
|
}
|
||||||
|
|
||||||
default Mask and(Mask other) {
|
default Mask and(Mask other) {
|
||||||
return null;
|
Mask value = and(other);
|
||||||
|
return value == null ? new MaskIntersection(this, other) : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
default Mask or(Mask other) {
|
default Mask or(Mask other) {
|
||||||
return null;
|
Mask value = or(other);
|
||||||
|
return value == null ? new MaskUnion(this, other) : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
default Mask inverse() {
|
default Mask inverse() {
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.Fawe;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -58,6 +59,30 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
formArray();
|
formArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Mask of(Mask... masks) {
|
||||||
|
Set<Mask> set = new LinkedHashSet<>();
|
||||||
|
for (Mask mask : masks) {
|
||||||
|
if (mask == Masks.alwaysFalse()) {
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
if (mask != null && mask != Masks.alwaysTrue()) {
|
||||||
|
if (mask.getClass() == MaskIntersection.class) {
|
||||||
|
set.addAll(((MaskIntersection) mask).getMasks());
|
||||||
|
} else {
|
||||||
|
set.add(mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (set.size()) {
|
||||||
|
case 0:
|
||||||
|
return Masks.alwaysTrue();
|
||||||
|
case 1:
|
||||||
|
return set.iterator().next();
|
||||||
|
default:
|
||||||
|
return new MaskIntersection(masks).optimize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new intersection.
|
* Create a new intersection.
|
||||||
*
|
*
|
||||||
@ -76,47 +101,68 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
|
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
|
||||||
return input -> input.getKey().and(input.getValue());
|
return input -> input.getKey().tryCombine(input.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void optimizeMasks(Set<Mask> ignore) {
|
private boolean optimizeMasks(Set<Mask> ignore) {
|
||||||
LinkedHashSet<Mask> newMasks = null;
|
boolean changed = false;
|
||||||
for (Mask mask : masks) {
|
// Optimize sub masks
|
||||||
|
for (int i = 0; i < masksArray.length; i++) {
|
||||||
|
Mask mask = masksArray[i];
|
||||||
if (ignore.contains(mask)) continue;
|
if (ignore.contains(mask)) continue;
|
||||||
Mask newMask = mask.optimize();
|
Mask newMask = mask.tryOptimize();
|
||||||
if (newMask != null) {
|
if (newMask != null) {
|
||||||
if (newMask != mask) {
|
changed = true;
|
||||||
if (newMasks == null) newMasks = new LinkedHashSet<>();
|
masksArray[i] = newMask;
|
||||||
newMasks.add(newMask);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ignore.add(mask);
|
ignore.add(mask);
|
||||||
}
|
}
|
||||||
if (newMasks != null) {
|
}
|
||||||
|
if (changed) {
|
||||||
masks.clear();
|
masks.clear();
|
||||||
masks.addAll(newMasks);
|
for (Mask mask : masksArray) masks.add(mask);
|
||||||
|
}
|
||||||
|
// Optimize this
|
||||||
|
boolean formArray = false;
|
||||||
|
for (int i = 0; i < masksArray.length; i++) {
|
||||||
|
Mask mask = masksArray[i];
|
||||||
|
if (mask.getClass() == this.getClass()) {
|
||||||
|
this.masks.remove(mask);
|
||||||
|
this.masks.addAll(((MaskIntersection) mask).getMasks());
|
||||||
|
formArray = true;
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (formArray) formArray();
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask optimize() {
|
public Mask tryOptimize() {
|
||||||
|
int maxIteration = 1000;
|
||||||
Set<Mask> optimized = new HashSet<>();
|
Set<Mask> optimized = new HashSet<>();
|
||||||
Set<Map.Entry<Mask, Mask>> failedCombines = new HashSet<>();
|
Set<Map.Entry<Mask, Mask>> failedCombines = new HashSet<>();
|
||||||
// Combine the masks
|
// Combine the masks
|
||||||
while (combine(pairingFunction(), failedCombines)) {
|
boolean changed = false;
|
||||||
}
|
while (changed |= combineMasks(pairingFunction(), failedCombines));
|
||||||
// Optimize / combine
|
// Optimize / combine
|
||||||
do optimizeMasks(optimized);
|
do changed |= optimizeMasks(optimized);
|
||||||
while (combine(pairingFunction(), failedCombines));
|
while (changed |= combineMasks(pairingFunction(), failedCombines) && --maxIteration > 0);
|
||||||
|
|
||||||
|
if (maxIteration == 0) {
|
||||||
|
Fawe.debug("Failed optimize MaskIntersection");
|
||||||
|
for (Mask mask : masks) {
|
||||||
|
System.out.println(mask.getClass() + " / " + mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Return result
|
// Return result
|
||||||
formArray();
|
formArray();
|
||||||
if (masks.size() == 0) return Masks.alwaysTrue();
|
if (masks.size() == 0) return Masks.alwaysTrue();
|
||||||
if (masks.size() == 1) return masks.iterator().next();
|
if (masks.size() == 1) return masks.iterator().next();
|
||||||
return this;
|
return changed ? this : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean combine(Function<Map.Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) {
|
private boolean combineMasks(Function<Map.Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) {
|
||||||
boolean hasOptimized = false;
|
boolean hasOptimized = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
Mask[] result = null;
|
Mask[] result = null;
|
||||||
|
@ -19,15 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,9 +56,33 @@ public class MaskUnion extends MaskIntersection {
|
|||||||
super(mask);
|
super(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Mask of(Mask... masks) {
|
||||||
|
Set<Mask> set = new LinkedHashSet<>();
|
||||||
|
for (Mask mask : masks) {
|
||||||
|
if (mask == Masks.alwaysTrue()) {
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
if (mask != null) {
|
||||||
|
if (mask.getClass() == MaskUnion.class) {
|
||||||
|
set.addAll(((MaskUnion) mask).getMasks());
|
||||||
|
} else {
|
||||||
|
set.add(mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (set.size()) {
|
||||||
|
case 0:
|
||||||
|
return Masks.alwaysTrue();
|
||||||
|
case 1:
|
||||||
|
return set.iterator().next();
|
||||||
|
default:
|
||||||
|
return new MaskUnion(masks).optimize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
|
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
|
||||||
return input -> input.getKey().or(input.getValue());
|
return input -> input.getKey().tryOr(input.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,12 +135,12 @@ public final class Masks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask and(Mask other) {
|
public Mask tryCombine(Mask other) {
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask or(Mask other) {
|
public Mask tryOr(Mask other) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,12 +163,12 @@ public final class Masks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask and(Mask other) {
|
public Mask tryCombine(Mask other) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask or(Mask other) {
|
public Mask tryOr(Mask other) {
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class SingleBlockStateMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask and(Mask mask) {
|
public Mask tryCombine(Mask mask) {
|
||||||
if (mask instanceof ABlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
ABlockMask other = (ABlockMask) mask;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
if (other.test(BlockState.getFromOrdinal(ordinal))) {
|
if (other.test(BlockState.getFromOrdinal(ordinal))) {
|
||||||
|
@ -20,32 +20,13 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class SolidBlockMask extends BlockMask {
|
public class SolidBlockMask extends BlockMask {
|
||||||
public SolidBlockMask(Extent extent) {
|
public SolidBlockMask(Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
add(state -> state.getMaterial().isSolid());
|
add(state -> state.getMaterial().isMovementBlocker());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
Extent extent = getExtent();
|
|
||||||
BlockState block = extent.getBlock(vector);
|
|
||||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean[] getTypes() {
|
|
||||||
boolean[] types = new boolean[BlockTypes.size()];
|
|
||||||
for (BlockType type : BlockTypes.values) {
|
|
||||||
types[type.getInternalId()] = type.getMaterial().isSolid();
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -163,6 +163,10 @@ public class ForwardExtentCopy implements Operation {
|
|||||||
this.sourceMask = sourceMask;
|
this.sourceMask = sourceMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFilterFunction(RegionFunction filterFunction) {
|
||||||
|
this.filterFunction = filterFunction;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the function that gets applied to all source blocks <em>after</em>
|
* Get the function that gets applied to all source blocks <em>after</em>
|
||||||
* the copy has been made.
|
* the copy has been made.
|
||||||
|
@ -357,7 +357,7 @@ public class WorldEditBinding {
|
|||||||
String input = context.next();
|
String input = context.next();
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
|
|
||||||
if (MathMan.isInteger(input)) return BiomeTypes.register(Integer.parseInt(input));
|
if (MathMan.isInteger(input)) return BiomeTypes.get(Integer.parseInt(input));
|
||||||
|
|
||||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||||
|
@ -127,7 +127,48 @@ public class Expression {
|
|||||||
root = Parser.parse(tokens, this);
|
root = Parser.parse(tokens, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double evaluate(double x, double y, double z) throws EvaluationException {
|
||||||
|
return evaluateTimeout(WorldEdit.getInstance().getConfiguration().calculationTimeout, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double evaluate() throws EvaluationException {
|
||||||
|
return evaluateFinal(WorldEdit.getInstance().getConfiguration().calculationTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
public double evaluate(double... values) throws EvaluationException {
|
public double evaluate(double... values) throws EvaluationException {
|
||||||
|
return evaluateTimeout(WorldEdit.getInstance().getConfiguration().calculationTimeout, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double evaluateTimeout(int timeout) throws EvaluationException {
|
||||||
|
if (root instanceof Constant) return root.getValue();
|
||||||
|
return evaluateFinal(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double evaluateTimeout(int timeout, double x, double y) throws EvaluationException {
|
||||||
|
if (root instanceof Constant) return root.getValue();
|
||||||
|
variableArray[0].value = x;
|
||||||
|
variableArray[1].value = y;
|
||||||
|
return evaluateFinal(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double evaluateTimeout(int timeout, double x, double y, double z) throws EvaluationException {
|
||||||
|
if (root instanceof Constant) return root.getValue();
|
||||||
|
variableArray[0].value = x;
|
||||||
|
variableArray[1].value = y;
|
||||||
|
variableArray[2].value = z;
|
||||||
|
return evaluateFinal(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double evaluateTimeout(int timeout, double... values) throws EvaluationException {
|
||||||
|
if (root instanceof Constant) return root.getValue();
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
Variable var = variableArray[i];
|
||||||
|
var.value = values[i];
|
||||||
|
}
|
||||||
|
return evaluateFinal(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double evaluate(double[] values, int timeout) throws EvaluationException {
|
||||||
if (root instanceof Constant) {
|
if (root instanceof Constant) {
|
||||||
return root.getValue();
|
return root.getValue();
|
||||||
}
|
}
|
||||||
@ -135,21 +176,10 @@ public class Expression {
|
|||||||
Variable var = variableArray[i];
|
Variable var = variableArray[i];
|
||||||
var.value = values[i];
|
var.value = values[i];
|
||||||
}
|
}
|
||||||
pushInstance();
|
return evaluateFinal(timeout);
|
||||||
return evaluate(values, WorldEdit.getInstance().getConfiguration().calculationTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double evaluate(double[] values, int timeout) throws EvaluationException {
|
|
||||||
for (int i = 0; i < values.length; ++i) {
|
|
||||||
final String variableName = variableNames[i];
|
|
||||||
final RValue invokable = variables.get(variableName);
|
|
||||||
if (!(invokable instanceof Variable)) {
|
|
||||||
throw new EvaluationException(invokable.getPosition(), "Tried to assign constant " + variableName + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
((Variable) invokable).value = values[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double evaluateFinal(int timeout) throws EvaluationException {
|
||||||
try {
|
try {
|
||||||
if (timeout < 0) {
|
if (timeout < 0) {
|
||||||
return evaluateRoot();
|
return evaluateRoot();
|
||||||
|
@ -392,7 +392,7 @@ public abstract class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 shr(int x, int y, int z) {
|
public BlockVector3 shr(int x, int y, int z) {
|
||||||
return at(this.x >> x, this.y >> y, this.z >> z);
|
return at(this.getX() >> x, this.getY() >> y, this.getZ() >> z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -414,7 +414,7 @@ public abstract class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 shl(int x, int y, int z) {
|
public BlockVector3 shl(int x, int y, int z) {
|
||||||
return at(this.x << x, this.y << y, this.z << z);
|
return at(this.getX() << x, this.getY() << y, this.getZ() << z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,7 @@ package com.sk89q.worldedit.math;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
|
||||||
public class MutableVector3 extends Vector3 {
|
public class MutableVector3 extends Vector3 {
|
||||||
|
private double x,y,z;
|
||||||
public MutableVector3() {
|
public MutableVector3() {
|
||||||
}
|
}
|
||||||
public static MutableVector3 get(int x, int y, int z) {
|
public static MutableVector3 get(int x, int y, int z) {
|
||||||
@ -15,22 +15,39 @@ public class MutableVector3 extends Vector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3(double x, double y, double z) {
|
public MutableVector3(double x, double y, double z) {
|
||||||
super(x, y, z);
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3(float x, float y, float z) {
|
public MutableVector3(float x, float y, float z) {
|
||||||
super(x, y, z);
|
this((double) x, (double) y, (double) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3(Vector3 other) {
|
public MutableVector3(Vector3 other) {
|
||||||
super(other);
|
this(other.getX(), other.getY(), other.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getZ() {
|
||||||
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MutableVector3 setComponents(Vector3 other) {
|
public MutableVector3 setComponents(Vector3 other) {
|
||||||
this.x = other.x;
|
this.x = other.getX();
|
||||||
this.y = other.y;
|
this.y = other.getY();
|
||||||
this.z = other.z;
|
this.z = other.getZ();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,25 +30,25 @@ import java.util.Comparator;
|
|||||||
/**
|
/**
|
||||||
* An immutable 3-dimensional vector.
|
* An immutable 3-dimensional vector.
|
||||||
*/
|
*/
|
||||||
public class Vector3 {
|
public abstract class Vector3 {
|
||||||
|
|
||||||
public static final Vector3 ZERO = new Vector3(0, 0, 0);
|
public static final Vector3 ZERO = Vector3.at(0, 0, 0);
|
||||||
public static final Vector3 UNIT_X = new Vector3(1, 0, 0);
|
public static final Vector3 UNIT_X = Vector3.at(1, 0, 0);
|
||||||
public static final Vector3 UNIT_Y = new Vector3(0, 1, 0);
|
public static final Vector3 UNIT_Y = Vector3.at(0, 1, 0);
|
||||||
public static final Vector3 UNIT_Z = new Vector3(0, 0, 1);
|
public static final Vector3 UNIT_Z = Vector3.at(0, 0, 1);
|
||||||
public static final Vector3 ONE = new Vector3(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) {
|
||||||
return new Vector3(x, y, z);
|
return new Vector3Impl(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// thread-safe initialization idiom
|
// thread-safe initialization idiom
|
||||||
private static final class YzxOrderComparator {
|
private static final class YzxOrderComparator {
|
||||||
private static final Comparator<Vector3> YZX_ORDER = (a, b) -> {
|
private static final Comparator<Vector3> YZX_ORDER = (a, b) -> {
|
||||||
return ComparisonChain.start()
|
return ComparisonChain.start()
|
||||||
.compare(a.y, b.y)
|
.compare(a.getY(), b.getY())
|
||||||
.compare(a.z, b.z)
|
.compare(a.getZ(), b.getZ())
|
||||||
.compare(a.x, b.x)
|
.compare(a.getX(), b.getX())
|
||||||
.result();
|
.result();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -63,29 +63,6 @@ public class Vector3 {
|
|||||||
return YzxOrderComparator.YZX_ORDER;
|
return YzxOrderComparator.YZX_ORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double x, y, z;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
protected Vector3(double x, double y, double z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Vector3() {}
|
|
||||||
|
|
||||||
protected Vector3(Vector3 other) {
|
|
||||||
this.x = other.x;
|
|
||||||
this.y = other.y;
|
|
||||||
this.z = other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBlockX() {
|
public int getBlockX() {
|
||||||
return MathMan.roundInt(getX());
|
return MathMan.roundInt(getX());
|
||||||
}
|
}
|
||||||
@ -111,11 +88,11 @@ public class Vector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3 mutX(int x) {
|
public MutableVector3 mutX(int x) {
|
||||||
return new MutableVector3(x, y, getZ());
|
return new MutableVector3(x, getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3 mutX(double x) {
|
public MutableVector3 mutX(double x) {
|
||||||
return new MutableVector3(x, y, getZ());
|
return new MutableVector3(x, getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3 mutY(int y) {
|
public MutableVector3 mutY(int y) {
|
||||||
@ -127,11 +104,11 @@ public class Vector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3 mutZ(int z) {
|
public MutableVector3 mutZ(int z) {
|
||||||
return new MutableVector3(getX(), y, z);
|
return new MutableVector3(getX(), getY(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3 mutZ(double z) {
|
public MutableVector3 mutZ(double z) {
|
||||||
return new MutableVector3(getX(), y, z);
|
return new MutableVector3(getX(), getY(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,9 +116,7 @@ public class Vector3 {
|
|||||||
*
|
*
|
||||||
* @return the x coordinate
|
* @return the x coordinate
|
||||||
*/
|
*/
|
||||||
public double getX() {
|
public abstract double getX();
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the X coordinate.
|
* Set the X coordinate.
|
||||||
@ -150,7 +125,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 withX(double x) {
|
public Vector3 withX(double x) {
|
||||||
return Vector3.at(x, y, z);
|
return Vector3.at(x, getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,9 +133,7 @@ public class Vector3 {
|
|||||||
*
|
*
|
||||||
* @return the y coordinate
|
* @return the y coordinate
|
||||||
*/
|
*/
|
||||||
public double getY() {
|
public abstract double getY();
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Y coordinate.
|
* Set the Y coordinate.
|
||||||
@ -169,7 +142,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 withY(double y) {
|
public Vector3 withY(double y) {
|
||||||
return Vector3.at(x, y, z);
|
return Vector3.at(getX(), y, getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -177,9 +150,7 @@ public class Vector3 {
|
|||||||
*
|
*
|
||||||
* @return the z coordinate
|
* @return the z coordinate
|
||||||
*/
|
*/
|
||||||
public double getZ() {
|
public abstract double getZ();
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Z coordinate.
|
* Set the Z coordinate.
|
||||||
@ -188,7 +159,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 withZ(double z) {
|
public Vector3 withZ(double z) {
|
||||||
return Vector3.at(x, y, z);
|
return Vector3.at(getX(), getY(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,7 +169,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 add(Vector3 other) {
|
public Vector3 add(Vector3 other) {
|
||||||
return add(other.x, other.y, other.z);
|
return add(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,7 +181,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 add(double x, double y, double z) {
|
public Vector3 add(double x, double y, double z) {
|
||||||
return Vector3.at(this.x + x, this.y + y, this.z + z);
|
return Vector3.at(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,12 +192,12 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 add(Vector3... others) {
|
public Vector3 add(Vector3... others) {
|
||||||
double newX = x, newY = y, newZ = z;
|
double newX = getX(), newY = getY(), newZ = getZ();
|
||||||
|
|
||||||
for (Vector3 other : others) {
|
for (Vector3 other : others) {
|
||||||
newX += other.x;
|
newX += other.getX();
|
||||||
newY += other.y;
|
newY += other.getY();
|
||||||
newZ += other.z;
|
newZ += other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vector3.at(newX, newY, newZ);
|
return Vector3.at(newX, newY, newZ);
|
||||||
@ -240,7 +211,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 subtract(Vector3 other) {
|
public Vector3 subtract(Vector3 other) {
|
||||||
return subtract(other.x, other.y, other.z);
|
return subtract(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,7 +224,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 subtract(double x, double y, double z) {
|
public Vector3 subtract(double x, double y, double z) {
|
||||||
return Vector3.at(this.x - x, this.y - y, this.z - z);
|
return Vector3.at(this.getX() - x, this.getY() - y, this.getZ() - z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,12 +235,12 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 subtract(Vector3... others) {
|
public Vector3 subtract(Vector3... others) {
|
||||||
double newX = x, newY = y, newZ = z;
|
double newX = getX(), newY = getY(), newZ = getZ();
|
||||||
|
|
||||||
for (Vector3 other : others) {
|
for (Vector3 other : others) {
|
||||||
newX -= other.x;
|
newX -= other.getX();
|
||||||
newY -= other.y;
|
newY -= other.getY();
|
||||||
newZ -= other.z;
|
newZ -= other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vector3.at(newX, newY, newZ);
|
return Vector3.at(newX, newY, newZ);
|
||||||
@ -282,7 +253,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 multiply(Vector3 other) {
|
public Vector3 multiply(Vector3 other) {
|
||||||
return multiply(other.x, other.y, other.z);
|
return multiply(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,7 +265,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 multiply(double x, double y, double z) {
|
public Vector3 multiply(double x, double y, double z) {
|
||||||
return Vector3.at(this.x * x, this.y * y, this.z * z);
|
return Vector3.at(this.getX() * x, this.getY() * y, this.getZ() * z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -304,12 +275,12 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 multiply(Vector3... others) {
|
public Vector3 multiply(Vector3... others) {
|
||||||
double newX = x, newY = y, newZ = z;
|
double newX = getX(), newY = getY(), newZ = getZ();
|
||||||
|
|
||||||
for (Vector3 other : others) {
|
for (Vector3 other : others) {
|
||||||
newX *= other.x;
|
newX *= other.getX();
|
||||||
newY *= other.y;
|
newY *= other.getY();
|
||||||
newZ *= other.z;
|
newZ *= other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vector3.at(newX, newY, newZ);
|
return Vector3.at(newX, newY, newZ);
|
||||||
@ -332,7 +303,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 divide(Vector3 other) {
|
public Vector3 divide(Vector3 other) {
|
||||||
return divide(other.x, other.y, other.z);
|
return divide(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -344,7 +315,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 divide(double x, double y, double z) {
|
public Vector3 divide(double x, double y, double z) {
|
||||||
return Vector3.at(this.x / x, this.y / y, this.z / z);
|
return Vector3.at(this.getX() / x, this.getY() / y, this.getZ() / z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -372,7 +343,7 @@ public class Vector3 {
|
|||||||
* @return length, squared
|
* @return length, squared
|
||||||
*/
|
*/
|
||||||
public double lengthSq() {
|
public double lengthSq() {
|
||||||
return x * x + y * y + z * z;
|
return getX() * getX() + getY() * getY() + getZ() * getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -392,9 +363,9 @@ public class Vector3 {
|
|||||||
* @return distance
|
* @return distance
|
||||||
*/
|
*/
|
||||||
public double distanceSq(Vector3 other) {
|
public double distanceSq(Vector3 other) {
|
||||||
double dx = other.x - x;
|
double dx = other.getX() - getX();
|
||||||
double dy = other.y - y;
|
double dy = other.getY() - getY();
|
||||||
double dz = other.z - z;
|
double dz = other.getZ() - getZ();
|
||||||
return dx * dx + dy * dy + dz * dz;
|
return dx * dx + dy * dy + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +386,7 @@ public class Vector3 {
|
|||||||
* @return the dot product of this and the other vector
|
* @return the dot product of this and the other vector
|
||||||
*/
|
*/
|
||||||
public double dot(Vector3 other) {
|
public double dot(Vector3 other) {
|
||||||
return x * other.x + y * other.y + z * other.z;
|
return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -425,10 +396,10 @@ public class Vector3 {
|
|||||||
* @return the cross product of this and the other vector
|
* @return the cross product of this and the other vector
|
||||||
*/
|
*/
|
||||||
public Vector3 cross(Vector3 other) {
|
public Vector3 cross(Vector3 other) {
|
||||||
return new Vector3(
|
return Vector3.at(
|
||||||
y * other.z - z * other.y,
|
getY() * other.getZ() - getZ() * other.getY(),
|
||||||
z * other.x - x * other.z,
|
getZ() * other.getX() - getX() * other.getZ(),
|
||||||
x * other.y - y * other.x
|
getX() * other.getY() - getY() * other.getX()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,7 +411,7 @@ public class Vector3 {
|
|||||||
* @return true if the vector is contained
|
* @return true if the vector is contained
|
||||||
*/
|
*/
|
||||||
public boolean containedWithin(Vector3 min, Vector3 max) {
|
public boolean containedWithin(Vector3 min, Vector3 max) {
|
||||||
return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;
|
return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max.getY() && getZ() >= min.getZ() && getZ() <= max.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -452,11 +423,11 @@ public class Vector3 {
|
|||||||
*/
|
*/
|
||||||
public Vector3 clampY(int min, int max) {
|
public Vector3 clampY(int min, int max) {
|
||||||
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
||||||
if (y < min) {
|
if (getY() < min) {
|
||||||
return Vector3.at(x, min, z);
|
return Vector3.at(getX(), min, getZ());
|
||||||
}
|
}
|
||||||
if (y > max) {
|
if (getY() > max) {
|
||||||
return Vector3.at(x, max, z);
|
return Vector3.at(getX(), max, getZ());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -467,7 +438,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 floor() {
|
public Vector3 floor() {
|
||||||
return Vector3.at(Math.floor(x), Math.floor(y), Math.floor(z));
|
return Vector3.at(Math.floor(getX()), Math.floor(getY()), Math.floor(getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -476,7 +447,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 ceil() {
|
public Vector3 ceil() {
|
||||||
return Vector3.at(Math.ceil(x), Math.ceil(y), Math.ceil(z));
|
return Vector3.at(Math.ceil(getX()), Math.ceil(getY()), Math.ceil(getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -487,7 +458,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 round() {
|
public Vector3 round() {
|
||||||
return Vector3.at(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5));
|
return Vector3.at(Math.floor(getX() + 0.5), Math.floor(getY() + 0.5), Math.floor(getZ() + 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -497,7 +468,7 @@ public class Vector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public Vector3 abs() {
|
public Vector3 abs() {
|
||||||
return Vector3.at(Math.abs(x), Math.abs(y), Math.abs(z));
|
return Vector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -513,16 +484,16 @@ public class Vector3 {
|
|||||||
*/
|
*/
|
||||||
public Vector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
public Vector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
||||||
angle = Math.toRadians(angle);
|
angle = Math.toRadians(angle);
|
||||||
double x = this.x - aboutX;
|
double x = this.getX() - aboutX;
|
||||||
double z = this.z - aboutZ;
|
double z = this.getZ() - aboutZ;
|
||||||
double cos = Math.cos(angle);
|
double cos = Math.cos(angle);
|
||||||
double sin = Math.sin(angle);
|
double sin = Math.sin(angle);
|
||||||
double x2 = x * cos - z * sin;
|
double x2 = x * cos - z * sin;
|
||||||
double z2 = x * sin + z * cos;
|
double z2 = x * sin + z * cos;
|
||||||
|
|
||||||
return new Vector3(
|
return Vector3.at(
|
||||||
x2 + aboutX + translateX,
|
x2 + aboutX + translateX,
|
||||||
y,
|
getY(),
|
||||||
z2 + aboutZ + translateZ
|
z2 + aboutZ + translateZ
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -568,10 +539,10 @@ public class Vector3 {
|
|||||||
* @return minimum
|
* @return minimum
|
||||||
*/
|
*/
|
||||||
public Vector3 getMinimum(Vector3 v2) {
|
public Vector3 getMinimum(Vector3 v2) {
|
||||||
return new Vector3(
|
return Vector3.at(
|
||||||
Math.min(x, v2.x),
|
Math.min(getX(), v2.getX()),
|
||||||
Math.min(y, v2.y),
|
Math.min(getY(), v2.getY()),
|
||||||
Math.min(z, v2.z)
|
Math.min(getZ(), v2.getZ())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,10 +553,10 @@ public class Vector3 {
|
|||||||
* @return maximum
|
* @return maximum
|
||||||
*/
|
*/
|
||||||
public Vector3 getMaximum(Vector3 v2) {
|
public Vector3 getMaximum(Vector3 v2) {
|
||||||
return new Vector3(
|
return Vector3.at(
|
||||||
Math.max(x, v2.x),
|
Math.max(getX(), v2.getX()),
|
||||||
Math.max(y, v2.y),
|
Math.max(getY(), v2.getY()),
|
||||||
Math.max(z, v2.z)
|
Math.max(getZ(), v2.getZ())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +578,7 @@ public class Vector3 {
|
|||||||
* @return a new {@code BlockVector}
|
* @return a new {@code BlockVector}
|
||||||
*/
|
*/
|
||||||
public BlockVector3 toBlockPoint() {
|
public BlockVector3 toBlockPoint() {
|
||||||
return toBlockPoint(x, y, z);
|
return toBlockPoint(getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -616,7 +587,7 @@ public class Vector3 {
|
|||||||
* @return a new {@link Vector2}
|
* @return a new {@link Vector2}
|
||||||
*/
|
*/
|
||||||
public Vector2 toVector2() {
|
public Vector2 toVector2() {
|
||||||
return Vector2.at(x, z);
|
return Vector2.at(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -626,12 +597,12 @@ public class Vector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3 other = (Vector3) obj;
|
Vector3 other = (Vector3) obj;
|
||||||
return other.x == this.x && other.y == this.y && other.z == this.z;
|
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return (int) x ^ (int) z << 12 ^ (int) y << 24;
|
return (int) getX() ^ (int) getZ() << 12 ^ (int) getY() << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.sk89q.worldedit.math;
|
||||||
|
|
||||||
|
public class Vector3Impl extends Vector3 {
|
||||||
|
private final double x,y,z;
|
||||||
|
|
||||||
|
public Vector3Impl(double x, double y, double z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3Impl(Vector3 other) {
|
||||||
|
this(other.getX(), other.getY(), other.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final double getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final double getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
}
|
@ -42,6 +42,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
|
|||||||
private Vector3[] coeffC;
|
private Vector3[] coeffC;
|
||||||
private Vector3[] coeffD;
|
private Vector3[] coeffD;
|
||||||
private double scaling;
|
private double scaling;
|
||||||
|
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
public KochanekBartelsInterpolation() {
|
public KochanekBartelsInterpolation() {
|
||||||
setNodes(Collections.<Node>emptyList());
|
setNodes(Collections.<Node>emptyList());
|
||||||
@ -136,8 +137,6 @@ public class KochanekBartelsInterpolation implements Interpolation {
|
|||||||
return nodes.get(index).getPosition();
|
return nodes.get(index).getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3 getPosition(double position) {
|
public Vector3 getPosition(double position) {
|
||||||
if (coeffA == null)
|
if (coeffA == null)
|
||||||
|
@ -546,7 +546,12 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector2 next() {
|
public BlockVector2 next() {
|
||||||
if (!hasNext()) throw new NoSuchElementException();
|
if (!hasNext()) throw new NoSuchElementException() {
|
||||||
|
@Override
|
||||||
|
public synchronized Throwable fillInStackTrace() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
BlockVector2 answer = BlockVector2.at(nextX, nextZ);
|
BlockVector2 answer = BlockVector2.at(nextX, nextZ);
|
||||||
if (++nextX > max.getBlockX()) {
|
if (++nextX > max.getBlockX()) {
|
||||||
nextX = min.getBlockX();
|
nextX = min.getBlockX();
|
||||||
|
@ -21,7 +21,10 @@ package com.sk89q.worldedit.session;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
@ -49,6 +52,7 @@ public class PasteBuilder {
|
|||||||
private boolean ignoreAirBlocks;
|
private boolean ignoreAirBlocks;
|
||||||
private boolean copyEntities = true; // default because it used to be this way
|
private boolean copyEntities = true; // default because it used to be this way
|
||||||
private boolean copyBiomes;
|
private boolean copyBiomes;
|
||||||
|
private RegionFunction canApply;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -125,6 +129,7 @@ public class PasteBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public PasteBuilder filter(RegionFunction function) {
|
public PasteBuilder filter(RegionFunction function) {
|
||||||
|
this.canApply = function;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,13 +139,33 @@ public class PasteBuilder {
|
|||||||
* @return the operation
|
* @return the operation
|
||||||
*/
|
*/
|
||||||
public Operation build() {
|
public Operation build() {
|
||||||
BlockTransformExtent extent = new BlockTransformExtent(clipboard, transform);
|
Extent extent = clipboard;
|
||||||
|
if (!transform.isIdentity()) {
|
||||||
|
extent = new BlockTransformExtent(extent, transform);
|
||||||
|
}
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to);
|
ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to);
|
||||||
copy.setTransform(transform);
|
copy.setTransform(transform);
|
||||||
|
|
||||||
|
copy.setCopyingEntities(copyEntities);
|
||||||
|
copy.setCopyingBiomes(copyBiomes && clipboard.hasBiomes());
|
||||||
|
if (this.canApply != null) {
|
||||||
|
copy.setFilterFunction(this.canApply);
|
||||||
|
}
|
||||||
if (ignoreAirBlocks) {
|
if (ignoreAirBlocks) {
|
||||||
copy.setSourceMask(sourceMask == Masks.alwaysTrue() ? new ExistingBlockMask(clipboard)
|
sourceMask = MaskIntersection.of(sourceMask, new ExistingBlockMask(clipboard));
|
||||||
: new MaskIntersection(sourceMask, new ExistingBlockMask(clipboard)));
|
}
|
||||||
} else {
|
if (targetExtent instanceof EditSession) {
|
||||||
|
Mask esSourceMask = ((EditSession) targetExtent).getSourceMask();
|
||||||
|
if (esSourceMask == Masks.alwaysFalse()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (esSourceMask != null) {
|
||||||
|
new MaskTraverser(esSourceMask).reset(extent);
|
||||||
|
((EditSession) targetExtent).setSourceMask(null);
|
||||||
|
sourceMask = MaskIntersection.of(sourceMask, esSourceMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sourceMask != null && sourceMask != Masks.alwaysTrue()) {
|
||||||
copy.setSourceMask(sourceMask);
|
copy.setSourceMask(sourceMask);
|
||||||
}
|
}
|
||||||
copy.setCopyingEntities(copyEntities);
|
copy.setCopyingEntities(copyEntities);
|
||||||
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3Impl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a location in a world with has a direction.
|
* Represents a location in a world with has a direction.
|
||||||
@ -35,7 +36,7 @@ import com.sk89q.worldedit.math.Vector3;
|
|||||||
* {@link #equals(Object)} are subject to minor differences caused by
|
* {@link #equals(Object)} are subject to minor differences caused by
|
||||||
* floating point errors.</p>
|
* floating point errors.</p>
|
||||||
*/
|
*/
|
||||||
public class Location extends Vector3 {
|
public class Location extends Vector3Impl {
|
||||||
|
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private final float pitch;
|
private final float pitch;
|
||||||
@ -294,11 +295,11 @@ public class Location extends Vector3 {
|
|||||||
|
|
||||||
@Override public Location clampY(int min, int max) {
|
@Override public Location clampY(int min, int max) {
|
||||||
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
||||||
if (y < min) {
|
if (getY() < min) {
|
||||||
return new Location(extent, x, min, z);
|
return new Location(extent, getX(), min, getZ());
|
||||||
}
|
}
|
||||||
if (y > max) {
|
if (getY() > max) {
|
||||||
return new Location(extent, x, max, z);
|
return new Location(extent, getX(), max, getZ());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public class BlockType implements FawePattern, Keyed {
|
|||||||
* @return the properties
|
* @return the properties
|
||||||
*/
|
*/
|
||||||
public List<? extends Property<?>> getProperties() {
|
public List<? extends Property<?>> getProperties() {
|
||||||
return ImmutableList.copyOf(this.getPropertyMap().values());
|
return this.settings.propertiesList; // stop changing this
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren