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.NMSAdapter;
import com.boydti.fawe.bukkit.adapter.DelegateLock; import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.config.Settings; 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.MathMan;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
@ -34,10 +34,8 @@ import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.function.Function; import java.util.function.Function;
public final class BukkitAdapter_1_14 extends NMSAdapter { 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); methodGetVisibleChunk = MethodHandles.lookup().unreflect(declaredGetVisibleChunk);
{ {
Field tmp; Field tmp = DataPaletteBlock.class.getDeclaredField("j");
try {
tmp = DataPaletteBlock.class.getDeclaredField("writeLock");
} catch (NoSuchFieldException paper) {
tmp = DataPaletteBlock.class.getDeclaredField("j");
}
ReflectionUtils.setAccessibleNonFinal(tmp); ReflectionUtils.setAccessibleNonFinal(tmp);
fieldLock = tmp; fieldLock = tmp;
fieldLock.setAccessible(true); fieldLock.setAccessible(true);
@ -236,7 +229,7 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
if (num_palette == 1) { if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0; for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else { } else {
final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry); final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy); 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.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14; 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.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.base.Suppliers;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -509,7 +509,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
final int bitsPerEntry = bits.c(); final int bitsPerEntry = bits.c();
final long[] blockStates = bits.a(); final long[] blockStates = bits.a();
new BitArray4096(blockStates, bitsPerEntry).toRaw(data); new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette; int num_palette;
if (palette instanceof DataPaletteLinear) { 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.DelegateLock;
import com.boydti.fawe.bukkit.adapter.NMSAdapter; import com.boydti.fawe.bukkit.adapter.NMSAdapter;
import com.boydti.fawe.config.Settings; 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.MathMan;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
@ -25,7 +25,6 @@ import sun.misc.Unsafe;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.function.Function; import java.util.function.Function;
public final class BukkitAdapter_1_15 extends NMSAdapter { public final class BukkitAdapter_1_15 extends NMSAdapter {
@ -217,7 +216,7 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
if (num_palette == 1) { if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0; for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else { } else {
final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry); final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy); 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.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_15.nbt.LazyCompoundTag_1_15; 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.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.base.Suppliers;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -439,6 +439,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
//Lighting //Lighting
// TODO optimize, cause this is really slow // TODO optimize, cause this is really slow
LightEngineThreaded engine = (LightEngineThreaded) nmsChunk.e(); LightEngineThreaded engine = (LightEngineThreaded) nmsChunk.e();
//lightChunk()
engine.a(nmsChunk, false); engine.a(nmsChunk, false);
Runnable callback; Runnable callback;
@ -448,6 +449,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
int finalMask = bitMask; int finalMask = bitMask;
callback = () -> { callback = () -> {
// Set Modified // Set Modified
//setLastSaveHadEntities
nmsChunk.d(true); // Set Modified nmsChunk.d(true); // Set Modified
nmsChunk.mustNotSave = false; nmsChunk.mustNotSave = false;
nmsChunk.markDirty(); nmsChunk.markDirty();
@ -518,15 +520,19 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
final DataBits bits = (DataBits) BukkitAdapter_1_15.fieldBits.get(blocks); final DataBits bits = (DataBits) BukkitAdapter_1_15.fieldBits.get(blocks);
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_15.fieldPalette.get(blocks); final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_15.fieldPalette.get(blocks);
//getBits()
final int bitsPerEntry = bits.c(); final int bitsPerEntry = bits.c();
//getRaw()
final long[] blockStates = bits.a(); final long[] blockStates = bits.a();
new BitArray4096(blockStates, bitsPerEntry).toRaw(data); new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette; int num_palette;
if (palette instanceof DataPaletteLinear) { if (palette instanceof DataPaletteLinear) {
//Get the size of the palette
num_palette = ((DataPaletteLinear<IBlockData>) palette).b(); num_palette = ((DataPaletteLinear<IBlockData>) palette).b();
} else if (palette instanceof DataPaletteHash) { } else if (palette instanceof DataPaletteHash) {
//Get the size of the palette
num_palette = ((DataPaletteHash<IBlockData>) palette).b(); num_palette = ((DataPaletteHash<IBlockData>) palette).b();
} else { } else {
num_palette = 0; num_palette = 0;
@ -538,6 +544,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
char ordinal = paletteToBlockChars[paletteVal]; char ordinal = paletteToBlockChars[paletteVal];
if (ordinal == Character.MAX_VALUE) { if (ordinal == Character.MAX_VALUE) {
paletteToBlockInts[num_palette++] = paletteVal; paletteToBlockInts[num_palette++] = paletteVal;
//palette.a(Object) is palette.idFor(Object)
IBlockData ibd = palette.a(data[i]); IBlockData ibd = palette.a(data[i]);
if (ibd == null) { if (ibd == null) {
ordinal = BlockTypes.AIR.getDefaultState().getOrdinalChar(); ordinal = BlockTypes.AIR.getDefaultState().getOrdinalChar();
@ -561,6 +568,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
try { try {
if (num_palette != 1) { if (num_palette != 1) {
for (int i = 0; i < num_palette; i++) { for (int i = 0; i < num_palette; i++) {
//palette.a(Object) is palette.idFor(Object)
char ordinal = ordinal(palette.a(i), adapter); char ordinal = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = ordinal; 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.DelegateLock;
import com.boydti.fawe.bukkit.adapter.NMSAdapter; import com.boydti.fawe.bukkit.adapter.NMSAdapter;
import com.boydti.fawe.config.Settings; 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.MathMan;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
@ -14,7 +14,6 @@ import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import net.jpountz.util.UnsafeUtils; import net.jpountz.util.UnsafeUtils;
@ -26,7 +25,6 @@ import sun.misc.Unsafe;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.function.Function; import java.util.function.Function;
public final class BukkitAdapter_1_15_2 extends NMSAdapter { 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) { if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0; for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else { } else {
final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry); final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy); 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.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2; 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.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.base.Suppliers;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -530,7 +530,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
final int bitsPerEntry = bits.c(); final int bitsPerEntry = bits.c();
final long[] blockStates = bits.a(); final long[] blockStates = bits.a();
new BitArray4096(blockStates, bitsPerEntry).toRaw(data); new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette; int num_palette;
if (palette instanceof DataPaletteLinear) { 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.Pool;
import com.boydti.fawe.beta.implementation.queue.QueuePool; import com.boydti.fawe.beta.implementation.queue.QueuePool;
import com.boydti.fawe.config.Settings; 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.CleanableThreadLocal;
import com.boydti.fawe.object.collection.VariableThreadLocal; import com.boydti.fawe.object.collection.VariableThreadLocal;
import com.boydti.fawe.object.exception.FaweBlockBagException; import com.boydti.fawe.object.exception.FaweBlockBagException;
@ -278,7 +278,7 @@ public enum FaweCache implements Trimable {
blockStates[0] = 0; blockStates[0] = 0;
blockBitArrayEnd = 1; blockBitArrayEnd = 1;
} else { } else {
BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry); BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy); 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.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.jnbt.streamer.StreamDelegate; import com.boydti.fawe.jnbt.streamer.StreamDelegate;
import com.boydti.fawe.jnbt.streamer.ValueReader; 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.object.collection.BlockVector3ChunkMap;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -71,7 +71,7 @@ public class MCAChunk implements IChunk {
} }
int bitsPerEntry = MathMan.log2nlz(section.palette.length - 1); 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(); char[] buffer = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
bitArray.toRaw(buffer); bitArray.toRaw(buffer);
int offset = section.layer << 12; int offset = section.layer << 12;
@ -324,7 +324,7 @@ public class MCAChunk implements IChunk {
blockstates[0] = 0; blockstates[0] = 0;
blockBitArrayEnd = 1; blockBitArrayEnd = 1;
} else { } else {
BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockstates);
bitArray.fromRaw(blocksCopy); 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()) { if (!block.getBlockType().getMaterial().isMovementBlocker()) {
return -1; return -1;
} }
int slope; int slope = Math.abs(
slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7; 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, 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;
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); BlockState block = extent.getBlock(position);
int slope = getSlope(block, position, extent); int slope = getSlope(block, position, extent);
if (slope == -1) return block.toBaseBlock(); 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(); return block.withPropertyId(data).toBaseBlock();
} }

Datei anzeigen

@ -1,10 +1,10 @@
package com.boydti.fawe.object; package com.boydti.fawe.object;
public class IntegerPair { public final class IntPair {
public int x; public int x;
public int z; public int z;
public IntegerPair(final int x, final int z) { public IntPair(final int x, final int z) {
this.x = x; this.x = x;
this.z = z; this.z = z;
} }
@ -27,7 +27,7 @@ public class IntegerPair {
if ((obj == null) || (this.getClass() != obj.getClass())) { if ((obj == null) || (this.getClass() != obj.getClass())) {
return false; return false;
} }
final IntegerPair other = (IntegerPair) obj; final IntPair other = (IntPair) obj;
return ((this.x == other.x) && (this.z == other.z)); 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; 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.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -65,9 +65,9 @@ public class ScalableHeightMap implements HeightMap {
int minY = clipboard.getMinimumPoint().getBlockY(); int minY = clipboard.getMinimumPoint().getBlockY();
int maxY = clipboard.getMaximumPoint().getBlockY(); int maxY = clipboard.getMaximumPoint().getBlockY();
int clipHeight = maxY - minY + 1; int clipHeight = maxY - minY + 1;
HashSet<IntegerPair> visited = new HashSet<>(); HashSet<IntPair> visited = new HashSet<>();
for (BlockVector3 pos : clipboard.getRegion()) { 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)) { if (visited.contains(pair)) {
continue; continue;
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,15 +1,14 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException; 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.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
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.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
public class BlockTranslateExtent extends AbstractDelegateExtent { public class BlockTranslateExtent extends AbstractDelegateExtent {
@ -25,9 +24,9 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override @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 {
mutable.mutX((location.getX() + dx)); mutable.mutX(location.getX() + dx);
mutable.mutY((location.getY() + dy)); mutable.mutY(location.getY() + dy);
mutable.mutZ((location.getZ() + dz)); mutable.mutZ(location.getZ() + dz);
return getExtent().setBlock(mutable, block); 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.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.extent.PassthroughExtent;
import java.util.Arrays; import java.util.Arrays;
public class ExtentHeightCacher extends PassthroughExtent { 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) { public ExtentHeightCacher(Extent extent) {
super(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 @Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) { public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
int rx = x - cacheBotX + 16; int rx = x - cacheBotX + 16;
@ -46,7 +44,8 @@ public class ExtentHeightCacher extends PassthroughExtent {
} }
int result = cacheHeights[index] & 0xFF; int result = cacheHeights[index] & 0xFF;
if (result == 0) { 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; return result;
} }

Datei anzeigen

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

Datei anzeigen

@ -38,7 +38,9 @@ public class HeightBoundExtent extends FaweRegionExtent {
@Override @Override
public Collection<Region> getRegions() { 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 @Override

Datei anzeigen

@ -10,6 +10,7 @@ import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class MemoryCheckingExtent extends PassthroughExtent { public class MemoryCheckingExtent extends PassthroughExtent {
private final Player player; private final Player player;
public MemoryCheckingExtent(Player player, Extent extent) { 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.extent.Extent;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionIntersection; import com.sk89q.worldedit.regions.RegionIntersection;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
public class MultiRegionExtent extends FaweRegionExtent { public class MultiRegionExtent extends FaweRegionExtent {
private final RegionIntersection intersection; private final RegionIntersection intersection;
private Region region;
private final Region[] regions; private final Region[] regions;
private Region region;
private int index; 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.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class MultiTransform extends RandomTransform { public class MultiTransform extends RandomTransform {
private ResettableExtent[] extents; private ResettableExtent[] extents;
public MultiTransform(Collection<ResettableExtent> extents) { public MultiTransform(Collection<ResettableExtent> extents) {
for (ResettableExtent extent : extents) add(extent, 1); for (ResettableExtent extent : extents) {
add(extent, 1);
}
} }
public MultiTransform() { public MultiTransform() {
@ -31,18 +33,24 @@ public class MultiTransform extends RandomTransform {
} }
@Override @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 // don't use streams for each block place, it'd be incredibly slow
boolean result = false; 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; return result;
} }
@Override @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 // don't use streams for each block place, it'd be incredibly slow
boolean result = false; boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(location, block); for (AbstractDelegateExtent extent : extents) {
result |= extent.setBlock(location, block);
}
return result; return result;
} }
@ -50,7 +58,9 @@ public class MultiTransform extends RandomTransform {
public boolean setBiome(BlockVector2 position, BiomeType biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
// don't use streams for each block place, it'd be incredibly slow // don't use streams for each block place, it'd be incredibly slow
boolean result = false; boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBiome(position, biome); for (AbstractDelegateExtent extent : extents) {
result |= extent.setBiome(position, biome);
}
return result; return result;
} }
@ -58,7 +68,9 @@ public class MultiTransform extends RandomTransform {
@Override @Override
public Entity createEntity(Location location, BaseEntity entity) { public Entity createEntity(Location location, BaseEntity entity) {
Entity created = null; Entity created = null;
for (AbstractDelegateExtent extent : extents) created = extent.createEntity(location, entity); for (AbstractDelegateExtent extent : extents) {
created = extent.createEntity(location, entity);
}
return created; return created;
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,13 +1,13 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
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.BlockStateHolder;
public class PatternTransform extends ResettableExtent { public class PatternTransform extends ResettableExtent {
private final Pattern pattern; private final Pattern pattern;
public PatternTransform(Extent parent, Pattern pattern) { public PatternTransform(Extent parent, Pattern pattern) {
@ -16,7 +16,8 @@ public class PatternTransform extends ResettableExtent {
} }
@Override @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); return pattern.apply(getExtent(), location, location);
} }
} }

Datei anzeigen

@ -30,6 +30,7 @@ public class PositionTransformExtent extends ResettableExtent {
return super.setExtent(extent); return super.setExtent(extent);
} }
@Override
public void setOrigin(BlockVector3 pos) { public void setOrigin(BlockVector3 pos) {
this.min = pos; this.min = pos;
} }
@ -38,9 +39,9 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) { if (min == null) {
min = pos; min = pos;
} }
mutable.mutX(((pos.getX() - min.getX()))); mutable.mutX(pos.getX() - min.getX());
mutable.mutY(((pos.getY() - min.getY()))); mutable.mutY(pos.getY() - min.getY());
mutable.mutZ(((pos.getZ() - min.getZ()))); mutable.mutZ(pos.getZ() - min.getZ());
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3())); MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
return min.add(tmp.toBlockPoint()); 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.FaweCache;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
@ -19,6 +18,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
public class ProcessedWEExtent extends AbstractDelegateExtent { public class ProcessedWEExtent extends AbstractDelegateExtent {
private final FaweLimit limit; private final FaweLimit limit;
private final Extent extent; private final Extent extent;
@ -65,7 +65,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
} }
@Override @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); return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
} }
@ -75,7 +76,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
} }
@Override @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(); boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
if (hasNbt) { if (hasNbt) {
if (!limit.MAX_BLOCKSTATES()) { if (!limit.MAX_BLOCKSTATES()) {

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -14,6 +14,7 @@ import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class ResettableExtent extends AbstractDelegateExtent implements Serializable { public class ResettableExtent extends AbstractDelegateExtent implements Serializable {
public ResettableExtent(Extent parent) { public ResettableExtent(Extent parent) {
super(parent); super(parent);
} }
@ -26,12 +27,14 @@ public class ResettableExtent extends AbstractDelegateExtent implements Serializ
setOrigin(pos); setOrigin(pos);
} }
protected void setOrigin(BlockVector3 pos) {} protected void setOrigin(BlockVector3 pos) {
}
public ResettableExtent setExtent(Extent extent) { public ResettableExtent setExtent(Extent extent) {
checkNotNull(extent); checkNotNull(extent);
Extent next = getExtent(); 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); ((ResettableExtent) next).setExtent(extent);
} else { } else {
new ExtentTraverser(this).setNext(new AbstractDelegateExtent(extent)); 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(); stream.defaultReadObject();
if (stream.readBoolean()) { if (stream.readBoolean()) {
try { try {

Datei anzeigen

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

Datei anzeigen

@ -14,6 +14,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public abstract class SelectTransform extends ResettableExtent { public abstract class SelectTransform extends ResettableExtent {
public SelectTransform() { public SelectTransform() {
super(new NullExtent()); super(new NullExtent());
} }
@ -31,19 +32,22 @@ public abstract class SelectTransform extends ResettableExtent {
} }
@Override @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); return getExtent(x, y, z).setBlock(x, y, z, block);
} }
@Override @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); return getExtent(position).setBlock(position, block);
} }
@Nullable @Nullable
@Override @Override
public Entity createEntity(Location position, BaseEntity entity) { 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 @Override

Datei anzeigen

@ -93,13 +93,15 @@ public class TransformExtent extends BlockTransformExtent {
} }
@Override @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)); return super.setBlock(getPos(x, y, z), transformInverse(block));
} }
@Override @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)); 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; import com.sk89q.worldedit.math.MutableBlockVector2;
public class BiomeCopy implements RegionFunction { public class BiomeCopy implements RegionFunction {
protected final Extent source; protected final Extent source;
protected final Extent destination; protected final Extent destination;
private final MutableBlockVector2 mPos2d; private final MutableBlockVector2 mPos2d;

Datei anzeigen

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

Datei anzeigen

@ -1,15 +1,14 @@
package com.boydti.fawe.object.visitor; 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 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 * An implementation of an {@link com.sk89q.worldedit.function.visitor.BreadthFirstSearch} that uses
* determine where a block should be visited. * a mask to determine where a block should be visited.
*/ */
public class DFSRecursiveVisitor extends DFSVisitor { public class DFSRecursiveVisitor extends DFSVisitor {
@ -25,7 +24,8 @@ public class DFSRecursiveVisitor extends DFSVisitor {
* @param mask the mask * @param mask the mask
* @param function the function * @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); super(function, maxDepth, maxBranching);
checkNotNull(mask); checkNotNull(mask);
this.mask = mask; this.mask = mask;

Datei anzeigen

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