mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
fix: correctly create Minecraft Structure format schematics (#2787)
- fixes #2784 - fixes #2785
This commit is contained in:
parent
af83b2f9c9
commit
3761b5184c
@ -19,7 +19,6 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
|||||||
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;
|
||||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -174,27 +173,23 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
ArrayList<HashMap<String, Object>> palette = new ArrayList<>();
|
ArrayList<HashMap<String, Object>> palette = new ArrayList<>();
|
||||||
for (BlockVector3 point : region) {
|
for (BlockVector3 point : region) {
|
||||||
BlockState block = clipboard.getBlock(point);
|
BlockState block = clipboard.getBlock(point);
|
||||||
int combined = block.getInternalId();
|
char ordinal = block.getOrdinalChar();
|
||||||
BlockType type = block.getBlockType();
|
BlockType type = block.getBlockType();
|
||||||
|
|
||||||
if (type == BlockTypes.STRUCTURE_VOID || indexes.containsKey(combined)) {
|
if (type == BlockTypes.STRUCTURE_VOID || indexes.containsKey(ordinal)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
indexes.put(combined, (Integer) palette.size());
|
indexes.put(ordinal, palette.size());
|
||||||
HashMap<String, Object> paletteEntry = new HashMap<>();
|
HashMap<String, Object> paletteEntry = new HashMap<>();
|
||||||
paletteEntry.put("Name", type.id());
|
paletteEntry.put("Name", type.id());
|
||||||
if (block.getInternalId() != type.getInternalId()) {
|
if (block.getInternalId() != type.getInternalId()) {
|
||||||
Map<String, Object> properties = null;
|
Map<String, Object> properties = null;
|
||||||
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
|
for (Map.Entry<Property<?>, Object> entry : block.getStates().entrySet()) {
|
||||||
int propIndex = property.getIndex(block.getInternalId());
|
|
||||||
if (propIndex != 0) {
|
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
properties = new HashMap<>();
|
properties = new HashMap<>();
|
||||||
}
|
}
|
||||||
Object value = property.getValues().get(propIndex);
|
properties.put(entry.getKey().getName(), entry.getValue().toString());
|
||||||
properties.put(property.getName(), value.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
paletteEntry.put("Properties", properties);
|
paletteEntry.put("Properties", properties);
|
||||||
@ -211,16 +206,23 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
for (BlockVector3 point : region) {
|
for (BlockVector3 point : region) {
|
||||||
BaseBlock block = clipboard.getFullBlock(point);
|
BaseBlock block = clipboard.getFullBlock(point);
|
||||||
if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) {
|
if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) {
|
||||||
int combined = block.getInternalId();
|
char ordinal = block.getOrdinalChar();
|
||||||
int index = indexes.get(combined);
|
int index = indexes.get(ordinal);
|
||||||
List<Integer> pos = Arrays.asList(point.x() - min.x(),
|
List<Integer> pos = Arrays.asList(
|
||||||
point.y() - min.y(), point.z() - min.z()
|
point.x() - min.x(),
|
||||||
|
point.y() - min.y(),
|
||||||
|
point.z() - min.z()
|
||||||
);
|
);
|
||||||
if (!block.hasNbtData()) {
|
if (!block.hasNbtData()) {
|
||||||
blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos));
|
blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos));
|
||||||
} else {
|
} else {
|
||||||
|
Map<String, Tag> tag = new HashMap<>(block.getNbtData().getValue());
|
||||||
|
tag.remove("x");
|
||||||
|
tag.remove("y");
|
||||||
|
tag.remove("z");
|
||||||
|
CompoundTag cTag = new CompoundTag(tag);
|
||||||
blocks.add(
|
blocks.add(
|
||||||
FaweCache.INSTANCE.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
|
FaweCache.INSTANCE.asMap("state", index, "pos", pos, "nbt", cTag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,8 +233,16 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
ArrayList<Map<String, Object>> entities = new ArrayList<>();
|
ArrayList<Map<String, Object>> entities = new ArrayList<>();
|
||||||
for (Entity entity : clipboard.getEntities()) {
|
for (Entity entity : clipboard.getEntities()) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
List<Double> pos = Arrays.asList(loc.x(), loc.y(), loc.z());
|
List<Double> pos = Arrays.asList(
|
||||||
List<Integer> blockPos = Arrays.asList(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
loc.x() - min.x(),
|
||||||
|
loc.y() - min.y(),
|
||||||
|
loc.z() - min.z()
|
||||||
|
);
|
||||||
|
List<Integer> blockPos = Arrays.asList(
|
||||||
|
loc.getBlockX() - min.x(),
|
||||||
|
loc.getBlockY() - min.y(),
|
||||||
|
loc.getBlockZ() - min.z()
|
||||||
|
);
|
||||||
BaseEntity state = entity.getState();
|
BaseEntity state = entity.getState();
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
CompoundTag nbt = state.getNbtData();
|
CompoundTag nbt = state.getNbtData();
|
||||||
|
Loading…
Reference in New Issue
Block a user