geforkt von Mirrors/FastAsyncWorldEdit
Upstream
Dieser Commit ist enthalten in:
Ursprung
a1c15e1c39
Commit
a69b239848
@ -1,18 +1,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.registry.BundledItemRegistry;
|
import com.sk89q.worldedit.world.registry.BundledItemRegistry;
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class BukkitItemRegistry extends BundledItemRegistry {
|
public class BukkitItemRegistry extends BundledItemRegistry {
|
||||||
@Override
|
|
||||||
public Collection<String> registerItems() {
|
|
||||||
ArrayList<String> items = new ArrayList<>();
|
|
||||||
for (Material m : Material.values()) {
|
|
||||||
if (!m.isLegacy() && m.isItem()) items.add(m.getKey().getNamespace() + ":" + m.getKey().getKey());
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -41,7 +42,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -51,12 +51,11 @@ import org.bukkit.event.player.PlayerDropItemEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class BukkitPlayer extends AbstractPlayerActor {
|
public class BukkitPlayer extends AbstractPlayerActor {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
@ -168,13 +167,10 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
Extent extent = loc.getExtent();
|
Extent extent = loc.getExtent();
|
||||||
if (extent instanceof World) {
|
if (extent instanceof World) {
|
||||||
org.bukkit.World world = Bukkit.getWorld(((World) extent).getName());
|
org.bukkit.World world = Bukkit.getWorld(((World) extent).getName());
|
||||||
// System.out.println("Teleport to world " + world);
|
player.teleport(new Location(world, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch));
|
||||||
player.teleport(new Location(world, pos.getX(), pos.getY(),
|
|
||||||
pos.getZ(), yaw, pitch));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
|
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw, pitch));
|
||||||
pos.getZ(), yaw, pitch));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,6 +10,7 @@ import com.boydti.fawe.object.clipboard.FaweClipboard;
|
|||||||
import com.boydti.fawe.object.clipboard.MemoryOptimizedClipboard;
|
import com.boydti.fawe.object.clipboard.MemoryOptimizedClipboard;
|
||||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||||
import com.boydti.fawe.object.io.FastByteArraysInputStream;
|
import com.boydti.fawe.object.io.FastByteArraysInputStream;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
@ -18,15 +19,17 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
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.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.block.*;
|
import com.sk89q.worldedit.world.block.BlockID;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypeSwitch;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypeSwitchBuilder;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.FaweCache;
|
|||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.NBTConstants;
|
import com.sk89q.jnbt.NBTConstants;
|
||||||
@ -91,7 +92,6 @@ public class WritableMCAChunk extends FaweChunk<Void> {
|
|||||||
nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND);
|
nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND);
|
||||||
nbtOut.writeNamedTag("DataVersion", 1631);
|
nbtOut.writeNamedTag("DataVersion", 1631);
|
||||||
nbtOut.writeLazyCompoundTag("Level", out -> {
|
nbtOut.writeLazyCompoundTag("Level", out -> {
|
||||||
// out.writeNamedTag("V", (byte) 1);
|
|
||||||
out.writeNamedTag("Status", "decorated");
|
out.writeNamedTag("Status", "decorated");
|
||||||
out.writeNamedTag("xPos", getX());
|
out.writeNamedTag("xPos", getX());
|
||||||
out.writeNamedTag("zPos", getZ());
|
out.writeNamedTag("zPos", getZ());
|
||||||
@ -111,14 +111,18 @@ public class WritableMCAChunk extends FaweChunk<Void> {
|
|||||||
out.writeNamedTag("Biomes", biomes);
|
out.writeNamedTag("Biomes", biomes);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
for (boolean hasSection : hasSections) {
|
for (boolean hasSection : hasSections) {
|
||||||
if (hasSection) len++;
|
if (hasSection) {
|
||||||
|
len++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out.writeNamedTagName("Sections", NBTConstants.TYPE_LIST);
|
out.writeNamedTagName("Sections", NBTConstants.TYPE_LIST);
|
||||||
nbtOut.writeByte(NBTConstants.TYPE_COMPOUND);
|
nbtOut.writeByte(NBTConstants.TYPE_COMPOUND);
|
||||||
nbtOut.writeInt(len);
|
nbtOut.writeInt(len);
|
||||||
|
|
||||||
for (int layer = 0; layer < hasSections.length; layer++) {
|
for (int layer = 0; layer < hasSections.length; layer++) {
|
||||||
if (!hasSections[layer]) continue;
|
if (!hasSections[layer]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
out.writeNamedTag("Y", (byte) layer);
|
out.writeNamedTag("Y", (byte) layer);
|
||||||
|
|
||||||
int blockIndexStart = layer << 12;
|
int blockIndexStart = layer << 12;
|
||||||
@ -186,7 +190,9 @@ public class WritableMCAChunk extends FaweChunk<Void> {
|
|||||||
|
|
||||||
out.writeNamedTagName("BlockStates", NBTConstants.TYPE_LONG_ARRAY);
|
out.writeNamedTagName("BlockStates", NBTConstants.TYPE_LONG_ARRAY);
|
||||||
out.writeInt(blockBitArrayEnd);
|
out.writeInt(blockBitArrayEnd);
|
||||||
for (int i = 0; i < blockBitArrayEnd; i++) out.writeLong(blockstates[i]);
|
for (int i = 0; i < blockBitArrayEnd; i++) {
|
||||||
|
out.writeLong(blockstates[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
out.writeNamedTagName("BlockLight", NBTConstants.TYPE_BYTE_ARRAY);
|
out.writeNamedTagName("BlockLight", NBTConstants.TYPE_BYTE_ARRAY);
|
||||||
@ -337,12 +343,16 @@ public class WritableMCAChunk extends FaweChunk<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSkyLight(int x, int y, int z) {
|
public int getSkyLight(int x, int y, int z) {
|
||||||
if (!hasSections[y >> 4]) return 0;
|
if (!hasSections[y >> 4]) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return getNibble(getIndex(x, y, z), skyLight);
|
return getNibble(getIndex(x, y, z), skyLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockLight(int x, int y, int z) {
|
public int getBlockLight(int x, int y, int z) {
|
||||||
if (!hasSections[y >> 4]) return 0;
|
if (!hasSections[y >> 4]) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return getNibble(getIndex(x, y, z), blockLight);
|
return getNibble(getIndex(x, y, z), blockLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package com.boydti.fawe.object.clipboard;
|
package com.boydti.fawe.object.clipboard;
|
||||||
|
|
||||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
|
||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
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.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.object.collection;
|
|||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -115,14 +116,13 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
int b3 = ((byte) (index >> 15)) & 0xFF;
|
int b3 = ((byte) (index >> 15)) & 0xFF;
|
||||||
int b4 = ((byte) (index >> 23)) & 0xFF;
|
int b4 = ((byte) (index >> 23)) & 0xFF;
|
||||||
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
|
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
|
||||||
int y = b1;
|
|
||||||
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
|
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
|
||||||
return MutableBlockVector3.get(x, y, z);
|
return MutableBlockVector3.get(x, b1, z);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NotNull @Override
|
||||||
public Iterator<BlockVector3> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
return new Iterator<BlockVector3>() {
|
return new Iterator<BlockVector3>() {
|
||||||
int index = set.nextSetBit(0);
|
int index = set.nextSetBit(0);
|
||||||
@ -158,12 +158,12 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NotNull @Override
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
return toArray(null);
|
return toArray(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NotNull @Override
|
||||||
public <T> T[] toArray(T[] array) {
|
public <T> T[] toArray(T[] array) {
|
||||||
int size = size();
|
int size = size();
|
||||||
if (array == null || array.length < size) {
|
if (array == null || array.length < size) {
|
||||||
@ -177,9 +177,8 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
int b3 = ((byte) (index >> 15)) & 0xFF;
|
int b3 = ((byte) (index >> 15)) & 0xFF;
|
||||||
int b4 = ((byte) (index >> 23)) & 0xFF;
|
int b4 = ((byte) (index >> 23)) & 0xFF;
|
||||||
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
|
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
|
||||||
int y = b1;
|
|
||||||
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
|
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
|
||||||
array[i] = (T) BlockVector3.at(x, y, z);
|
array[i] = (T) BlockVector3.at(x, b1, z);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
@ -258,25 +257,16 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
for (Object o : c) {
|
return c.stream().allMatch(this::contains);
|
||||||
if (!contains(o)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(Collection<? extends BlockVector3> c) {
|
public boolean addAll(Collection<? extends BlockVector3> c) {
|
||||||
boolean result = false;
|
return c.stream().map(this::add).reduce(false, (a, b) -> a || b);
|
||||||
for (BlockVector3 v : c) {
|
|
||||||
result |= add(v);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(@NotNull Collection<?> c) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
int size = size();
|
int size = size();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
@ -300,11 +290,7 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
boolean result = false;
|
return c.stream().map(this::remove).reduce(false, (a, b) -> a || b);
|
||||||
for (Object o : c) {
|
|
||||||
result |= remove(o);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forEach(BlockVectorSetVisitor visitor) {
|
public void forEach(BlockVectorSetVisitor visitor) {
|
||||||
@ -318,9 +304,8 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
int b3 = ((byte) (index >> 15)) & 0xFF;
|
int b3 = ((byte) (index >> 15)) & 0xFF;
|
||||||
int b4 = ((byte) (index >> 23)) & 0xFF;
|
int b4 = ((byte) (index >> 23)) & 0xFF;
|
||||||
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
|
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
|
||||||
int y = b1;
|
|
||||||
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
|
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
|
||||||
visitor.run(x, y, z, index);
|
visitor.run(x, b1, z, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,6 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
|
|||||||
new MaskTraverser(mask).reset(getExtent());
|
new MaskTraverser(mask).reset(getExtent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BlockVector3> getVerticies() {
|
|
||||||
return positions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
|
@ -63,11 +63,6 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
region = new PolyhedralRegion(world);
|
region = new PolyhedralRegion(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BlockVector3> getVerticies() {
|
|
||||||
return new ArrayList<>(region.getVertices());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
|
@ -41,15 +41,6 @@ public class CompoundTag extends Tag {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getRaw() {
|
|
||||||
HashMap<String, Object> raw = new HashMap<>();
|
|
||||||
for (Map.Entry<String, Tag> entry : value.entrySet()) {
|
|
||||||
raw.put(entry.getKey(), entry.getValue().getRaw());
|
|
||||||
}
|
|
||||||
return raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this compound tag contains the given key.
|
* Returns whether this compound tag contains the given key.
|
||||||
*
|
*
|
||||||
|
@ -34,7 +34,7 @@ public class CompoundTagBuilder {
|
|||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder() {
|
CompoundTagBuilder() {
|
||||||
this.entries = new HashMap<>();
|
this.entries = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @param value the value
|
* @param value the value
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder(Map<String, Tag> value) {
|
CompoundTagBuilder(Map<String, Tag> value) {
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
this.entries = value;
|
this.entries = value;
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,12 @@
|
|||||||
package com.sk89q.jnbt;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||||
import com.boydti.fawe.object.RunnableVal2;
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -64,10 +60,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
this.is = dis;
|
this.is = dis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataInputStream getInputStream() {
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an NBT tag from the stream.
|
* Reads an NBT tag from the stream.
|
||||||
*
|
*
|
||||||
@ -78,16 +70,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
return readNamedTag(0);
|
return readNamedTag(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads an NBT map from the stream.
|
|
||||||
*
|
|
||||||
* @return The map that was read.
|
|
||||||
* @throws IOException if an I/O error occurs.
|
|
||||||
*/
|
|
||||||
public NamedData readNamedData() throws IOException {
|
|
||||||
return readNamedData(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an NBT from the stream.
|
* Reads an NBT from the stream.
|
||||||
*
|
*
|
||||||
@ -100,21 +82,11 @@ public final class NBTInputStream implements Closeable {
|
|||||||
return new NamedTag(readNamedTagName(type), readTagPayload(type, depth));
|
return new NamedTag(readNamedTagName(type), readTagPayload(type, depth));
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamedData readNamedData(int depth) throws IOException {
|
|
||||||
int type = is.readByte();
|
|
||||||
return new NamedData(readNamedTagName(type), readDataPayload(type, depth));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tag readTag() throws IOException {
|
public Tag readTag() throws IOException {
|
||||||
int type = is.readByte();
|
int type = is.readByte();
|
||||||
return readTagPayload(type, 0);
|
return readTagPayload(type, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object readData() throws IOException {
|
|
||||||
int type = is.readByte();
|
|
||||||
return readDataPayload(type, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readNamedTagLazy(Function<String, BiConsumer> getReader) throws IOException {
|
public void readNamedTagLazy(Function<String, BiConsumer> getReader) throws IOException {
|
||||||
int type = is.readByte();
|
int type = is.readByte();
|
||||||
String name = readNamedTagName(type);
|
String name = readNamedTagName(type);
|
||||||
@ -528,7 +500,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
* @return the tag
|
* @return the tag
|
||||||
* @throws IOException if an I/O error occurs.
|
* @throws IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public Tag readTagPayload(int type, int depth) throws IOException {
|
private Tag readTagPayload(int type, int depth) throws IOException {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NBTConstants.TYPE_END:
|
case NBTConstants.TYPE_END:
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
@ -598,11 +570,11 @@ public final class NBTInputStream implements Closeable {
|
|||||||
}
|
}
|
||||||
case NBTConstants.TYPE_LONG_ARRAY: {
|
case NBTConstants.TYPE_LONG_ARRAY: {
|
||||||
length = is.readInt();
|
length = is.readInt();
|
||||||
long[] data = new long[length];
|
long[] longData = new long[length];
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
data[i] = is.readLong();
|
longData[i] = is.readLong();
|
||||||
}
|
}
|
||||||
return new LongArrayTag(data);
|
return new LongArrayTag(longData);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new IOException("Invalid tag type: " + type + ".");
|
throw new IOException("Invalid tag type: " + type + ".");
|
||||||
|
@ -21,7 +21,6 @@ package com.sk89q.jnbt;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.object.io.LittleEndianOutputStream;
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -67,12 +66,6 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLittleEndian() {
|
|
||||||
if (!(os instanceof LittleEndianOutputStream)) {
|
|
||||||
this.os = new LittleEndianOutputStream((OutputStream) os);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a tag.
|
* Writes a tag.
|
||||||
*
|
*
|
||||||
@ -86,10 +79,16 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
checkNotNull(tag);
|
checkNotNull(tag);
|
||||||
|
|
||||||
int type = NBTUtils.getTypeCode(tag.getClass());
|
int type = NBTUtils.getTypeCode(tag.getClass());
|
||||||
writeNamedTagName(name, type);
|
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
|
||||||
|
|
||||||
|
os.writeByte(type);
|
||||||
|
os.writeShort(nameBytes.length);
|
||||||
|
os.write(nameBytes);
|
||||||
|
|
||||||
if (type == NBTConstants.TYPE_END) {
|
if (type == NBTConstants.TYPE_END) {
|
||||||
throw new IOException("Named TAG_End not permitted.");
|
throw new IOException("Named TAG_End not permitted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
writeTagPayload(tag);
|
writeTagPayload(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,16 +148,6 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNamedTag(String name, long[] data) throws IOException {
|
|
||||||
checkNotNull(name);
|
|
||||||
int type = NBTConstants.TYPE_LONG_ARRAY;
|
|
||||||
writeNamedTagName(name, type);
|
|
||||||
os.writeInt(data.length);
|
|
||||||
for (long aData : data) {
|
|
||||||
os.writeLong(aData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeNamedEmptyList(String name) throws IOException {
|
public void writeNamedEmptyList(String name) throws IOException {
|
||||||
writeNamedEmptyList(name, NBTConstants.TYPE_COMPOUND);
|
writeNamedEmptyList(name, NBTConstants.TYPE_COMPOUND);
|
||||||
}
|
}
|
||||||
@ -171,6 +160,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
|
|
||||||
public void writeNamedTagName(String name, int type) throws IOException {
|
public void writeNamedTagName(String name, int type) throws IOException {
|
||||||
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
|
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
|
||||||
|
|
||||||
os.writeByte(type);
|
os.writeByte(type);
|
||||||
os.writeShort(nameBytes.length);
|
os.writeShort(nameBytes.length);
|
||||||
os.write(nameBytes);
|
os.write(nameBytes);
|
||||||
@ -292,7 +282,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
for (Map.Entry<String, Tag> entry : tag.getValue().entrySet()) {
|
for (Map.Entry<String, Tag> entry : tag.getValue().entrySet()) {
|
||||||
writeNamedTag(entry.getKey(), entry.getValue());
|
writeNamedTag(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
os.writeByte(NBTConstants.TYPE_END); // end tag - better way?
|
os.writeByte((byte) 0); // end tag - better way?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,4 @@ public abstract class Tag {
|
|||||||
*/
|
*/
|
||||||
public abstract Object getValue();
|
public abstract Object getValue();
|
||||||
|
|
||||||
public Object getRaw() {
|
|
||||||
return getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,21 +0,0 @@
|
|||||||
package com.sk89q.minecraft.util.commands;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface SuggestedRange {
|
|
||||||
/**
|
|
||||||
* The minimum value that the number can be at, inclusive.
|
|
||||||
*
|
|
||||||
* @return the minimum value
|
|
||||||
*/
|
|
||||||
double min() default Double.MIN_VALUE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum value that the number can be at, inclusive.
|
|
||||||
*
|
|
||||||
* @return the maximum value
|
|
||||||
*/
|
|
||||||
double max() default Double.MAX_VALUE;
|
|
||||||
}
|
|
@ -26,6 +26,7 @@ public final class ReflectionUtil {
|
|||||||
private ReflectionUtil() {
|
private ReflectionUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T getField(Object from, String name) {
|
public static <T> T getField(Object from, String name) {
|
||||||
if (from instanceof Class)
|
if (from instanceof Class)
|
||||||
return getField((Class) from, null, name);
|
return getField((Class) from, null, name);
|
||||||
@ -34,12 +35,12 @@ public final class ReflectionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T getField(Class checkClass, Object obj, String name) {
|
public static <T> T getField(Class checkClass, Object from, String name) {
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
Field field = checkClass.getDeclaredField(name);
|
Field field = checkClass.getDeclaredField(name);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
return (T) field.get(obj);
|
return (T) field.get(from);
|
||||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||||
}
|
}
|
||||||
} while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
} while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
||||||
|
@ -1,477 +0,0 @@
|
|||||||
/*
|
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
||||||
* Copyright (C) WorldEdit team and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit;
|
|
||||||
|
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
|
||||||
import com.sk89q.worldedit.command.ClipboardCommands;
|
|
||||||
import com.sk89q.worldedit.command.FlattenedClipboardTransform;
|
|
||||||
import com.sk89q.worldedit.command.SchematicCommands;
|
|
||||||
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.io.BuiltInClipboardFormat;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.util.Countable;
|
|
||||||
import com.sk89q.worldedit.util.Direction;
|
|
||||||
import com.sk89q.worldedit.world.DataException;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The clipboard remembers the state of a cuboid region.
|
|
||||||
*
|
|
||||||
* @deprecated This is slowly being replaced with {@link Clipboard}, which is
|
|
||||||
* far more versatile. Transforms are supported using affine
|
|
||||||
* transformations and full entity support is provided because
|
|
||||||
* the clipboard properly implements {@link Extent}. However,
|
|
||||||
* the new clipboard class is only available in WorldEdit 6.x and
|
|
||||||
* beyond. We intend on keeping this deprecated class in WorldEdit
|
|
||||||
* for an extended amount of time so there is no rush to
|
|
||||||
* switch (but new features will not be supported). To copy between
|
|
||||||
* a clipboard and a world (or between any two {@code Extent}s),
|
|
||||||
* one can use {@link ForwardExtentCopy}. See
|
|
||||||
* {@link ClipboardCommands} and {@link SchematicCommands} for
|
|
||||||
* more information.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class CuboidClipboard {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An enum of possible flip directions.
|
|
||||||
*/
|
|
||||||
public enum FlipDirection {
|
|
||||||
NORTH_SOUTH(Direction.NORTH),
|
|
||||||
WEST_EAST(Direction.WEST),
|
|
||||||
UP_DOWN(Direction.UP),
|
|
||||||
;
|
|
||||||
private final Direction direction;
|
|
||||||
FlipDirection(Direction direction) {
|
|
||||||
this.direction = direction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BlockArrayClipboard clipboard;
|
|
||||||
private AffineTransform transform;
|
|
||||||
public BlockVector3 size;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the clipboard.
|
|
||||||
*
|
|
||||||
* @param size the dimensions of the clipboard (should be at least 1 on every dimension)
|
|
||||||
*/
|
|
||||||
public CuboidClipboard(BlockVector3 size) {
|
|
||||||
checkNotNull(size);
|
|
||||||
this.size = size;
|
|
||||||
this.clipboard = this.init(BlockVector3.ZERO, BlockVector3.ZERO);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CuboidClipboard(BlockArrayClipboard clipboard) {
|
|
||||||
this.clipboard = clipboard;
|
|
||||||
this.size = clipboard.getDimensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the clipboard.
|
|
||||||
*
|
|
||||||
* @param size the dimensions of the clipboard (should be at least 1 on every dimension)
|
|
||||||
* @param origin the origin point where the copy was made, which must be the
|
|
||||||
* {@link CuboidRegion#getMinimumPoint()} relative to the copy
|
|
||||||
*/
|
|
||||||
public CuboidClipboard(BlockVector3 size, BlockVector3 origin) {
|
|
||||||
checkNotNull(size);
|
|
||||||
checkNotNull(origin);
|
|
||||||
this.size = size;
|
|
||||||
this.clipboard = init(BlockVector3.ZERO, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the clipboard.
|
|
||||||
*
|
|
||||||
* @param size the dimensions of the clipboard (should be at least 1 on every dimension)
|
|
||||||
* @param origin the origin point where the copy was made, which must be the
|
|
||||||
* {@link CuboidRegion#getMinimumPoint()} relative to the copy
|
|
||||||
* @param offset the offset from the minimum point of the copy where the user was
|
|
||||||
*/
|
|
||||||
public CuboidClipboard(BlockVector3 size, BlockVector3 origin, BlockVector3 offset) {
|
|
||||||
checkNotNull(size);
|
|
||||||
checkNotNull(origin);
|
|
||||||
checkNotNull(offset);
|
|
||||||
this.size = size;
|
|
||||||
this.clipboard = this.init(offset, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
private BlockArrayClipboard init(BlockVector3 offset, BlockVector3 min) {
|
|
||||||
BlockVector3 origin = min.subtract(offset);
|
|
||||||
CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(BlockVector3.ONE));
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
|
||||||
clipboard.setOrigin(origin);
|
|
||||||
return clipboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
public BaseBlock getBlock(BlockVector3 position) {
|
|
||||||
return getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public BaseBlock getBlock(int x, int y, int z) {
|
|
||||||
// return adapt(clipboard.IMP.getBlock(x, y, z));
|
|
||||||
return clipboard.IMP.getBlock(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseBlock getLazyBlock(BlockVector3 position) {
|
|
||||||
return getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlock(BlockVector3 location, BaseBlock block) {
|
|
||||||
setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setBlock(int x, int y, int z, BaseBlock block) {
|
|
||||||
return setBlock(x, y, z, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setBlock(int x, int y, int z, BlockState block) {
|
|
||||||
return clipboard.IMP.setBlock(x, y, z, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the width (X-direction) of the clipboard.
|
|
||||||
*
|
|
||||||
* @return width
|
|
||||||
*/
|
|
||||||
public int getWidth() {
|
|
||||||
return size.getBlockX();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the length (Z-direction) of the clipboard.
|
|
||||||
*
|
|
||||||
* @return length
|
|
||||||
*/
|
|
||||||
public int getLength() {
|
|
||||||
return size.getBlockZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the height (Y-direction) of the clipboard.
|
|
||||||
*
|
|
||||||
* @return height
|
|
||||||
*/
|
|
||||||
public int getHeight() {
|
|
||||||
return size.getBlockY();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotate the clipboard in 2D. It can only rotate by angles divisible by 90.
|
|
||||||
*
|
|
||||||
* @param angle in degrees
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void rotate2D(int angle) {
|
|
||||||
AffineTransform newTransform = new AffineTransform().rotateY(-angle);
|
|
||||||
this.transform = transform == null ? newTransform : newTransform.combine(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flip the clipboard.
|
|
||||||
*
|
|
||||||
* @param dir direction to flip
|
|
||||||
*/
|
|
||||||
public void flip(FlipDirection dir) {
|
|
||||||
flip(dir, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flip the clipboard.
|
|
||||||
*
|
|
||||||
* @param dir direction to flip
|
|
||||||
* @param aroundPlayer flip the offset around the player
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void flip(FlipDirection dir, boolean aroundPlayer) {
|
|
||||||
checkNotNull(dir);
|
|
||||||
Direction direction = dir.direction;
|
|
||||||
AffineTransform newTransform = new AffineTransform().scale(direction.toVector().abs().multiply(-2).add(1, 1, 1));
|
|
||||||
this.transform = transform == null ? newTransform : newTransform.combine(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copies blocks to the clipboard.
|
|
||||||
*
|
|
||||||
* @param editSession the EditSession from which to take the blocks
|
|
||||||
*/
|
|
||||||
public void copy(EditSession editSession) {
|
|
||||||
for (int x = 0; x < size.getBlockX(); ++x) {
|
|
||||||
for (int y = 0; y < size.getBlockY(); ++y) {
|
|
||||||
for (int z = 0; z < size.getBlockZ(); ++z) {
|
|
||||||
setBlock(x, y, z, editSession.getBlock(BlockVector3.at(x, y, z).add(getOrigin())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copies blocks to the clipboard.
|
|
||||||
*
|
|
||||||
* @param editSession The EditSession from which to take the blocks
|
|
||||||
* @param region A region that further constrains which blocks to take.
|
|
||||||
*/
|
|
||||||
public void copy(EditSession editSession, Region region) {
|
|
||||||
for (int x = 0; x < size.getBlockX(); ++x) {
|
|
||||||
for (int y = 0; y < size.getBlockY(); ++y) {
|
|
||||||
for (int z = 0; z < size.getBlockZ(); ++z) {
|
|
||||||
final BlockVector3 pt = BlockVector3.at(x, y, z).add(getOrigin());
|
|
||||||
if (region.contains(pt)) {
|
|
||||||
setBlock(x, y, z, editSession.getBlock(pt));
|
|
||||||
} else {
|
|
||||||
setBlock(x, y, z, (BlockState)null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Paste the clipboard at the given location using the given {@code EditSession}.
|
|
||||||
* <p>
|
|
||||||
* <p>This method blocks the server/game until the entire clipboard is
|
|
||||||
* pasted. In the future, {@link ForwardExtentCopy} will be recommended,
|
|
||||||
* which, if combined with the proposed operation scheduler framework,
|
|
||||||
* will not freeze the game/server.</p>
|
|
||||||
*
|
|
||||||
* @param editSession the EditSession to which blocks are to be copied to
|
|
||||||
* @param newOrigin the new origin point (must correspond to the minimum point of the cuboid)
|
|
||||||
* @param noAir true to not copy air blocks in the source
|
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks were changed
|
|
||||||
*/
|
|
||||||
public void paste(EditSession editSession, BlockVector3 newOrigin, boolean noAir) throws MaxChangedBlocksException {
|
|
||||||
paste(editSession, newOrigin, noAir, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Paste the clipboard at the given location using the given {@code EditSession}.
|
|
||||||
* <p>
|
|
||||||
* <p>This method blocks the server/game until the entire clipboard is
|
|
||||||
* pasted. In the future, {@link ForwardExtentCopy} will be recommended,
|
|
||||||
* which, if combined with the proposed operation scheduler framework,
|
|
||||||
* will not freeze the game/server.</p>
|
|
||||||
*
|
|
||||||
* @param editSession the EditSession to which blocks are to be copied to
|
|
||||||
* @param newOrigin the new origin point (must correspond to the minimum point of the cuboid)
|
|
||||||
* @param noAir true to not copy air blocks in the source
|
|
||||||
* @param entities true to copy entities
|
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks were changed
|
|
||||||
*/
|
|
||||||
public void paste(EditSession editSession, BlockVector3 newOrigin, boolean noAir, boolean entities) throws MaxChangedBlocksException {
|
|
||||||
new Schematic(clipboard).paste(editSession, newOrigin, false, !noAir, entities, transform);
|
|
||||||
editSession.flushQueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Paste the clipboard at the given location using the given {@code EditSession}.
|
|
||||||
* <p>
|
|
||||||
* <p>This method blocks the server/game until the entire clipboard is
|
|
||||||
* pasted. In the future, {@link ForwardExtentCopy} will be recommended,
|
|
||||||
* which, if combined with the proposed operation scheduler framework,
|
|
||||||
* will not freeze the game/server.</p>
|
|
||||||
*
|
|
||||||
* @param editSession the EditSession to which blocks are to be copied to
|
|
||||||
* @param newOrigin the new origin point (must correspond to the minimum point of the cuboid)
|
|
||||||
* @param noAir true to not copy air blocks in the source
|
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks were changed
|
|
||||||
*/
|
|
||||||
public void place(EditSession editSession, BlockVector3 newOrigin, boolean noAir) throws MaxChangedBlocksException {
|
|
||||||
paste(editSession, newOrigin, noAir, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the block at the given position.
|
|
||||||
* <p>
|
|
||||||
* <p>If the position is out of bounds, air will be returned.</p>
|
|
||||||
*
|
|
||||||
* @param position the point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin
|
|
||||||
* @return air, if this block was outside the (non-cuboid) selection while copying
|
|
||||||
* @throws ArrayIndexOutOfBoundsException if the position is outside the bounds of the CuboidClipboard
|
|
||||||
* @deprecated use {@link #getBlock(Vector)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BaseBlock getPoint(BlockVector3 position) throws ArrayIndexOutOfBoundsException {
|
|
||||||
final BaseBlock block = getBlock(position);
|
|
||||||
if (block == null) {
|
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the origin point, which corresponds to where the copy was
|
|
||||||
* originally copied from. The origin is the lowest possible X, Y, and
|
|
||||||
* Z components of the cuboid region that was copied.
|
|
||||||
*
|
|
||||||
* @return the origin
|
|
||||||
*/
|
|
||||||
public BlockVector3 getOrigin() {
|
|
||||||
return clipboard.getMinimumPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the origin point, which corresponds to where the copy was
|
|
||||||
* originally copied from. The origin is the lowest possible X, Y, and
|
|
||||||
* Z components of the cuboid region that was copied.
|
|
||||||
*
|
|
||||||
* @param origin the origin to set
|
|
||||||
*/
|
|
||||||
public void setOrigin(BlockVector3 origin) {
|
|
||||||
checkNotNull(origin);
|
|
||||||
setOriginAndOffset(getOffset(), origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOriginAndOffset(BlockVector3 offset, BlockVector3 min) {
|
|
||||||
BlockVector3 origin = min.subtract(offset);
|
|
||||||
CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(BlockVector3.ONE));
|
|
||||||
clipboard.setRegion(region);
|
|
||||||
clipboard.setOrigin(origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the offset of the player to the clipboard's minimum point
|
|
||||||
* (minimum X, Y, Z coordinates).
|
|
||||||
* <p>
|
|
||||||
* <p>The offset is inverse (multiplied by -1).</p>
|
|
||||||
*
|
|
||||||
* @return the offset the offset
|
|
||||||
*/
|
|
||||||
public BlockVector3 getOffset() {
|
|
||||||
BlockVector3 min = clipboard.getMinimumPoint();
|
|
||||||
BlockVector3 origin = clipboard.getOrigin();
|
|
||||||
BlockVector3 offset = min.subtract(origin);
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the offset of the player to the clipboard's minimum point
|
|
||||||
* (minimum X, Y, Z coordinates).
|
|
||||||
* <p>
|
|
||||||
* <p>The offset is inverse (multiplied by -1).</p>
|
|
||||||
*
|
|
||||||
* @param offset the new offset
|
|
||||||
*/
|
|
||||||
public void setOffset(BlockVector3 offset) {
|
|
||||||
checkNotNull(offset);
|
|
||||||
setOriginAndOffset(offset, getOrigin());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the dimensions of the clipboard.
|
|
||||||
*
|
|
||||||
* @return the dimensions, where (1, 1, 1) is 1 wide, 1 across, 1 deep
|
|
||||||
*/
|
|
||||||
public BlockVector3 getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the clipboard data to a .schematic-format file.
|
|
||||||
*
|
|
||||||
* @param path the path to the file to save
|
|
||||||
* @throws IOException thrown on I/O error
|
|
||||||
* @throws DataException thrown on error writing the data for other reasons
|
|
||||||
* @deprecated use {@link ClipboardFormat#SCHEMATIC}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void saveSchematic(File path) throws IOException, DataException {
|
|
||||||
checkNotNull(path);
|
|
||||||
if (transform != null && !transform.isIdentity()) {
|
|
||||||
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
|
||||||
BlockArrayClipboard target = new BlockArrayClipboard(result.getTransformedRegion(), UUID.randomUUID());
|
|
||||||
target.setOrigin(clipboard.getOrigin());
|
|
||||||
Operations.completeLegacy(result.copyTo(target));
|
|
||||||
this.clipboard = target;
|
|
||||||
}
|
|
||||||
new Schematic(clipboard).save(path, BuiltInClipboardFormat.SPONGE_SCHEMATIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a .schematic file into a clipboard.
|
|
||||||
*
|
|
||||||
* @param path the path to the file to load
|
|
||||||
* @return a clipboard
|
|
||||||
* @throws IOException thrown on I/O error
|
|
||||||
* @throws DataException thrown on error writing the data for other reasons
|
|
||||||
* @deprecated use {@link ClipboardFormat#SCHEMATIC}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static CuboidClipboard loadSchematic(File path) throws DataException, IOException {
|
|
||||||
checkNotNull(path);
|
|
||||||
return new CuboidClipboard((BlockVector3) BuiltInClipboardFormat.MCEDIT_SCHEMATIC.load(path).getClipboard());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the block distribution inside a clipboard.
|
|
||||||
*
|
|
||||||
* @return a block distribution
|
|
||||||
*/
|
|
||||||
public List<Countable<Integer>> getBlockDistribution() {
|
|
||||||
List<Countable<Integer>> distribution = new ArrayList<>();
|
|
||||||
List<Countable<BlockState>> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion());
|
|
||||||
for (Countable<BlockState> item : distr) {
|
|
||||||
BlockStateHolder state = item.getID();
|
|
||||||
int[] legacyId = LegacyMapper.getInstance().getLegacyFromBlock(state.toImmutableState());
|
|
||||||
if (legacyId[0] != 0) distribution.add(new Countable<>(legacyId[0], item.getAmount()));
|
|
||||||
}
|
|
||||||
return distribution;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the block distribution inside a clipboard with data values.
|
|
||||||
*
|
|
||||||
* @return a block distribution
|
|
||||||
*/
|
|
||||||
public List<Countable<BaseBlock>> getBlockDistributionWithData() {
|
|
||||||
List<Countable<BaseBlock>> distribution = new ArrayList<>();
|
|
||||||
List<Countable<BlockState>> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion());
|
|
||||||
for (Countable<BlockState> item : distr) {
|
|
||||||
distribution.add(new Countable<>(item.getID().toBaseBlock(), item.getAmount()));
|
|
||||||
}
|
|
||||||
return distribution;
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,14 +21,11 @@ package com.sk89q.worldedit.blocks;
|
|||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block-related utility methods.
|
* Block-related utility methods.
|
||||||
|
@ -23,10 +23,12 @@ import com.boydti.fawe.config.BBC;
|
|||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||||
import com.boydti.fawe.util.chat.Message;
|
import com.boydti.fawe.util.chat.Message;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -62,8 +64,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements biome-related commands such as "/biomelist".
|
* Implements biome-related commands such as "/biomelist".
|
||||||
*/
|
*/
|
||||||
@ -192,11 +192,20 @@ public class BiomeCommands extends MethodCommands {
|
|||||||
Collections.sort(distribution);
|
Collections.sort(distribution);
|
||||||
for (Countable<BiomeType> c : distribution) {
|
for (Countable<BiomeType> c : distribution) {
|
||||||
BiomeData data = biomeRegistry.getData(c.getID());
|
BiomeData data = biomeRegistry.getData(c.getID());
|
||||||
String str = String.format("%-7s (%.3f%%) %s #%d",
|
String str;
|
||||||
|
if (data == null) {
|
||||||
|
str = String.format("%-7s (%.3f%%) %s #%d",
|
||||||
String.valueOf(c.getAmount()),
|
String.valueOf(c.getAmount()),
|
||||||
c.getAmount() / (double) size * 100,
|
c.getAmount() / (double) size * 100,
|
||||||
data == null ? "Unknown" : data.getName(),
|
"Unknown",
|
||||||
c.getID().getInternalId());
|
c.getID().getInternalId());
|
||||||
|
} else {
|
||||||
|
str = String.format("%-7s (%.3f%%) %s #%d",
|
||||||
|
String.valueOf(c.getAmount()),
|
||||||
|
c.getAmount() / (double) size * 100,
|
||||||
|
data.getName(),
|
||||||
|
c.getID().getInternalId());
|
||||||
|
}
|
||||||
player.print(str);
|
player.print(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +229,7 @@ public class BiomeCommands extends MethodCommands {
|
|||||||
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
|
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
|
||||||
|
|
||||||
if (atPosition) {
|
if (atPosition) {
|
||||||
region = new CuboidRegion(player.getLocation().toBlockPoint(), player.getLocation().toBlockPoint());
|
region = new CuboidRegion(player.getLocation().toVector().toBlockPoint(), player.getLocation().toVector().toBlockPoint());
|
||||||
} else {
|
} else {
|
||||||
region = session.getSelection(world);
|
region = session.getSelection(world);
|
||||||
}
|
}
|
||||||
@ -236,4 +245,5 @@ public class BiomeCommands extends MethodCommands {
|
|||||||
if (!player.hasPermission("fawe.tips"))
|
if (!player.hasPermission("fawe.tips"))
|
||||||
BBC.TIP_BIOME_PATTERN.or(BBC.TIP_BIOME_MASK).send(player);
|
BBC.TIP_BIOME_PATTERN.or(BBC.TIP_BIOME_MASK).send(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,4 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
|||||||
return locals.get(Actor.class).hasPermission(permission);
|
return locals.get(Actor.class).hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.composition;
|
package com.sk89q.worldedit.command.composition;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
|
@ -1,15 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
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;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
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;
|
||||||
|
|
||||||
@ -30,11 +47,11 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
int ox = clicked.getBlockX();
|
int ox = clicked.getBlockX();
|
||||||
int oy = clicked.getBlockY();
|
int oy = clicked.getBlockY();
|
||||||
int oz = clicked.getBlockZ();
|
int oz = clicked.getBlockZ();
|
||||||
BlockType initialType = clicked.getExtent().getBlock(clicked.toBlockPoint()).getBlockType();
|
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector().toBlockPoint()).getBlockType();
|
||||||
|
|
||||||
if (initialType.getMaterial().isAir()) {
|
if (initialType.getMaterial().isAir()) {
|
||||||
return true;
|
return true;
|
||||||
@ -45,23 +62,29 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
try {
|
|
||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||||
|
|
||||||
|
try {
|
||||||
for (int x = ox - range; x <= ox + range; ++x) {
|
for (int x = ox - range; x <= ox + range; ++x) {
|
||||||
for (int z = oz - range; z <= oz + range; ++z) {
|
for (int z = oz - range; z <= oz + range; ++z) {
|
||||||
for (int y = oy + range; y >= oy - range; --y) {
|
for (int y = oy + range; y >= oy - range; --y) {
|
||||||
if (initialType.equals(editSession.getLazyBlock(x, y, z))) {
|
BlockVector3 pos = BlockVector3.at(x, y, z);
|
||||||
|
if (editSession.getLazyBlock(pos).getBlockType() != initialType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
editSession.flushQueue();
|
editSession.flushQueue();
|
||||||
|
} catch (MaxChangedBlocksException e) {
|
||||||
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
|
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
|
|
||||||
// BlockStateHolder block = world.getBlock(clicked);
|
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||||
BlockVector3 blockPoint = clicked.toBlockPoint();
|
|
||||||
BlockState block = world.getBlock(blockPoint);
|
BlockState block = world.getBlock(blockPoint);
|
||||||
|
|
||||||
if (!config.allowedDataCycleBlocks.isEmpty()
|
if (!config.allowedDataCycleBlocks.isEmpty()
|
||||||
@ -85,8 +84,9 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
Property<Object> objProp = (Property<Object>) currentProperty;
|
Property<Object> objProp = (Property<Object>) currentProperty;
|
||||||
BlockState newBlock = block.with(objProp, currentProperty.getValues().get(index));
|
BlockState newBlock = block.with(objProp, currentProperty.getValues().get(index));
|
||||||
|
|
||||||
try {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
EditSession editSession = session.createEditSession(player);
|
editSession.disableBuffering();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(blockPoint, newBlock);
|
editSession.setBlock(blockPoint, newBlock);
|
||||||
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
||||||
@ -95,7 +95,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
}catch (Exception e) {}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<Property<?>> properties = Lists.newArrayList(block.getStates().keySet());
|
List<Property<?>> properties = Lists.newArrayList(block.getStates().keySet());
|
||||||
int index = properties.indexOf(currentProperty);
|
int index = properties.indexOf(currentProperty);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -32,10 +31,9 @@ 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.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A mode that replaces one block.
|
||||||
*/
|
*/
|
||||||
public class BlockReplacer implements DoubleActionBlockTool {
|
public class BlockReplacer implements DoubleActionBlockTool {
|
||||||
|
|
||||||
@ -75,12 +73,11 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
@Override
|
@Override
|
||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
BlockStateHolder targetBlock = (editSession).getBlock(clicked.toBlockPoint());
|
BlockState targetBlock = editSession.getBlock(clicked.toVector().toBlockPoint());
|
||||||
BlockType type = targetBlock.getBlockType();
|
|
||||||
|
|
||||||
if (type != null) {
|
if (targetBlock != null) {
|
||||||
this.pattern = targetBlock;
|
pattern = new BlockPattern(targetBlock);
|
||||||
player.print("Replacer tool switched to: " + type.getName());
|
player.print("Replacer tool switched to: " + targetBlock.getBlockType().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
@ -16,15 +35,21 @@ import com.boydti.fawe.object.brush.visualization.VisualMode;
|
|||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.boydti.fawe.object.mask.MaskedTargetBlock;
|
import com.boydti.fawe.object.mask.MaskedTargetBlock;
|
||||||
import com.boydti.fawe.object.pattern.PatternTraverser;
|
import com.boydti.fawe.object.pattern.PatternTraverser;
|
||||||
import com.boydti.fawe.util.*;
|
import com.boydti.fawe.util.BrushCache;
|
||||||
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
|
import com.boydti.fawe.util.StringMan;
|
||||||
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
@ -36,10 +61,14 @@ import com.sk89q.worldedit.function.mask.Mask;
|
|||||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -47,11 +76,10 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a shape at the place being looked at.
|
||||||
|
*/
|
||||||
public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool, ResettableTool, Serializable {
|
public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool, ResettableTool, Serializable {
|
||||||
// TODO:
|
// TODO:
|
||||||
// Serialize methods
|
// Serialize methods
|
||||||
@ -79,7 +107,13 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
|
|
||||||
private transient BaseItem holder;
|
private transient BaseItem holder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the tool.
|
||||||
|
*
|
||||||
|
* @param permission the permission to check before use is allowed
|
||||||
|
*/
|
||||||
public BrushTool(String permission) {
|
public BrushTool(String permission) {
|
||||||
|
checkNotNull(permission);
|
||||||
getContext().addPermission(permission);
|
getContext().addPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +322,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
* @param brush tbe brush
|
* @param brush tbe brush
|
||||||
* @param permission the permission
|
* @param permission the permission
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public void setBrush(Brush brush, String permission) {
|
public void setBrush(Brush brush, String permission) {
|
||||||
setBrush(brush, permission, null);
|
setBrush(brush, permission, null);
|
||||||
update();
|
update();
|
||||||
@ -388,7 +421,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
pitch = 23 - (pitch / 4);
|
pitch = 23 - (pitch / 4);
|
||||||
d += (int) (Math.sin(Math.toRadians(pitch)) * 50);
|
d += (int) (Math.sin(Math.toRadians(pitch)) * 50);
|
||||||
final Vector3 vector = loc.getDirection().withY(0).normalize().multiply(d).add(loc.getX(), loc.getY(), loc.getZ());
|
final Vector3 vector = loc.getDirection().withY(0).normalize().multiply(d).add(loc.getX(), loc.getY(), loc.getZ());
|
||||||
// vector = vector.add(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
return offset(vector, loc).toBlockPoint();
|
return offset(vector, loc).toBlockPoint();
|
||||||
}
|
}
|
||||||
case TARGET_POINT_HEIGHT: {
|
case TARGET_POINT_HEIGHT: {
|
||||||
|
@ -51,7 +51,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
|||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
BlockVector3 blockPoint = target.toBlockPoint();
|
BlockVector3 blockPoint = target.toVector().toBlockPoint();
|
||||||
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
selector.explainPrimarySelection(player, session, blockPoint);
|
selector.explainPrimarySelection(player, session, blockPoint);
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
|||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
BlockVector3 blockPoint = target.toBlockPoint();
|
BlockVector3 blockPoint = target.toVector().toBlockPoint();
|
||||||
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
selector.explainSecondarySelection(player, session, blockPoint);
|
selector.explainSecondarySelection(player, session, blockPoint);
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -38,9 +38,7 @@ 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.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.boydti.fawe.object.mask.IdMask;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -28,7 +27,6 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -39,7 +37,6 @@ import com.sk89q.worldedit.world.World;
|
|||||||
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.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +61,7 @@ public class FloodFillTool implements BlockTool {
|
|||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
|
|
||||||
BlockVector3 origin = clicked.toBlockPoint();
|
BlockVector3 origin = clicked.toVector().toBlockPoint();
|
||||||
BlockType initialType = world.getBlock(origin).getBlockType();
|
BlockType initialType = world.getBlock(origin).getBlockType();
|
||||||
|
|
||||||
if (initialType.getMaterial().isAir()) {
|
if (initialType.getMaterial().isAir()) {
|
||||||
@ -88,6 +85,7 @@ public class FloodFillTool implements BlockTool {
|
|||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,5 +118,4 @@ public class FloodFillTool implements BlockTool {
|
|||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -61,25 +61,27 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
eS.setBlock(blockPoint, secondary);
|
eS.setBlock(blockPoint, secondary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.subtract(pos.getDirection()).toBlockPoint(), secondary);
|
eS.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), secondary);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
// one block? eat it
|
// one block? eat it
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
Location pos = getTargetFace(player);
|
Location pos = getTargetFace(player);
|
||||||
|
if (pos == null) return false;
|
||||||
try (EditSession eS = session.createEditSession(player)) {
|
try (EditSession eS = session.createEditSession(player)) {
|
||||||
BlockVector3 blockPoint = pos.toBlockPoint();
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
BaseBlock applied = primary.apply(blockPoint);
|
BaseBlock applied = primary.apply(blockPoint);
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
eS.setBlock(blockPoint, primary);
|
eS.setBlock(blockPoint, primary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.subtract(pos.getDirection()).toBlockPoint(), primary);
|
eS.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), primary);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
|
@ -45,10 +45,10 @@ public class QueryTool implements BlockTool {
|
|||||||
|
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
BlockVector3 blockPoint = clicked.toBlockPoint();
|
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||||
BaseBlock block = editSession.getFullBlock(blockPoint);
|
BaseBlock block = editSession.getFullBlock(blockPoint);
|
||||||
|
|
||||||
player.print("\u00A79@" + blockPoint + ": " + "\u00A7e"
|
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
||||||
+ block.getBlockType().getName() + "\u00A77" + " ("
|
+ block.getBlockType().getName() + "\u00A77" + " ("
|
||||||
+ block.toString() + ") "
|
+ block.toString() + ") "
|
||||||
+ "\u00A7f"
|
+ "\u00A7f"
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.boydti.fawe.object.mask.IdMask;
|
import com.boydti.fawe.object.mask.IdMask;
|
||||||
@ -22,6 +41,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
* an initial block and of the same type.
|
* an initial block and of the same type.
|
||||||
*/
|
*/
|
||||||
public class RecursivePickaxe implements BlockTool {
|
public class RecursivePickaxe implements BlockTool {
|
||||||
|
|
||||||
private double range;
|
private double range;
|
||||||
|
|
||||||
public RecursivePickaxe(double range) {
|
public RecursivePickaxe(double range) {
|
||||||
@ -39,7 +59,7 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
final BlockVector3 pos = clicked.toBlockPoint();
|
final BlockVector3 pos = clicked.toBlockPoint();
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
BlockVector3 origin = clicked.toBlockPoint();
|
BlockVector3 origin = clicked.toVector().toBlockPoint();
|
||||||
BlockType initialType = world.getBlock(origin).getBlockType();
|
BlockType initialType = world.getBlock(origin).getBlockType();
|
||||||
|
|
||||||
BlockStateHolder block = editSession.getBlock(pos);
|
BlockStateHolder block = editSession.getBlock(pos);
|
||||||
|
@ -21,11 +21,9 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class GravityBrush implements Brush {
|
public class GravityBrush implements Brush {
|
||||||
@ -37,24 +35,21 @@ public class GravityBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
Mask mask = editSession.getMask();
|
double endY = position.getBlockY() + size;
|
||||||
if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) {
|
double startPerformY = Math.max(0, position.getBlockY() - size);
|
||||||
mask = null;
|
double startCheckY = fullHeight ? 0 : startPerformY;
|
||||||
}
|
for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
||||||
int size = (int) sizeDouble;
|
for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
||||||
int endY = position.getBlockY() + size;
|
double freeSpot = startCheckY;
|
||||||
int startPerformY = Math.max(0, position.getBlockY() - size);
|
for (double y = startCheckY; y <= endY; ++y) {
|
||||||
int startCheckY = fullHeight ? 0 : startPerformY;
|
final BlockVector3 pt = BlockVector3.at(x, y, z);
|
||||||
for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
final BlockState block = editSession.getLazyBlock(pt);
|
||||||
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
|
||||||
int freeSpot = startCheckY;
|
|
||||||
for (int y = startCheckY; y <= endY; y++) {
|
|
||||||
BlockStateHolder block = editSession.getLazyBlock(x, y, z);
|
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
if (y != freeSpot) {
|
if (y != freeSpot) {
|
||||||
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(pt, BlockTypes.AIR.getDefaultState());
|
||||||
editSession.setBlock(x, freeSpot, z, block);
|
final BlockVector3 pt2 = BlockVector3.at(x, freeSpot, z);
|
||||||
|
editSession.setBlock(pt2, block);
|
||||||
}
|
}
|
||||||
freeSpot = y + 1;
|
freeSpot = y + 1;
|
||||||
}
|
}
|
||||||
@ -63,6 +58,4 @@ public class GravityBrush implements Brush {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class HollowCylinderBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = (BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||||
}
|
}
|
||||||
editSession.makeCylinder(position, pattern, size, size, height, false);
|
editSession.makeCylinder(position, pattern, size, size, height, false);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class HollowSphereBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = (BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||||
}
|
}
|
||||||
editSession.makeSphere(position, pattern, size, size, size, false);
|
editSession.makeSphere(position, pattern, size, size, size, false);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class SmoothBrush implements Brush {
|
|||||||
Vector3 posDouble = position.toVector3();
|
Vector3 posDouble = position.toVector3();
|
||||||
Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size));
|
Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size));
|
||||||
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
|
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
|
||||||
Region region = new CuboidRegion(editSession.getWorld(), min.toBlockPoint(), max);
|
Region region = new CuboidRegion(editSession.getWorld(), min.toVector().toBlockPoint(), max);
|
||||||
HeightMap heightMap = new HeightMap(editSession, region, mask);
|
HeightMap heightMap = new HeightMap(editSession, region, mask);
|
||||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||||
heightMap.applyFilter(filter, iterations);
|
heightMap.applyFilter(filter, iterations);
|
||||||
|
@ -31,7 +31,7 @@ public class SphereBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = (BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||||
}
|
}
|
||||||
editSession.makeSphere(position, pattern, size, size, size, true);
|
editSession.makeSphere(position, pattern, size, size, size, true);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.factory.parser;
|
package com.sk89q.worldedit.extension.factory.parser;
|
||||||
|
|
||||||
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.jnbt.JSON2NBT;
|
import com.boydti.fawe.jnbt.JSON2NBT;
|
||||||
import com.boydti.fawe.jnbt.NBTException;
|
import com.boydti.fawe.jnbt.NBTException;
|
||||||
@ -229,7 +230,13 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (state != null) {
|
||||||
nbt = state.getNbtData();
|
nbt = state.getNbtData();
|
||||||
|
} else {
|
||||||
|
Fawe.debug("State was null.");
|
||||||
|
Fawe.debug("Input was: " + input);
|
||||||
|
Fawe.debug("typestring was: " + typeString);
|
||||||
|
}
|
||||||
|
|
||||||
if (stateString != null) {
|
if (stateString != null) {
|
||||||
state = BlockState.get(state.getBlockType(), "[" + stateString + "]", state);
|
state = BlockState.get(state.getBlockType(), "[" + stateString + "]", state);
|
||||||
|
@ -22,8 +22,8 @@ package com.sk89q.worldedit.extent;
|
|||||||
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
|
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
|
||||||
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
||||||
import com.boydti.fawe.object.extent.LightingExtent;
|
import com.boydti.fawe.object.extent.LightingExtent;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
@ -41,10 +41,9 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class for {@link Extent}s that merely passes extents onto another.
|
* A base class for {@link Extent}s that merely passes extents onto another.
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -40,11 +37,10 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores changes to a {@link ChangeSet}.
|
* Stores changes to a {@link ChangeSet}.
|
||||||
*/
|
*/
|
||||||
|
@ -19,12 +19,15 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.boydti.fawe.jnbt.anvil.generator.*;
|
import com.boydti.fawe.jnbt.anvil.generator.CavesGen;
|
||||||
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
|
||||||
|
import com.boydti.fawe.jnbt.anvil.generator.OreGen;
|
||||||
|
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
||||||
|
import com.boydti.fawe.jnbt.anvil.generator.SchemGen;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
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.extent.clipboard.BlockArrayClipboard;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -173,13 +176,13 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
for (int d = 0; d <= clearance; d++) {
|
for (int d = 0; d <= clearance; d++) {
|
||||||
int y1 = y + d;
|
int y1 = y + d;
|
||||||
block = getLazyBlock(x, y1, z);
|
block = getLazyBlock(x, y1, z);
|
||||||
if (!block.getBlockType().getMaterial().isMovementBlocker() != state) {
|
if (block.getBlockType().getMaterial().isMovementBlocker() == state) {
|
||||||
return ((y1 - offset) << 4) - (15 - (state ? PropertyGroup.LEVEL.get(block) : data1));
|
return ((y1 - offset) << 4) - (15 - (state ? PropertyGroup.LEVEL.get(block) : data1));
|
||||||
}
|
}
|
||||||
data1 = PropertyGroup.LEVEL.get(block);
|
data1 = PropertyGroup.LEVEL.get(block);
|
||||||
int y2 = y - d;
|
int y2 = y - d;
|
||||||
block = getLazyBlock(x, y2, z);
|
block = getLazyBlock(x, y2, z);
|
||||||
if (!block.getBlockType().getMaterial().isMovementBlocker() != state) {
|
if (block.getBlockType().getMaterial().isMovementBlocker() == state) {
|
||||||
return ((y2 + offset) << 4) - (15 - (state ? PropertyGroup.LEVEL.get(block) : data2));
|
return ((y2 + offset) << 4) - (15 - (state ? PropertyGroup.LEVEL.get(block) : data2));
|
||||||
}
|
}
|
||||||
data2 = PropertyGroup.LEVEL.get(block);
|
data2 = PropertyGroup.LEVEL.get(block);
|
||||||
@ -188,16 +191,15 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
if (clearanceAbove < clearanceBelow) {
|
if (clearanceAbove < clearanceBelow) {
|
||||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||||
block = getLazyBlock(x, layer, z);
|
block = getLazyBlock(x, layer, z);
|
||||||
if (!block.getBlockType().getMaterial().isMovementBlocker() != state) {
|
if (block.getBlockType().getMaterial().isMovementBlocker() == state) {
|
||||||
int data = (state ? PropertyGroup.LEVEL.get(block) : data1);
|
return layer + offset << 4;
|
||||||
return ((layer + offset) << 4) + 0;
|
|
||||||
}
|
}
|
||||||
data1 = PropertyGroup.LEVEL.get(block);
|
data1 = PropertyGroup.LEVEL.get(block);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||||
block = getLazyBlock(x, layer, z);
|
block = getLazyBlock(x, layer, z);
|
||||||
if (!block.getBlockType().getMaterial().isMovementBlocker() != state) {
|
if (block.getBlockType().getMaterial().isMovementBlocker() == state) {
|
||||||
return ((layer - offset) << 4) - (15 - (state ? PropertyGroup.LEVEL.get(block) : data2));
|
return ((layer - offset) << 4) - (15 - (state ? PropertyGroup.LEVEL.get(block) : data2));
|
||||||
}
|
}
|
||||||
data2 = PropertyGroup.LEVEL.get(block);
|
data2 = PropertyGroup.LEVEL.get(block);
|
||||||
@ -243,8 +245,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int result = state ? failedMin : failedMax;
|
return state ? failedMin : failedMax;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
||||||
@ -258,21 +259,21 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
for (int d = 0; d <= clearance; d++) {
|
for (int d = 0; d <= clearance; d++) {
|
||||||
int y1 = y + d;
|
int y1 = y + d;
|
||||||
block = getLazyBlock(x, y1, z);
|
block = getLazyBlock(x, y1, z);
|
||||||
if (!block.getMaterial().isMovementBlocker() != state && block.getBlockType() != BlockTypes.__RESERVED__) return y1 - offset;
|
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return y1 - offset;
|
||||||
int y2 = y - d;
|
int y2 = y - d;
|
||||||
block = getLazyBlock(x, y2, z);
|
block = getLazyBlock(x, y2, z);
|
||||||
if (!block.getMaterial().isMovementBlocker() != state && block.getBlockType() != BlockTypes.__RESERVED__) return y2 + offset;
|
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return y2 + offset;
|
||||||
}
|
}
|
||||||
if (clearanceAbove != clearanceBelow) {
|
if (clearanceAbove != clearanceBelow) {
|
||||||
if (clearanceAbove < clearanceBelow) {
|
if (clearanceAbove < clearanceBelow) {
|
||||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||||
block = getLazyBlock(x, layer, z);
|
block = getLazyBlock(x, layer, z);
|
||||||
if (!block.getMaterial().isMovementBlocker() != state && block.getBlockType() != BlockTypes.__RESERVED__) return layer + offset;
|
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return layer + offset;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||||
block = getLazyBlock(x, layer, z);
|
block = getLazyBlock(x, layer, z);
|
||||||
if (!block.getMaterial().isMovementBlocker() != state && block.getBlockType() != BlockTypes.__RESERVED__) return layer - offset;
|
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return layer - offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,7 +295,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
default void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
||||||
spawnResource(region, new SchemGen(mask, this, clipboards, rotate), rarity, 1);
|
spawnResource(region, new SchemGen(mask, this, clipboards, rotate), rarity, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,11 +319,11 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
return (pt.containedWithin(min, max));
|
return (pt.containedWithin(min, max));
|
||||||
}
|
}
|
||||||
|
|
||||||
default public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
default void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||||
spawnResource(region, new OreGen(this, mask, material, size, minY, maxY), rarity, frequency);
|
spawnResource(region, new OreGen(this, mask, material, size, minY, maxY), rarity, frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
default public void addOres(Region region, Mask mask) throws WorldEditException {
|
default void addOres(Region region, Mask mask) throws WorldEditException {
|
||||||
addOre(region, mask, BlockTypes.DIRT.getDefaultState(), 33, 10, 100, 0, 255);
|
addOre(region, mask, BlockTypes.DIRT.getDefaultState(), 33, 10, 100, 0, 255);
|
||||||
addOre(region, mask, BlockTypes.GRAVEL.getDefaultState(), 33, 8, 100, 0, 255);
|
addOre(region, mask, BlockTypes.GRAVEL.getDefaultState(), 33, 8, 100, 0, 255);
|
||||||
addOre(region, mask, BlockTypes.ANDESITE.getDefaultState(), 33, 10, 100, 0, 79);
|
addOre(region, mask, BlockTypes.ANDESITE.getDefaultState(), 33, 10, 100, 0, 79);
|
||||||
@ -398,19 +399,6 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
return distribution;
|
return distribution;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lazily copy a region
|
|
||||||
*
|
|
||||||
* @param region
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
default BlockArrayClipboard lazyCopy(Region region) {
|
|
||||||
WorldCopyClipboard faweClipboard = new WorldCopyClipboard(this, region);
|
|
||||||
BlockArrayClipboard weClipboard = new BlockArrayClipboard(region, faweClipboard);
|
|
||||||
weClipboard.setOrigin(region.getMinimumPoint());
|
|
||||||
return weClipboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
default Operation commit() {
|
default Operation commit() {
|
||||||
|
@ -20,14 +20,11 @@
|
|||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,9 +58,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
|||||||
|
|
||||||
private Region region;
|
private Region region;
|
||||||
private BlockVector3 origin;
|
private BlockVector3 origin;
|
||||||
|
private BlockStateHolder[][][] blocks;
|
||||||
public FaweClipboard IMP;
|
public FaweClipboard IMP;
|
||||||
private BlockVector3 size;
|
private BlockVector3 size;
|
||||||
private BlockStateHolder[][][] blocks;
|
|
||||||
private final List<ClipboardEntity> entities = new ArrayList<>();
|
private final List<ClipboardEntity> entities = new ArrayList<>();
|
||||||
|
|
||||||
public BlockArrayClipboard(Region region) {
|
public BlockArrayClipboard(Region region) {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.extent.clipboard;
|
package com.sk89q.worldedit.extent.clipboard;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
@ -59,15 +58,4 @@ public interface Clipboard extends Extent {
|
|||||||
*/
|
*/
|
||||||
void setOrigin(BlockVector3 origin);
|
void setOrigin(BlockVector3 origin);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)}
|
|
||||||
* strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes.OCEAN} instead of {@code null}
|
|
||||||
* if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting
|
|
||||||
* to ocean, instead of having biomes explicitly set.
|
|
||||||
*
|
|
||||||
* @return true if the clipboard has biome data set
|
|
||||||
*/
|
|
||||||
default boolean hasBiomes() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,21 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.clipboard.io;
|
package com.sk89q.worldedit.extent.clipboard.io;
|
||||||
|
|
||||||
|
import com.boydti.fawe.config.Settings;
|
||||||
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||||
|
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||||
|
import com.boydti.fawe.object.schematic.Schematic;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -29,23 +44,6 @@ import java.net.URL;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
|
||||||
import com.boydti.fawe.config.Settings;
|
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
|
||||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
|
||||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
|
||||||
import com.boydti.fawe.util.MainUtil;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of supported clipboard formats.
|
* A collection of supported clipboard formats.
|
||||||
*/
|
*/
|
||||||
@ -111,10 +109,9 @@ public interface ClipboardFormat {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param uri
|
* @param uri
|
||||||
* @param in
|
* @param in
|
||||||
* @return the held clipboard
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
default ClipboardHolder hold(Player player, URI uri, InputStream in) throws IOException {
|
default void hold(Player player, URI uri, InputStream in) throws IOException {
|
||||||
checkNotNull(player);
|
checkNotNull(player);
|
||||||
checkNotNull(uri);
|
checkNotNull(uri);
|
||||||
checkNotNull(in);
|
checkNotNull(in);
|
||||||
@ -128,7 +125,6 @@ public interface ClipboardFormat {
|
|||||||
clipboard = reader.read(player.getUniqueId());
|
clipboard = reader.read(player.getUniqueId());
|
||||||
URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard);
|
URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard);
|
||||||
session.setClipboard(holder);
|
session.setClipboard(holder);
|
||||||
return holder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default Schematic load(File file) throws IOException {
|
default Schematic load(File file) throws IOException {
|
||||||
|
@ -284,7 +284,6 @@ public class ClipboardFormats {
|
|||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
while ((entry = zip.getNextEntry()) != null) {
|
while ((entry = zip.getNextEntry()) != null) {
|
||||||
String filename = entry.getName();
|
String filename = entry.getName();
|
||||||
String extension = filename.substring(filename.lastIndexOf('.') + 1, filename.length());
|
|
||||||
ClipboardFormat format = findByExtension(filename);
|
ClipboardFormat format = findByExtension(filename);
|
||||||
if (format != null) {
|
if (format != null) {
|
||||||
FastByteArrayOutputStream out = new FastByteArrayOutputStream();
|
FastByteArrayOutputStream out = new FastByteArrayOutputStream();
|
||||||
|
@ -29,7 +29,6 @@ import com.sk89q.jnbt.ShortTag;
|
|||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
@ -22,21 +22,14 @@ package com.sk89q.worldedit.extent.clipboard.io;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.jnbt.CorruptSchematicStreamer;
|
import com.boydti.fawe.jnbt.CorruptSchematicStreamer;
|
||||||
import com.boydti.fawe.jnbt.SchematicStreamer;
|
import com.boydti.fawe.jnbt.SchematicStreamer;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads schematic files based that are compatible with MCEdit and other editors.
|
* Reads schematic files based that are compatible with MCEdit and other editors.
|
||||||
@ -75,36 +68,6 @@ public class SchematicReader implements ClipboardReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends Tag> T requireTag(Map<String, Tag> items, String key, Class<T> expected) throws IOException {
|
|
||||||
if (!items.containsKey(key)) {
|
|
||||||
throw new IOException("Schematic file is missing a \"" + key + "\" tag");
|
|
||||||
}
|
|
||||||
|
|
||||||
Tag tag = items.get(key);
|
|
||||||
if (!expected.isInstance(tag)) {
|
|
||||||
throw new IOException(key + " tag is not of tag type " + expected.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return expected.cast(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static <T extends Tag> T getTag(CompoundTag tag, Class<T> expected, String key) {
|
|
||||||
Map<String, Tag> items = tag.getValue();
|
|
||||||
|
|
||||||
if (!items.containsKey(key)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tag test = items.get(key);
|
|
||||||
if (!expected.isInstance(test)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return expected.cast(test);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
@ -249,7 +249,6 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.extent.clipboard.io;
|
|||||||
|
|
||||||
import com.boydti.fawe.object.clipboard.FaweClipboard;
|
import com.boydti.fawe.object.clipboard.FaweClipboard;
|
||||||
import com.boydti.fawe.util.IOUtil;
|
import com.boydti.fawe.util.IOUtil;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.DoubleTag;
|
import com.sk89q.jnbt.DoubleTag;
|
||||||
import com.sk89q.jnbt.FloatTag;
|
import com.sk89q.jnbt.FloatTag;
|
||||||
@ -33,12 +35,12 @@ import com.sk89q.jnbt.Tag;
|
|||||||
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.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -55,9 +57,6 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes schematic files using the Sponge schematic format.
|
* Writes schematic files using the Sponge schematic format.
|
||||||
@ -82,8 +81,13 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
write1(clipboard);
|
write1(clipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write1(Clipboard clipboard) throws IOException {
|
/**
|
||||||
// metadata
|
* Writes a version 1 schematic file.
|
||||||
|
*
|
||||||
|
* @param clipboard The clipboard
|
||||||
|
* @throws IOException If an error occurs
|
||||||
|
*/
|
||||||
|
private void write1(Clipboard clipboard) throws IOException {
|
||||||
Region region = clipboard.getRegion();
|
Region region = clipboard.getRegion();
|
||||||
BlockVector3 origin = clipboard.getOrigin();
|
BlockVector3 origin = clipboard.getOrigin();
|
||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
@ -91,6 +95,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
int width = region.getWidth();
|
int width = region.getWidth();
|
||||||
int height = region.getHeight();
|
int height = region.getHeight();
|
||||||
int length = region.getLength();
|
int length = region.getLength();
|
||||||
|
|
||||||
if (width > MAX_SIZE) {
|
if (width > MAX_SIZE) {
|
||||||
throw new IllegalArgumentException("Width of region too large for a .schematic");
|
throw new IllegalArgumentException("Width of region too large for a .schematic");
|
||||||
}
|
}
|
||||||
@ -100,13 +105,15 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
if (length > MAX_SIZE) {
|
if (length > MAX_SIZE) {
|
||||||
throw new IllegalArgumentException("Length of region too large for a .schematic");
|
throw new IllegalArgumentException("Length of region too large for a .schematic");
|
||||||
}
|
}
|
||||||
// output
|
|
||||||
final DataOutput rawStream = outputStream.getOutputStream();
|
final DataOutput rawStream = outputStream.getOutputStream();
|
||||||
outputStream.writeLazyCompoundTag("Schematic", out -> {
|
outputStream.writeLazyCompoundTag("Schematic", out -> {
|
||||||
out.writeNamedTag("Version", 1);
|
out.writeNamedTag("Version", 1);
|
||||||
out.writeNamedTag("Width", (short) width);
|
out.writeNamedTag("Width", (short) width);
|
||||||
out.writeNamedTag("Height", (short) height);
|
out.writeNamedTag("Height", (short) height);
|
||||||
out.writeNamedTag("Length", (short) length);
|
out.writeNamedTag("Length", (short) length);
|
||||||
|
|
||||||
|
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
|
||||||
out.writeNamedTag("Offset", new int[]{
|
out.writeNamedTag("Offset", new int[]{
|
||||||
min.getBlockX(),
|
min.getBlockX(),
|
||||||
min.getBlockY(),
|
min.getBlockY(),
|
||||||
@ -124,7 +131,6 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
|
|
||||||
ByteArrayOutputStream tilesCompressed = new ByteArrayOutputStream();
|
ByteArrayOutputStream tilesCompressed = new ByteArrayOutputStream();
|
||||||
NBTOutputStream tilesOut = new NBTOutputStream(new LZ4BlockOutputStream(tilesCompressed));
|
NBTOutputStream tilesOut = new NBTOutputStream(new LZ4BlockOutputStream(tilesCompressed));
|
||||||
int[] numTiles = {0};
|
|
||||||
|
|
||||||
List<Integer> paletteList = new ArrayList<>();
|
List<Integer> paletteList = new ArrayList<>();
|
||||||
char[] palette = new char[BlockTypes.states.length];
|
char[] palette = new char[BlockTypes.states.length];
|
||||||
@ -132,20 +138,26 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
int[] paletteMax = {0};
|
int[] paletteMax = {0};
|
||||||
|
|
||||||
|
|
||||||
|
int[] numTiles = {0};
|
||||||
FaweClipboard.BlockReader reader = new FaweClipboard.BlockReader() {
|
FaweClipboard.BlockReader reader = new FaweClipboard.BlockReader() {
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
||||||
try {
|
try {
|
||||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
|
if (block.getNbtData() != null) {
|
||||||
BaseBlock localBlock = (BaseBlock) block;
|
BaseBlock localBlock = (BaseBlock) block;
|
||||||
Map<String, Tag> values = localBlock.getNbtData().getValue();
|
Map<String, Tag> values = localBlock.getNbtData().getValue();
|
||||||
|
|
||||||
values.remove("id"); // Remove 'id' if it exists. We want 'Id'
|
values.remove("id"); // Remove 'id' if it exists. We want 'Id'
|
||||||
|
|
||||||
// Positions are kept in NBT, we don't want that.
|
// Positions are kept in NBT, we don't want that.
|
||||||
values.remove("x");
|
values.remove("x");
|
||||||
values.remove("y");
|
values.remove("y");
|
||||||
values.remove("z");
|
values.remove("z");
|
||||||
if (!values.containsKey("Id")) values.put("Id", new StringTag(localBlock.getNbtId()));
|
if (!values.containsKey("Id")) {
|
||||||
|
values.put("Id", new StringTag(block.getNbtId()));
|
||||||
|
}
|
||||||
values.put("Pos", new IntArrayTag(new int[]{
|
values.put("Pos", new IntArrayTag(new int[]{
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
@ -154,6 +166,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
numTiles[0]++;
|
numTiles[0]++;
|
||||||
tilesOut.writeTagPayload(localBlock.getNbtData());
|
tilesOut.writeTagPayload(localBlock.getNbtData());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
int ordinal = block.getOrdinal();
|
int ordinal = block.getOrdinal();
|
||||||
char value = palette[ordinal];
|
char value = palette[ordinal];
|
||||||
if (value == Character.MAX_VALUE) {
|
if (value == Character.MAX_VALUE) {
|
||||||
@ -185,9 +198,9 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
// close
|
// close
|
||||||
tilesOut.close();
|
tilesOut.close();
|
||||||
blocksOut.close();
|
blocksOut.close();
|
||||||
// palette max
|
|
||||||
out.writeNamedTag("PaletteMax", paletteMax[0]);
|
out.writeNamedTag("PaletteMax", paletteMax[0]);
|
||||||
// palette
|
|
||||||
out.writeLazyCompoundTag("Palette", out12 -> {
|
out.writeLazyCompoundTag("Palette", out12 -> {
|
||||||
for (int i = 0; i < paletteList.size(); i++) {
|
for (int i = 0; i < paletteList.size(); i++) {
|
||||||
int stateOrdinal = paletteList.get(i);
|
int stateOrdinal = paletteList.get(i);
|
||||||
@ -195,13 +208,13 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
out12.writeNamedTag(state.getAsString(), i);
|
out12.writeNamedTag(state.getAsString(), i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Block data
|
|
||||||
out.writeNamedTagName("BlockData", NBTConstants.TYPE_BYTE_ARRAY);
|
out.writeNamedTagName("BlockData", NBTConstants.TYPE_BYTE_ARRAY);
|
||||||
rawStream.writeInt(blocksOut.size());
|
rawStream.writeInt(blocksOut.size());
|
||||||
try (LZ4BlockInputStream in = new LZ4BlockInputStream(new ByteArrayInputStream(blocksCompressed.toByteArray()))) {
|
try (LZ4BlockInputStream in = new LZ4BlockInputStream(new ByteArrayInputStream(blocksCompressed.toByteArray()))) {
|
||||||
IOUtil.copy(in, rawStream);
|
IOUtil.copy(in, rawStream);
|
||||||
}
|
}
|
||||||
// tiles
|
|
||||||
if (numTiles[0] != 0) {
|
if (numTiles[0] != 0) {
|
||||||
out.writeNamedTagName("TileEntities", NBTConstants.TYPE_LIST);
|
out.writeNamedTagName("TileEntities", NBTConstants.TYPE_LIST);
|
||||||
rawStream.write(NBTConstants.TYPE_COMPOUND);
|
rawStream.write(NBTConstants.TYPE_COMPOUND);
|
||||||
@ -213,14 +226,12 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
out.writeNamedEmptyList("TileEntities");
|
out.writeNamedEmptyList("TileEntities");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Tag> entities = new ArrayList<>();
|
||||||
// Entities
|
|
||||||
List<Tag> entities = new ArrayList<Tag>();
|
|
||||||
for (Entity entity : clipboard.getEntities()) {
|
for (Entity entity : clipboard.getEntities()) {
|
||||||
BaseEntity state = entity.getState();
|
BaseEntity state = entity.getState();
|
||||||
|
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<>();
|
||||||
|
|
||||||
// Put NBT provided data
|
// Put NBT provided data
|
||||||
CompoundTag rawTag = state.getNbtData();
|
CompoundTag rawTag = state.getNbtData();
|
||||||
@ -246,7 +257,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Tag writeVector(Vector3 vector, String name) {
|
private static Tag writeVector(Vector3 vector, String name) {
|
||||||
List<DoubleTag> list = new ArrayList<DoubleTag>();
|
List<DoubleTag> list = new ArrayList<>();
|
||||||
list.add(new DoubleTag(vector.getX()));
|
list.add(new DoubleTag(vector.getX()));
|
||||||
list.add(new DoubleTag(vector.getY()));
|
list.add(new DoubleTag(vector.getY()));
|
||||||
list.add(new DoubleTag(vector.getZ()));
|
list.add(new DoubleTag(vector.getZ()));
|
||||||
@ -254,7 +265,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Tag writeRotation(Location location, String name) {
|
private static Tag writeRotation(Location location, String name) {
|
||||||
List<FloatTag> list = new ArrayList<FloatTag>();
|
List<FloatTag> list = new ArrayList<>();
|
||||||
list.add(new FloatTag(location.getYaw()));
|
list.add(new FloatTag(location.getYaw()));
|
||||||
list.add(new FloatTag(location.getPitch()));
|
list.add(new FloatTag(location.getPitch()));
|
||||||
return new ListTag(FloatTag.class, list);
|
return new ListTag(FloatTag.class, list);
|
||||||
|
@ -1,557 +0,0 @@
|
|||||||
package com.sk89q.worldedit.extent.clipboard.io;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.object.collection.SoftHashMap;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
public class WavefrontReader implements ClipboardReader {
|
|
||||||
private final InputStream inputStream;
|
|
||||||
private final File root;
|
|
||||||
|
|
||||||
private final Map<String, BufferedImage> textures = new SoftHashMap<>();
|
|
||||||
private final Map<String, Map<String, Material>> materialFiles = new HashMap<>();
|
|
||||||
private final Map<String, Material> materials = new HashMap<>();
|
|
||||||
|
|
||||||
public WavefrontReader(File file) throws FileNotFoundException {
|
|
||||||
this.inputStream = new BufferedInputStream(new FileInputStream(file));
|
|
||||||
File parent = file.getParentFile();
|
|
||||||
this.root = parent == null ? new File(".") : parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static double parse(String s) {
|
|
||||||
int len = s.length();
|
|
||||||
int index;
|
|
||||||
int numIndex = 1;
|
|
||||||
|
|
||||||
double neg;
|
|
||||||
|
|
||||||
if (s.charAt(0) == '-') {
|
|
||||||
neg = -1;
|
|
||||||
index = 1;
|
|
||||||
} else {
|
|
||||||
index = 0;
|
|
||||||
neg = 1;
|
|
||||||
}
|
|
||||||
double val = 0;
|
|
||||||
outer:
|
|
||||||
for (; index < len; index++) {
|
|
||||||
char c = s.charAt(index);
|
|
||||||
switch (c) {
|
|
||||||
case ' ': break outer;
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
val = val * 10 + (c - 48);
|
|
||||||
continue;
|
|
||||||
case '.': {
|
|
||||||
double factor = 0.1;
|
|
||||||
for (; index < len; index++) {
|
|
||||||
c = s.charAt(index);
|
|
||||||
switch (c) {
|
|
||||||
case ' ': break outer;
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
val += ((c - 48) * factor);
|
|
||||||
factor *= 0.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return val * neg;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Clipboard read() throws IOException {
|
|
||||||
try (InputStream finalStream = inputStream) {
|
|
||||||
load(finalStream);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final BufferedImage getTexture(String file) throws IOException {
|
|
||||||
BufferedImage texture = textures.get(file);
|
|
||||||
if (texture == null) {
|
|
||||||
texture = ImageIO.read(new File(root, file));
|
|
||||||
textures.put(file, texture);
|
|
||||||
}
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readLines(InputStream stream, Consumer<String> onEachLine, boolean nullTerminate) throws IOException {
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
|
|
||||||
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
|
||||||
if (line.isEmpty() || line.charAt(0) == '#') continue;
|
|
||||||
onEachLine.accept(line);
|
|
||||||
}
|
|
||||||
if (nullTerminate) onEachLine.accept(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int toIntColor(float color) {
|
|
||||||
return (int) (color * 256 + 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFileName(String arg) {
|
|
||||||
String[] pathSplit = arg.split("[/|\\\\]");
|
|
||||||
return pathSplit[pathSplit.length - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Material {
|
|
||||||
private double dissolve = 1;
|
|
||||||
private int color = Integer.MIN_VALUE;
|
|
||||||
private String texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final void loadMaterials(String fileName) throws IOException {
|
|
||||||
File file = new File(root, fileName);
|
|
||||||
if (!file.exists()) {
|
|
||||||
Fawe.debug(".mtl not found: " + fileName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Map<String, Material> mtl = materialFiles.get(fileName);
|
|
||||||
if (mtl == null) {
|
|
||||||
final Map<String, Material> tmp = mtl = new HashMap<>();
|
|
||||||
materialFiles.put(fileName, tmp);
|
|
||||||
readLines(new FileInputStream(file), new Consumer<String>() {
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private Material material;
|
|
||||||
private int index;
|
|
||||||
|
|
||||||
private void add() {
|
|
||||||
if (material != null) {
|
|
||||||
if (material.color == Integer.MIN_VALUE) {
|
|
||||||
material.color = -1;
|
|
||||||
}
|
|
||||||
tmp.put(name, material);
|
|
||||||
material = null;
|
|
||||||
name = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(String s) {
|
|
||||||
if (s == null) {
|
|
||||||
add();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String[] args = s.split("[ ]+");
|
|
||||||
switch (args[0]) {
|
|
||||||
// Name
|
|
||||||
case "newmtl": {
|
|
||||||
add();
|
|
||||||
material = new Material();
|
|
||||||
name = args[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Color
|
|
||||||
case "Ka":
|
|
||||||
if (material.color != Integer.MIN_VALUE) break;
|
|
||||||
case "Kd": {
|
|
||||||
float r = Float.parseFloat(args[1]);
|
|
||||||
float g = Float.parseFloat(args[2]);
|
|
||||||
float b = Float.parseFloat(args[3]);
|
|
||||||
material.color = (toIntColor(r) << 16) + (toIntColor(g) << 8) + toIntColor(b);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Density
|
|
||||||
case "d": {
|
|
||||||
material.dissolve = Double.parseDouble(args[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Tr": {
|
|
||||||
material.dissolve = 1.0 - Double.parseDouble(args[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "map_Ka":
|
|
||||||
if (material.texture != null) break;
|
|
||||||
case "map_Kd": {
|
|
||||||
material.texture = getFileName(args[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
materials.putAll(mtl);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Material getMaterial(String name) {
|
|
||||||
Material mtl = materials.get(name);
|
|
||||||
return mtl != null ? mtl : new Material();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void load(InputStream in) throws IOException {
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
|
|
||||||
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
|
||||||
if (line.isEmpty()) continue;
|
|
||||||
char char0 = line.charAt(0);
|
|
||||||
switch (char0) {
|
|
||||||
case '#': continue;
|
|
||||||
case 'v':
|
|
||||||
switch (line.charAt(1)) {
|
|
||||||
case ' ':
|
|
||||||
case 'n': {
|
|
||||||
Double.parseDouble("");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 't': {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'f': {
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'l':
|
|
||||||
case 's':
|
|
||||||
case 'o':
|
|
||||||
case 'g':
|
|
||||||
// Ignore
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
String[] args = line.split(" ");
|
|
||||||
switch (args[0]) {
|
|
||||||
case "mtllib": {
|
|
||||||
String[] pathSplit = args[1].split("[/|\\\\]");
|
|
||||||
String fileName = pathSplit[pathSplit.length - 1];
|
|
||||||
loadMaterials(fileName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// final File directory = file.getParentFile();
|
|
||||||
// final Map<String, SimpleMaterial> materials = new HashMap<String, SimpleMaterial>();
|
|
||||||
// final Map<Face, BufferedImage> textures = new HashMap<Face, BufferedImage>();
|
|
||||||
// final Map<Face, Color> colors = new HashMap<Face, Color>();
|
|
||||||
// final List<Vertex> v = new LinkedList<Vertex>();
|
|
||||||
// final List<VertexTexture> vt = new LinkedList<VertexTexture>();
|
|
||||||
// final List<Vertex> vn = new LinkedList<Vertex>();
|
|
||||||
// final List<Face> f = new LinkedList<Face>();
|
|
||||||
// final List<String[]> obj = new LinkedList<String[]>();
|
|
||||||
// for (final String[] entry : obj) {
|
|
||||||
// if (entry[0].equals("v") || entry[0].equals("vn")) {
|
|
||||||
// if (entry.length == 1) {
|
|
||||||
// VLogger.log("[ERROR] Invalid vertex or vertex normal entry found (no data)");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// double x;
|
|
||||||
// double y;
|
|
||||||
// double z;
|
|
||||||
// try {
|
|
||||||
// x = Double.parseDouble(entry[1]);
|
|
||||||
// y = Double.parseDouble(entry[2]);
|
|
||||||
// z = Double.parseDouble(entry[3]);
|
|
||||||
// }
|
|
||||||
// catch (NumberFormatException | ArrayIndexOutOfBoundsException ex8) {
|
|
||||||
// final RuntimeException ex5;
|
|
||||||
// final RuntimeException ex = ex5;
|
|
||||||
// VLogger.log("[ERROR] Invalid vertex or vertex normal entry found (not parseable data)");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// if (entry[0].equals("v")) {
|
|
||||||
// if (entry.length >= 6) {
|
|
||||||
// try {
|
|
||||||
// final float r = Float.parseFloat(entry[4]);
|
|
||||||
// final float g = Float.parseFloat(entry[5]);
|
|
||||||
// final float b = Float.parseFloat(entry[6]);
|
|
||||||
// final Color c = new Color(r, g, b);
|
|
||||||
// v.add(new Vertex(x, y, z, v.size() + 1, c));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// catch (NumberFormatException | ArrayIndexOutOfBoundsException ex9) {
|
|
||||||
// final RuntimeException ex6;
|
|
||||||
// final RuntimeException ex = ex6;
|
|
||||||
// VLogger.log("[ERROR] Invalid vertex color (not parseable data)");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// v.add(new Vertex(x, y, z, v.size() + 1));
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// vn.add(new Vertex(x, y, z, vn.size() + 1));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// if (!entry[0].equals("vt")) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (entry.length == 1) {
|
|
||||||
// VLogger.log("[ERROR] Invalid vertex texture entry found (no data)");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// double vt_u;
|
|
||||||
// double vt_v;
|
|
||||||
// try {
|
|
||||||
// vt_u = Double.parseDouble(entry[1]);
|
|
||||||
// vt_v = Double.parseDouble(entry[2]);
|
|
||||||
// if (vt_u < 0.0 || vt_v < 0.0 || vt_u > 1.0 || vt_v > 1.0) {
|
|
||||||
// VLogger.log("[ERROR] UV of vertex texture out of bounds");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch (NumberFormatException | ArrayIndexOutOfBoundsException ex10) {
|
|
||||||
// final RuntimeException ex7;
|
|
||||||
// final RuntimeException ex2 = ex7;
|
|
||||||
// VLogger.log("[ERROR] Invalid vertex texture entry found (not parseable data)");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// vt.add(new VertexTexture(vt_u, vt_v, vn.size() + 1));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// VLogger.log("[IMPORT] Loaded " + v.size() + " vertexes");
|
|
||||||
// VLogger.log("[IMPORT] Loaded " + vt.size() + " vertex textures");
|
|
||||||
// VLogger.log("[IMPORT] Loaded " + vn.size() + " vertex normals");
|
|
||||||
// BufferedImage usemtl_texture = null;
|
|
||||||
// Color usemtl_color = null;
|
|
||||||
// for (final String[] entry2 : obj) {
|
|
||||||
// if (entry2[0].equals("usemtl")) {
|
|
||||||
// if (entry2.length == 1) {
|
|
||||||
// VLogger.log("[ERROR] Invalid usemtl entry");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// SimpleMaterial material = (SimpleMaterial)materials.get(entry2[1]);
|
|
||||||
// if (material == null) {
|
|
||||||
// VLogger.log("[WARN] Material '" + entry2[1] + "' does not exist");
|
|
||||||
// material = getFallbackMaterial();
|
|
||||||
// VLogger.log("[WARN] Replacing with fallback material");
|
|
||||||
// }
|
|
||||||
// usemtl_texture = material.texture;
|
|
||||||
// usemtl_color = material.color;
|
|
||||||
// VLogger.log("[IMPORT] Now using material '" + entry2[1] + "'");
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// if (!entry2[0].equals("f")) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (entry2.length == 1) {
|
|
||||||
// VLogger.log("[ERROR] Invalid face entry (no arguments)");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// if (usemtl_texture == null && usemtl_color == null) {
|
|
||||||
// VLogger.log("[WARN] Current Material has neither a texture nor a color");
|
|
||||||
// usemtl_color = Colors.getGray(1.0f);
|
|
||||||
// VLogger.log("[WARN] Using fallback color");
|
|
||||||
// }
|
|
||||||
// final Collection<FacePoint> points = new LinkedList<FacePoint>();
|
|
||||||
// for (int i = 1; i < entry2.length; ++i) {
|
|
||||||
// final String[] comp = entry2[i].split("/");
|
|
||||||
// Integer comp_v;
|
|
||||||
// Integer comp_vt;
|
|
||||||
// Integer comp_vn;
|
|
||||||
// try {
|
|
||||||
// comp_v = Integer.parseInt(comp[0]);
|
|
||||||
// comp_vt = ((comp.length <= 1 || comp[1].isEmpty()) ? null : Integer.parseInt(comp[1]));
|
|
||||||
// comp_vn = ((comp.length <= 2 || comp[2].isEmpty()) ? null : Integer.parseInt(comp[2]));
|
|
||||||
// }
|
|
||||||
// catch (NumberFormatException ex3) {
|
|
||||||
// final StringBuilder debug = new StringBuilder();
|
|
||||||
// String[] array;
|
|
||||||
// for (int length = (array = comp).length, j = 0; j < length; ++j) {
|
|
||||||
// final String segment = array[j];
|
|
||||||
// debug.append(segment);
|
|
||||||
// debug.append("/");
|
|
||||||
// }
|
|
||||||
// VLogger.log("[ERROR] Face point failed to load (" + (Object)debug + ")");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// final FacePoint point = new FacePoint();
|
|
||||||
// point.v = v.get((int)comp_v - 1);
|
|
||||||
// point.vt = ((comp_vt == null) ? null : ((VertexTexture)vt.get((int)comp_vt - 1)));
|
|
||||||
// point.vn = ((comp_vn == null) ? null : ((Vertex)vn.get((int)comp_vn - 1)));
|
|
||||||
// points.add(point);
|
|
||||||
// }
|
|
||||||
// catch (IndexOutOfBoundsException ex4) {
|
|
||||||
// VLogger.log("[ERROR] Face point reference to missing vertex");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// final Face face = new Face(points);
|
|
||||||
// f.add(face);
|
|
||||||
// if (usemtl_texture != null) {
|
|
||||||
// textures.put(face, usemtl_texture);
|
|
||||||
// }
|
|
||||||
// if (usemtl_color == null) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// colors.put(face, usemtl_color);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// double minX = Double.MAX_VALUE;
|
|
||||||
// double minY = Double.MAX_VALUE;
|
|
||||||
// double minZ = Double.MAX_VALUE;
|
|
||||||
// double maxX = -1.7976931348623157E308;
|
|
||||||
// double maxY = -1.7976931348623157E308;
|
|
||||||
// double maxZ = -1.7976931348623157E308;
|
|
||||||
// for (final Face face2 : f) {
|
|
||||||
// for (final FacePoint point2 : face2.points) {
|
|
||||||
// final double x2 = point2.v.getX();
|
|
||||||
// final double y2 = point2.v.getY();
|
|
||||||
// final double z2 = point2.v.getZ();
|
|
||||||
// if (x2 < minX) {
|
|
||||||
// minX = x2;
|
|
||||||
// }
|
|
||||||
// else if (x2 > maxX) {
|
|
||||||
// maxX = x2;
|
|
||||||
// }
|
|
||||||
// if (y2 < minY) {
|
|
||||||
// minY = y2;
|
|
||||||
// }
|
|
||||||
// else if (y2 > maxY) {
|
|
||||||
// maxY = y2;
|
|
||||||
// }
|
|
||||||
// if (z2 < minZ) {
|
|
||||||
// minZ = z2;
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// if (z2 <= maxZ) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// maxZ = z2;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// final double size = Math.max(maxX - minX, Math.max(maxY - minY, maxZ - minZ));
|
|
||||||
// final double scale = size / (resolution - 1.0);
|
|
||||||
// final List<Face> polygons = new LinkedList<Face>();
|
|
||||||
// for (final Face face3 : f) {
|
|
||||||
// polygons.addAll(shatterFace(face3, colors, textures));
|
|
||||||
// }
|
|
||||||
// VLogger.log("[IMPORT] " + f.size() + " faces -> " + polygons.size() + " polygons");
|
|
||||||
// final Map<Position3D, Color> colormap = new HashMap<Position3D, Color>();
|
|
||||||
// for (final Face poly : polygons) {
|
|
||||||
// final FacePoint a = (FacePoint)poly.points.get(0);
|
|
||||||
// final FacePoint b2 = (FacePoint)poly.points.get(1);
|
|
||||||
// final FacePoint c2 = (FacePoint)poly.points.get(2);
|
|
||||||
// final Vector3D vAB = new Vector3D((Point3D)a.v, (Point3D)b2.v);
|
|
||||||
// final Vector3D vAC = new Vector3D((Point3D)a.v, (Point3D)c2.v);
|
|
||||||
// final float lAB = (float)vAB.length();
|
|
||||||
// final float lAC = (float)vAC.length();
|
|
||||||
// double[] array3;
|
|
||||||
// if (a.vt == null || b2.vt == null) {
|
|
||||||
// final double[] array2 = array3 = new double[2];
|
|
||||||
// array2[1] = (array2[0] = 0.0);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// final double[] array4 = array3 = new double[2];
|
|
||||||
// array4[0] = b2.vt.u - a.vt.u;
|
|
||||||
// array4[1] = b2.vt.v - a.vt.v;
|
|
||||||
// }
|
|
||||||
// final double[] uvAB = array3;
|
|
||||||
// double[] array6;
|
|
||||||
// if (a.vt == null || c2.vt == null) {
|
|
||||||
// final double[] array5 = array6 = new double[2];
|
|
||||||
// array5[1] = (array5[0] = 0.0);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// final double[] array7 = array6 = new double[2];
|
|
||||||
// array7[0] = c2.vt.u - a.vt.u;
|
|
||||||
// array7[1] = c2.vt.v - a.vt.v;
|
|
||||||
// }
|
|
||||||
// final double[] uvAC = array6;
|
|
||||||
// double[] array9;
|
|
||||||
// if (a.vt == null) {
|
|
||||||
// final double[] array8 = array9 = new double[2];
|
|
||||||
// array8[1] = (array8[0] = 0.0);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// final double[] array10 = array9 = new double[2];
|
|
||||||
// array10[0] = a.vt.u;
|
|
||||||
// array10[1] = a.vt.v;
|
|
||||||
// }
|
|
||||||
// final double[] uvA = array9;
|
|
||||||
// final Vector3D i2 = vAB.clone();
|
|
||||||
// i2.normalize();
|
|
||||||
// i2.multiply(scale);
|
|
||||||
// final Vector3D i3 = vAC.clone();
|
|
||||||
// i3.normalize();
|
|
||||||
// i3.multiply(scale);
|
|
||||||
// final BufferedImage texture = (BufferedImage)textures.get(poly);
|
|
||||||
// final Color poly_color = (Color)colors.get(poly);
|
|
||||||
// final int maxW = (texture == null) ? 0 : (texture.getWidth() - 1);
|
|
||||||
// final int maxH = (texture == null) ? 0 : (texture.getHeight() - 1);
|
|
||||||
// final double l = scale / 2.0;
|
|
||||||
// for (float aloop = 0.0f; aloop < lAB; aloop += l) {
|
|
||||||
// for (float bloop = 0.0f; bloop < lAC; bloop += l) {
|
|
||||||
// final float ratio1 = aloop / lAB;
|
|
||||||
// final float ratio2 = bloop / lAC;
|
|
||||||
// if (ratio1 + ratio2 > 1.0f) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// final Point3D point3 = a.v.clone();
|
|
||||||
// point3.add(vAB.clone().multiply((double)ratio1));
|
|
||||||
// point3.add(vAC.clone().multiply((double)ratio2));
|
|
||||||
// final double colorU = uvA[0] + uvAB[0] * ratio1 + uvAC[0] * ratio2;
|
|
||||||
// final double colorV = uvA[1] + uvAB[1] * ratio1 + uvAC[1] * ratio2;
|
|
||||||
// Color pointcolor = null;
|
|
||||||
// if (texture == null) {
|
|
||||||
// if (poly.hasVertexColors()) {
|
|
||||||
// final WeightedColor cA = new WeightedColor(a.v.getColor().getRGB(), 1.0f - ratio1 - ratio2);
|
|
||||||
// final WeightedColor cB = new WeightedColor(b2.v.getColor().getRGB(), ratio1);
|
|
||||||
// final WeightedColor cC = new WeightedColor(c2.v.getColor().getRGB(), ratio2);
|
|
||||||
// pointcolor = Colors.blendColors(new WeightedColor[] { cA, cB, cC });
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// pointcolor = poly_color;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// pointcolor = new Color(texture.getRGB((int)Math.floor((double)maxW * colorU), (int)Math.floor((double)maxH - maxH * colorV)), true);
|
|
||||||
// }
|
|
||||||
// if (pointcolor.getAlpha() != 0) {
|
|
||||||
// point3.divide(scale);
|
|
||||||
// colormap.put(point3.toPositionRound(), pointcolor);
|
|
||||||
// colormap.put(point3.toPositionFloor(), pointcolor);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// VLogger.log("[IMPORT] Import complete, loaded " + f.size() + " faces");
|
|
||||||
// VLogger.log("[IMPORT] Import complete, created " + colormap.size() + " voxels");
|
|
||||||
// return new VoxelBox(colormap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.extent.clipboard.io.legacycompat;
|
package com.sk89q.worldedit.extent.clipboard.io.legacycompat;
|
||||||
|
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -26,8 +26,6 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.world.block.BlockID;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
@ -37,13 +35,7 @@ public class SignCompatibilityHandler implements NBTCompatibilityHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean isAffectedBlock(B block) {
|
public <B extends BlockStateHolder<B>> boolean isAffectedBlock(B block) {
|
||||||
switch (block.getBlockType().getInternalId()) {
|
return block.getBlockType() == BlockTypes.SIGN || block.getBlockType() == BlockTypes.WALL_SIGN;
|
||||||
case BlockID.SIGN:
|
|
||||||
case BlockID.WALL_SIGN:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -27,23 +26,17 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a {@link BlockBag} to operations.
|
* Applies a {@link BlockBag} to operations.
|
||||||
*/
|
*/
|
||||||
public class BlockBagExtent extends AbstractDelegateExtent {
|
public class BlockBagExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
private final boolean mine;
|
private Map<BlockType, Integer> missingBlocks = new HashMap<>();
|
||||||
private int[] missingBlocks = new int[BlockTypes.size()];
|
|
||||||
private BlockBag blockBag;
|
private BlockBag blockBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,15 +45,9 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param blockBag the block bag
|
* @param blockBag the block bag
|
||||||
*/
|
*/
|
||||||
public BlockBagExtent(Extent extent, @Nonnull BlockBag blockBag) {
|
public BlockBagExtent(Extent extent, @Nullable BlockBag blockBag) {
|
||||||
this(extent, blockBag, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockBagExtent(Extent extent, @Nonnull BlockBag blockBag, boolean mine) {
|
|
||||||
super(extent);
|
super(extent);
|
||||||
checkNotNull(blockBag);
|
|
||||||
this.blockBag = blockBag;
|
this.blockBag = blockBag;
|
||||||
this.mine = mine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,39 +75,31 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
* @return a map of missing blocks
|
* @return a map of missing blocks
|
||||||
*/
|
*/
|
||||||
public Map<BlockType, Integer> popMissing() {
|
public Map<BlockType, Integer> popMissing() {
|
||||||
HashMap<BlockType, Integer> map = new HashMap<>();
|
Map<BlockType, Integer> missingBlocks = this.missingBlocks;
|
||||||
for (int i = 0; i < missingBlocks.length; i++) {
|
this.missingBlocks = new HashMap<>();
|
||||||
int count = missingBlocks[i];
|
return missingBlocks;
|
||||||
if (count > 0) {
|
|
||||||
map.put(BlockTypes.get(i), count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Arrays.fill(missingBlocks, 0);
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pos, B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws WorldEditException {
|
||||||
return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
|
||||||
if (blockBag != null) {
|
if (blockBag != null) {
|
||||||
BlockState existing = getExtent().getBlock(BlockVector3.at(x,y,z));
|
BlockState existing = getExtent().getBlock(position);
|
||||||
|
|
||||||
if (!block.getBlockType().equals(existing.getBlockType())) {
|
if (!block.getBlockType().equals(existing.getBlockType())) {
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
try {
|
try {
|
||||||
blockBag.fetchPlacedBlock(block.toImmutableState());
|
blockBag.fetchPlacedBlock(block.toImmutableState());
|
||||||
} catch (UnplaceableBlockException e) {
|
} catch (UnplaceableBlockException e) {
|
||||||
throw new FaweException.FaweBlockBagException();
|
return false;
|
||||||
} catch (BlockBagException e) {
|
} catch (BlockBagException e) {
|
||||||
missingBlocks[block.getBlockType().getInternalId()]++;
|
if (!missingBlocks.containsKey(block.getBlockType())) {
|
||||||
throw new FaweException.FaweBlockBagException();
|
missingBlocks.put(block.getBlockType(), 1);
|
||||||
|
} else {
|
||||||
|
missingBlocks.put(block.getBlockType(), missingBlocks.get(block.getBlockType()) + 1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mine) {
|
|
||||||
|
|
||||||
if (!existing.getBlockType().getMaterial().isAir()) {
|
if (!existing.getBlockType().getMaterial().isAir()) {
|
||||||
try {
|
try {
|
||||||
@ -130,8 +109,12 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return super.setBlock(position, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.setBlock(x, y, z, block);
|
@Override
|
||||||
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
|
return setBlock(BlockVector3.at(x,y,z),block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
||||||
* Copyright (C) WorldEdit team and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent.logging;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
|
||||||
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.BlockStateHolder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An abstract class to implement block loggers and so on with.
|
|
||||||
*/
|
|
||||||
public abstract class AbstractLoggingExtent extends AbstractDelegateExtent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new instance.
|
|
||||||
*
|
|
||||||
* @param extent the extent
|
|
||||||
*/
|
|
||||||
public AbstractLoggingExtent(Extent extent) {
|
|
||||||
super(extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a block is being changed.
|
|
||||||
*
|
|
||||||
* @param position the position
|
|
||||||
* @param newBlock the new block to replace the old one
|
|
||||||
*/
|
|
||||||
protected void onBlockChange(BlockVector3 position, BlockStateHolder newBlock) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws WorldEditException {
|
|
||||||
onBlockChange(position, block);
|
|
||||||
return super.setBlock(position, block);
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.extent.transform;
|
|||||||
|
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.jnbt.ByteTag;
|
import com.sk89q.jnbt.ByteTag;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
@ -37,6 +39,7 @@ import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
|||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.*;
|
||||||
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;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -51,9 +54,10 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
/**
|
||||||
import static com.sk89q.worldedit.util.Direction.*;
|
* Transforms blocks themselves (but not their position) according to a
|
||||||
|
* given transform.
|
||||||
|
*/
|
||||||
public class BlockTransformExtent extends ResettableExtent {
|
public class BlockTransformExtent extends ResettableExtent {
|
||||||
private Transform transform;
|
private Transform transform;
|
||||||
private Transform transformInverse;
|
private Transform transformInverse;
|
||||||
@ -81,27 +85,17 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
|
|
||||||
|
|
||||||
private static long combine(Direction... directions) {
|
private static long combine(Direction... directions) {
|
||||||
long mask = 0;
|
return Arrays.stream(directions).mapToLong(dir -> (1L << dir.ordinal())).reduce(0, (a, b) -> a | b);
|
||||||
for (Direction dir : directions) {
|
|
||||||
mask = mask | (1L << dir.ordinal());
|
|
||||||
}
|
|
||||||
return mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Direction... dirs) {
|
private static long[] adapt(Direction... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
long[] arr = new long[dirs.length];
|
||||||
for (int i = 0; i < arr.length; i++) {
|
Arrays.setAll(arr, i -> 1L << dirs[i].ordinal());
|
||||||
arr[i] = 1L << dirs[i].ordinal();
|
|
||||||
}
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Long... dirs) {
|
private static long[] adapt(Long... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
return Arrays.stream(dirs).mapToLong(dir -> dir).toArray();
|
||||||
for (int i = 0; i < arr.length; i++) {
|
|
||||||
arr[i] = dirs[i];
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] getDirections(AbstractProperty property) {
|
private static long[] getDirections(AbstractProperty property) {
|
||||||
@ -215,9 +209,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long notIndex(long mask, int... indexes) {
|
private static long notIndex(long mask, int... indexes) {
|
||||||
for (int index : indexes) {
|
mask |= Arrays.stream(indexes).mapToLong(index -> (1L << (index + values().length))).reduce(0, (a, b) -> a | b);
|
||||||
mask = mask | (1L << (index + values().length));
|
|
||||||
}
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +263,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
if (newIndex != null) return newIndex;
|
if (newIndex != null) return newIndex;
|
||||||
}
|
}
|
||||||
return newIndex != null ? newIndex : null;
|
return newIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDirectional(Property property) {
|
private static boolean isDirectional(Property property) {
|
||||||
@ -361,24 +353,6 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return newMaskedId;
|
return newMaskedId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Slow - does not cache results
|
|
||||||
* @param block
|
|
||||||
* @param transform
|
|
||||||
* @param <B>
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static <B extends BlockStateHolder<B>> B transform(B block, Transform transform) {
|
|
||||||
BlockState state = block.toImmutableState();
|
|
||||||
|
|
||||||
int transformedId = transformState(state, transform);
|
|
||||||
BlockState transformed = BlockState.getFromInternalId(transformedId);
|
|
||||||
if (block.hasNbtData()) {
|
|
||||||
return (B) transformBaseBlockNBT(transformed, block.getNbtData(), transform);
|
|
||||||
}
|
|
||||||
return (B) (block instanceof BaseBlock ? transformed.toBaseBlock() : transformed);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cache() {
|
private void cache() {
|
||||||
BLOCK_ROTATION_BITMASK = new int[BlockTypes.size()];
|
BLOCK_ROTATION_BITMASK = new int[BlockTypes.size()];
|
||||||
@ -407,16 +381,58 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return super.setExtent(extent);
|
return super.setExtent(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the transform.
|
||||||
|
*
|
||||||
|
* @return the transform
|
||||||
|
*/
|
||||||
public Transform getTransform() {
|
public Transform getTransform() {
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
|
return transform(super.getBlock(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
|
return transform(super.getFullBlock(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
|
return super.setBlock(location, transformInverse(block));
|
||||||
|
}
|
||||||
|
|
||||||
public void setTransform(Transform affine) {
|
public void setTransform(Transform affine) {
|
||||||
this.transform = affine;
|
this.transform = affine;
|
||||||
this.transformInverse = this.transform.inverse();
|
this.transformInverse = this.transform.inverse();
|
||||||
cache();
|
cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the given block using the given transform.
|
||||||
|
*
|
||||||
|
* <p>The provided block is <em>not</em> modified.</p>
|
||||||
|
*
|
||||||
|
* @param block the block
|
||||||
|
* @param transform the transform
|
||||||
|
* @return the same block
|
||||||
|
*/
|
||||||
|
public static <B extends BlockStateHolder<B>> B transform(B block, Transform transform) {
|
||||||
|
checkNotNull(block);
|
||||||
|
checkNotNull(transform);
|
||||||
|
BlockState state = block.toImmutableState();
|
||||||
|
|
||||||
|
int transformedId = transformState(state, transform);
|
||||||
|
BlockState transformed = BlockState.getFromInternalId(transformedId);
|
||||||
|
if (block.hasNbtData()) {
|
||||||
|
return (B) transformBaseBlockNBT(transformed, block.getNbtData(), transform);
|
||||||
|
}
|
||||||
|
return (B) (block instanceof BaseBlock ? transformed.toBaseBlock() : transformed);
|
||||||
|
}
|
||||||
|
|
||||||
private BlockState transform(BlockState state, int[][] transformArray, Transform transform) {
|
private BlockState transform(BlockState state, int[][] transformArray, Transform transform) {
|
||||||
int typeId = state.getInternalBlockTypeId();
|
int typeId = state.getInternalBlockTypeId();
|
||||||
int[] arr = transformArray[typeId];
|
int[] arr = transformArray[typeId];
|
||||||
@ -450,7 +466,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return transformed.toBaseBlock();
|
return transformed.toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockStateHolder transformInverse(BlockStateHolder block) {
|
protected final BlockStateHolder transformInverse(BlockStateHolder block) {
|
||||||
BlockState transformed = transformInverse(block.toImmutableState());
|
BlockState transformed = transformInverse(block.toImmutableState());
|
||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
return transformBaseBlockNBT(transformed, block.getNbtData(), transformInverse);
|
return transformBaseBlockNBT(transformed, block.getNbtData(), transformInverse);
|
||||||
@ -462,7 +478,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return transform(block, BLOCK_TRANSFORM, transform);
|
return transform(block, BLOCK_TRANSFORM, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockState transformInverse(BlockState block) {
|
private BlockState transformInverse(BlockState block) {
|
||||||
return transform(block, BLOCK_TRANSFORM_INVERSE, transformInverse);
|
return transform(block, BLOCK_TRANSFORM_INVERSE, transformInverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,21 +487,11 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return transform(super.getLazyBlock(x, y, z));
|
return transform(super.getLazyBlock(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
|
||||||
return transform(super.getFullBlock(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
public BlockState getLazyBlock(BlockVector3 position) {
|
||||||
return transform(super.getLazyBlock(position));
|
return transform(super.getLazyBlock(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
|
||||||
return transform(super.getBlock(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiome(BlockVector2 position) {
|
public BiomeType getBiome(BlockVector2 position) {
|
||||||
return super.getBiome(position);
|
return super.getBiome(position);
|
||||||
@ -497,10 +503,5 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
|
||||||
return super.setBlock(location, transformInverse(block));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,6 @@ public class BlockMask extends AbstractExtentMask {
|
|||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param blocks a list of blocks to match
|
* @param blocks a list of blocks to match
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
||||||
super(extent);
|
super(extent);
|
||||||
checkNotNull(blocks);
|
checkNotNull(blocks);
|
||||||
@ -73,7 +72,6 @@ public class BlockMask extends AbstractExtentMask {
|
|||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param block an array of blocks to match
|
* @param block an array of blocks to match
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public BlockMask(Extent extent, BaseBlock... block) {
|
public BlockMask(Extent extent, BaseBlock... block) {
|
||||||
super(extent);
|
super(extent);
|
||||||
checkNotNull(block);
|
checkNotNull(block);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
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.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -39,19 +40,9 @@ import java.util.Set;
|
|||||||
* use {@link BlockMask}.</p>
|
* use {@link BlockMask}.</p>
|
||||||
*/
|
*/
|
||||||
public class BlockTypeMask extends AbstractExtentMask {
|
public class BlockTypeMask extends AbstractExtentMask {
|
||||||
|
|
||||||
private final boolean[] types;
|
private final boolean[] types;
|
||||||
|
|
||||||
protected BlockTypeMask(Extent extent, boolean[] types) {
|
|
||||||
super(extent);
|
|
||||||
this.types = types;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockTypeMask(Extent extent, BlockType... types) {
|
|
||||||
super(extent);
|
|
||||||
this.types = new boolean[BlockTypes.size()];
|
|
||||||
for (BlockType type : types) this.types[type.getInternalId()] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new block mask.
|
* Create a new block mask.
|
||||||
*
|
*
|
||||||
@ -59,7 +50,24 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
* @param blocks a list of blocks to match
|
* @param blocks a list of blocks to match
|
||||||
*/
|
*/
|
||||||
public BlockTypeMask(Extent extent, Collection<BlockType> blocks) {
|
public BlockTypeMask(Extent extent, Collection<BlockType> blocks) {
|
||||||
this(extent, blocks.toArray(new BlockType[blocks.size()]));
|
this(extent, blocks.toArray(new BlockType[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new block mask.
|
||||||
|
*
|
||||||
|
* @param extent the extent
|
||||||
|
* @param block an array of blocks to match
|
||||||
|
*/
|
||||||
|
public BlockTypeMask(Extent extent, BlockType... block) {
|
||||||
|
super(extent);
|
||||||
|
this.types = new boolean[BlockTypes.size()];
|
||||||
|
for (BlockType type : block) this.types[type.getInternalId()] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockTypeMask(Extent extent, boolean[] types) {
|
||||||
|
super(extent);
|
||||||
|
this.types = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,9 +25,6 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.sk89q.worldedit.function.mask.Masks.negate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a given vector meets a criteria.
|
* Tests whether a given vector meets a criteria.
|
||||||
*/
|
*/
|
||||||
|
@ -104,7 +104,8 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
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));
|
while (combine(pairingFunction(), failedCombines)) {
|
||||||
|
}
|
||||||
// Optimize / combine
|
// Optimize / combine
|
||||||
do optimizeMasks(optimized);
|
do optimizeMasks(optimized);
|
||||||
while (combine(pairingFunction(), failedCombines));
|
while (combine(pairingFunction(), failedCombines));
|
||||||
@ -122,7 +123,7 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
outer:
|
outer:
|
||||||
for (Mask mask : masks) {
|
for (Mask mask : masks) {
|
||||||
for (Mask other : masks) {
|
for (Mask other : masks) {
|
||||||
AbstractMap.SimpleEntry pair = new AbstractMap.SimpleEntry(mask, other);
|
AbstractMap.SimpleEntry<Mask, Mask> pair = new AbstractMap.SimpleEntry<>(mask, other);
|
||||||
if (failedCombines.contains(pair)) continue;
|
if (failedCombines.contains(pair)) continue;
|
||||||
Mask combined = pairing.apply(pair);
|
Mask combined = pairing.apply(pair);
|
||||||
if (combined != null) {
|
if (combined != null) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -2,7 +2,6 @@ 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.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
public class SingleBlockStateMask extends AbstractExtentMask {
|
public class SingleBlockStateMask extends AbstractExtentMask {
|
||||||
|
@ -2,7 +2,6 @@ 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.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -1,29 +1,25 @@
|
|||||||
package com.sk89q.worldedit.function.operation;
|
package com.sk89q.worldedit.function.operation;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BackwardsExtentBlockCopy implements Operation {
|
public class BackwardsExtentBlockCopy implements Operation {
|
||||||
private final Region region;
|
private final Region region;
|
||||||
private final Transform transform;
|
private final Transform transform;
|
||||||
private final Extent destination;
|
|
||||||
private final Extent source;
|
|
||||||
private final RegionFunction function;
|
private final RegionFunction function;
|
||||||
private final BlockVector3 origin;
|
private final BlockVector3 origin;
|
||||||
|
|
||||||
// private Vector mutable = new MutableBlockVector3();
|
// private Vector mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
public BackwardsExtentBlockCopy(Extent source, Region region, Extent destination, BlockVector3 origin, Transform transform, RegionFunction function) {
|
BackwardsExtentBlockCopy(Region region, BlockVector3 origin, Transform transform, RegionFunction function) {
|
||||||
this.source = source;
|
|
||||||
this.region = region;
|
this.region = region;
|
||||||
this.destination = destination;
|
|
||||||
this.transform = transform;
|
this.transform = transform;
|
||||||
this.function = function;
|
this.function = function;
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
|
@ -299,7 +299,7 @@ public class ForwardExtentCopy implements Operation {
|
|||||||
if (copyBiomes && (!(source instanceof BlockArrayClipboard) || ((BlockArrayClipboard) source).IMP.hasBiomes())) {
|
if (copyBiomes && (!(source instanceof BlockArrayClipboard) || ((BlockArrayClipboard) source).IMP.hasBiomes())) {
|
||||||
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));
|
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));
|
||||||
}
|
}
|
||||||
blockCopy = new BackwardsExtentBlockCopy(transExt, region, finalDest, from, transform, copy);
|
blockCopy = new BackwardsExtentBlockCopy(region, from, transform, copy);
|
||||||
} else {
|
} else {
|
||||||
transExt = new PositionTransformExtent(finalDest, currentTransform);
|
transExt = new PositionTransformExtent(finalDest, currentTransform);
|
||||||
transExt.setOrigin(from);
|
transExt.setOrigin(from);
|
||||||
|
@ -4,11 +4,9 @@ import com.sk89q.minecraft.util.commands.Link;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.command.UtilityCommands;
|
import com.sk89q.worldedit.command.UtilityCommands;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link BlockStateHolder} for a given position.
|
* Returns a {@link BlockStateHolder} for a given position.
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
package com.sk89q.worldedit.function.visitor;
|
package com.sk89q.worldedit.function.visitor;
|
||||||
|
|
||||||
import com.boydti.fawe.object.HasFaweQueue;
|
import com.boydti.fawe.object.HasFaweQueue;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.history.change;
|
package com.sk89q.worldedit.history.change;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
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.history.UndoContext;
|
import com.sk89q.worldedit.history.UndoContext;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the creation of an entity and removes the entity upon undo.
|
* Logs the creation of an entity and removes the entity upon undo.
|
||||||
*/
|
*/
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.history.change;
|
package com.sk89q.worldedit.history.change;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
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.history.UndoContext;
|
import com.sk89q.worldedit.history.UndoContext;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tracks the removal of an entity.
|
* Tracks the removal of an entity.
|
||||||
*/
|
*/
|
||||||
|
@ -102,7 +102,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (logMode != null && sender.isPlayer()) {
|
if (logMode != null && sender.isPlayer()) {
|
||||||
Vector3 position = player.getLocation();
|
Vector3 position = player.getLocation().toVector();
|
||||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||||
|
|
||||||
switch (logMode) {
|
switch (logMode) {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit.internal.command;
|
package com.sk89q.worldedit.internal.command;
|
||||||
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -36,14 +37,12 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ArgumentStack;
|
import com.sk89q.worldedit.util.command.parametric.ArgumentStack;
|
||||||
import com.sk89q.worldedit.util.command.parametric.BindingBehavior;
|
import com.sk89q.worldedit.util.command.parametric.BindingBehavior;
|
||||||
import com.sk89q.worldedit.util.command.parametric.BindingHelper;
|
|
||||||
import com.sk89q.worldedit.util.command.parametric.BindingMatch;
|
import com.sk89q.worldedit.util.command.parametric.BindingMatch;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -166,7 +165,7 @@ public class WorldEditBinding {
|
|||||||
* Gets an {@link BaseBlock} from a {@link ArgumentStack}.
|
* Gets an {@link BaseBlock} from a {@link ArgumentStack}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @return a block state
|
* @return a pattern
|
||||||
* @throws ParameterException on error
|
* @throws ParameterException on error
|
||||||
* @throws WorldEditException on error
|
* @throws WorldEditException on error
|
||||||
*/
|
*/
|
||||||
@ -377,6 +376,4 @@ public class WorldEditBinding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,22 +45,22 @@ import java.util.concurrent.TimeoutException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles and evaluates expressions.
|
* Compiles and evaluates expressions.
|
||||||
* <p>
|
*
|
||||||
* <p>Supported operators:</p>
|
* <p>Supported operators:</p>
|
||||||
* <p>
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Logical: &&, ||, ! (unary)</li>
|
* <li>Logical: &&, ||, ! (unary)</li>
|
||||||
* <li>Bitwise: ~ (unary), >>, <<</li>
|
* <li>Bitwise: ~ (unary), >>, <<</li>
|
||||||
* <li>Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only)</li>
|
* <li>Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only)</li>
|
||||||
* <li>Comparison: <=, >=, >, <, ==, !=, ~= (near)</li>
|
* <li>Comparison: <=, >=, >, <, ==, !=, ~= (near)</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
*
|
||||||
* <p>Supported functions: abs, acos, asin, atan, atan2, cbrt, ceil, cos, cosh,
|
* <p>Supported functions: abs, acos, asin, atan, atan2, cbrt, ceil, cos, cosh,
|
||||||
* exp, floor, ln, log, log10, max, max, min, min, rint, round, sin, sinh,
|
* exp, floor, ln, log, log10, max, max, min, min, rint, round, sin, sinh,
|
||||||
* sqrt, tan, tanh and more. (See the Functions class or the wiki)</p>
|
* sqrt, tan, tanh and more. (See the Functions class or the wiki)</p>
|
||||||
* <p>
|
*
|
||||||
* <p>Constants: e, pi</p>
|
* <p>Constants: e, pi</p>
|
||||||
* <p>
|
*
|
||||||
* <p>To compile an equation, run
|
* <p>To compile an equation, run
|
||||||
* {@code Expression.compile("expression here", "var1", "var2"...)}.
|
* {@code Expression.compile("expression here", "var1", "var2"...)}.
|
||||||
* If you wish to run the equation multiple times, you can then optimize it,
|
* If you wish to run the equation multiple times, you can then optimize it,
|
||||||
@ -70,7 +70,7 @@ import java.util.concurrent.TimeoutException;
|
|||||||
* To query variables after evaluation, you can use
|
* To query variables after evaluation, you can use
|
||||||
* {@link #getVariable(String, boolean)}. To get a value out of these, use
|
* {@link #getVariable(String, boolean)}. To get a value out of these, use
|
||||||
* {@link Variable#getValue()}.</p>
|
* {@link Variable#getValue()}.</p>
|
||||||
* <p>
|
*
|
||||||
* <p>Variables are also supported and can be set either by passing values
|
* <p>Variables are also supported and can be set either by passing values
|
||||||
* to {@link #evaluate(double...)}.</p>
|
* to {@link #evaluate(double...)}.</p>
|
||||||
*/
|
*/
|
||||||
@ -146,6 +146,7 @@ public class Expression {
|
|||||||
|
|
||||||
((Variable) invokable).value = values[i];
|
((Variable) invokable).value = values[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (timeout < 0) {
|
if (timeout < 0) {
|
||||||
return evaluateRoot();
|
return evaluateRoot();
|
||||||
@ -236,6 +237,4 @@ public class Expression {
|
|||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.runtime;
|
package com.sk89q.worldedit.internal.expression.runtime;
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Java/C-style for loop.
|
||||||
|
*/
|
||||||
public class For extends Node {
|
public class For extends Node {
|
||||||
|
|
||||||
RValue init;
|
RValue init;
|
||||||
RValue condition;
|
RValue condition;
|
||||||
RValue increment;
|
RValue increment;
|
||||||
@ -11,34 +34,35 @@ public class For extends Node {
|
|||||||
|
|
||||||
public For(int position, RValue init, RValue condition, RValue increment, RValue body) {
|
public For(int position, RValue init, RValue condition, RValue increment, RValue body) {
|
||||||
super(position);
|
super(position);
|
||||||
|
|
||||||
this.init = init;
|
this.init = init;
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.increment = increment;
|
this.increment = increment;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getValue() throws EvaluationException {
|
public double getValue() throws EvaluationException {
|
||||||
|
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
double ret = 0.0D;
|
double ret = 0.0;
|
||||||
this.init.getValue();
|
|
||||||
|
|
||||||
for(; this.condition.getValue() > 0.0D; this.increment.getValue()) {
|
|
||||||
|
|
||||||
|
for (init.getValue(); condition.getValue() > 0; increment.getValue()) {
|
||||||
if (iterations > 256) {
|
if (iterations > 256) {
|
||||||
throw new EvaluationException(this.getPosition(), "Loop exceeded 256 iterations.");
|
throw new EvaluationException(getPosition(), "Loop exceeded 256 iterations.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Thread.interrupted()) {
|
if (Thread.interrupted()) {
|
||||||
throw new EvaluationException(this.getPosition(), "Thread has been interrupted.");
|
throw new EvaluationException(getPosition(), "Calculations exceeded time limit.");
|
||||||
}
|
}
|
||||||
++iterations;
|
++iterations;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ret = this.body.getValue();
|
ret = body.getValue();
|
||||||
} catch (BreakException var5) {
|
} catch (BreakException e) {
|
||||||
if(!var5.doContinue) {
|
if (e.doContinue) {
|
||||||
return ret;
|
//noinspection UnnecessaryContinue
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,30 +70,38 @@ public class For extends Node {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char id() {
|
public char id() {
|
||||||
return 'F';
|
return 'F';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "for (" + this.init + "; " + this.condition + "; " + this.increment + ") { " + this.body + " }";
|
return "for (" + init + "; " + condition + "; " + increment + ") { " + body + " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public RValue optimize() throws EvaluationException {
|
public RValue optimize() throws EvaluationException {
|
||||||
final RValue newCondition = condition.optimize();
|
final RValue newCondition = condition.optimize();
|
||||||
|
|
||||||
if (newCondition instanceof Constant && newCondition.getValue() <= 0) {
|
if (newCondition instanceof Constant && newCondition.getValue() <= 0) {
|
||||||
// If the condition is always false, the loop can be flattened.
|
// If the condition is always false, the loop can be flattened.
|
||||||
// So we run the init part and then return 0.0.
|
// So we run the init part and then return 0.0.
|
||||||
return new Sequence(getPosition(), init, new Constant(getPosition(), 0.0)).optimize();
|
return new Sequence(getPosition(), init, new Constant(getPosition(), 0.0)).optimize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//return new Sequence(getPosition(), init.optimize(), new While(getPosition(), condition, new Sequence(getPosition(), body, increment), false)).optimize();
|
||||||
return new For(getPosition(), init.optimize(), newCondition, increment.optimize(), body.optimize());
|
return new For(getPosition(), init.optimize(), newCondition, increment.optimize(), body.optimize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException {
|
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException {
|
||||||
this.init = this.init.bindVariables(expression, false);
|
init = init.bindVariables(expression, false);
|
||||||
this.condition = this.condition.bindVariables(expression, false);
|
condition = condition.bindVariables(expression, false);
|
||||||
this.increment = this.increment.bindVariables(expression, false);
|
increment = increment.bindVariables(expression, false);
|
||||||
this.body = this.body.bindVariables(expression, false);
|
body = body.bindVariables(expression, false);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.internal.expression.runtime;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -36,8 +37,7 @@ public class Function extends Node {
|
|||||||
* for the same inputs and on functions with side-effects.
|
* for the same inputs and on functions with side-effects.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Dynamic {
|
public @interface Dynamic { }
|
||||||
}
|
|
||||||
|
|
||||||
public final Method method;
|
public final Method method;
|
||||||
public final RValue[] args;
|
public final RValue[] args;
|
||||||
@ -121,5 +121,4 @@ public class Function extends Node {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.runtime;
|
package com.sk89q.worldedit.internal.expression.runtime;
|
||||||
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.Function.Dynamic;
|
import com.sk89q.worldedit.internal.expression.runtime.Function.Dynamic;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.noise.PerlinNoise;
|
import com.sk89q.worldedit.math.noise.PerlinNoise;
|
||||||
import com.sk89q.worldedit.math.noise.RidgedMultiFractalNoise;
|
import com.sk89q.worldedit.math.noise.RidgedMultiFractalNoise;
|
||||||
import com.sk89q.worldedit.math.noise.VoronoiNoise;
|
import com.sk89q.worldedit.math.noise.VoronoiNoise;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -125,13 +124,11 @@ public final class Functions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<String, List<Overload>> functions = new HashMap<>();
|
private static final Map<String, List<Overload>> functions = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Method method : Functions.class.getMethods()) {
|
for (Method method : Functions.class.getMethods()) {
|
||||||
try {
|
try {
|
||||||
addFunction(method);
|
addFunction(method);
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) { }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,10 +138,7 @@ public final class Functions {
|
|||||||
|
|
||||||
Overload overload = new Overload(method);
|
Overload overload = new Overload(method);
|
||||||
|
|
||||||
List<Overload> overloads = functions.get(methodName);
|
List<Overload> overloads = functions.computeIfAbsent(methodName, k -> new ArrayList<>());
|
||||||
if (overloads == null) {
|
|
||||||
functions.put(methodName, overloads = new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
overloads.add(overload);
|
overloads.add(overload);
|
||||||
}
|
}
|
||||||
@ -256,6 +250,7 @@ public final class Functions {
|
|||||||
return Math.log10(x.getValue());
|
return Math.log10(x.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static double rotate(LValue x, LValue y, RValue angle) throws EvaluationException {
|
public static double rotate(LValue x, LValue y, RValue angle) throws EvaluationException {
|
||||||
final double f = angle.getValue();
|
final double f = angle.getValue();
|
||||||
|
|
||||||
@ -489,5 +484,4 @@ public final class Functions {
|
|||||||
return queryInternal(type, data, typeId, dataValue);
|
return queryInternal(type, data, typeId, dataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.registry;
|
package com.sk89q.worldedit.internal.registry;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
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;
|
||||||
|
@ -117,34 +117,4 @@ public final class MathUtils {
|
|||||||
public static double roundHalfUp(double value) {
|
public static double roundHalfUp(double value) {
|
||||||
return Math.signum(value) * Math.round(Math.abs(value));
|
return Math.signum(value) * Math.round(Math.abs(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the midpoint Vector3 of the two given Vector3's.
|
|
||||||
*
|
|
||||||
* @param first Vector3
|
|
||||||
* @param second Vector3
|
|
||||||
* @return midpoint Vector3
|
|
||||||
*/
|
|
||||||
public static Vector3 midpoint(Vector3 v1, Vector3 v2) {
|
|
||||||
return Vector3.at(
|
|
||||||
(v1.getX() + v2.getX()) / 2,
|
|
||||||
(v1.getY() + v2.getY()) / 2,
|
|
||||||
(v1.getZ() + v2.getZ()) / 2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the midpoint BlockVector3 of the two given BlockVector3's.
|
|
||||||
*
|
|
||||||
* @param first BlockVector3
|
|
||||||
* @param second BlockVector3
|
|
||||||
* @return midpoint BlockVector3
|
|
||||||
*/
|
|
||||||
public static BlockVector3 midpoint(BlockVector3 v1, BlockVector3 v2) {
|
|
||||||
return BlockVector3.at(
|
|
||||||
(v1.getBlockX() + v2.getBlockX()) / 2,
|
|
||||||
(v1.getBlockY() + v2.getBlockY()) / 2,
|
|
||||||
(v1.getBlockZ() + v2.getBlockZ()) / 2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,12 +2,7 @@ package com.sk89q.worldedit.math;
|
|||||||
|
|
||||||
public class MutableBlockVector2 extends BlockVector2 {
|
public class MutableBlockVector2 extends BlockVector2 {
|
||||||
|
|
||||||
private static ThreadLocal<MutableBlockVector2> MUTABLE_CACHE = new ThreadLocal<MutableBlockVector2>() {
|
private static ThreadLocal<MutableBlockVector2> MUTABLE_CACHE = ThreadLocal.withInitial(() -> new MutableBlockVector2());
|
||||||
@Override
|
|
||||||
protected MutableBlockVector2 initialValue() {
|
|
||||||
return new MutableBlockVector2();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static MutableBlockVector2 get(int x, int z) {
|
public static MutableBlockVector2 get(int x, int z) {
|
||||||
return MUTABLE_CACHE.get().setComponents(x, z);
|
return MUTABLE_CACHE.get().setComponents(x, z);
|
||||||
|
@ -2,12 +2,7 @@ package com.sk89q.worldedit.math;
|
|||||||
|
|
||||||
public class MutableBlockVector3 extends BlockVector3 {
|
public class MutableBlockVector3 extends BlockVector3 {
|
||||||
|
|
||||||
private static ThreadLocal<MutableBlockVector3> MUTABLE_CACHE = new ThreadLocal<MutableBlockVector3>() {
|
private static ThreadLocal<MutableBlockVector3> MUTABLE_CACHE = ThreadLocal.withInitial(() -> new MutableBlockVector3());
|
||||||
@Override
|
|
||||||
protected MutableBlockVector3 initialValue() {
|
|
||||||
return new MutableBlockVector3();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static MutableBlockVector3 get(int x, int y, int z) {
|
public static MutableBlockVector3 get(int x, int y, int z) {
|
||||||
return MUTABLE_CACHE.get().setComponents(x, y, z);
|
return MUTABLE_CACHE.get().setComponents(x, y, z);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.sk89q.worldedit.math;
|
package com.sk89q.worldedit.math;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class MutableVector3 extends Vector3 {
|
public class MutableVector3 extends Vector3 {
|
||||||
|
|
||||||
public MutableVector3() {}
|
public MutableVector3() {}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
package com.sk89q.worldedit.math.convolution;
|
package com.sk89q.worldedit.math.convolution;
|
||||||
|
|
||||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
@ -34,8 +36,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows applications of Kernels onto the region's height map.
|
* Allows applications of Kernels onto the region's height map.
|
||||||
*
|
*
|
||||||
@ -167,7 +167,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
BlockVector3 minY = region.getMinimumPoint();
|
BlockVector3 minY = region.getMinimumPoint();
|
||||||
int originX = minY.getBlockX();
|
int originX = minY.getBlockX();
|
||||||
int originY = minY.getBlockY();
|
|
||||||
int originZ = minY.getBlockZ();
|
int originZ = minY.getBlockZ();
|
||||||
|
|
||||||
int maxY = region.getMaximumPoint().getBlockY();
|
int maxY = region.getMaximumPoint().getBlockY();
|
||||||
@ -177,10 +176,10 @@ public class HeightMap {
|
|||||||
|
|
||||||
BlockStateHolder tmpBlock = BlockTypes.AIR.getDefaultState();
|
BlockStateHolder tmpBlock = BlockTypes.AIR.getDefaultState();
|
||||||
|
|
||||||
// Apply heightmap
|
|
||||||
int maxY4 = maxY << 4;
|
int maxY4 = maxY << 4;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
// Apply heightmap
|
||||||
for (int z = 0; z < height; ++z) {
|
for (int z = 0; z < height; ++z) {
|
||||||
int zr = z + originZ;
|
int zr = z + originZ;
|
||||||
for (int x = 0; x < width; ++x) {
|
for (int x = 0; x < width; ++x) {
|
||||||
|
@ -22,21 +22,17 @@
|
|||||||
package com.sk89q.worldedit.math.interpolation;
|
package com.sk89q.worldedit.math.interpolation;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Kochanek-Bartels interpolation; continuous in the 2nd derivative.
|
* A Kochanek-Bartels interpolation; continuous in the 2nd derivative.
|
||||||
* <p>
|
*
|
||||||
* <p>Supports {@link Node#tension tension}, {@link Node#bias bias} and
|
* <p>Supports Node#tension tension, Node#bias bias and
|
||||||
* {@link Node#continuity continuity} parameters per {@link Node}.</p>
|
* Node#continuity continuity parameters per {@link Node}.</p>
|
||||||
*/
|
*/
|
||||||
public class KochanekBartelsInterpolation implements Interpolation {
|
public class KochanekBartelsInterpolation implements Interpolation {
|
||||||
|
|
||||||
@ -48,7 +44,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
|
|||||||
private double scaling;
|
private double scaling;
|
||||||
|
|
||||||
public KochanekBartelsInterpolation() {
|
public KochanekBartelsInterpolation() {
|
||||||
setNodes(Collections.<Node>emptyList());
|
setNodes(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,6 +112,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
|
|||||||
final Vector3 r2 = retrieve(baseIndex ).multiply(f2);
|
final Vector3 r2 = retrieve(baseIndex ).multiply(f2);
|
||||||
final Vector3 r3 = retrieve(baseIndex + 1).multiply(f3);
|
final Vector3 r3 = retrieve(baseIndex + 1).multiply(f3);
|
||||||
final Vector3 r4 = retrieve(baseIndex + 2).multiply(f4);
|
final Vector3 r4 = retrieve(baseIndex + 2).multiply(f4);
|
||||||
|
|
||||||
return r1.add(r2).add(r3).add(r4);
|
return r1.add(r2).add(r3).add(r4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,5 +256,4 @@ public class KochanekBartelsInterpolation implements Interpolation {
|
|||||||
return (int) Math.floor(position);
|
return (int) Math.floor(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class Node {
|
|||||||
private double continuity;
|
private double continuity;
|
||||||
|
|
||||||
public Node() {
|
public Node() {
|
||||||
this(Vector3.at(0, 0, 0));
|
this(Vector3.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node(Node other) {
|
public Node(Node other) {
|
||||||
|
@ -1,17 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.math.transform;
|
package com.sk89q.worldedit.math.transform;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.MathUtils;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.math.MathUtils;
|
|
||||||
import com.sk89q.worldedit.math.MutableVector3;
|
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An affine transform.
|
* An affine transform.
|
||||||
* <p>
|
*
|
||||||
* <p>This class is from the
|
* <p>This class is from the
|
||||||
* <a href="http://geom-java.sourceforge.net/index.html">JavaGeom project</a>,
|
* <a href="http://geom-java.sourceforge.net/index.html">JavaGeom project</a>,
|
||||||
* which is licensed under LGPL v2.1.</p>
|
* which is licensed under LGPL v2.1.</p>
|
||||||
@ -153,7 +170,7 @@ public class AffineTransform implements Transform, Serializable {
|
|||||||
*
|
*
|
||||||
* @return the determinant of the transform.
|
* @return the determinant of the transform.
|
||||||
*/
|
*/
|
||||||
public double determinant() {
|
private double determinant() {
|
||||||
return m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m20 * m12)
|
return m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m20 * m12)
|
||||||
+ m02 * (m10 * m21 - m20 * m11);
|
+ m02 * (m10 * m21 - m20 * m11);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package com.sk89q.worldedit.math.transform;
|
package com.sk89q.worldedit.math.transform;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
|
||||||
public class RoundedTransform implements Transform{
|
public class RoundedTransform implements Transform{
|
||||||
private final Transform transform;
|
private final Transform transform;
|
||||||
// private MutableBlockVector3 mutable = new MutableBlockVector3();
|
|
||||||
|
|
||||||
public RoundedTransform(Transform transform) {
|
public RoundedTransform(Transform transform) {
|
||||||
this.transform = transform;
|
this.transform = transform;
|
||||||
@ -19,9 +17,6 @@ public class RoundedTransform implements Transform{
|
|||||||
@Override
|
@Override
|
||||||
public Vector3 apply(Vector3 input) {
|
public Vector3 apply(Vector3 input) {
|
||||||
Vector3 val = transform.apply(input);
|
Vector3 val = transform.apply(input);
|
||||||
// mutable.mutX((int) Math.floor(val.getX() + 0.5));
|
|
||||||
// mutable.mutY((int) Math.floor(val.getY() + 0.5));
|
|
||||||
// mutable.mutZ((int) Math.floor(val.getZ() + 0.5));
|
|
||||||
return Vector3.at(Math.floor(val.getX() + 0.5), Math.floor(val.getY() + 0.5), Math.floor(val.getY() + 0.5));
|
return Vector3.at(Math.floor(val.getX() + 0.5), Math.floor(val.getY() + 0.5), Math.floor(val.getY() + 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public final class Transforms {
|
|||||||
public static Location transform(Location location, Transform transform) {
|
public static Location transform(Location location, Transform transform) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
checkNotNull(transform);
|
checkNotNull(transform);
|
||||||
return new Location(location.getExtent(), transform.apply(location), location.getDirection());
|
return new Location(location.getExtent(), transform.apply(location.toVector()), location.getDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -381,4 +381,5 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
int maxY = extent.getMaximumPoint().getBlockY();
|
int maxY = extent.getMaximumPoint().getBlockY();
|
||||||
return new CylinderRegion(center, radiusVec, minY, maxY);
|
return new CylinderRegion(center, radiusVec, minY, maxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,11 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A region that contains no points.
|
* A region that contains no points.
|
||||||
|
@ -156,13 +156,4 @@ public interface RegionSelector {
|
|||||||
*/
|
*/
|
||||||
List<String> getInformationLines();
|
List<String> getInformationLines();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the verticies
|
|
||||||
* @return
|
|
||||||
* @throws IncompleteRegionException
|
|
||||||
*/
|
|
||||||
default List<BlockVector3> getVerticies() throws IncompleteRegionException {
|
|
||||||
return Collections.singletonList(getPrimaryPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -37,11 +37,13 @@ import com.sk89q.worldedit.regions.polyhedron.Triangle;
|
|||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@code ConvexPolyhedralRegion} from a user's selections.
|
* Creates a {@code ConvexPolyhedralRegion} from a user's selections.
|
||||||
@ -108,11 +110,6 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BlockVector3> getVerticies() {
|
|
||||||
return new ArrayList<>(region.getVertices());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
@ -279,5 +276,4 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,12 @@ package com.sk89q.worldedit.regions.selector;
|
|||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
import com.boydti.fawe.util.chat.Message;
|
import com.boydti.fawe.util.chat.Message;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.command.SelectionCommands;
|
import com.sk89q.worldedit.command.SelectionCommands;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||||
@ -39,13 +37,10 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@code CuboidRegion} from a user's selections.
|
* Creates a {@code CuboidRegion} from a user's selections.
|
||||||
@ -96,6 +91,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
position1 = oldRegion.getMinimumPoint();
|
position1 = oldRegion.getMinimumPoint();
|
||||||
position2 = oldRegion.getMaximumPoint();
|
position2 = oldRegion.getMaximumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
region.setPos1(position1);
|
region.setPos1(position1);
|
||||||
region.setPos2(position2);
|
region.setPos2(position2);
|
||||||
}
|
}
|
||||||
@ -117,11 +113,6 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
region.setPos2(position2);
|
region.setPos2(position2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BlockVector3> getVerticies() {
|
|
||||||
return Arrays.asList(position1, position2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
@ -317,5 +308,4 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
return "cuboid";
|
return "cuboid";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -38,13 +38,11 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@code CylinderRegionSelector} from a user's selections.
|
* Creates a {@code CylinderRegionSelector} from a user's selections.
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -35,12 +35,10 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@code EllipsoidRegionSelector} from a user's selections.
|
* Creates a {@code EllipsoidRegionSelector} from a user's selections.
|
||||||
@ -251,5 +249,4 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
return region.getCenter().toBlockPoint();
|
return region.getCenter().toBlockPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -142,5 +142,4 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
|||||||
explainRegionAdjust(player, session);
|
explainRegionAdjust(player, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -36,13 +36,11 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@code Polygonal2DRegion} from a user's selections.
|
* Creates a {@code Polygonal2DRegion} from a user's selections.
|
||||||
|
@ -79,17 +79,17 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
*
|
*
|
||||||
* @param x X coordinate to be queried
|
* @param x X coordinate to be queried
|
||||||
* @param z Z coordinate to be queried
|
* @param z Z coordinate to be queried
|
||||||
* @param defaultBiomeType The default biome for the current column.
|
* @param defaultBaseBiome The default biome for the current column.
|
||||||
* @return material to place or null to not place anything.
|
* @return material to place or null to not place anything.
|
||||||
*/
|
*/
|
||||||
protected abstract BiomeType getBiome(int x, int z, BiomeType defaultBiomeType);
|
protected abstract BiomeType getBiome(int x, int z, BiomeType defaultBaseBiome);
|
||||||
|
|
||||||
private BiomeType getBiomeCached(int x, int z, BiomeType biomeType) {
|
private BiomeType getBiomeCached(int x, int z, BiomeType baseBiome) {
|
||||||
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
||||||
|
|
||||||
final BiomeType cacheEntry = cache[index];
|
final BiomeType cacheEntry = cache[index];
|
||||||
if (cacheEntry == null) {// unknown, fetch material
|
if (cacheEntry == null) {// unknown, fetch material
|
||||||
final BiomeType material = getBiome(x, z, biomeType);
|
final BiomeType material = getBiome(x, z, baseBiome);
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
// outside
|
// outside
|
||||||
cache[index] = BiomeTypes.THE_VOID;
|
cache[index] = BiomeTypes.THE_VOID;
|
||||||
@ -108,13 +108,13 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
return cacheEntry;
|
return cacheEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInsideCached(int x, int z, BiomeType biomeType) {
|
private boolean isInsideCached(int x, int z, BiomeType baseBiome) {
|
||||||
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
||||||
|
|
||||||
final BiomeType cacheEntry = cache[index];
|
final BiomeType cacheEntry = cache[index];
|
||||||
if (cacheEntry == null) {
|
if (cacheEntry == null) {
|
||||||
// unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape
|
// unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape
|
||||||
return getBiomeCached(x, z, biomeType) != null;
|
return getBiomeCached(x, z, baseBiome) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cacheEntry != BiomeTypes.THE_VOID;
|
return cacheEntry != BiomeTypes.THE_VOID;
|
||||||
@ -124,11 +124,11 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
* Generates the shape.
|
* Generates the shape.
|
||||||
*
|
*
|
||||||
* @param editSession The EditSession to use.
|
* @param editSession The EditSession to use.
|
||||||
* @param biomeType The default biome type.
|
* @param baseBiome The default biome type.
|
||||||
* @param hollow Specifies whether to generate a hollow shape.
|
* @param hollow Specifies whether to generate a hollow shape.
|
||||||
* @return number of affected blocks.
|
* @return number of affected blocks.
|
||||||
*/
|
*/
|
||||||
public int generate(EditSession editSession, BiomeType biomeType, boolean hollow) {
|
public int generate(EditSession editSession, BiomeType baseBiome, boolean hollow) {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (BlockVector2 position : getExtent()) {
|
for (BlockVector2 position : getExtent()) {
|
||||||
@ -136,7 +136,7 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
int z = position.getBlockZ();
|
int z = position.getBlockZ();
|
||||||
|
|
||||||
if (!hollow) {
|
if (!hollow) {
|
||||||
final BiomeType material = getBiome(x, z, biomeType);
|
final BiomeType material = getBiome(x, z, baseBiome);
|
||||||
if (material != null && material != BiomeTypes.THE_VOID) {
|
if (material != null && material != BiomeTypes.THE_VOID) {
|
||||||
editSession.getWorld().setBiome(position, material);
|
editSession.getWorld().setBiome(position, material);
|
||||||
++affected;
|
++affected;
|
||||||
@ -145,26 +145,26 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final BiomeType material = getBiomeCached(x, z, biomeType);
|
final BiomeType material = getBiomeCached(x, z, baseBiome);
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean draw = false;
|
boolean draw = false;
|
||||||
do {
|
do {
|
||||||
if (!isInsideCached(x + 1, z, biomeType)) {
|
if (!isInsideCached(x + 1, z, baseBiome)) {
|
||||||
draw = true;
|
draw = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isInsideCached(x - 1, z, biomeType)) {
|
if (!isInsideCached(x - 1, z, baseBiome)) {
|
||||||
draw = true;
|
draw = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isInsideCached(x, z + 1, biomeType)) {
|
if (!isInsideCached(x, z + 1, baseBiome)) {
|
||||||
draw = true;
|
draw = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isInsideCached(x, z - 1, biomeType)) {
|
if (!isInsideCached(x, z - 1, baseBiome)) {
|
||||||
draw = true;
|
draw = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ import com.sk89q.worldedit.math.MutableVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
|
||||||
public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
||||||
|
|
||||||
private final Vector3 unit;
|
private final Vector3 unit;
|
||||||
private final Vector3 zero2;
|
private final Vector3 zero2;
|
||||||
private Vector3 current = new MutableVector3(Vector3.ZERO);
|
private Vector3 current = new MutableVector3(Vector3.ZERO);
|
||||||
private EditSession editSession;
|
|
||||||
private Extent extent;
|
private Extent extent;
|
||||||
|
|
||||||
public WorldEditExpressionEnvironment(EditSession editSession, Vector3 unit, Vector3 zero) {
|
public WorldEditExpressionEnvironment(EditSession editSession, Vector3 unit, Vector3 zero) {
|
||||||
@ -90,5 +90,4 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
|||||||
this.current = current;
|
this.current = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,5 @@ public class Registry<V> implements Iterable<V> {
|
|||||||
public Iterator<V> iterator() {
|
public Iterator<V> iterator() {
|
||||||
return this.map.values().iterator();
|
return this.map.values().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||||||
* Holds the clipboard and the current transform on the clipboard.
|
* Holds the clipboard and the current transform on the clipboard.
|
||||||
*/
|
*/
|
||||||
public class ClipboardHolder {
|
public class ClipboardHolder {
|
||||||
|
|
||||||
private Clipboard clipboard;
|
private Clipboard clipboard;
|
||||||
private Transform transform = new Identity();
|
private Transform transform = new Identity();
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package com.sk89q.worldedit.session;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
|
||||||
|
|
||||||
public class DelegateClipboardHolder extends ClipboardHolder {
|
|
||||||
private final ClipboardHolder parent;
|
|
||||||
|
|
||||||
public DelegateClipboardHolder(ClipboardHolder holder) {
|
|
||||||
super(holder.getClipboard());
|
|
||||||
this.parent = holder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Clipboard getClipboard() {
|
|
||||||
return parent.getClipboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTransform(Transform transform) {
|
|
||||||
parent.setTransform(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Transform getTransform() {
|
|
||||||
return parent.getTransform();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PasteBuilder createPaste(Extent targetExtent) {
|
|
||||||
return parent.createPaste(targetExtent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
parent.close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,9 +20,9 @@
|
|||||||
package com.sk89q.worldedit.session;
|
package com.sk89q.worldedit.session;
|
||||||
|
|
||||||
import com.boydti.fawe.util.MaskTraverser;
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
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.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
@ -35,9 +35,6 @@ import com.sk89q.worldedit.function.operation.Operation;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds an operation to paste the contents of a clipboard.
|
* Builds an operation to paste the contents of a clipboard.
|
||||||
*/
|
*/
|
||||||
@ -59,7 +56,7 @@ public class PasteBuilder {
|
|||||||
* @param holder the clipboard holder
|
* @param holder the clipboard holder
|
||||||
* @param targetExtent an extent
|
* @param targetExtent an extent
|
||||||
*/
|
*/
|
||||||
public PasteBuilder(ClipboardHolder holder, Extent targetExtent) {
|
PasteBuilder(ClipboardHolder holder, Extent targetExtent) {
|
||||||
checkNotNull(holder);
|
checkNotNull(holder);
|
||||||
checkNotNull(targetExtent);
|
checkNotNull(targetExtent);
|
||||||
this.clipboard = holder.getClipboard();
|
this.clipboard = holder.getClipboard();
|
||||||
@ -134,5 +131,4 @@ public class PasteBuilder {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,11 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of cardinal, ordinal, and secondary-ordinal directions.
|
* A collection of cardinal, ordinal, and secondary-ordinal directions.
|
||||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren