geforkt von Mirrors/FastAsyncWorldEdit
Fix schem save order
Dieser Commit ist enthalten in:
Ursprung
032942c0e8
Commit
53ad3d3cd2
@ -5,6 +5,7 @@ import com.boydti.fawe.jnbt.streamer.IntValueReader;
|
||||
import com.google.common.collect.ForwardingIterator;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.visitor.Order;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -57,25 +58,34 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return iterator(Order.YZX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator(Order order) {
|
||||
Region region = getRegion();
|
||||
if (region instanceof CuboidRegion) {
|
||||
Iterator<BlockVector3> iter = ((CuboidRegion) region).iterator_old();
|
||||
LinearFilter filter = new LinearFilter();
|
||||
switch (order) {
|
||||
case YZX:
|
||||
if (region instanceof CuboidRegion) {
|
||||
Iterator<BlockVector3> iter = ((CuboidRegion) region).iterator_old();
|
||||
LinearFilter filter = new LinearFilter();
|
||||
|
||||
return new ForwardingIterator<BlockVector3>() {
|
||||
@Override
|
||||
protected Iterator<BlockVector3> delegate() {
|
||||
return iter;
|
||||
}
|
||||
return new ForwardingIterator<BlockVector3>() {
|
||||
@Override
|
||||
protected Iterator<BlockVector3> delegate() {
|
||||
return iter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 next() {
|
||||
return filter.next(super.next());
|
||||
@Override
|
||||
public BlockVector3 next() {
|
||||
return filter.next(super.next());
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return super.iterator();
|
||||
default:
|
||||
return order.create(region);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class LinearFilter extends AbstractFilterBlock {
|
||||
|
@ -19,12 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.object.clipboard.DelegateClipboard;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.visitor.Order;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -38,6 +40,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -232,6 +235,21 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
||||
return getParent().getBiomeType(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return getParent().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector2> iterator2d() {
|
||||
return getParent().iterator2d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator(Order order) {
|
||||
return getParent().iterator(order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores entity data.
|
||||
*/
|
||||
|
@ -41,6 +41,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.Order;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -155,6 +156,10 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
return getWidth() * getHeight() * getLength();
|
||||
}
|
||||
|
||||
default Iterator<BlockVector3> iterator(Order order) {
|
||||
return order.create(getRegion());
|
||||
}
|
||||
|
||||
default Iterator<BlockVector3> iterator() {
|
||||
return getRegion().iterator();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import com.boydti.fawe.jnbt.streamer.IntValueReader;
|
||||
import com.boydti.fawe.object.FaweOutputStream;
|
||||
import com.boydti.fawe.object.clipboard.LinearClipboard;
|
||||
import com.boydti.fawe.util.IOUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -34,7 +35,9 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.visitor.Order;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -55,6 +58,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -144,8 +148,18 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
Arrays.fill(palette, Character.MAX_VALUE);
|
||||
int paletteMax = 0;
|
||||
int numTiles = 0;
|
||||
for (BlockVector3 pos : clipboard) {
|
||||
BaseBlock block = pos.getFullBlock(clipboard);
|
||||
Clipboard finalClipboard;
|
||||
if (clipboard instanceof BlockArrayClipboard) {
|
||||
finalClipboard = ((BlockArrayClipboard) clipboard).getParent();
|
||||
} else {
|
||||
finalClipboard = clipboard;
|
||||
}
|
||||
System.out.println(finalClipboard.getClass());
|
||||
System.out.println(finalClipboard.getRegion());
|
||||
Iterator<BlockVector3> iterator = finalClipboard.iterator(Order.YZX);
|
||||
while (iterator.hasNext()) {
|
||||
BlockVector3 pos = iterator.next();
|
||||
BaseBlock block = pos.getFullBlock(finalClipboard);
|
||||
CompoundTag nbt = block.getNbtData();
|
||||
if (nbt != null) {
|
||||
Map<String, Tag> values = nbt.getValue();
|
||||
@ -208,12 +222,12 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
out.writeNamedEmptyList("TileEntities");
|
||||
}
|
||||
|
||||
if (clipboard.hasBiomes()) {
|
||||
writeBiomes(clipboard, out);
|
||||
if (finalClipboard.hasBiomes()) {
|
||||
writeBiomes(finalClipboard, out);
|
||||
}
|
||||
|
||||
List<Tag> entities = new ArrayList<>();
|
||||
for (Entity entity : clipboard.getEntities()) {
|
||||
for (Entity entity : finalClipboard.getEntities()) {
|
||||
BaseEntity state = entity.getState();
|
||||
|
||||
if (state != null) {
|
||||
@ -267,7 +281,6 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
}
|
||||
}
|
||||
};
|
||||
System.out.println("TODO Optimize biome write");
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
int width = clipboard.getRegion().getWidth();
|
||||
int length = clipboard.getRegion().getLength();
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public enum Order {
|
||||
YZX() {
|
||||
@Override
|
||||
public Iterator<BlockVector3> create(Region region) {
|
||||
if (!(region instanceof CuboidRegion)) {
|
||||
region = new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
|
||||
}
|
||||
return ((CuboidRegion) region).iterator_old();
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public abstract Iterator<BlockVector3> create(Region region);
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren