Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Remove redundant name from Tag instances.
Dieser Commit ist enthalten in:
Ursprung
7192780251
Commit
fe5cfced4f
@ -72,8 +72,8 @@ public class ChestBlock extends ContainerBlock {
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("Items", new ListTag("Items", CompoundTag.class, serializeInventory(getItems())));
|
||||
return new CompoundTag(getNbtId(), values);
|
||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,21 +74,21 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc
|
||||
|
||||
public Map<String, Tag> serializeItem(BaseItemStack item) {
|
||||
Map<String, Tag> data = new HashMap<String, Tag>();
|
||||
data.put("id", new ShortTag("id", (short) item.getType()));
|
||||
data.put("Damage", new ShortTag("Damage", item.getData()));
|
||||
data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
|
||||
data.put("id", new ShortTag((short) item.getType()));
|
||||
data.put("Damage", new ShortTag(item.getData()));
|
||||
data.put("Count", new ByteTag((byte) item.getAmount()));
|
||||
if (!item.getEnchantments().isEmpty()) {
|
||||
List<CompoundTag> enchantmentList = new ArrayList<CompoundTag>();
|
||||
for(Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
|
||||
Map<String, Tag> enchantment = new HashMap<String, Tag>();
|
||||
enchantment.put("id", new ShortTag("id", entry.getKey().shortValue()));
|
||||
enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue()));
|
||||
enchantmentList.add(new CompoundTag(null, enchantment));
|
||||
enchantment.put("id", new ShortTag(entry.getKey().shortValue()));
|
||||
enchantment.put("lvl", new ShortTag(entry.getValue().shortValue()));
|
||||
enchantmentList.add(new CompoundTag(enchantment));
|
||||
}
|
||||
|
||||
Map<String, Tag> auxData = new HashMap<String, Tag>();
|
||||
auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList));
|
||||
data.put("tag", new CompoundTag("tag", auxData));
|
||||
auxData.put("ench", new ListTag(CompoundTag.class, enchantmentList));
|
||||
data.put("tag", new CompoundTag(auxData));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@ -131,8 +131,8 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
if (items[i] != null) {
|
||||
Map<String, Tag> tagData = serializeItem(items[i]);
|
||||
tagData.put("Slot", new ByteTag("Slot", (byte) i));
|
||||
tags.add(new CompoundTag("", tagData));
|
||||
tagData.put("Slot", new ByteTag((byte) i));
|
||||
tags.add(new CompoundTag(tagData));
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
|
@ -71,9 +71,8 @@ public class DispenserBlock extends ContainerBlock {
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("Items", new ListTag("Items", CompoundTag.class,
|
||||
serializeInventory(getItems())));
|
||||
return new CompoundTag(getNbtId(), values);
|
||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,11 +115,10 @@ public class FurnaceBlock extends ContainerBlock {
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("Items", new ListTag("Items", CompoundTag.class,
|
||||
serializeInventory(getItems())));
|
||||
values.put("BurnTime", new ShortTag("BurnTime", burnTime));
|
||||
values.put("CookTime", new ShortTag("CookTime", cookTime));
|
||||
return new CompoundTag(getNbtId(), values);
|
||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
||||
values.put("BurnTime", new ShortTag(burnTime));
|
||||
values.put("CookTime", new ShortTag(cookTime));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,22 +136,22 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("EntityId", new StringTag("EntityId", mobType));
|
||||
values.put("Delay", new ShortTag("Delay", delay));
|
||||
values.put("SpawnCount", new ShortTag("SpawnCount", spawnCount));
|
||||
values.put("SpawnRange", new ShortTag("SpawnRange", spawnRange));
|
||||
values.put("MinSpawnDelay", new ShortTag("MinSpawnDelay", minSpawnDelay));
|
||||
values.put("MaxSpawnDelay", new ShortTag("MaxSpawnDelay", maxSpawnDelay));
|
||||
values.put("MaxNearbyEntities", new ShortTag("MaxNearbyEntities", maxNearbyEntities));
|
||||
values.put("RequiredPlayerRange", new ShortTag("RequiredPlayerRange", requiredPlayerRange));
|
||||
values.put("EntityId", new StringTag(mobType));
|
||||
values.put("Delay", new ShortTag(delay));
|
||||
values.put("SpawnCount", new ShortTag(spawnCount));
|
||||
values.put("SpawnRange", new ShortTag(spawnRange));
|
||||
values.put("MinSpawnDelay", new ShortTag(minSpawnDelay));
|
||||
values.put("MaxSpawnDelay", new ShortTag(maxSpawnDelay));
|
||||
values.put("MaxNearbyEntities", new ShortTag(maxNearbyEntities));
|
||||
values.put("RequiredPlayerRange", new ShortTag(requiredPlayerRange));
|
||||
if (spawnData != null) {
|
||||
values.put("SpawnData", new CompoundTag("SpawnData", spawnData.getValue()));
|
||||
values.put("SpawnData", new CompoundTag(spawnData.getValue()));
|
||||
}
|
||||
if (spawnPotentials != null) {
|
||||
values.put("SpawnPotentials", new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentials.getValue()));
|
||||
values.put("SpawnPotentials", new ListTag(CompoundTag.class, spawnPotentials.getValue()));
|
||||
}
|
||||
|
||||
return new CompoundTag(getNbtId(), values);
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -240,10 +240,10 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
|
||||
this.requiredPlayerRange = requiredPlayerRangeTag.getValue();
|
||||
}
|
||||
if (spawnPotentialsTag != null) {
|
||||
this.spawnPotentials = new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentialsTag.getValue());
|
||||
this.spawnPotentials = new ListTag(CompoundTag.class, spawnPotentialsTag.getValue());
|
||||
}
|
||||
if (spawnDataTag != null) {
|
||||
this.spawnData = new CompoundTag("SpawnData", spawnDataTag.getValue());
|
||||
this.spawnData = new CompoundTag(spawnDataTag.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,8 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("note", new ByteTag("note", note));
|
||||
return new CompoundTag(getNbtId(), values);
|
||||
values.put("note", new ByteTag(note));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,11 +93,11 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("Text1", new StringTag("Text1", text[0]));
|
||||
values.put("Text2", new StringTag("Text2", text[1]));
|
||||
values.put("Text3", new StringTag("Text3", text[2]));
|
||||
values.put("Text4", new StringTag("Text4", text[3]));
|
||||
return new CompoundTag(getNbtId(), values);
|
||||
values.put("Text1", new StringTag(text[0]));
|
||||
values.put("Text2", new StringTag(text[1]));
|
||||
values.put("Text3", new StringTag(text[2]));
|
||||
values.put("Text4", new StringTag(text[3]));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,11 +156,11 @@ public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("SkullType", new ByteTag("SkullType", skullType));
|
||||
values.put("SkullType", new ByteTag(skullType));
|
||||
if (owner == null) owner = "";
|
||||
values.put("ExtraType", new StringTag("ExtraType", owner));
|
||||
values.put("Rot", new ByteTag("Rot", rot));
|
||||
return new CompoundTag(getNbtId(), values);
|
||||
values.put("ExtraType", new StringTag( owner));
|
||||
values.put("Rot", new ByteTag(rot));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,17 +36,6 @@ public final class ByteArrayTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ByteArrayTag(String name, byte[] value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getValue() {
|
||||
return value;
|
||||
@ -62,12 +51,7 @@ public final class ByteArrayTag extends Tag {
|
||||
}
|
||||
hex.append(hexDigits).append(" ");
|
||||
}
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Byte_Array" + append + ": " + hex;
|
||||
return "TAG_Byte_Array(" + hex + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,17 +36,6 @@ public final class ByteTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ByteTag(String name, byte value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte getValue() {
|
||||
return value;
|
||||
@ -54,12 +43,7 @@ public final class ByteTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Byte" + append + ": " + value;
|
||||
return "TAG_Byte(" + value + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,17 +41,6 @@ public final class CompoundTag extends Tag {
|
||||
this.value = Collections.unmodifiableMap(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public CompoundTag(String name, Map<String, Tag> value) {
|
||||
super(name);
|
||||
this.value = Collections.unmodifiableMap(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this compound tag contains the given key.
|
||||
*
|
||||
@ -74,7 +63,7 @@ public final class CompoundTag extends Tag {
|
||||
* @return the new compound tag
|
||||
*/
|
||||
public CompoundTag setValue(Map<String, Tag> value) {
|
||||
return new CompoundTag(getName(), value);
|
||||
return new CompoundTag(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -296,7 +285,7 @@ public final class CompoundTag extends Tag {
|
||||
if (tag instanceof ListTag) {
|
||||
return (ListTag) tag;
|
||||
} else {
|
||||
return new ListTag(key, StringTag.class, Collections.<Tag>emptyList());
|
||||
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,13 +408,8 @@ public final class CompoundTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_Compound").append(append).append(": ").append(value.size()).append(" entries\r\n{\r\n");
|
||||
bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n");
|
||||
for (Map.Entry<String, Tag> entry : value.entrySet()) {
|
||||
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putByteArray(String key, byte[] value) {
|
||||
return put(key, new ByteArrayTag(key, value));
|
||||
return put(key, new ByteArrayTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +83,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putByte(String key, byte value) {
|
||||
return put(key, new ByteTag(key, value));
|
||||
return put(key, new ByteTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putDouble(String key, double value) {
|
||||
return put(key, new DoubleTag(key, value));
|
||||
return put(key, new DoubleTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putFloat(String key, float value) {
|
||||
return put(key, new FloatTag(key, value));
|
||||
return put(key, new FloatTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +119,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putIntArray(String key, int[] value) {
|
||||
return put(key, new IntArrayTag(key, value));
|
||||
return put(key, new IntArrayTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +130,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putInt(String key, int value) {
|
||||
return put(key, new IntTag(key, value));
|
||||
return put(key, new IntTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,7 +142,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putLong(String key, long value) {
|
||||
return put(key, new LongTag(key, value));
|
||||
return put(key, new LongTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +154,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putShort(String key, short value) {
|
||||
return put(key, new ShortTag(key, value));
|
||||
return put(key, new ShortTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,7 +166,7 @@ public class CompoundTagBuilder {
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putString(String key, String value) {
|
||||
return put(key, new StringTag(key, value));
|
||||
return put(key, new StringTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,16 +192,6 @@ public class CompoundTagBuilder {
|
||||
return new CompoundTag(new HashMap<String, Tag>(entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new compound tag with this builder's entries.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @return the created compound tag
|
||||
*/
|
||||
public CompoundTag build(String name) {
|
||||
return new CompoundTag(name, new HashMap<String, Tag>(entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new builder instance.
|
||||
*
|
||||
|
@ -37,17 +37,6 @@ public final class DoubleTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public DoubleTag(String name, double value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getValue() {
|
||||
return value;
|
||||
@ -55,12 +44,7 @@ public final class DoubleTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Double" + append + ": " + value;
|
||||
return "TAG_Double(" + value + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,13 +24,6 @@ package com.sk89q.jnbt;
|
||||
*/
|
||||
public final class EndTag extends Tag {
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*/
|
||||
public EndTag() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return null;
|
||||
|
@ -36,17 +36,6 @@ public final class FloatTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public FloatTag(String name, float value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getValue() {
|
||||
return value;
|
||||
@ -54,12 +43,7 @@ public final class FloatTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Float" + append + ": " + value;
|
||||
return "TAG_Float(" + value + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,18 +39,6 @@ public final class IntArrayTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public IntArrayTag(String name, int[] value) {
|
||||
super(name);
|
||||
checkNotNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getValue() {
|
||||
return value;
|
||||
@ -66,12 +54,7 @@ public final class IntArrayTag extends Tag {
|
||||
}
|
||||
hex.append(hexDigits).append(" ");
|
||||
}
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Int_Array" + append + ": " + hex;
|
||||
return "TAG_Int_Array(" + hex + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,17 +36,6 @@ public final class IntTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public IntTag(String name, int value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
@ -54,12 +43,7 @@ public final class IntTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Int" + append + ": " + value;
|
||||
return "TAG_Int(" + value + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,20 +47,6 @@ public final class ListTag extends Tag {
|
||||
this.value = Collections.unmodifiableList(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param type the type of tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ListTag(String name, Class<? extends Tag> type, List<? extends Tag> value) {
|
||||
super(name);
|
||||
checkNotNull(value);
|
||||
this.type = type;
|
||||
this.value = Collections.unmodifiableList(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of item in this list.
|
||||
*
|
||||
@ -82,7 +68,7 @@ public final class ListTag extends Tag {
|
||||
* @return a new list tag
|
||||
*/
|
||||
public ListTag setValue(List<Tag> list) {
|
||||
return new ListTag(getName(), getType(), list);
|
||||
return new ListTag(getType(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -433,13 +419,8 @@ public final class ListTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
||||
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
||||
for (Tag t : value) {
|
||||
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
|
@ -83,16 +83,6 @@ public class ListTagBuilder {
|
||||
return new ListTag(type, new ArrayList<Tag>(entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new list tag with this builder's entries.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @return the created list tag
|
||||
*/
|
||||
public ListTag build(String name) {
|
||||
return new ListTag(name, type, new ArrayList<Tag>(entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new builder instance.
|
||||
*
|
||||
|
@ -37,17 +37,6 @@ public final class LongTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public LongTag(String name, long value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getValue() {
|
||||
return value;
|
||||
@ -55,12 +44,7 @@ public final class LongTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Long" + append + ": " + value;
|
||||
return "TAG_Long(" + value + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ public final class NBTInputStream implements Closeable {
|
||||
* @return The tag that was read.
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
public Tag readTag() throws IOException {
|
||||
return readTag(0);
|
||||
public NamedTag readNamedTag() throws IOException {
|
||||
return readNamedTag(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,7 +69,7 @@ public final class NBTInputStream implements Closeable {
|
||||
* @return The tag that was read.
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
private Tag readTag(int depth) throws IOException {
|
||||
private NamedTag readNamedTag(int depth) throws IOException {
|
||||
int type = is.readByte() & 0xFF;
|
||||
|
||||
String name;
|
||||
@ -82,19 +82,18 @@ public final class NBTInputStream implements Closeable {
|
||||
name = "";
|
||||
}
|
||||
|
||||
return readTagPayload(type, name, depth);
|
||||
return new NamedTag(name, readTagPayload(type, depth));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the payload of a tag, given the name and type.
|
||||
* Reads the payload of a tag given the type.
|
||||
*
|
||||
* @param type the type
|
||||
* @param name the name
|
||||
* @param depth the depth
|
||||
* @return the tag
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
private Tag readTagPayload(int type, String name, int depth) throws IOException {
|
||||
private Tag readTagPayload(int type, int depth) throws IOException {
|
||||
switch (type) {
|
||||
case NBTConstants.TYPE_END:
|
||||
if (depth == 0) {
|
||||
@ -104,60 +103,61 @@ public final class NBTInputStream implements Closeable {
|
||||
return new EndTag();
|
||||
}
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
return new ByteTag(name, is.readByte());
|
||||
return new ByteTag(is.readByte());
|
||||
case NBTConstants.TYPE_SHORT:
|
||||
return new ShortTag(name, is.readShort());
|
||||
return new ShortTag(is.readShort());
|
||||
case NBTConstants.TYPE_INT:
|
||||
return new IntTag(name, is.readInt());
|
||||
return new IntTag(is.readInt());
|
||||
case NBTConstants.TYPE_LONG:
|
||||
return new LongTag(name, is.readLong());
|
||||
return new LongTag(is.readLong());
|
||||
case NBTConstants.TYPE_FLOAT:
|
||||
return new FloatTag(name, is.readFloat());
|
||||
return new FloatTag(is.readFloat());
|
||||
case NBTConstants.TYPE_DOUBLE:
|
||||
return new DoubleTag(name, is.readDouble());
|
||||
return new DoubleTag(is.readDouble());
|
||||
case NBTConstants.TYPE_BYTE_ARRAY:
|
||||
int length = is.readInt();
|
||||
byte[] bytes = new byte[length];
|
||||
is.readFully(bytes);
|
||||
return new ByteArrayTag(name, bytes);
|
||||
return new ByteArrayTag(bytes);
|
||||
case NBTConstants.TYPE_STRING:
|
||||
length = is.readShort();
|
||||
bytes = new byte[length];
|
||||
is.readFully(bytes);
|
||||
return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
|
||||
return new StringTag(new String(bytes, NBTConstants.CHARSET));
|
||||
case NBTConstants.TYPE_LIST:
|
||||
int childType = is.readByte();
|
||||
length = is.readInt();
|
||||
|
||||
List<Tag> tagList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
Tag tag = readTagPayload(childType, "", depth + 1);
|
||||
Tag tag = readTagPayload(childType, depth + 1);
|
||||
if (tag instanceof EndTag) {
|
||||
throw new IOException("TAG_End not permitted in a list.");
|
||||
}
|
||||
tagList.add(tag);
|
||||
}
|
||||
|
||||
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
|
||||
return new ListTag(NBTUtils.getTypeClass(childType), tagList);
|
||||
case NBTConstants.TYPE_COMPOUND:
|
||||
Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
||||
while (true) {
|
||||
Tag tag = readTag(depth + 1);
|
||||
NamedTag namedTag = readNamedTag(depth + 1);
|
||||
Tag tag = namedTag.getTag();
|
||||
if (tag instanceof EndTag) {
|
||||
break;
|
||||
} else {
|
||||
tagMap.put(tag.getName(), tag);
|
||||
tagMap.put(namedTag.getName(), tag);
|
||||
}
|
||||
}
|
||||
|
||||
return new CompoundTag(name, tagMap);
|
||||
return new CompoundTag(tagMap);
|
||||
case NBTConstants.TYPE_INT_ARRAY:
|
||||
length = is.readInt();
|
||||
int[] data = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
data[i] = is.readInt();
|
||||
}
|
||||
return new IntArrayTag(name, data);
|
||||
return new IntArrayTag(data);
|
||||
default:
|
||||
throw new IOException("Invalid tag type: " + type + ".");
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
|
||||
@ -61,9 +64,11 @@ public final class NBTOutputStream implements Closeable {
|
||||
* @throws IOException
|
||||
* if an I/O error occurs.
|
||||
*/
|
||||
public void writeTag(Tag tag) throws IOException {
|
||||
public void writeNamedTag(String name, Tag tag) throws IOException {
|
||||
checkNotNull(name);
|
||||
checkNotNull(tag);
|
||||
|
||||
int type = NBTUtils.getTypeCode(tag.getClass());
|
||||
String name = tag.getName();
|
||||
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
|
||||
|
||||
os.writeByte(type);
|
||||
@ -164,8 +169,8 @@ public final class NBTOutputStream implements Closeable {
|
||||
* if an I/O error occurs.
|
||||
*/
|
||||
private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
|
||||
for (Tag childTag : tag.getValue().values()) {
|
||||
writeTag(childTag);
|
||||
for (Map.Entry<String, Tag> entry : tag.getValue().entrySet()) {
|
||||
writeNamedTag(entry.getKey(), entry.getValue());
|
||||
}
|
||||
os.writeByte((byte) 0); // end tag - better way?
|
||||
}
|
||||
|
63
worldedit-core/src/main/java/com/sk89q/jnbt/NamedTag.java
Normale Datei
63
worldedit-core/src/main/java/com/sk89q/jnbt/NamedTag.java
Normale Datei
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A tag that has a name.
|
||||
*/
|
||||
public class NamedTag {
|
||||
|
||||
private final String name;
|
||||
private final Tag tag;
|
||||
|
||||
/**
|
||||
* Create a new named tag.
|
||||
*
|
||||
* @param name the name
|
||||
* @param tag the tag
|
||||
*/
|
||||
public NamedTag(String name, Tag tag) {
|
||||
checkNotNull(name);
|
||||
checkNotNull(tag);
|
||||
this.name = name;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the tag.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag.
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
public Tag getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
@ -36,17 +36,6 @@ public final class ShortTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ShortTag(String name, short value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getValue() {
|
||||
return value;
|
||||
@ -54,12 +43,7 @@ public final class ShortTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_Short" + append + ": " + value;
|
||||
return "TAG_Short(" + value + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,18 +39,6 @@ public final class StringTag extends Tag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public StringTag(String name, String value) {
|
||||
super(name);
|
||||
checkNotNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
@ -58,12 +46,7 @@ public final class StringTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
return "TAG_String" + append + ": " + value;
|
||||
return "TAG_String(" + value + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,36 +24,6 @@ package com.sk89q.jnbt;
|
||||
*/
|
||||
public abstract class Tag {
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Create a new tag with an empty name.
|
||||
*/
|
||||
Tag() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag with the specified name.
|
||||
*
|
||||
* @param name the name
|
||||
*/
|
||||
Tag(String name) {
|
||||
if (name == null) {
|
||||
name = "";
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this tag.
|
||||
*
|
||||
* @return the name of this tag
|
||||
*/
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of this tag.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -71,10 +72,11 @@ public class SchematicReader implements ClipboardReader {
|
||||
@Override
|
||||
public Clipboard read(WorldData data) throws IOException {
|
||||
// Schematic tag
|
||||
CompoundTag schematicTag = (CompoundTag) inputStream.readTag();
|
||||
if (!schematicTag.getName().equals("Schematic")) {
|
||||
NamedTag rootTag = inputStream.readNamedTag();
|
||||
if (!rootTag.getName().equals("Schematic")) {
|
||||
throw new IOException("Tag 'Schematic' does not exist or is not first");
|
||||
}
|
||||
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
|
||||
|
||||
// Check
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
@ -197,7 +199,7 @@ public class SchematicReader implements ClipboardReader {
|
||||
BaseBlock block = new BaseBlock(blocks[index], blockData[index]);
|
||||
|
||||
if (tileEntitiesMap.containsKey(pt)) {
|
||||
block.setNbtData(new CompoundTag("", tileEntitiesMap.get(pt)));
|
||||
block.setNbtData(new CompoundTag(tileEntitiesMap.get(pt)));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -90,16 +90,16 @@ public class SchematicWriter implements ClipboardWriter {
|
||||
// ====================================================================
|
||||
|
||||
HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
||||
schematic.put("WEOriginX", new IntTag("WEOriginX", min.getBlockX()));
|
||||
schematic.put("WEOriginY", new IntTag("WEOriginY", min.getBlockY()));
|
||||
schematic.put("WEOriginZ", new IntTag("WEOriginZ", min.getBlockZ()));
|
||||
schematic.put("WEOffsetX", new IntTag("WEOffsetX", offset.getBlockX()));
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", offset.getBlockY()));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", offset.getBlockZ()));
|
||||
schematic.put("Width", new ShortTag((short) width));
|
||||
schematic.put("Length", new ShortTag((short) length));
|
||||
schematic.put("Height", new ShortTag((short) height));
|
||||
schematic.put("Materials", new StringTag("Alpha"));
|
||||
schematic.put("WEOriginX", new IntTag(min.getBlockX()));
|
||||
schematic.put("WEOriginY", new IntTag(min.getBlockY()));
|
||||
schematic.put("WEOriginZ", new IntTag(min.getBlockZ()));
|
||||
schematic.put("WEOffsetX", new IntTag(offset.getBlockX()));
|
||||
schematic.put("WEOffsetY", new IntTag(offset.getBlockY()));
|
||||
schematic.put("WEOffsetZ", new IntTag(offset.getBlockZ()));
|
||||
|
||||
// ====================================================================
|
||||
// Block handling
|
||||
@ -141,22 +141,22 @@ public class SchematicWriter implements ClipboardWriter {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
values.put("id", new StringTag("id", block.getNbtId()));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
values.put("z", new IntTag("z", z));
|
||||
values.put("id", new StringTag(block.getNbtId()));
|
||||
values.put("x", new IntTag(x));
|
||||
values.put("y", new IntTag(y));
|
||||
values.put("z", new IntTag(z));
|
||||
|
||||
CompoundTag tileEntityTag = new CompoundTag("TileEntity", values);
|
||||
CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
}
|
||||
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
schematic.put("Blocks", new ByteArrayTag(blocks));
|
||||
schematic.put("Data", new ByteArrayTag(blockData));
|
||||
schematic.put("TileEntities", new ListTag(CompoundTag.class, tileEntities));
|
||||
|
||||
if (addBlocks != null) {
|
||||
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||
schematic.put("AddBlocks", new ByteArrayTag(addBlocks));
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
@ -177,38 +177,38 @@ public class SchematicWriter implements ClipboardWriter {
|
||||
}
|
||||
|
||||
// Store our location data, overwriting any
|
||||
values.put("id", new StringTag("id", state.getTypeId()));
|
||||
values.put("id", new StringTag(state.getTypeId()));
|
||||
values.put("Pos", writeVector(entity.getLocation().toVector(), "Pos"));
|
||||
values.put("Rotation", writeRotation(entity.getLocation(), "Rotation"));
|
||||
|
||||
CompoundTag entityTag = new CompoundTag("Entity", values);
|
||||
CompoundTag entityTag = new CompoundTag(values);
|
||||
entities.add(entityTag);
|
||||
}
|
||||
}
|
||||
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, entities));
|
||||
schematic.put("Entities", new ListTag(CompoundTag.class, entities));
|
||||
|
||||
// ====================================================================
|
||||
// Output
|
||||
// ====================================================================
|
||||
|
||||
CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
||||
outputStream.writeTag(schematicTag);
|
||||
CompoundTag schematicTag = new CompoundTag(schematic);
|
||||
outputStream.writeNamedTag("Schematic", schematicTag);
|
||||
}
|
||||
|
||||
private Tag writeVector(Vector vector, String name) {
|
||||
List<DoubleTag> list = new ArrayList<DoubleTag>();
|
||||
list.add(new DoubleTag("", vector.getX()));
|
||||
list.add(new DoubleTag("", vector.getY()));
|
||||
list.add(new DoubleTag("", vector.getZ()));
|
||||
return new ListTag(name, DoubleTag.class, list);
|
||||
list.add(new DoubleTag(vector.getX()));
|
||||
list.add(new DoubleTag(vector.getY()));
|
||||
list.add(new DoubleTag(vector.getZ()));
|
||||
return new ListTag(DoubleTag.class, list);
|
||||
}
|
||||
|
||||
private Tag writeRotation(Location location, String name) {
|
||||
List<FloatTag> list = new ArrayList<FloatTag>();
|
||||
list.add(new FloatTag("", location.getYaw()));
|
||||
list.add(new FloatTag("", location.getPitch()));
|
||||
return new ListTag(name, FloatTag.class, list);
|
||||
list.add(new FloatTag(location.getYaw()));
|
||||
list.add(new FloatTag(location.getPitch()));
|
||||
return new ListTag(FloatTag.class, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,15 +19,29 @@
|
||||
|
||||
package com.sk89q.worldedit.schematic;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.jnbt.ByteArrayTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTConstants;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||
import com.sk89q.worldedit.data.DataException;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -52,12 +66,14 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
Vector offset = new Vector();
|
||||
|
||||
// Schematic tag
|
||||
CompoundTag schematicTag = (CompoundTag) nbtStream.readTag();
|
||||
NamedTag rootTag = nbtStream.readNamedTag();
|
||||
nbtStream.close();
|
||||
if (!schematicTag.getName().equals("Schematic")) {
|
||||
if (!rootTag.getName().equals("Schematic")) {
|
||||
throw new DataException("Tag \"Schematic\" does not exist or is not first");
|
||||
}
|
||||
|
||||
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
|
||||
|
||||
// Check
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
if (!schematic.containsKey("Blocks")) {
|
||||
@ -169,7 +185,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
BaseBlock block = getBlockForId(blocks[index], blockData[index]);
|
||||
|
||||
if (tileEntitiesMap.containsKey(pt)) {
|
||||
block.setNbtData(new CompoundTag("", tileEntitiesMap.get(pt)));
|
||||
block.setNbtData(new CompoundTag(tileEntitiesMap.get(pt)));
|
||||
}
|
||||
clipboard.setBlock(pt, block);
|
||||
}
|
||||
@ -201,16 +217,16 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
}
|
||||
|
||||
HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
||||
schematic.put("WEOriginX", new IntTag("WEOriginX", clipboard.getOrigin().getBlockX()));
|
||||
schematic.put("WEOriginY", new IntTag("WEOriginY", clipboard.getOrigin().getBlockY()));
|
||||
schematic.put("WEOriginZ", new IntTag("WEOriginZ", clipboard.getOrigin().getBlockZ()));
|
||||
schematic.put("WEOffsetX", new IntTag("WEOffsetX", clipboard.getOffset().getBlockX()));
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", clipboard.getOffset().getBlockY()));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", clipboard.getOffset().getBlockZ()));
|
||||
schematic.put("Width", new ShortTag((short) width));
|
||||
schematic.put("Length", new ShortTag((short) length));
|
||||
schematic.put("Height", new ShortTag((short) height));
|
||||
schematic.put("Materials", new StringTag("Alpha"));
|
||||
schematic.put("WEOriginX", new IntTag(clipboard.getOrigin().getBlockX()));
|
||||
schematic.put("WEOriginY", new IntTag(clipboard.getOrigin().getBlockY()));
|
||||
schematic.put("WEOriginZ", new IntTag(clipboard.getOrigin().getBlockZ()));
|
||||
schematic.put("WEOffsetX", new IntTag(clipboard.getOffset().getBlockX()));
|
||||
schematic.put("WEOffsetY", new IntTag(clipboard.getOffset().getBlockY()));
|
||||
schematic.put("WEOffsetZ", new IntTag(clipboard.getOffset().getBlockZ()));
|
||||
|
||||
// Copy
|
||||
byte[] blocks = new byte[width * height * length];
|
||||
@ -246,30 +262,30 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
values.put("id", new StringTag("id", block.getNbtId()));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
values.put("z", new IntTag("z", z));
|
||||
values.put("id", new StringTag(block.getNbtId()));
|
||||
values.put("x", new IntTag(x));
|
||||
values.put("y", new IntTag(y));
|
||||
values.put("z", new IntTag(z));
|
||||
|
||||
CompoundTag tileEntityTag = new CompoundTag("TileEntity", values);
|
||||
CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
schematic.put("Blocks", new ByteArrayTag(blocks));
|
||||
schematic.put("Data", new ByteArrayTag(blockData));
|
||||
schematic.put("Entities", new ListTag(CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("TileEntities", new ListTag(CompoundTag.class, tileEntities));
|
||||
if (addBlocks != null) {
|
||||
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||
schematic.put("AddBlocks", new ByteArrayTag(addBlocks));
|
||||
}
|
||||
|
||||
// Build and output
|
||||
CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
||||
CompoundTag schematicTag = new CompoundTag(schematic);
|
||||
NBTOutputStream stream = new NBTOutputStream(new GZIPOutputStream(new FileOutputStream(file)));
|
||||
stream.writeTag(schematicTag);
|
||||
stream.writeNamedTag("Schematic", schematicTag);
|
||||
stream.close();
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ public class AnvilChunk implements Chunk {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CompoundTag("", values);
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,7 +179,7 @@ public class OldChunk implements Chunk {
|
||||
if (values == null) {
|
||||
return null;
|
||||
}
|
||||
return new CompoundTag("", values);
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,7 +85,7 @@ public abstract class LegacyChunkStore extends ChunkStore {
|
||||
Tag tag;
|
||||
|
||||
try {
|
||||
tag = nbt.readTag();
|
||||
tag = nbt.readNamedTag().getTag();
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new ChunkStoreException("CompoundTag expected for chunk; got "
|
||||
+ tag.getClass().getName());
|
||||
|
@ -75,7 +75,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
|
||||
Tag tag;
|
||||
|
||||
try {
|
||||
tag = nbt.readTag();
|
||||
tag = nbt.readNamedTag().getTag();
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new ChunkStoreException("CompoundTag expected for chunk; got " + tag.getClass().getName());
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren