Remove redundant name from Tag instances.

This commit is contained in:
sk89q
2014-11-14 11:38:54 -08:00
parent 7192780251
commit fe5cfced4f
33 changed files with 242 additions and 396 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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());
}
}

View File

@ -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

View File

@ -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

View File

@ -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