mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Selective upstream merge
Signed-off-by: MattBDev <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
@ -442,7 +442,7 @@ public class Fawe {
|
||||
}
|
||||
|
||||
public static boolean isMainThread() {
|
||||
return INSTANCE != null ? INSTANCE.thread == Thread.currentThread() : true;
|
||||
return INSTANCE == null || INSTANCE.thread == Thread.currentThread();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +75,7 @@ public abstract class FaweParser<T> extends InputParser<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
inputs.add(toParse.substring(last, toParse.length()));
|
||||
inputs.add(toParse.substring(last));
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
String full = inputs.get(i);
|
||||
String command = full;
|
||||
|
@ -41,7 +41,7 @@ public class JSystemFileChooser extends JFileChooser {
|
||||
|
||||
private static FilePane findFilePane(Container parent){
|
||||
for(Component comp: parent.getComponents()){
|
||||
if(FilePane.class.isInstance(comp)){
|
||||
if(comp instanceof FilePane){
|
||||
return (FilePane)comp;
|
||||
}
|
||||
if(comp instanceof Container){
|
||||
|
@ -227,14 +227,14 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
if (forwardType.hasProperty(PropertyKey.SHAPE) && forwardType.hasProperty(PropertyKey.FACING)) {
|
||||
Direction forwardFacing = (Direction) forwardBlock.getState(PropertyKey.FACING);
|
||||
if (forwardFacing == left) {
|
||||
BlockStateHolder rightBlock = fc.getBlock(x + right.getBlockX(), y + right.getBlockY(), z + right.getBlockZ());
|
||||
BlockStateHolder rightBlock = fc.getBlock(x + right.toBlockVector().getBlockX(), y + right.toBlockVector().getBlockY(), z + right.toBlockVector().getBlockZ());
|
||||
BlockType rightType = rightBlock.getBlockType();
|
||||
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_left"));
|
||||
}
|
||||
return;
|
||||
} else if (forwardFacing == right) {
|
||||
BlockStateHolder leftBlock = fc.getBlock(x + left.getBlockX(), y + left.getBlockY(), z + left.getBlockZ());
|
||||
BlockStateHolder leftBlock = fc.getBlock(x + left.toBlockVector().getBlockX(), y + left.toBlockVector().getBlockY(), z + left.toBlockVector().getBlockZ());
|
||||
BlockType leftType = leftBlock.getBlockType();
|
||||
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_right"));
|
||||
@ -248,14 +248,14 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
if (backwardsType.hasProperty(PropertyKey.SHAPE) && backwardsType.hasProperty(PropertyKey.FACING)) {
|
||||
Direction backwardsFacing = (Direction) backwardsBlock.getState(PropertyKey.FACING);
|
||||
if (backwardsFacing == left) {
|
||||
BlockStateHolder rightBlock = fc.getBlock(x + right.getBlockX(), y + right.getBlockY(), z + right.getBlockZ());
|
||||
BlockStateHolder rightBlock = fc.getBlock(x + right.toBlockVector().getBlockX(), y + right.toBlockVector().getBlockY(), z + right.toBlockVector().getBlockZ());
|
||||
BlockType rightType = rightBlock.getBlockType();
|
||||
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_left"));
|
||||
}
|
||||
return;
|
||||
} else if (backwardsFacing == right) {
|
||||
BlockStateHolder leftBlock = fc.getBlock(x + left.getBlockX(), y + left.getBlockY(), z + left.getBlockZ());
|
||||
BlockStateHolder leftBlock = fc.getBlock(x + left.toBlockVector().getBlockX(), y + left.toBlockVector().getBlockY(), z + left.toBlockVector().getBlockZ());
|
||||
BlockType leftType = leftBlock.getBlockType();
|
||||
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_right"));
|
||||
|
@ -14,7 +14,6 @@ import java.util.concurrent.ForkJoinPool;
|
||||
public class MCAFilter<T> extends IterableThreadLocal<T> {
|
||||
|
||||
public void withPool(ForkJoinPool pool, MCAQueue queue) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -621,8 +621,8 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
|
||||
@Override
|
||||
public boolean supports(Capability capability) {
|
||||
switch (capability) {
|
||||
case CHANGE_TASKS: return false;
|
||||
if (capability == Capability.CHANGE_TASKS) {
|
||||
return false;
|
||||
}
|
||||
return super.supports(capability);
|
||||
}
|
||||
@ -823,4 +823,4 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
parentNMS.sendBlockUpdate(chunk, players);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,9 +108,7 @@ public class WritableMCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
out.writeNamedTag("InhabitedTime", inhabitedTime);
|
||||
out.writeNamedTag("LastUpdate", lastUpdate);
|
||||
if (biomes != null) {
|
||||
out.writeNamedTag("Biomes", biomes);
|
||||
}
|
||||
out.writeNamedTag("Biomes", biomes);
|
||||
int len = 0;
|
||||
for (boolean hasSection : hasSections) {
|
||||
if (hasSection) len++;
|
||||
|
@ -98,7 +98,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
FakePlayer fake = new FakePlayer(actor.getName(), actor.getUniqueId(), actor);
|
||||
return fake.toFawePlayer();
|
||||
}
|
||||
if (obj != null && obj.getClass().getName().contains("CraftPlayer") && !Fawe.imp().getPlatform().equals("bukkit")) {
|
||||
if (obj.getClass().getName().contains("CraftPlayer") && !Fawe.imp().getPlatform().equals("bukkit")) {
|
||||
try {
|
||||
Method methodGetHandle = obj.getClass().getDeclaredMethod("getHandle");
|
||||
obj = methodGetHandle.invoke(obj);
|
||||
@ -206,7 +206,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
if (region != null) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
|
||||
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1);
|
||||
if (area > 2 << 18) {
|
||||
setConfirmTask(task, context, command);
|
||||
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
||||
@ -220,7 +220,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
|
||||
public synchronized boolean confirm() {
|
||||
Runnable confirm = deleteMeta("cmdConfirm");
|
||||
if (!(confirm instanceof Runnable)) {
|
||||
if (confirm == null) {
|
||||
return false;
|
||||
}
|
||||
queueAction(() -> {
|
||||
@ -341,7 +341,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
if (session.getClipboard() != null) {
|
||||
return;
|
||||
}
|
||||
} catch (EmptyClipboardException e) {
|
||||
} catch (EmptyClipboardException ignored) {
|
||||
}
|
||||
if (player != null) {
|
||||
Clipboard clip = doc.toClipboard();
|
||||
|
@ -222,7 +222,7 @@ public class BrushSettings {
|
||||
}
|
||||
|
||||
public BrushSettings addPermissions(String... perms) {
|
||||
for (String perm : perms) permissions.add(perm);
|
||||
Collections.addAll(permissions, perms);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class SweepBrush implements Brush, ResettableTool {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean newPos = this.position == null || !position.equals(this.position);
|
||||
boolean newPos = !position.equals(this.position);
|
||||
this.position = position;
|
||||
FawePlayer player = editSession.getPlayer();
|
||||
if (newPos) {
|
||||
@ -98,7 +98,6 @@ public class SweepBrush implements Brush, ResettableTool {
|
||||
MutableVector3 last = new MutableVector3(0, 0, 0);
|
||||
for (double pos = 0D; pos <= 1D; pos += step) {
|
||||
Vector3 gradient = interpol.get1stDerivative(pos);
|
||||
if (last == null) last = new MutableVector3(interpol.get1stDerivative(pos));
|
||||
double dist = MathMan.sqrtApprox(last.distanceSq(gradient));
|
||||
last.mutX(gradient.getX());
|
||||
last.mutY(gradient.getY());
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.object.changeset;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
@ -14,9 +13,6 @@ import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
@ -27,7 +23,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@ -58,7 +55,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
|
||||
public FaweChangeSet(String world) {
|
||||
this.worldName = world;
|
||||
this.mainThread = (Fawe.get() != null) ? Fawe.isMainThread() : true;
|
||||
this.mainThread = (Fawe.get() == null) || Fawe.isMainThread();
|
||||
this.layers = FaweChunk.HEIGHT >> 4;
|
||||
}
|
||||
|
||||
@ -85,15 +82,12 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
|
||||
public boolean closeAsync() {
|
||||
waitingAsync.incrementAndGet();
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
waitingAsync.decrementAndGet();
|
||||
synchronized (waitingAsync) {
|
||||
waitingAsync.notifyAll();
|
||||
}
|
||||
close();
|
||||
TaskManager.IMP.async(() -> {
|
||||
waitingAsync.decrementAndGet();
|
||||
synchronized (waitingAsync) {
|
||||
waitingAsync.notifyAll();
|
||||
}
|
||||
close();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@ -153,8 +147,6 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
public void delete() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public EditSession toEditSession(FawePlayer player) {
|
||||
return toEditSession(player, null);
|
||||
}
|
||||
@ -258,115 +250,109 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
@Override
|
||||
public void run(final FaweChunk previous, final FaweChunk next) {
|
||||
FaweChangeSet.this.waitingCombined.incrementAndGet();
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
int cx = previous.getX();
|
||||
int cz = previous.getZ();
|
||||
int bx = cx << 4;
|
||||
int bz = cz << 4;
|
||||
synchronized (FaweChangeSet.this) {
|
||||
BiomeType[] previousBiomes = previous.getBiomeArray();
|
||||
if (previousBiomes != null) {
|
||||
BiomeType[] nextBiomes = next.getBiomeArray();
|
||||
int index = 0;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int zz = bz + z;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
BiomeType idFrom = previousBiomes[index];
|
||||
BiomeType idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != null) {
|
||||
addBiomeChange(bx + x, zz, idFrom, idTo);
|
||||
}
|
||||
index++;
|
||||
Runnable run = () -> {
|
||||
try {
|
||||
int cx = previous.getX();
|
||||
int cz = previous.getZ();
|
||||
int bx = cx << 4;
|
||||
int bz = cz << 4;
|
||||
synchronized (FaweChangeSet.this) {
|
||||
BiomeType[] previousBiomes = previous.getBiomeArray();
|
||||
if (previousBiomes != null) {
|
||||
BiomeType[] nextBiomes = next.getBiomeArray();
|
||||
int index = 0;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int zz = bz + z;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
BiomeType idFrom = previousBiomes[index];
|
||||
BiomeType idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != null) {
|
||||
addBiomeChange(bx + x, zz, idFrom, idTo);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
// Block changes
|
||||
for (int layer = 0; layer < layers; layer++) {
|
||||
int[] currentLayer = next.getIdArray(layer);
|
||||
int[] previousLayer = previous.getIdArray(layer);
|
||||
if (currentLayer == null) {
|
||||
continue;
|
||||
}
|
||||
int startY = layer << 4;
|
||||
int index = 0;
|
||||
for (int y = 0; y < 16; y++) {
|
||||
int yy = y + startY;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int zz = z + bz;
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
int xx = x + bx;
|
||||
int combinedIdCurrent = currentLayer[index];
|
||||
switch (combinedIdCurrent) {
|
||||
case 0:
|
||||
continue;
|
||||
default:
|
||||
int combinedIdPrevious;
|
||||
if (previousLayer != null) {
|
||||
combinedIdPrevious = previousLayer[index];
|
||||
if (combinedIdPrevious == 0) {
|
||||
combinedIdPrevious = BlockID.AIR;
|
||||
}
|
||||
} else {
|
||||
combinedIdPrevious = BlockID.AIR;
|
||||
}
|
||||
if (combinedIdCurrent != combinedIdPrevious) {
|
||||
add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent);
|
||||
}
|
||||
}
|
||||
// Block changes
|
||||
for (int layer = 0; layer < layers; layer++) {
|
||||
int[] currentLayer = next.getIdArray(layer);
|
||||
int[] previousLayer = previous.getIdArray(layer);
|
||||
if (currentLayer == null) {
|
||||
continue;
|
||||
}
|
||||
int startY = layer << 4;
|
||||
int index = 0;
|
||||
for (int y = 0; y < 16; y++) {
|
||||
int yy = y + startY;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int zz = z + bz;
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
int xx = x + bx;
|
||||
int combinedIdCurrent = currentLayer[index];
|
||||
if (combinedIdCurrent != 0) {
|
||||
int combinedIdPrevious;
|
||||
if (previousLayer != null) {
|
||||
combinedIdPrevious = previousLayer[index];
|
||||
if (combinedIdPrevious == 0) {
|
||||
combinedIdPrevious = BlockID.AIR;
|
||||
}
|
||||
} else {
|
||||
combinedIdPrevious = BlockID.AIR;
|
||||
}
|
||||
if (combinedIdCurrent != combinedIdPrevious) {
|
||||
add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Tile changes
|
||||
{
|
||||
// Tiles created
|
||||
Map<Short, CompoundTag> tiles = next.getTiles();
|
||||
if (!tiles.isEmpty()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
addTileCreate(entry.getValue());
|
||||
}
|
||||
}
|
||||
// Tiles removed
|
||||
tiles = previous.getTiles();
|
||||
if (!tiles.isEmpty()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
addTileRemove(entry.getValue());
|
||||
}
|
||||
}
|
||||
// Tile changes
|
||||
{
|
||||
// Tiles created
|
||||
Map<Short, CompoundTag> tiles = next.getTiles();
|
||||
if (!tiles.isEmpty()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
addTileCreate(entry.getValue());
|
||||
}
|
||||
}
|
||||
// Entity changes
|
||||
{
|
||||
// Entities created
|
||||
Set<CompoundTag> entities = next.getEntities();
|
||||
if (!entities.isEmpty()) {
|
||||
for (CompoundTag entityTag : entities) {
|
||||
addEntityCreate(entityTag);
|
||||
}
|
||||
}
|
||||
// Entities removed
|
||||
entities = previous.getEntities();
|
||||
if (!entities.isEmpty()) {
|
||||
for (CompoundTag entityTag : entities) {
|
||||
addEntityRemove(entityTag);
|
||||
}
|
||||
// Tiles removed
|
||||
tiles = previous.getTiles();
|
||||
if (!tiles.isEmpty()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
addTileRemove(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
} finally {
|
||||
if (FaweChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
|
||||
synchronized (FaweChangeSet.this.waitingAsync) {
|
||||
FaweChangeSet.this.waitingAsync.notifyAll();
|
||||
// Entity changes
|
||||
{
|
||||
// Entities created
|
||||
Set<CompoundTag> entities = next.getEntities();
|
||||
if (!entities.isEmpty()) {
|
||||
for (CompoundTag entityTag : entities) {
|
||||
addEntityCreate(entityTag);
|
||||
}
|
||||
}
|
||||
synchronized (FaweChangeSet.this.waitingCombined) {
|
||||
FaweChangeSet.this.waitingCombined.notifyAll();
|
||||
// Entities removed
|
||||
entities = previous.getEntities();
|
||||
if (!entities.isEmpty()) {
|
||||
for (CompoundTag entityTag : entities) {
|
||||
addEntityRemove(entityTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
} finally {
|
||||
if (FaweChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
|
||||
synchronized (FaweChangeSet.this.waitingAsync) {
|
||||
FaweChangeSet.this.waitingAsync.notifyAll();
|
||||
}
|
||||
synchronized (FaweChangeSet.this.waitingCombined) {
|
||||
FaweChangeSet.this.waitingCombined.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (mainThread) {
|
||||
@ -377,4 +363,4 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,8 +229,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
// skip mode
|
||||
int mode = is.read();
|
||||
// origin
|
||||
int x = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int x = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + is.read());
|
||||
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + is.read());
|
||||
setOrigin(x, z);
|
||||
setupStreamDelegates(mode);
|
||||
}
|
||||
@ -328,7 +328,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
blockSize++;
|
||||
try {
|
||||
OutputStream os = getBiomeOS();
|
||||
FaweOutputStream os = getBiomeOS();
|
||||
os.write((byte) (x >> 24));
|
||||
os.write((byte) (x >> 16));
|
||||
os.write((byte) (x >> 8));
|
||||
@ -337,8 +337,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
os.write((byte) (z >> 16));
|
||||
os.write((byte) (z >> 8));
|
||||
os.write((byte) (z));
|
||||
((FaweOutputStream) os).writeVarInt(from.getInternalId());
|
||||
((FaweOutputStream) os).writeVarInt(to.getInternalId());
|
||||
os.writeVarInt(from.getInternalId());
|
||||
os.writeVarInt(to.getInternalId());
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -412,7 +412,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
change.z = posDel.readZ(is) + originZ;
|
||||
idDel.readCombined(is, change, dir);
|
||||
return change;
|
||||
} catch (EOFException ignoreOEF) {
|
||||
} catch (EOFException ignored) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.handleError(e);
|
||||
@ -448,7 +448,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
public Iterator<MutableBiomeChange> getBiomeIterator(final boolean dir) throws IOException {
|
||||
final InputStream is = getBiomeIS();
|
||||
final FaweInputStream is = getBiomeIS();
|
||||
if (is == null) {
|
||||
return new ArrayList<MutableBiomeChange>().iterator();
|
||||
}
|
||||
@ -460,14 +460,14 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
try {
|
||||
int int1 = is.read();
|
||||
if (int1 != -1) {
|
||||
int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int from = ((FaweInputStream) is).readVarInt();
|
||||
int to = ((FaweInputStream) is).readVarInt();
|
||||
int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + is.read());
|
||||
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + is.read());
|
||||
int from = is.readVarInt();
|
||||
int to = is.readVarInt();
|
||||
change.setBiome(x, z, from, to);
|
||||
return change;
|
||||
}
|
||||
} catch (EOFException ignoreOEF) {
|
||||
} catch (EOFException ignored) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.handleError(e);
|
||||
@ -516,9 +516,6 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
|
||||
public Iterator<MutableFullBlockChange> getFullBlockIterator(BlockBag blockBag, int inventory, final boolean dir) throws IOException {
|
||||
final FaweInputStream is = new FaweInputStream(getBlockIS());
|
||||
if (is == null) {
|
||||
return new ArrayList<MutableFullBlockChange>().iterator();
|
||||
}
|
||||
final MutableFullBlockChange change = new MutableFullBlockChange(blockBag, inventory, dir);
|
||||
return new Iterator<MutableFullBlockChange>() {
|
||||
private MutableFullBlockChange last = read();
|
||||
@ -530,7 +527,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
change.z = posDel.readZ(is) + originZ;
|
||||
idDel.readCombined(is, change, dir);
|
||||
return change;
|
||||
} catch (EOFException ignoreOEF) {
|
||||
} catch (EOFException ignored) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.handleError(e);
|
||||
@ -576,10 +573,9 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
|
||||
public MutableEntityChange read() {
|
||||
try {
|
||||
CompoundTag tag = (CompoundTag) is.readTag();
|
||||
change.tag = tag;
|
||||
change.tag = (CompoundTag) is.readTag();
|
||||
return change;
|
||||
} catch (Exception ignoreOEF) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
is.close();
|
||||
@ -626,10 +622,9 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
|
||||
public MutableTileChange read() {
|
||||
try {
|
||||
CompoundTag tag = (CompoundTag) is.readTag();
|
||||
change.tag = tag;
|
||||
change.tag = (CompoundTag) is.readTag();
|
||||
return change;
|
||||
} catch (Exception ignoreOEF) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
is.close();
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
@ -209,7 +210,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
this.braf = new RandomAccessFile(file, "rw");
|
||||
long volume = (long) width * (long) height * (long) length * 4l + (long) HEADER_SIZE;
|
||||
long volume = (long) width * (long) height * (long) length * 4L + (long) HEADER_SIZE;
|
||||
braf.setLength(0);
|
||||
braf.setLength(volume);
|
||||
if (width * height * length != 0) {
|
||||
@ -243,7 +244,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
length = dimensions.getBlockZ();
|
||||
area = width * length;
|
||||
volume = width * length * height;
|
||||
long size = width * height * length * 4l + HEADER_SIZE + (hasBiomes() ? area : 0);
|
||||
long size = width * height * length * 4L + HEADER_SIZE + (hasBiomes() ? area : 0);
|
||||
if (braf.length() < size) {
|
||||
close();
|
||||
this.braf = new RandomAccessFile(file, "rw");
|
||||
@ -505,7 +506,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
mbb.putInt(index, combined);
|
||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
||||
if (hasNbt) {
|
||||
setTile(x, y, z, ((BaseBlock)block).getNbtData());
|
||||
setTile(x, y, z, block.getNbtData());
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@ -520,13 +521,13 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
int combined = block.getInternalId();
|
||||
int index = (HEADER_SIZE) + (i << 2);
|
||||
mbb.putInt(index, combined);
|
||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
if (hasNbt) {
|
||||
int y = i / area;
|
||||
int newI = (i - (y * area));
|
||||
int z = newI / width;
|
||||
int x = newI - z * width;
|
||||
setTile(x, y, z, ((BaseBlock)block).getNbtData());
|
||||
setTile(x, y, z, block.getNbtData());
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
@ -2,8 +2,6 @@ package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -14,12 +12,13 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
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 javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class EmptyClipboard implements Clipboard {
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory {
|
||||
int x = tileChange.tag.getInt("x");
|
||||
int y = tileChange.tag.getInt("y");
|
||||
int z = tileChange.tag.getInt("z");
|
||||
clipboard.setTile(x, y, z, tileChange.tag);
|
||||
clipboard.setTile(BlockVector3.at(x,y,z), tileChange.tag);
|
||||
}
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
|
@ -7,13 +7,9 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The BlockVectorSet is a Memory optimized Set for storing BlockVectors
|
||||
@ -35,23 +31,19 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
|
||||
public BlockVector3 get(int index) {
|
||||
int count = 0;
|
||||
ObjectIterator<Int2ObjectMap.Entry<LocalBlockVectorSet>> iter = localSets.int2ObjectEntrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Int2ObjectMap.Entry<LocalBlockVectorSet> entry = iter.next();
|
||||
for (Int2ObjectMap.Entry<LocalBlockVectorSet> entry : localSets.int2ObjectEntrySet()) {
|
||||
LocalBlockVectorSet set = entry.getValue();
|
||||
int size = set.size();
|
||||
int newSize = count + size;
|
||||
if (newSize > index) {
|
||||
int localIndex = index - count;
|
||||
MutableBlockVector3 pos = new MutableBlockVector3(set.getIndex(localIndex));
|
||||
if (pos != null) {
|
||||
int pair = entry.getIntKey();
|
||||
int cx = MathMan.unpairX(pair);
|
||||
int cz = MathMan.unpairY(pair);
|
||||
pos.mutX((cx << 11) + pos.getBlockX());
|
||||
pos.mutZ((cz << 11) + pos.getBlockZ());
|
||||
return pos;
|
||||
}
|
||||
int pair = entry.getIntKey();
|
||||
int cx = MathMan.unpairX(pair);
|
||||
int cz = MathMan.unpairY(pair);
|
||||
pos.mutX((cx << 11) + pos.getBlockX());
|
||||
pos.mutZ((cz << 11) + pos.getBlockZ());
|
||||
return pos;
|
||||
}
|
||||
count += newSize;
|
||||
}
|
||||
@ -83,11 +75,12 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
final ObjectIterator<Int2ObjectMap.Entry<LocalBlockVectorSet>> entries = localSets.int2ObjectEntrySet().iterator();
|
||||
if (!entries.hasNext()) {
|
||||
return new ArrayList<BlockVector3>().iterator();
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
return new Iterator<BlockVector3>() {
|
||||
Int2ObjectMap.Entry<LocalBlockVectorSet> entry = entries.next();
|
||||
@ -182,7 +175,7 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
public boolean retainAll(@NotNull Collection<?> c) {
|
||||
Objects.requireNonNull(c);
|
||||
boolean modified = false;
|
||||
Iterator it = iterator();
|
||||
@ -209,4 +202,4 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
public void clear() {
|
||||
localSets.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class HeightBoundExtent extends FaweRegionExtent {
|
||||
|
||||
@ -35,6 +36,6 @@ public class HeightBoundExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
public Collection<Region> getRegions() {
|
||||
return Arrays.asList(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));
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class SingleRegionExtent extends FaweRegionExtent {
|
||||
|
||||
@ -32,6 +33,6 @@ public class SingleRegionExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
public Collection<Region> getRegions() {
|
||||
return Arrays.asList(region);
|
||||
return Collections.singletonList(region);
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public abstract class DFSVisitor implements Operation {
|
||||
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 ((current.from == null || !adjacent.equals(current.from))) {
|
||||
if ((!adjacent.equals(current.from))) {
|
||||
AtomicInteger adjacentCount = visited.get(adjacent);
|
||||
if (adjacentCount == null) {
|
||||
if (countAdd++ < maxBranch) {
|
||||
|
@ -8,6 +8,7 @@ import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nonnull;
|
||||
@ -27,18 +28,19 @@ public class FastChunkIterator implements Iterable<BlockVector2> {
|
||||
}
|
||||
|
||||
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable HasFaweQueue editSession) {
|
||||
this(iter, (FaweQueue) (editSession != null ? editSession.getQueue() : null));
|
||||
this(iter, editSession != null ? editSession.getQueue() : null);
|
||||
}
|
||||
|
||||
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable FaweQueue faweQueue) {
|
||||
this.iterable = iter;
|
||||
this.queue = faweQueue != null && faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null;
|
||||
this.queue = faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null;
|
||||
}
|
||||
|
||||
public Iterable<? extends BlockVector2> getIterable() {
|
||||
return iterable;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<BlockVector2> iterator() {
|
||||
if (queue == null || Settings.IMP.QUEUE.PRELOAD_CHUNKS <= 1) {
|
||||
|
@ -44,66 +44,57 @@ public class FaweChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ()));
|
||||
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint());
|
||||
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint());
|
||||
try {
|
||||
Operations.completeLegacy(copyA);
|
||||
Operations.completeLegacy(copyB);
|
||||
sessionA.flushQueue();
|
||||
sessionB.flushQueue();
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.IMP.task(whenDone);
|
||||
TaskManager.IMP.async(() -> {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ()));
|
||||
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint());
|
||||
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint());
|
||||
try {
|
||||
Operations.completeLegacy(copyA);
|
||||
Operations.completeLegacy(copyB);
|
||||
sessionA.flushQueue();
|
||||
sessionB.flushQueue();
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()));
|
||||
try {
|
||||
Operations.completeLegacy(copy);
|
||||
to.flushQueue();
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.IMP.async(() -> {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()));
|
||||
try {
|
||||
Operations.completeLegacy(copy);
|
||||
to.flushQueue();
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
TaskManager.IMP.task(whenDone);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
World world = editSession.getWorld();
|
||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
world.regenerate(region, editSession);
|
||||
editSession.flushQueue();
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
TaskManager.IMP.async(() -> {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
World world = editSession.getWorld();
|
||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
world.regenerate(region, editSession);
|
||||
editSession.flushQueue();
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.boydti.fawe.regions.general.plot;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweOutputStream;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.boydti.fawe.object.io.FastByteArraysInputStream;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.IOUtil;
|
||||
@ -22,15 +19,12 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompressedCompoundTag;
|
||||
import com.sk89q.jnbt.CompressedSchematicTag;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicWriter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -45,7 +39,6 @@ import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class FaweSchematicHandler extends SchematicHandler {
|
||||
@Override
|
||||
@ -62,25 +55,22 @@ public class FaweSchematicHandler extends SchematicHandler {
|
||||
|
||||
@Override
|
||||
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
TaskManager.IMP.async(() -> {
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
|
||||
final int mx = pos1.getX();
|
||||
final int my = pos1.getY();
|
||||
final int mz = pos1.getZ();
|
||||
final int mx = pos1.getX();
|
||||
final int my = pos1.getY();
|
||||
final int mz = pos1.getZ();
|
||||
|
||||
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);
|
||||
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);
|
||||
|
||||
Clipboard holder = new BlockArrayClipboard(region, clipboard);
|
||||
CompressedSchematicTag tag = new CompressedSchematicTag(holder);
|
||||
whenDone.run(tag);
|
||||
}
|
||||
Clipboard holder = new BlockArrayClipboard(region, clipboard);
|
||||
CompressedSchematicTag tag = new CompressedSchematicTag(holder);
|
||||
whenDone.run(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@ -109,7 +99,7 @@ public class FaweSchematicHandler extends SchematicHandler {
|
||||
} else {
|
||||
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new PGZIPOutputStream(stream))) {
|
||||
Map<String, com.sk89q.jnbt.Tag> map = tag.getValue();
|
||||
output.writeNamedTag("Schematic", map.containsKey("Schematic") ? map.get("Schematic") : tag);
|
||||
output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
@ -136,7 +126,7 @@ public class FaweSchematicHandler extends SchematicHandler {
|
||||
com.sk89q.jnbt.CompoundTag weTag = (com.sk89q.jnbt.CompoundTag) FaweCache.asTag(tag);
|
||||
try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
|
||||
Map<String, com.sk89q.jnbt.Tag> map = weTag.getValue();
|
||||
nos.writeNamedTag("Schematic", map.containsKey("Schematic") ? map.get("Schematic") : weTag);
|
||||
nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -88,8 +88,7 @@ public class PlotTrim {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
plots.addAll(PlotSquared.get().getPlots(area));
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots(area));
|
||||
if (ExpireManager.IMP != null) {
|
||||
plots.removeAll(ExpireManager.IMP.getPendingExpired());
|
||||
}
|
||||
|
@ -50,13 +50,11 @@ public final class BrushCache {
|
||||
tool.setHolder(item);
|
||||
brushCache.put(key, tool);
|
||||
return tool;
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (Exception throwable) {
|
||||
throwable.printStackTrace();
|
||||
Fawe.debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue());
|
||||
if (item != null) {
|
||||
item.setNbtData(null);
|
||||
brushCache.remove(key);
|
||||
}
|
||||
item.setNbtData(null);
|
||||
brushCache.remove(key);
|
||||
} finally {
|
||||
RECURSION.remove();
|
||||
}
|
||||
@ -123,4 +121,4 @@ public final class BrushCache {
|
||||
}
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class CachedMathMan {
|
||||
add = 0.0f;
|
||||
}
|
||||
|
||||
float invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
||||
float invDiv = 1.0f / ((Math.max(x, y)) * INV_ATAN2_DIM_MINUS_1);
|
||||
|
||||
int xi = (int) (x * invDiv);
|
||||
int yi = (int) (y * invDiv);
|
||||
|
@ -26,7 +26,7 @@ public class ColorUtil {
|
||||
: Float.parseFloat(color));
|
||||
switch (type) {
|
||||
case PARSE_ALPHA:
|
||||
return (c < 0f) ? 0f : ((c > 1f) ? 1f : c);
|
||||
return (c < 0f) ? 0f : (Math.min(c, 1f));
|
||||
case PARSE_PERCENT:
|
||||
return (c <= 0f) ? 0f : ((c >= 100f) ? 1f : (c / 100f));
|
||||
case PARSE_COMPONENT:
|
||||
|
@ -54,7 +54,7 @@ public class EditSessionBuilder {
|
||||
public EditSessionBuilder(@Nonnull World world) {
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
this.worldName = Fawe.imp().getWorldName(world);
|
||||
this.worldName = world.getName();
|
||||
}
|
||||
|
||||
public EditSessionBuilder(@Nonnull String worldName) {
|
||||
|
@ -81,11 +81,11 @@ public class MathMan {
|
||||
}
|
||||
|
||||
public static int clamp(int check, int min, int max) {
|
||||
return check > max ? max : (check < min ? min : check);
|
||||
return check > max ? max : (Math.max(check, min));
|
||||
}
|
||||
|
||||
public static float clamp(float check, float min, float max) {
|
||||
return check > max ? max : (check < min ? min : check);
|
||||
return check > max ? max : (Math.max(check, min));
|
||||
}
|
||||
|
||||
public static double hypot(final double... pars) {
|
||||
@ -104,7 +104,7 @@ public class MathMan {
|
||||
return sum;
|
||||
}
|
||||
|
||||
public static final int wrap(int value, int min, int max) {
|
||||
public static int wrap(int value, int min, int max) {
|
||||
if (max < min) {
|
||||
return value;
|
||||
}
|
||||
|
@ -7,11 +7,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.FieldAccessor;
|
||||
@ -126,7 +122,7 @@ public class ReflectionUtils {
|
||||
Class<?>[] additionalTypes, Object[] additionalValues) throws Exception {
|
||||
Object[] parms = new Object[additionalValues.length + 2];
|
||||
parms[0] = value;
|
||||
parms[1] = Integer.valueOf(ordinal);
|
||||
parms[1] = ordinal;
|
||||
System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length);
|
||||
return enumClass.cast(getConstructorAccessor(enumClass, additionalTypes).newInstance(parms));
|
||||
}
|
||||
@ -332,12 +328,12 @@ public class ReflectionUtils {
|
||||
}
|
||||
|
||||
public static Method[] sortMethods(Method[] methods) {
|
||||
Arrays.sort(methods, (o1, o2) -> o1.getName().compareTo(o2.getName()));
|
||||
Arrays.sort(methods, Comparator.comparing(Method::getName));
|
||||
return methods;
|
||||
}
|
||||
|
||||
public static Field[] sortFields(Field[] fields) {
|
||||
Arrays.sort(fields, (o1, o2) -> o1.getName().compareTo(o2.getName()));
|
||||
Arrays.sort(fields, Comparator.comparing(Field::getName));
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user