mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fix schem save order
This commit is contained in:
parent
032942c0e8
commit
53ad3d3cd2
@ -5,6 +5,7 @@ import com.boydti.fawe.jnbt.streamer.IntValueReader;
|
|||||||
import com.google.common.collect.ForwardingIterator;
|
import com.google.common.collect.ForwardingIterator;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.function.visitor.Order;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
@ -57,7 +58,14 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<BlockVector3> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
|
return iterator(Order.YZX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<BlockVector3> iterator(Order order) {
|
||||||
Region region = getRegion();
|
Region region = getRegion();
|
||||||
|
switch (order) {
|
||||||
|
case YZX:
|
||||||
if (region instanceof CuboidRegion) {
|
if (region instanceof CuboidRegion) {
|
||||||
Iterator<BlockVector3> iter = ((CuboidRegion) region).iterator_old();
|
Iterator<BlockVector3> iter = ((CuboidRegion) region).iterator_old();
|
||||||
LinearFilter filter = new LinearFilter();
|
LinearFilter filter = new LinearFilter();
|
||||||
@ -73,9 +81,11 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
|
|||||||
return filter.next(super.next());
|
return filter.next(super.next());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
return super.iterator();
|
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
return order.create(region);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LinearFilter extends AbstractFilterBlock {
|
private class LinearFilter extends AbstractFilterBlock {
|
||||||
|
@ -19,12 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.clipboard;
|
package com.sk89q.worldedit.extent.clipboard;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.Filter;
|
||||||
import com.boydti.fawe.object.clipboard.DelegateClipboard;
|
import com.boydti.fawe.object.clipboard.DelegateClipboard;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
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;
|
||||||
|
import com.sk89q.worldedit.function.visitor.Order;
|
||||||
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.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
@ -38,6 +40,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -232,6 +235,21 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
return getParent().getBiomeType(x, z);
|
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.
|
* 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.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
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.function.visitor.RegionVisitor;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -155,6 +156,10 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
|||||||
return getWidth() * getHeight() * getLength();
|
return getWidth() * getHeight() * getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Iterator<BlockVector3> iterator(Order order) {
|
||||||
|
return order.create(getRegion());
|
||||||
|
}
|
||||||
|
|
||||||
default Iterator<BlockVector3> iterator() {
|
default Iterator<BlockVector3> iterator() {
|
||||||
return getRegion().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.jnbt.streamer.IntValueReader;
|
||||||
import com.boydti.fawe.object.FaweOutputStream;
|
import com.boydti.fawe.object.FaweOutputStream;
|
||||||
|
import com.boydti.fawe.object.clipboard.LinearClipboard;
|
||||||
import com.boydti.fawe.util.IOUtil;
|
import com.boydti.fawe.util.IOUtil;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
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.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.function.visitor.Order;
|
||||||
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.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
@ -55,6 +58,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -144,8 +148,18 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
Arrays.fill(palette, Character.MAX_VALUE);
|
Arrays.fill(palette, Character.MAX_VALUE);
|
||||||
int paletteMax = 0;
|
int paletteMax = 0;
|
||||||
int numTiles = 0;
|
int numTiles = 0;
|
||||||
for (BlockVector3 pos : clipboard) {
|
Clipboard finalClipboard;
|
||||||
BaseBlock block = pos.getFullBlock(clipboard);
|
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();
|
CompoundTag nbt = block.getNbtData();
|
||||||
if (nbt != null) {
|
if (nbt != null) {
|
||||||
Map<String, Tag> values = nbt.getValue();
|
Map<String, Tag> values = nbt.getValue();
|
||||||
@ -208,12 +222,12 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
out.writeNamedEmptyList("TileEntities");
|
out.writeNamedEmptyList("TileEntities");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clipboard.hasBiomes()) {
|
if (finalClipboard.hasBiomes()) {
|
||||||
writeBiomes(clipboard, out);
|
writeBiomes(finalClipboard, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Tag> entities = new ArrayList<>();
|
List<Tag> entities = new ArrayList<>();
|
||||||
for (Entity entity : clipboard.getEntities()) {
|
for (Entity entity : finalClipboard.getEntities()) {
|
||||||
BaseEntity state = entity.getState();
|
BaseEntity state = entity.getState();
|
||||||
|
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
@ -267,7 +281,6 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
System.out.println("TODO Optimize biome write");
|
|
||||||
BlockVector3 min = clipboard.getMinimumPoint();
|
BlockVector3 min = clipboard.getMinimumPoint();
|
||||||
int width = clipboard.getRegion().getWidth();
|
int width = clipboard.getRegion().getWidth();
|
||||||
int length = clipboard.getRegion().getLength();
|
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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user