3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Small spring cleaning

I changed really small bits and pieces of code. If you have questions just comment and I'll answer them.
Dieser Commit ist enthalten in:
MattBDev 2020-04-30 16:26:52 -04:00
Ursprung 508d595b8d
Commit ef3642d521
45 geänderte Dateien mit 305 neuen und 409 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.adapter.NMSAdapter;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
@ -34,10 +34,8 @@ import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
import sun.misc.Unsafe;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.function.Function;
public final class BukkitAdapter_1_14 extends NMSAdapter {
@ -88,12 +86,7 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
methodGetVisibleChunk = MethodHandles.lookup().unreflect(declaredGetVisibleChunk);
{
Field tmp;
try {
tmp = DataPaletteBlock.class.getDeclaredField("writeLock");
} catch (NoSuchFieldException paper) {
tmp = DataPaletteBlock.class.getDeclaredField("j");
}
Field tmp = DataPaletteBlock.class.getDeclaredField("j");
ReflectionUtils.setAccessibleNonFinal(tmp);
fieldLock = tmp;
fieldLock.setAccessible(true);
@ -236,7 +229,7 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else {
final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry);
final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -10,7 +10,7 @@ import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14;
import com.boydti.fawe.object.collection.AdaptedMap;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag;
@ -509,7 +509,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
final int bitsPerEntry = bits.c();
final long[] blockStates = bits.a();
new BitArray4096(blockStates, bitsPerEntry).toRaw(data);
new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette;
if (palette instanceof DataPaletteLinear) {

Datei anzeigen

@ -5,7 +5,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.NMSAdapter;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
@ -25,7 +25,6 @@ import sun.misc.Unsafe;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.function.Function;
public final class BukkitAdapter_1_15 extends NMSAdapter {
@ -217,7 +216,7 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else {
final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry);
final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -10,7 +10,7 @@ import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_15.nbt.LazyCompoundTag_1_15;
import com.boydti.fawe.object.collection.AdaptedMap;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag;
@ -439,6 +439,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
//Lighting
// TODO optimize, cause this is really slow
LightEngineThreaded engine = (LightEngineThreaded) nmsChunk.e();
//lightChunk()
engine.a(nmsChunk, false);
Runnable callback;
@ -448,6 +449,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
int finalMask = bitMask;
callback = () -> {
// Set Modified
//setLastSaveHadEntities
nmsChunk.d(true); // Set Modified
nmsChunk.mustNotSave = false;
nmsChunk.markDirty();
@ -518,15 +520,19 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
final DataBits bits = (DataBits) BukkitAdapter_1_15.fieldBits.get(blocks);
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_15.fieldPalette.get(blocks);
//getBits()
final int bitsPerEntry = bits.c();
//getRaw()
final long[] blockStates = bits.a();
new BitArray4096(blockStates, bitsPerEntry).toRaw(data);
new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette;
if (palette instanceof DataPaletteLinear) {
//Get the size of the palette
num_palette = ((DataPaletteLinear<IBlockData>) palette).b();
} else if (palette instanceof DataPaletteHash) {
//Get the size of the palette
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
} else {
num_palette = 0;
@ -538,6 +544,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
char ordinal = paletteToBlockChars[paletteVal];
if (ordinal == Character.MAX_VALUE) {
paletteToBlockInts[num_palette++] = paletteVal;
//palette.a(Object) is palette.idFor(Object)
IBlockData ibd = palette.a(data[i]);
if (ibd == null) {
ordinal = BlockTypes.AIR.getDefaultState().getOrdinalChar();
@ -561,6 +568,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
try {
if (num_palette != 1) {
for (int i = 0; i < num_palette; i++) {
//palette.a(Object) is palette.idFor(Object)
char ordinal = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = ordinal;
}

Datei anzeigen

@ -5,7 +5,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.NMSAdapter;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
@ -14,7 +14,6 @@ import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
import java.util.concurrent.locks.ReentrantLock;
import net.jpountz.util.UnsafeUtils;
@ -26,7 +25,6 @@ import sun.misc.Unsafe;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.function.Function;
public final class BukkitAdapter_1_15_2 extends NMSAdapter {
@ -219,7 +217,7 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else {
final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry);
final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -8,7 +8,7 @@ import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2;
import com.boydti.fawe.object.collection.AdaptedMap;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag;
@ -530,7 +530,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
final int bitsPerEntry = bits.c();
final long[] blockStates = bits.a();
new BitArray4096(blockStates, bitsPerEntry).toRaw(data);
new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette;
if (palette instanceof DataPaletteLinear) {

Datei anzeigen

@ -8,7 +8,7 @@ import com.boydti.fawe.beta.Trimable;
import com.boydti.fawe.beta.implementation.queue.Pool;
import com.boydti.fawe.beta.implementation.queue.QueuePool;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.object.collection.CleanableThreadLocal;
import com.boydti.fawe.object.collection.VariableThreadLocal;
import com.boydti.fawe.object.exception.FaweBlockBagException;
@ -278,7 +278,7 @@ public enum FaweCache implements Trimable {
blockStates[0] = 0;
blockBitArrayEnd = 1;
} else {
BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry);
BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -1,29 +0,0 @@
//package com.boydti.fawe.command;
//
//import com.sk89q.worldedit.WorldEdit;
//import com.sk89q.worldedit.util.command.parametric.ParameterData;
//import com.sk89q.worldedit.world.block.BlockTypes;
//
//import java.util.ArrayList;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//public class MaskBinding extends FaweBinding {
// private final WorldEdit worldEdit;
//
// public MaskBinding(WorldEdit worldEdit) {
// super(worldEdit);
// this.worldEdit = worldEdit;
// }
//
// @Override
// public List<String> getSuggestions(ParameterData parameter, String prefix) {
// if (prefix.isEmpty()) {
// return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList());
// }
// return super.getSuggestions(parameter, prefix);
// }
//}

Datei anzeigen

@ -1,26 +0,0 @@
//package com.boydti.fawe.command;
//
//import com.sk89q.worldedit.WorldEdit;
//import com.sk89q.worldedit.util.command.parametric.ParameterData;
//import com.sk89q.worldedit.world.block.BlockTypes;
//
//import java.util.List;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//public class PatternBinding extends FaweBinding {
// private final WorldEdit worldEdit;
//
// public PatternBinding(WorldEdit worldEdit) {
// super(worldEdit);
// this.worldEdit = worldEdit;
// }
//
// @Override
// public List<String> getSuggestions(ParameterData parameter, String prefix) {
// if (prefix.isEmpty()) {
// return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream()).collect(Collectors.toList());
// }
// return super.getSuggestions(parameter, prefix);
// }
//}

Datei anzeigen

@ -8,7 +8,7 @@ import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.jnbt.streamer.StreamDelegate;
import com.boydti.fawe.jnbt.streamer.ValueReader;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.object.collection.BlockVector3ChunkMap;
import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.CompoundTag;
@ -71,7 +71,7 @@ public class MCAChunk implements IChunk {
}
int bitsPerEntry = MathMan.log2nlz(section.palette.length - 1);
BitArray4096 bitArray = new BitArray4096(section.blocks, bitsPerEntry);
BitArray bitArray = new BitArray(bitsPerEntry, 4096, section.blocks);
char[] buffer = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
bitArray.toRaw(buffer);
int offset = section.layer << 12;
@ -324,7 +324,7 @@ public class MCAChunk implements IChunk {
blockstates[0] = 0;
blockBitArrayEnd = 1;
} else {
BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry);
BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockstates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -1,42 +0,0 @@
package com.boydti.fawe.object;
import com.boydti.fawe.util.MathMan;
public class BytePair {
public short pair;
public BytePair(final byte x, final byte z) {
this.pair = MathMan.pairByte(x, z);
}
public int get0x() {
return MathMan.unpair16x((byte) get0());
}
public int get0y() {
return MathMan.unpair16y((byte) get0());
}
public int get0() {
return MathMan.unpairShortX(pair);
}
public int get1() {
return MathMan.unpairShortY(pair);
}
@Override
public int hashCode() {
return pair;
}
@Override
public String toString() {
return pair + "";
}
@Override
public boolean equals(final Object obj) {
return obj.hashCode() == pair;
}
}

Datei anzeigen

@ -29,8 +29,9 @@ public class DataAnglePattern extends AbstractPattern {
if (!block.getBlockType().getMaterial().isMovementBlocker()) {
return -1;
}
int slope;
slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7;
int slope = Math.abs(
extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent
.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - distance, y, 0, maxY)) * 7;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z - distance, y, 0, maxY)) * 5;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x - distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x + distance, z - distance, y, 0, maxY)) * 5;
@ -42,7 +43,7 @@ public class DataAnglePattern extends AbstractPattern {
BlockState block = extent.getBlock(position);
int slope = getSlope(block, position, extent);
if (slope == -1) return block.toBaseBlock();
int data = (Math.min(slope, 255)) >> 4;
int data = Math.min(slope, 255) >> 4;
return block.withPropertyId(data).toBaseBlock();
}

Datei anzeigen

@ -1,10 +1,10 @@
package com.boydti.fawe.object;
public class IntegerPair {
public final class IntPair {
public int x;
public int z;
public IntegerPair(final int x, final int z) {
public IntPair(final int x, final int z) {
this.x = x;
this.z = z;
}
@ -27,7 +27,7 @@ public class IntegerPair {
if ((obj == null) || (this.getClass() != obj.getClass())) {
return false;
}
final IntegerPair other = (IntegerPair) obj;
return ((this.x == other.x) && (this.z == other.z));
final IntPair other = (IntPair) obj;
return (this.x == other.x) && (this.z == other.z);
}
}

Datei anzeigen

@ -0,0 +1,45 @@
package com.boydti.fawe.object;
public final class IntTriple {
public int x;
public int y;
public int z;
public IntTriple(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public final int hashCode() {
return x ^ (z << 12) ^ (y << 24);
}
public final int getX() {
return x;
}
public final int getY() {
return y;
}
public final int getZ() {
return z;
}
@Override
public String toString() {
return x + "," + y + "," + z;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof IntTriple) {
IntTriple other = (IntTriple) obj;
return other.x == x && other.z == z && other.y == y;
}
return false;
}
}

Datei anzeigen

@ -1,60 +0,0 @@
package com.boydti.fawe.object;
public class IntegerTrio {
public int x, y, z;
public IntegerTrio(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public IntegerTrio(IntegerTrio node) {
this.x = node.x;
this.y = node.y;
this.z = node.z;
}
public IntegerTrio() {
}
public final void set(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public final void set(IntegerTrio node) {
this.x = node.x;
this.y = node.y;
this.z = node.z;
}
@Override
public final int hashCode() {
return (x ^ (z << 12)) ^ (y << 24);
}
public final int getX() {
return x;
}
public final int getY() {
return y;
}
public final int getZ() {
return z;
}
@Override
public String toString() {
return x + "," + y + "," + z;
}
@Override
public boolean equals(Object obj) {
IntegerTrio other = (IntegerTrio) obj;
return other.x == x && other.z == z && other.y == y;
}
}

Datei anzeigen

@ -1,6 +1,6 @@
package com.boydti.fawe.object.brush.heightmap;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.IntPair;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -65,9 +65,9 @@ public class ScalableHeightMap implements HeightMap {
int minY = clipboard.getMinimumPoint().getBlockY();
int maxY = clipboard.getMaximumPoint().getBlockY();
int clipHeight = maxY - minY + 1;
HashSet<IntegerPair> visited = new HashSet<>();
HashSet<IntPair> visited = new HashSet<>();
for (BlockVector3 pos : clipboard.getRegion()) {
IntegerPair pair = new IntegerPair(pos.getBlockX(), pos.getBlockZ());
IntPair pair = new IntPair(pos.getBlockX(), pos.getBlockZ());
if (visited.contains(pair)) {
continue;
}

Datei anzeigen

@ -6,8 +6,7 @@ import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase;
import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.change.MutableFullBlockChange;
import com.boydti.fawe.object.IntPair;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream;
@ -16,7 +15,6 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -386,7 +384,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
return null;
}
public IntegerPair readHeader() {
public IntPair readHeader() {
int ox = getOriginX();
int oz = getOriginZ();
if (ox == 0 && oz == 0 && bdFile.exists()) {
@ -404,7 +402,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
e.printStackTrace();
}
}
return new IntegerPair(ox, oz);
return new IntPair(ox, oz);
}
@Override

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.jnbt.streamer.IntValueReader;
import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.object.IntTriple;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag;
@ -28,7 +28,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
private BiomeType[] biomes = null;
private char[] states;
private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc;
private final HashMap<IntTriple, CompoundTag> nbtMapLoc;
private final HashMap<Integer, CompoundTag> nbtMapIndex;
@ -91,8 +91,8 @@ public class CPUOptimizedClipboard extends LinearClipboard {
if (nbtMapLoc.isEmpty()) {
return;
}
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMapLoc.entrySet()) {
IntegerTrio key = entry.getKey();
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMapLoc.entrySet()) {
IntTriple key = entry.getKey();
setTile(getIndex(key.x, key.y, key.z), entry.getValue());
}
nbtMapLoc.clear();
@ -164,7 +164,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
nbtMapLoc.put(new IntegerTrio(x, y, z), tag);
nbtMapLoc.put(new IntTriple(x, y, z), tag);
return true;
}

Datei anzeigen

@ -3,7 +3,7 @@ package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.jnbt.streamer.IntValueReader;
import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.object.IntTriple;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
@ -56,7 +56,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
private static int HEADER_SIZE = 14;
private static final int MAX_SIZE = Short.MAX_VALUE - Short.MIN_VALUE;
private final HashMap<IntegerTrio, CompoundTag> nbtMap;
private final HashMap<IntTriple, CompoundTag> nbtMap;
private final File file;
private RandomAccessFile braf;
@ -322,8 +322,8 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
CompoundTag nbt;
if (nbtMap.size() < 4) {
nbt = null;
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMap.entrySet()) {
IntegerTrio key = entry.getKey();
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple key = entry.getKey();
int index = getIndex(key.x, key.y, key.z);
if (index == i) {
nbt = entry.getValue();
@ -335,7 +335,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
int newI = i - y * getArea();
int z = newI / getWidth();
int x = newI - z * getWidth();
nbt = nbtMap.get(new IntegerTrio(x, y, z));
nbt = nbtMap.get(new IntTriple(x, y, z));
}
return state.toBaseBlock(nbt);
}
@ -344,7 +344,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
private BaseBlock toBaseBlock(BlockState state, int x, int y, int z) {
if (state.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
CompoundTag nbt = nbtMap.get(new IntegerTrio(x, y, z));
CompoundTag nbt = nbtMap.get(new IntTriple(x, y, z));
return state.toBaseBlock(nbt);
}
return state.toBaseBlock();
@ -375,7 +375,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
nbtMap.put(new IntegerTrio(x, y, z), tag);
nbtMap.put(new IntTriple(x, y, z), tag);
Map<String, Tag> values = tag.getValue();
values.put("x", new IntTag(x));
values.put("y", new IntTag(y));

Datei anzeigen

@ -2,7 +2,7 @@ package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.jnbt.streamer.IntValueReader;
import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.object.IntTriple;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
@ -39,7 +39,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
private byte[] buffer = new byte[MainUtil.getMaxCompressedLength(BLOCK_SIZE)];
private byte[] biomes = null;
private final HashMap<IntegerTrio, CompoundTag> nbtMap;
private final HashMap<IntTriple, CompoundTag> nbtMap;
private int lastOrdinalsI = -1;
@ -198,8 +198,8 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
CompoundTag nbt;
if (nbtMap.size() < 4) {
nbt = null;
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMap.entrySet()) {
IntegerTrio trio = entry.getKey();
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple trio = entry.getKey();
int index = getIndex(trio.x, trio.y, trio.z);
if (index == i) {
nbt = entry.getValue();
@ -211,7 +211,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
int newI = i - y * getArea();
int z = newI / getWidth();
int x = newI - z * getWidth();
nbt = nbtMap.get(new IntegerTrio(x, y, z));
nbt = nbtMap.get(new IntTriple(x, y, z));
}
return state.toBaseBlock(nbt);
}
@ -247,7 +247,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
nbtMap.put(new IntegerTrio(x, y, z), tag);
nbtMap.put(new IntTriple(x, y, z), tag);
Map<String, Tag> values = tag.getValue();
values.put("x", new IntTag(x));
values.put("y", new IntTag(y));

Datei anzeigen

@ -1,18 +1,18 @@
package com.boydti.fawe.object.collection;
public final class BitArray4096 {
public final class BitArray {
private final long[] data;
private final int bitsPerEntry;
private final int maxSeqLocIndex;
private final int maxEntryValue;
private final long mask;
private final int longLen;
public BitArray4096(long[] buffer, int bitsPerEntry) {
public BitArray(int bitsPerEntry, int arraySize, long[] buffer) {
this.bitsPerEntry = bitsPerEntry;
this.maxSeqLocIndex = 64 - bitsPerEntry;
maxEntryValue = (1 << bitsPerEntry) - 1;
this.longLen = (this.bitsPerEntry << 12) >> 6;
this.mask = (1L << bitsPerEntry) - 1L;
this.longLen = (arraySize * bitsPerEntry) >> 6;
if (buffer.length < longLen) {
this.data = new long[longLen];
} else {
@ -20,11 +20,11 @@ public final class BitArray4096 {
}
}
public BitArray4096(int bitsPerEntry) {
public BitArray(int bitsPerEntry, int arraySize) {
this.bitsPerEntry = bitsPerEntry;
this.maxSeqLocIndex = 64 - bitsPerEntry;
maxEntryValue = (1 << bitsPerEntry) - 1;
this.longLen = (this.bitsPerEntry * 4096) >> 6;
this.mask = (1L << bitsPerEntry) - 1L;
this.longLen = (arraySize * bitsPerEntry) >> 6;
this.data = new long[longLen];
}
@ -37,13 +37,13 @@ public final class BitArray4096 {
int bitIndexStart = index * bitsPerEntry;
int longIndexStart = bitIndexStart >> 6;
int localBitIndexStart = bitIndexStart & 63;
this.data[longIndexStart] = this.data[longIndexStart] & ~((long) maxEntryValue << localBitIndexStart) | ((long) value) << localBitIndexStart;
this.data[longIndexStart] = this.data[longIndexStart] & ~(mask << localBitIndexStart) | (long) value << localBitIndexStart;
if(localBitIndexStart > maxSeqLocIndex) {
int longIndexEnd = longIndexStart + 1;
int localShiftStart = 64 - localBitIndexStart;
int localShiftEnd = bitsPerEntry - localShiftStart;
this.data[longIndexEnd] = this.data[longIndexEnd] >>> localShiftEnd << localShiftEnd | (((long) value) >> localShiftStart);
this.data[longIndexEnd] = this.data[longIndexEnd] >>> localShiftEnd << localShiftEnd | ((long) value >> localShiftStart);
}
}
@ -55,10 +55,10 @@ public final class BitArray4096 {
int localBitIndexStart = bitIndexStart & 63;
if(localBitIndexStart <= maxSeqLocIndex) {
return (int)(this.data[longIndexStart] >>> localBitIndexStart & maxEntryValue);
return (int)(this.data[longIndexStart] >>> localBitIndexStart & mask);
} else {
int localShift = 64 - localBitIndexStart;
return (int) ((this.data[longIndexStart] >>> localBitIndexStart | this.data[longIndexStart + 1] << localShift) & maxEntryValue);
return (int) ((this.data[longIndexStart] >>> localBitIndexStart | this.data[longIndexStart + 1] << localShift) & mask);
}
}
@ -66,23 +66,16 @@ public final class BitArray4096 {
return longLen;
}
public final void fromRawSlow(char[] arr) {
for (int i = 0; i < arr.length; i++) {
set(i, arr[i]);
}
}
public final void fromRaw(int[] arr) {
final long[] data = this.data;
final int bitsPerEntry = this.bitsPerEntry;
final int maxSeqLocIndex = this.maxSeqLocIndex;
int localStart = 0;
int lastVal;
int arrI = 0;
long l = 0;
long nextVal;
for (int i = 0; i < longLen; i++) {
int lastVal;
for (; localStart <= maxSeqLocIndex; localStart += bitsPerEntry) {
lastVal = arr[arrI++];
l |= ((long) lastVal << localStart);
@ -92,7 +85,7 @@ public final class BitArray4096 {
lastVal = arr[arrI++];
int shift = 64 - localStart;
nextVal = lastVal >> shift;
long nextVal = lastVal >> shift;
l |= ((lastVal - (nextVal << shift)) << localStart);
@ -109,22 +102,6 @@ public final class BitArray4096 {
}
}
public BitArray4096 growSlow(int bitsPerEntry) {
BitArray4096 newBitArray = new BitArray4096(bitsPerEntry);
for (int i = 0; i < 4096; i++) {
newBitArray.set(i, get(i));
}
return newBitArray;
}
public final char[] toRawSlow() {
char[] arr = new char[4096];
for (int i = 0; i < arr.length; i++) {
arr[i] = (char) get(i);
}
return arr;
}
public final int[] toRaw() {
return toRaw(new int[4096]);
}
@ -133,15 +110,14 @@ public final class BitArray4096 {
final long[] data = this.data;
final int dataLength = longLen;
final int bitsPerEntry = this.bitsPerEntry;
final int maxEntryValue = this.maxEntryValue;
final long maxEntryValue = this.mask;
final int maxSeqLocIndex = this.maxSeqLocIndex;
int localStart = 0;
char lastVal;
int arrI = 0;
long l;
for (int i = 0; i < dataLength; i++) {
l = data[i];
long l = data[i];
char lastVal;
for (; localStart <= maxSeqLocIndex; localStart += bitsPerEntry) {
lastVal = (char) (l >>> localStart & maxEntryValue);
buffer[arrI++] = lastVal;
@ -167,15 +143,14 @@ public final class BitArray4096 {
final long[] data = this.data;
final int dataLength = longLen;
final int bitsPerEntry = this.bitsPerEntry;
final int maxEntryValue = this.maxEntryValue;
final long maxEntryValue = this.mask;
final int maxSeqLocIndex = this.maxSeqLocIndex;
int localStart = 0;
char lastVal;
int arrI = 0;
long l;
for (int i = 0; i < dataLength; i++) {
l = data[i];
long l = data[i];
char lastVal;
for (; localStart <= maxSeqLocIndex; localStart += bitsPerEntry) {
lastVal = (char) (l >>> localStart & maxEntryValue);
buffer[arrI++] = lastVal;

Datei anzeigen

@ -1,15 +1,14 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class BlockTranslateExtent extends AbstractDelegateExtent {
@ -25,9 +24,9 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
mutable.mutX((location.getX() + dx));
mutable.mutY((location.getY() + dy));
mutable.mutZ((location.getZ() + dz));
mutable.mutX(location.getX() + dx);
mutable.mutY(location.getY() + dy);
mutable.mutZ(location.getZ() + dz);
return getExtent().setBlock(mutable, block);
}

Datei anzeigen

@ -2,11 +2,14 @@ package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent;
import java.util.Arrays;
public class ExtentHeightCacher extends PassthroughExtent {
private transient int cacheBotX = Integer.MIN_VALUE;
private transient int cacheBotZ = Integer.MIN_VALUE;
private transient byte[] cacheHeights;
private transient int lastY;
public ExtentHeightCacher(Extent extent) {
super(extent);
}
@ -19,11 +22,6 @@ public class ExtentHeightCacher extends PassthroughExtent {
}
}
private transient int cacheBotX = Integer.MIN_VALUE;
private transient int cacheBotZ = Integer.MIN_VALUE;
private transient byte[] cacheHeights;
private transient int lastY;
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
int rx = x - cacheBotX + 16;
@ -46,7 +44,8 @@ public class ExtentHeightCacher extends PassthroughExtent {
}
int result = cacheHeights[index] & 0xFF;
if (result == 0) {
cacheHeights[index] = (byte) (result = lastY = super.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY));
cacheHeights[index] = (byte) (result = lastY = super
.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY));
}
return result;
}

Datei anzeigen

@ -22,6 +22,7 @@ import java.util.Collection;
import javax.annotation.Nullable;
public abstract class FaweRegionExtent extends ResettableExtent implements IBatchProcessor {
private final FaweLimit limit;
/**
@ -68,7 +69,8 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
throws WorldEditException {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);

Datei anzeigen

@ -38,7 +38,9 @@ public class HeightBoundExtent extends FaweRegionExtent {
@Override
public Collection<Region> getRegions() {
return Collections.singletonList(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, min, max, Integer.MIN_VALUE, Integer.MAX_VALUE));
return Collections.singletonList(
new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, min, max, Integer.MIN_VALUE,
Integer.MAX_VALUE));
}
@Override

Datei anzeigen

@ -10,6 +10,7 @@ import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class MemoryCheckingExtent extends PassthroughExtent {
private final Player player;
public MemoryCheckingExtent(Player player, Extent extent) {

Datei anzeigen

@ -7,15 +7,14 @@ import com.boydti.fawe.object.FaweLimit;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionIntersection;
import java.util.Arrays;
import java.util.Collection;
public class MultiRegionExtent extends FaweRegionExtent {
private final RegionIntersection intersection;
private Region region;
private final Region[] regions;
private Region region;
private int index;
/**

Datei anzeigen

@ -9,15 +9,17 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Arrays;
import java.util.Collection;
import javax.annotation.Nullable;
public class MultiTransform extends RandomTransform {
private ResettableExtent[] extents;
public MultiTransform(Collection<ResettableExtent> extents) {
for (ResettableExtent extent : extents) add(extent, 1);
for (ResettableExtent extent : extents) {
add(extent, 1);
}
}
public MultiTransform() {
@ -31,18 +33,24 @@ public class MultiTransform extends RandomTransform {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
// don't use streams for each block place, it'd be incredibly slow
boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(x, y, z, block);
for (AbstractDelegateExtent extent : extents) {
result |= extent.setBlock(x, y, z, block);
}
return result;
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
throws WorldEditException {
// don't use streams for each block place, it'd be incredibly slow
boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(location, block);
for (AbstractDelegateExtent extent : extents) {
result |= extent.setBlock(location, block);
}
return result;
}
@ -50,7 +58,9 @@ public class MultiTransform extends RandomTransform {
public boolean setBiome(BlockVector2 position, BiomeType biome) {
// don't use streams for each block place, it'd be incredibly slow
boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBiome(position, biome);
for (AbstractDelegateExtent extent : extents) {
result |= extent.setBiome(position, biome);
}
return result;
}
@ -58,7 +68,9 @@ public class MultiTransform extends RandomTransform {
@Override
public Entity createEntity(Location location, BaseEntity entity) {
Entity created = null;
for (AbstractDelegateExtent extent : extents) created = extent.createEntity(location, entity);
for (AbstractDelegateExtent extent : extents) {
created = extent.createEntity(location, entity);
}
return created;
}
}

Datei anzeigen

@ -39,6 +39,7 @@ import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
//todo This should be removed in favor of com.sk89q.worldedit.extent.NullExtent
public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
private final FaweException reason;

Datei anzeigen

@ -9,6 +9,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class OffsetExtent extends ResettableExtent {
private final int dx, dy, dz;
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
@ -21,7 +22,9 @@ public class OffsetExtent extends ResettableExtent {
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return getExtent().setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz), biome);
return getExtent()
.setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz),
biome);
}
@Override
@ -30,12 +33,15 @@ public class OffsetExtent extends ResettableExtent {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy, location.getBlockZ() + dz, block);
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
throws WorldEditException {
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy,
location.getBlockZ() + dz, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
}

Datei anzeigen

@ -1,13 +1,13 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class PatternTransform extends ResettableExtent {
private final Pattern pattern;
public PatternTransform(Extent parent, Pattern pattern) {
@ -16,7 +16,8 @@ public class PatternTransform extends ResettableExtent {
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
throws WorldEditException {
return pattern.apply(getExtent(), location, location);
}
}

Datei anzeigen

@ -30,6 +30,7 @@ public class PositionTransformExtent extends ResettableExtent {
return super.setExtent(extent);
}
@Override
public void setOrigin(BlockVector3 pos) {
this.min = pos;
}
@ -38,9 +39,9 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) {
min = pos;
}
mutable.mutX(((pos.getX() - min.getX())));
mutable.mutY(((pos.getY() - min.getY())));
mutable.mutZ(((pos.getZ() - min.getZ())));
mutable.mutX(pos.getX() - min.getX());
mutable.mutY(pos.getY() - min.getY());
mutable.mutZ(pos.getZ() - min.getZ());
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
return min.add(tmp.toBlockPoint());
}

Datei anzeigen

@ -2,7 +2,6 @@ package com.boydti.fawe.object.extent;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
@ -19,6 +18,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
public class ProcessedWEExtent extends AbstractDelegateExtent {
private final FaweLimit limit;
private final Extent extent;
@ -65,7 +65,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
throws WorldEditException {
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
}
@ -75,7 +76,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
throws WorldEditException {
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
if (hasNbt) {
if (!limit.MAX_BLOCKSTATES()) {

Datei anzeigen

@ -1,21 +1,19 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.SplittableRandom;
public class RandomOffsetTransform extends ResettableExtent {
private transient SplittableRandom random;
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
private final int dx, dy, dz;
private transient SplittableRandom random;
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
public RandomOffsetTransform(Extent parent, int dx, int dy, int dz) {
super(parent);
@ -33,7 +31,8 @@ public class RandomOffsetTransform extends ResettableExtent {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block)
throws WorldEditException {
int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx;
int y = pos.getBlockY() + random.nextInt(1 + (dy << 1)) - dy;
int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz;
@ -41,7 +40,8 @@ public class RandomOffsetTransform extends ResettableExtent {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
x = x + random.nextInt(1 + (dx << 1)) - dx;
y = y + random.nextInt(1 + (dy << 1)) - dy;
z = z + random.nextInt(1 + (dz << 1)) - dz;

Datei anzeigen

@ -1,5 +1,7 @@
package com.boydti.fawe.object.extent;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.object.collection.RandomCollection;
import com.boydti.fawe.object.random.SimpleRandom;
import com.boydti.fawe.object.random.TrueRandom;
@ -10,9 +12,6 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Uses a random pattern of a weighted list of patterns.
*/
@ -28,6 +27,10 @@ public class RandomTransform extends SelectTransform {
this(new TrueRandom());
}
public RandomTransform(SimpleRandom random) {
this.random = random;
}
@Override
public AbstractDelegateExtent getExtent(int x, int y, int z) {
return collection.next(x, y, z);
@ -38,10 +41,6 @@ public class RandomTransform extends SelectTransform {
return collection.next(x, 0, z);
}
public RandomTransform(SimpleRandom random) {
this.random = random;
}
@Override
public ResettableExtent setExtent(Extent extent) {
if (collection == null) {

Datei anzeigen

@ -14,6 +14,7 @@ import java.io.Serializable;
import java.lang.reflect.Field;
public class ResettableExtent extends AbstractDelegateExtent implements Serializable {
public ResettableExtent(Extent parent) {
super(parent);
}
@ -26,12 +27,14 @@ public class ResettableExtent extends AbstractDelegateExtent implements Serializ
setOrigin(pos);
}
protected void setOrigin(BlockVector3 pos) {}
protected void setOrigin(BlockVector3 pos) {
}
public ResettableExtent setExtent(Extent extent) {
checkNotNull(extent);
Extent next = getExtent();
if (!(next instanceof NullExtent) && !(next instanceof World) && next instanceof ResettableExtent) {
if (!(next instanceof NullExtent) && !(next instanceof World)
&& next instanceof ResettableExtent) {
((ResettableExtent) next).setExtent(extent);
} else {
new ExtentTraverser(this).setNext(new AbstractDelegateExtent(extent));
@ -49,7 +52,8 @@ public class ResettableExtent extends AbstractDelegateExtent implements Serializ
}
}
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
private void readObject(java.io.ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
if (stream.readBoolean()) {
try {

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
@ -11,16 +10,15 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import javax.annotation.Nullable;
public class ScaleTransform extends ResettableExtent {
private final double dx, dy, dz;
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
private transient int maxy;
private transient BlockVector3 min;
private final double dx, dy, dz;
public ScaleTransform(Extent parent, double dx, double dy, double dz) {
super(parent);
@ -42,9 +40,9 @@ public class ScaleTransform extends ResettableExtent {
if (min == null) {
min = pos;
}
mutable.mutX((min.getX() + (pos.getX() - min.getX()) * dx));
mutable.mutY((min.getY() + (pos.getY() - min.getY()) * dy));
mutable.mutZ((min.getZ() + (pos.getZ() - min.getZ()) * dz));
mutable.mutX(min.getX() + (pos.getX() - min.getX()) * dx);
mutable.mutY(min.getY() + (pos.getY() - min.getY()) * dy);
mutable.mutZ(min.getZ() + (pos.getZ() - min.getZ()) * dz);
return mutable;
}
@ -52,15 +50,16 @@ public class ScaleTransform extends ResettableExtent {
if (min == null) {
min = BlockVector3.at(x, y, z);
}
mutable.mutX((min.getX() + (x - min.getX()) * dx));
mutable.mutY((min.getY() + (y - min.getY()) * dy));
mutable.mutZ((min.getZ() + (z - min.getZ()) * dz));
mutable.mutX(min.getX() + (x - min.getX()) * dx);
mutable.mutY(min.getY() + (y - min.getY()) * dy);
mutable.mutZ(min.getZ() + (z - min.getZ()) * dz);
return mutable;
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
throws WorldEditException {
boolean result = false;
MutableBlockVector3 pos = new MutableBlockVector3(getPos(location));
double sx = pos.getX();
@ -82,7 +81,8 @@ public class ScaleTransform extends ResettableExtent {
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
boolean result = false;
MutableBlockVector3 pos = new MutableBlockVector3(getPos(position.getBlockX(), 0, position.getBlockZ()));
MutableBlockVector3 pos = new MutableBlockVector3(
getPos(position.getBlockX(), 0, position.getBlockZ()));
double sx = pos.getX();
double sz = pos.getZ();
double ex = pos.getX() + dx;
@ -96,7 +96,8 @@ public class ScaleTransform extends ResettableExtent {
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block)
throws WorldEditException {
boolean result = false;
MutableBlockVector3 pos = new MutableBlockVector3(getPos(x1, y1, z1));
double sx = pos.getX();
@ -118,7 +119,9 @@ public class ScaleTransform extends ResettableExtent {
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
Location newLoc = new Location(location.getExtent(), getPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()).toVector3(), location.getYaw(), location.getPitch());
Location newLoc = new Location(location.getExtent(),
getPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()).toVector3(),
location.getYaw(), location.getPitch());
return super.createEntity(newLoc, entity);
}
}

Datei anzeigen

@ -14,6 +14,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import javax.annotation.Nullable;
public abstract class SelectTransform extends ResettableExtent {
public SelectTransform() {
super(new NullExtent());
}
@ -31,19 +32,22 @@ public abstract class SelectTransform extends ResettableExtent {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return getExtent(x, y, z).setBlock(x, y, z, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block)
throws WorldEditException {
return getExtent(position).setBlock(position, block);
}
@Nullable
@Override
public Entity createEntity(Location position, BaseEntity entity) {
return getExtent(position.getBlockX(), position.getBlockY(), position.getBlockZ()).createEntity(position, entity);
return getExtent(position.getBlockX(), position.getBlockY(), position.getBlockZ())
.createEntity(position, entity);
}
@Override

Datei anzeigen

@ -93,13 +93,15 @@ public class TransformExtent extends BlockTransformExtent {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return super.setBlock(getPos(x, y, z), transformInverse(block));
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
throws WorldEditException {
return super.setBlock(getPos(location), transformInverse(block));
}

Datei anzeigen

@ -8,6 +8,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector2;
public class BiomeCopy implements RegionFunction {
protected final Extent source;
protected final Extent destination;
private final MutableBlockVector2 mPos2d;

Datei anzeigen

@ -1,17 +1,15 @@
package com.boydti.fawe.object.visitor;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Visits adjacent points on the same X-Z plane as long as the points
* pass the given mask, and then executes the provided region
* function on the entire column.
* Visits adjacent points on the same X-Z plane as long as the points pass the given mask, and then
* executes the provided region function on the entire column.
* <p>
* <p>This is used by {@code //fill}.</p>
*/

Datei anzeigen

@ -1,15 +1,14 @@
package com.boydti.fawe.object.visitor;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
/**
* An implementation of an {@link com.sk89q.worldedit.function.visitor.BreadthFirstSearch} that uses a mask to
* determine where a block should be visited.
* An implementation of an {@link com.sk89q.worldedit.function.visitor.BreadthFirstSearch} that uses
* a mask to determine where a block should be visited.
*/
public class DFSRecursiveVisitor extends DFSVisitor {
@ -25,7 +24,8 @@ public class DFSRecursiveVisitor extends DFSVisitor {
* @param mask the mask
* @param function the function
*/
public DFSRecursiveVisitor(final Mask mask, final RegionFunction function, int maxDepth, int maxBranching) {
public DFSRecursiveVisitor(final Mask mask, final RegionFunction function, int maxDepth,
int maxBranching) {
super(function, maxDepth, maxBranching);
checkNotNull(mask);
this.mask = mask;

Datei anzeigen

@ -1,17 +1,16 @@
package com.boydti.fawe.object.visitor;
import com.boydti.fawe.object.IntTriple;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.IntegerTrio;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
@ -57,11 +56,11 @@ public abstract class DFSVisitor implements Operation {
return this.directions;
}
private IntegerTrio[] getIntDirections() {
IntegerTrio[] array = new IntegerTrio[directions.size()];
private IntTriple[] getIntDirections() {
IntTriple[] array = new IntTriple[directions.size()];
for (int i = 0; i < array.length; i++) {
BlockVector3 dir = directions.get(i);
array[i] = new IntegerTrio(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());
array[i] = new IntTriple(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());
}
return array;
}
@ -77,17 +76,13 @@ public abstract class DFSVisitor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
NodePair current;
Node from;
Node adjacent;
// MutableBlockVector3 mutable = new MutableBlockVector3();
// MutableBlockVector3 mutable2 = new MutableBlockVector3();
int countAdd, countAttempt;
IntegerTrio[] dirs = getIntDirections();
IntTriple[] dirs = getIntDirections();
for (int layer = 0; !queue.isEmpty(); layer++) {
current = queue.poll();
from = current.to;
while (!queue.isEmpty()) {
NodePair current = queue.poll();
Node from = current.to;
hashQueue.remove(from);
if (visited.containsKey(from)) {
continue;
@ -97,16 +92,18 @@ public abstract class DFSVisitor implements Operation {
// mutable.mutZ(from.getZ());
BlockVector3 bv = BlockVector3.at(from.getX(), from.getY(), from.getZ());
function.apply(bv);
countAdd = 0;
countAttempt = 0;
for (IntegerTrio direction : dirs) {
int countAdd = 0;
int countAttempt = 0;
for (IntTriple direction : dirs) {
// mutable2.mutX(from.getX() + direction.x);
// mutable2.mutY(from.getY() + direction.y);
// mutable2.mutZ(from.getZ() + direction.z);
BlockVector3 bv2 = BlockVector3.at(from.getX() + direction.x, from.getY() + direction.y, from.getZ() + direction.z);
BlockVector3 bv2 = BlockVector3
.at(from.getX() + direction.x, from.getY() + direction.y,
from.getZ() + direction.z);
if (isVisitable(bv, bv2)) {
adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
if ((!adjacent.equals(current.from))) {
Node adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
if (!adjacent.equals(current.from)) {
AtomicInteger adjacentCount = visited.get(adjacent);
if (adjacentCount == null) {
if (countAdd++ < maxBranch) {
@ -115,7 +112,8 @@ public abstract class DFSVisitor implements Operation {
countAttempt++;
} else {
hashQueue.add(adjacent);
queue.addFirst(new NodePair(from, adjacent, current.depth + 1));
queue.addFirst(
new NodePair(from, adjacent, current.depth + 1));
}
} else {
countAttempt++;
@ -155,19 +153,8 @@ public abstract class DFSVisitor implements Operation {
return this.affected;
}
public class NodePair {
public final Node to;
public final Node from;
private final int depth;
public NodePair(Node from, Node to, int depth) {
this.from = from;
this.to = to;
this.depth = depth;
}
}
public static final class Node {
private int x, y, z;
public Node(int x, int y, int z) {
@ -176,13 +163,13 @@ public abstract class DFSVisitor implements Operation {
this.z = z;
}
private final void set(int x, int y, int z) {
private void set(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
private final void set(Node node) {
private void set(Node node) {
this.x = node.x;
this.y = node.y;
this.z = node.z;
@ -193,15 +180,15 @@ public abstract class DFSVisitor implements Operation {
return (x ^ (z << 12)) ^ (y << 24);
}
private final int getX() {
private int getX() {
return x;
}
private final int getY() {
private int getY() {
return y;
}
private final int getZ() {
private int getZ() {
return z;
}
@ -216,4 +203,17 @@ public abstract class DFSVisitor implements Operation {
return other.x == x && other.z == z && other.y == y;
}
}
public static class NodePair {
public final Node to;
public final Node from;
private final int depth;
NodePair(Node from, Node to, int depth) {
this.from = from;
this.to = to;
this.depth = depth;
}
}
}

Datei anzeigen

@ -248,10 +248,10 @@ public class TextureUtil implements TextureHolder {
new BiomeColor(167, "modified_badlands_plateau", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
new BiomeColor(168, "bamboo_jungle", 0.95f, 0.9f, 0x92BD59, 0x77AB2F),
new BiomeColor(169, "bamboo_jungle_hills", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
new BiomeColor(170, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
new BiomeColor(171, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
new BiomeColor(172, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
new BiomeColor(173, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
new BiomeColor(170, "Unknown Biome", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
new BiomeColor(171, "Unknown Biome", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
new BiomeColor(172, "Unknown Biome", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
new BiomeColor(173, "Unknown Biome", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
new BiomeColor(174, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
new BiomeColor(175, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
new BiomeColor(176, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),