compressed data tree cleanup, streamlining
This commit is contained in:
parent
f76d3c8b89
commit
b52053f5ea
50 changed files with 560 additions and 598 deletions
|
@ -2,9 +2,10 @@ package common.attributes;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.log.Log;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
|
||||
public class Attributes
|
||||
{
|
||||
|
@ -40,9 +41,9 @@ public class Attributes
|
|||
/**
|
||||
* Creates an NBTTagList from a BaseAttributeMap, including all its AttributeInstances
|
||||
*/
|
||||
public static TagObjectList writeBaseAttributeMapToNBT(AttributeMap map)
|
||||
public static List<TagObject> writeBaseAttributeMapToNBT(AttributeMap map)
|
||||
{
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (AttributeInstance iattributeinstance : map.getAllAttributes())
|
||||
{
|
||||
|
@ -65,7 +66,7 @@ public class Attributes
|
|||
|
||||
if (collection != null && !collection.isEmpty())
|
||||
{
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (AttributeModifier attributemodifier : collection)
|
||||
{
|
||||
|
@ -75,7 +76,7 @@ public class Attributes
|
|||
}
|
||||
}
|
||||
|
||||
nbttagcompound.setObjectList("Modifiers", nbttaglist);
|
||||
nbttagcompound.setList("Modifiers", nbttaglist);
|
||||
}
|
||||
|
||||
return nbttagcompound;
|
||||
|
@ -94,7 +95,7 @@ public class Attributes
|
|||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public static void setAttributeModifiers(AttributeMap map, TagObjectList list)
|
||||
public static void setAttributeModifiers(AttributeMap map, List<TagObject> list)
|
||||
{
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
|
@ -116,9 +117,9 @@ public class Attributes
|
|||
{
|
||||
instance.setBaseValue(compound.getDouble("Base"));
|
||||
|
||||
if (compound.hasObjectList("Modifiers"))
|
||||
if (compound.hasList("Modifiers"))
|
||||
{
|
||||
TagObjectList nbttaglist = compound.getObjectList("Modifiers");
|
||||
List<TagObject> nbttaglist = compound.getList("Modifiers");
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
{
|
||||
|
|
|
@ -12,8 +12,6 @@ import common.init.Blocks;
|
|||
import common.init.MetalType;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.tags.TagStringList;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Vec3;
|
||||
import common.world.State;
|
||||
|
@ -920,85 +918,85 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
this.alt1 = BlockRegistry.getFromIdName(tag.getString("AltBlock1"), Blocks.gravel.getState());
|
||||
this.alt2 = BlockRegistry.getFromIdName(tag.getString("AltBlock2"), Blocks.sand.getState());
|
||||
this.caveFiller = BlockRegistry.getFromIdName(tag.getString("CaveFillBlock"), Blocks.lava.getState());
|
||||
if(tag.hasStringList("Layers")) {
|
||||
TagStringList list = tag.getStringList("Layers");
|
||||
this.layers = new State[list.size()];
|
||||
if(tag.hasStringArray("Layers")) {
|
||||
String[] list = tag.getStringArray("Layers");
|
||||
this.layers = new State[list.length];
|
||||
for(int z = 0; z < this.layers.length; z++) {
|
||||
this.layers[z] = BlockRegistry.getFromIdName(list.get(z), Blocks.stone.getState());
|
||||
this.layers[z] = BlockRegistry.getFromIdName(list[z], Blocks.stone.getState());
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.layers = null;
|
||||
}
|
||||
if(tag.hasStringList("AddBiomes")) {
|
||||
TagStringList list = tag.getStringList("AddBiomes");
|
||||
if(list.isEmpty()) {
|
||||
if(tag.hasStringArray("AddBiomes")) {
|
||||
String[] list = tag.getStringArray("AddBiomes");
|
||||
if(list.length == 0) {
|
||||
this.addBiomes = null;
|
||||
}
|
||||
else {
|
||||
this.addBiomes = new Biome[list.size()];
|
||||
this.addBiomes = new Biome[list.length];
|
||||
for(int z = 0; z < this.addBiomes.length; z++) {
|
||||
this.addBiomes[z] = Biome.findByName(list.get(z));
|
||||
this.addBiomes[z] = Biome.findByName(list[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.addBiomes = null;
|
||||
}
|
||||
if(tag.hasStringList("FrostBiomes")) {
|
||||
TagStringList list = tag.getStringList("FrostBiomes");
|
||||
if(list.isEmpty()) {
|
||||
if(tag.hasStringArray("FrostBiomes")) {
|
||||
String[] list = tag.getStringArray("FrostBiomes");
|
||||
if(list.length == 0) {
|
||||
this.frostBiomes = null;
|
||||
}
|
||||
else {
|
||||
this.frostBiomes = new Biome[list.size()];
|
||||
this.frostBiomes = new Biome[list.length];
|
||||
for(int z = 0; z < this.frostBiomes.length; z++) {
|
||||
this.frostBiomes[z] = Biome.findByName(list.get(z));
|
||||
this.frostBiomes[z] = Biome.findByName(list[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.frostBiomes = null;
|
||||
}
|
||||
if(tag.hasStringList("ColdBiomes")) {
|
||||
TagStringList list = tag.getStringList("ColdBiomes");
|
||||
if(list.isEmpty()) {
|
||||
if(tag.hasStringArray("ColdBiomes")) {
|
||||
String[] list = tag.getStringArray("ColdBiomes");
|
||||
if(list.length == 0) {
|
||||
this.coldBiomes = null;
|
||||
}
|
||||
else {
|
||||
this.coldBiomes = new Biome[list.size()];
|
||||
this.coldBiomes = new Biome[list.length];
|
||||
for(int z = 0; z < this.coldBiomes.length; z++) {
|
||||
this.coldBiomes[z] = Biome.findByName(list.get(z));
|
||||
this.coldBiomes[z] = Biome.findByName(list[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.coldBiomes = null;
|
||||
}
|
||||
if(tag.hasStringList("MediumBiomes")) {
|
||||
TagStringList list = tag.getStringList("MediumBiomes");
|
||||
if(list.isEmpty()) {
|
||||
if(tag.hasStringArray("MediumBiomes")) {
|
||||
String[] list = tag.getStringArray("MediumBiomes");
|
||||
if(list.length == 0) {
|
||||
this.mediumBiomes = null;
|
||||
}
|
||||
else {
|
||||
this.mediumBiomes = new Biome[list.size()];
|
||||
this.mediumBiomes = new Biome[list.length];
|
||||
for(int z = 0; z < this.mediumBiomes.length; z++) {
|
||||
this.mediumBiomes[z] = Biome.findByName(list.get(z));
|
||||
this.mediumBiomes[z] = Biome.findByName(list[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.mediumBiomes = null;
|
||||
}
|
||||
if(tag.hasStringList("HotBiomes")) {
|
||||
TagStringList list = tag.getStringList("HotBiomes");
|
||||
if(list.isEmpty()) {
|
||||
if(tag.hasStringArray("HotBiomes")) {
|
||||
String[] list = tag.getStringArray("HotBiomes");
|
||||
if(list.length == 0) {
|
||||
this.hotBiomes = null;
|
||||
}
|
||||
else {
|
||||
this.hotBiomes = new Biome[list.size()];
|
||||
this.hotBiomes = new Biome[list.length];
|
||||
for(int z = 0; z < this.hotBiomes.length; z++) {
|
||||
this.hotBiomes[z] = Biome.findByName(list.get(z));
|
||||
this.hotBiomes[z] = Biome.findByName(list[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1006,8 +1004,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
this.hotBiomes = null;
|
||||
}
|
||||
this.ores.clear();
|
||||
if(tag.hasObjectList("Ores")) {
|
||||
TagObjectList list = tag.getObjectList("Ores");
|
||||
if(tag.hasList("Ores")) {
|
||||
List<TagObject> list = tag.getList("Ores");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject gen = list.get(z);
|
||||
this.ores.add(new Ore(BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
|
||||
|
@ -1016,8 +1014,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
}
|
||||
}
|
||||
this.lakes.clear();
|
||||
if(tag.hasObjectList("Lakes")) {
|
||||
TagObjectList list = tag.getObjectList("Lakes");
|
||||
if(tag.hasList("Lakes")) {
|
||||
List<TagObject> list = tag.getList("Lakes");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject gen = list.get(z);
|
||||
this.lakes.add(new Lake(
|
||||
|
@ -1028,8 +1026,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
}
|
||||
}
|
||||
this.liquids.clear();
|
||||
if(tag.hasObjectList("Liquids")) {
|
||||
TagObjectList list = tag.getObjectList("Liquids");
|
||||
if(tag.hasList("Liquids")) {
|
||||
List<TagObject> list = tag.getList("Liquids");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject gen = list.get(z);
|
||||
this.liquids.add(new Liquid(
|
||||
|
@ -1157,49 +1155,49 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
tag.setString("AltBlock2", BlockRegistry.toIdName(this.alt2));
|
||||
tag.setString("CaveFillBlock", BlockRegistry.toIdName(this.caveFiller));
|
||||
if(this.layers != null) {
|
||||
TagStringList list = new TagStringList();
|
||||
for(State gen : this.layers) {
|
||||
list.add(BlockRegistry.toIdName(gen));
|
||||
String[] list = new String[this.layers.length];
|
||||
for(int z = 0; z < this.layers.length; z++) {
|
||||
list[z] = BlockRegistry.toIdName(this.layers[z]);
|
||||
}
|
||||
tag.setStringList("Layers", list);
|
||||
tag.setStringArray("Layers", list);
|
||||
}
|
||||
if(this.addBiomes != null) {
|
||||
TagStringList list = new TagStringList();
|
||||
for(Biome biome : this.addBiomes) {
|
||||
list.add(biome.name.toLowerCase());
|
||||
String[] list = new String[this.addBiomes.length];
|
||||
for(int z = 0; z < this.addBiomes.length; z++) {
|
||||
list[z] = this.addBiomes[z].name.toLowerCase();
|
||||
}
|
||||
tag.setStringList("AddBiomes", list);
|
||||
tag.setStringArray("AddBiomes", list);
|
||||
}
|
||||
if(this.frostBiomes != null) {
|
||||
TagStringList list = new TagStringList();
|
||||
for(Biome biome : this.frostBiomes) {
|
||||
list.add(biome.name.toLowerCase());
|
||||
String[] list = new String[this.frostBiomes.length];
|
||||
for(int z = 0; z < this.frostBiomes.length; z++) {
|
||||
list[z] = this.frostBiomes[z].name.toLowerCase();
|
||||
}
|
||||
tag.setStringList("FrostBiomes", list);
|
||||
tag.setStringArray("FrostBiomes", list);
|
||||
}
|
||||
if(this.coldBiomes != null) {
|
||||
TagStringList list = new TagStringList();
|
||||
for(Biome biome : this.coldBiomes) {
|
||||
list.add(biome.name.toLowerCase());
|
||||
String[] list = new String[this.coldBiomes.length];
|
||||
for(int z = 0; z < this.coldBiomes.length; z++) {
|
||||
list[z] = this.coldBiomes[z].name.toLowerCase();
|
||||
}
|
||||
tag.setStringList("ColdBiomes", list);
|
||||
tag.setStringArray("ColdBiomes", list);
|
||||
}
|
||||
if(this.mediumBiomes != null) {
|
||||
TagStringList list = new TagStringList();
|
||||
for(Biome biome : this.mediumBiomes) {
|
||||
list.add(biome.name.toLowerCase());
|
||||
String[] list = new String[this.mediumBiomes.length];
|
||||
for(int z = 0; z < this.mediumBiomes.length; z++) {
|
||||
list[z] = this.mediumBiomes[z].name.toLowerCase();
|
||||
}
|
||||
tag.setStringList("MediumBiomes", list);
|
||||
tag.setStringArray("MediumBiomes", list);
|
||||
}
|
||||
if(this.hotBiomes != null) {
|
||||
TagStringList list = new TagStringList();
|
||||
for(Biome biome : this.hotBiomes) {
|
||||
list.add(biome.name.toLowerCase());
|
||||
String[] list = new String[this.hotBiomes.length];
|
||||
for(int z = 0; z < this.hotBiomes.length; z++) {
|
||||
list[z] = this.hotBiomes[z].name.toLowerCase();
|
||||
}
|
||||
tag.setStringList("HotBiomes", list);
|
||||
tag.setStringArray("HotBiomes", list);
|
||||
}
|
||||
if(!this.ores.isEmpty()) {
|
||||
TagObjectList list = new TagObjectList();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Ore gen : this.ores) {
|
||||
TagObject ore = new TagObject();
|
||||
ore.setString("Block", BlockRegistry.toIdName(gen.state));
|
||||
|
@ -1211,10 +1209,10 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
ore.setInt("MaxS", gen.max);
|
||||
list.add(ore);
|
||||
}
|
||||
tag.setObjectList("Ores", list);
|
||||
tag.setList("Ores", list);
|
||||
}
|
||||
if(!this.lakes.isEmpty()) {
|
||||
TagObjectList list = new TagObjectList();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Lake gen : this.lakes) {
|
||||
TagObject lake = new TagObject();
|
||||
lake.setString("Block", BlockRegistry.toIdName(gen.state));
|
||||
|
@ -1228,10 +1226,10 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
lake.setInt("Max", gen.maxHeight);
|
||||
list.add(lake);
|
||||
}
|
||||
tag.setObjectList("Lakes", list);
|
||||
tag.setList("Lakes", list);
|
||||
}
|
||||
if(!this.liquids.isEmpty()) {
|
||||
TagObjectList list = new TagObjectList();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Liquid gen : this.liquids) {
|
||||
TagObject liquid = new TagObject();
|
||||
liquid.setString("Block", BlockRegistry.toIdName(gen.state));
|
||||
|
@ -1241,7 +1239,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
liquid.setInt("Max", gen.maxHeight);
|
||||
list.add(liquid);
|
||||
}
|
||||
tag.setObjectList("Liquids", list);
|
||||
tag.setList("Liquids", list);
|
||||
}
|
||||
if(!this.populated)
|
||||
tag.setBool("NoPopulation", true);
|
||||
|
|
|
@ -15,7 +15,6 @@ import common.item.ItemStack;
|
|||
import common.rng.Random;
|
||||
import common.rng.WeightedList;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
|
||||
public class EnchantmentHelper
|
||||
{
|
||||
|
@ -45,7 +44,7 @@ public class EnchantmentHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
TagObjectList list = stack.getEnchantmentTagList();
|
||||
List<TagObject> list = stack.getEnchantmentTagList();
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
|
@ -72,7 +71,7 @@ public class EnchantmentHelper
|
|||
public static Map<Integer, Integer> getEnchantments(ItemStack stack)
|
||||
{
|
||||
Map<Integer, Integer> map = Maps.<Integer, Integer>newLinkedHashMap();
|
||||
TagObjectList list = stack.getItem() == Items.enchanted_book ? Items.enchanted_book.getEnchantments(stack) : stack.getEnchantmentTagList();
|
||||
List<TagObject> list = stack.getItem() == Items.enchanted_book ? Items.enchanted_book.getEnchantments(stack) : stack.getEnchantmentTagList();
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
|
@ -92,7 +91,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static void setEnchantments(Map<Integer, Integer> enchMap, ItemStack stack)
|
||||
{
|
||||
TagObjectList list = new TagObjectList();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
Iterator iterator = enchMap.keySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
|
@ -161,7 +160,7 @@ public class EnchantmentHelper
|
|||
{
|
||||
if (stack != null)
|
||||
{
|
||||
TagObjectList list = stack.getEnchantmentTagList();
|
||||
List<TagObject> list = stack.getEnchantmentTagList();
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ import common.attributes.AttributeInstance;
|
|||
import common.attributes.Attributes;
|
||||
import common.block.Block;
|
||||
import common.block.SoundType;
|
||||
import common.collect.Lists;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
@ -34,7 +35,7 @@ import common.model.ParticleType;
|
|||
import common.pathfinding.PathNavigateGround;
|
||||
import common.potion.Potion;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
import common.world.World;
|
||||
|
@ -1402,7 +1403,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
|
|||
|
||||
if (this.isChested())
|
||||
{
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 2; i < this.horseChest.getSizeInventory(); ++i)
|
||||
{
|
||||
|
@ -1417,7 +1418,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
|
|||
}
|
||||
}
|
||||
|
||||
tagCompound.setObjectList("Items", nbttaglist);
|
||||
tagCompound.setList("Items", nbttaglist);
|
||||
}
|
||||
|
||||
if (this.horseChest.getStackInSlot(1) != null)
|
||||
|
@ -1466,7 +1467,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
|
|||
|
||||
if (this.isChested())
|
||||
{
|
||||
TagObjectList nbttaglist = tagCompund.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Items");
|
||||
this.initHorseChest();
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package common.entity.item;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
@ -8,7 +9,7 @@ import common.inventory.Container;
|
|||
import common.inventory.InventoryHelper;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
import common.tileentity.ILockableContainer;
|
||||
import common.tileentity.LockCode;
|
||||
import common.util.BlockPos;
|
||||
|
@ -190,7 +191,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
|
|||
protected void writeEntity(TagObject tagCompound)
|
||||
{
|
||||
super.writeEntity(tagCompound);
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.minecartContainerItems.length; ++i)
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
|
|||
}
|
||||
}
|
||||
|
||||
tagCompound.setObjectList("Items", nbttaglist);
|
||||
tagCompound.setList("Items", nbttaglist);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,7 +213,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
|
|||
protected void readEntity(TagObject tagCompund)
|
||||
{
|
||||
super.readEntity(tagCompund);
|
||||
TagObjectList nbttaglist = tagCompund.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Items");
|
||||
this.minecartContainerItems = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.List;
|
|||
|
||||
import common.block.Block;
|
||||
import common.block.BlockFalling;
|
||||
import common.block.ITileEntityProvider;
|
||||
import common.block.tech.BlockAnvil;
|
||||
import common.collect.Lists;
|
||||
import common.entity.DamageSource;
|
||||
|
@ -15,9 +14,7 @@ import common.init.BlockRegistry;
|
|||
import common.init.Blocks;
|
||||
import common.init.Config;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.Tag;
|
||||
import common.tags.TagObject;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
|
@ -33,7 +30,6 @@ public class EntityFalling extends Entity implements IObjectData
|
|||
private boolean hurtEntities;
|
||||
private int fallHurtMax = 40;
|
||||
private float fallHurtAmount = 2.0F;
|
||||
public TagObject tileEntityData;
|
||||
|
||||
public EntityFalling(World worldIn)
|
||||
{
|
||||
|
@ -141,30 +137,6 @@ public class EntityFalling extends Entity implements IObjectData
|
|||
{
|
||||
((BlockFalling)block).onEndFalling(this.worldObj, blockpos1);
|
||||
}
|
||||
|
||||
if (this.tileEntityData != null && block instanceof ITileEntityProvider)
|
||||
{
|
||||
TileEntity tileentity = this.worldObj.getTileEntity(blockpos1);
|
||||
|
||||
if (tileentity != null)
|
||||
{
|
||||
TagObject nbttagcompound = new TagObject();
|
||||
tileentity.writeTags(nbttagcompound);
|
||||
|
||||
for (String s : this.tileEntityData.getKeySet())
|
||||
{
|
||||
Tag nbtbase = this.tileEntityData.get(s);
|
||||
|
||||
if (!s.equals("x") && !s.equals("y") && !s.equals("z"))
|
||||
{
|
||||
nbttagcompound.set(s, nbtbase.copy());
|
||||
}
|
||||
}
|
||||
|
||||
tileentity.readTags(nbttagcompound);
|
||||
tileentity.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.shouldDropItem && Config.objectDrop)
|
||||
{
|
||||
|
@ -239,11 +211,6 @@ public class EntityFalling extends Entity implements IObjectData
|
|||
tagCompound.setBool("HurtEntities", this.hurtEntities);
|
||||
tagCompound.setFloat("FallHurtAmount", this.fallHurtAmount);
|
||||
tagCompound.setInt("FallHurtMax", this.fallHurtMax);
|
||||
|
||||
if (this.tileEntityData != null)
|
||||
{
|
||||
tagCompound.setObject("TileEntityData", this.tileEntityData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,11 +238,6 @@ public class EntityFalling extends Entity implements IObjectData
|
|||
|
||||
this.shouldDropItem = tagCompund.getBool("DropItem");
|
||||
|
||||
if (tagCompund.hasObject("TileEntityData"))
|
||||
{
|
||||
this.tileEntityData = tagCompund.getObject("TileEntityData");
|
||||
}
|
||||
|
||||
if (block == null || block == Blocks.air)
|
||||
{
|
||||
this.fallTile = Blocks.sand.getState();
|
||||
|
|
|
@ -23,6 +23,7 @@ import common.attributes.AttributeInstance;
|
|||
import common.attributes.Attributes;
|
||||
import common.block.Block;
|
||||
import common.block.artificial.BlockBed;
|
||||
import common.collect.Lists;
|
||||
import common.dimension.Space;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
|
@ -84,7 +85,6 @@ import common.potion.PotionEffect;
|
|||
import common.rng.Random;
|
||||
import common.sound.MovingSoundMinecartRiding;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.tileentity.IInteractionObject;
|
||||
import common.tileentity.LockCode;
|
||||
import common.tileentity.TileEntitySign;
|
||||
|
@ -3389,8 +3389,8 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// this.setCanPickUpLoot(tagCompund.getBoolean("CanPickUpLoot"));
|
||||
// }
|
||||
|
||||
if(tagCompund.hasObjectList("Equipment")) {
|
||||
TagObjectList nbttaglist = tagCompund.getObjectList("Equipment");
|
||||
if(tagCompund.hasList("Equipment")) {
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Equipment");
|
||||
|
||||
for(int i = 0; i < this.equipment.length; ++i) {
|
||||
this.equipment[i] = ItemStack.readFromTag(nbttaglist.get(i));
|
||||
|
@ -3423,7 +3423,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.setNpcClass(type);
|
||||
this.setHeight(tagCompund.hasFloat("Height") ? tagCompund.getFloat("Height") : this.getBaseSize());
|
||||
|
||||
TagObjectList nbttaglist = tagCompund.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Items");
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
{
|
||||
|
@ -3435,9 +3435,9 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
}
|
||||
|
||||
if(tagCompund.hasObjectList("Offers")) {
|
||||
if(tagCompund.hasList("Offers")) {
|
||||
this.trades = new MerchantRecipeList();
|
||||
this.trades.fromTags(tagCompund.getObjectList("Offers"));
|
||||
this.trades.fromTags(tagCompund.getList("Offers"));
|
||||
}
|
||||
this.healTimer = tagCompund.getInt("healTimer");
|
||||
if(tagCompund.hasByteArray("Skin"))
|
||||
|
@ -3448,7 +3448,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
if(this.isPlayer()) {
|
||||
// this.entityUniqueID = getOfflineUUID(this.user);
|
||||
TagObjectList nbttaglist0 = tagCompund.getObjectList("Inventory");
|
||||
List<TagObject> nbttaglist0 = tagCompund.getList("Inventory");
|
||||
this.inventory.readFromNBT(nbttaglist0);
|
||||
this.inventory.currentItem = tagCompund.getInt("SelectedItemSlot");
|
||||
// this.sleeping = tagCompund.getBoolean("Sleeping");
|
||||
|
@ -3495,9 +3495,9 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// this.allowFlyingPersist = tagCompund.getBoolean("alwaysFly");
|
||||
this.noclip = tagCompund.getBool("noClip");
|
||||
|
||||
if (tagCompund.hasObjectList("WarpItems"))
|
||||
if (tagCompund.hasList("WarpItems"))
|
||||
{
|
||||
TagObjectList nbttaglist1 = tagCompund.getObjectList("WarpItems");
|
||||
List<TagObject> nbttaglist1 = tagCompund.getList("WarpItems");
|
||||
this.warpChest.readTags(nbttaglist1);
|
||||
}
|
||||
|
||||
|
@ -3534,7 +3534,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
super.writeEntity(tagCompound);
|
||||
|
||||
// tagCompound.setBoolean("CanPickUpLoot", this.canPickUpLoot());
|
||||
TagObjectList nbttaglist0 = new TagObjectList();
|
||||
List<TagObject> nbttaglist0 = Lists.newArrayList();
|
||||
|
||||
for(int i = 0; i < this.equipment.length; ++i) {
|
||||
TagObject nbttagcompound = new TagObject();
|
||||
|
@ -3546,7 +3546,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
nbttaglist0.add(nbttagcompound);
|
||||
}
|
||||
|
||||
tagCompound.setObjectList("Equipment", nbttaglist0);
|
||||
tagCompound.setList("Equipment", nbttaglist0);
|
||||
// tagCompound.setString("Species", this.getSpecies());
|
||||
tagCompound.setString("Char", this.getChar());
|
||||
tagCompound.setString("Cape", this.getCape());
|
||||
|
@ -3559,7 +3559,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
if(type != null)
|
||||
tagCompound.setString("ClassType", this.species.classnames.inverse().get(type));
|
||||
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.extraInventory.getSizeInventory(); ++i)
|
||||
{
|
||||
|
@ -3571,9 +3571,9 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
}
|
||||
|
||||
tagCompound.setObjectList("Items", nbttaglist);
|
||||
tagCompound.setList("Items", nbttaglist);
|
||||
if(this.trades != null)
|
||||
tagCompound.setObjectList("Offers", this.trades.toTags());
|
||||
tagCompound.setList("Offers", this.trades.toTags());
|
||||
tagCompound.setInt("healTimer", this.healTimer);
|
||||
if(this.skin != null)
|
||||
tagCompound.setByteArray("Skin", this.skin);
|
||||
|
@ -3587,7 +3587,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.getAttributeMap().applyAttributeModifiers(itemstack.getAttributeModifiers(2), z, itemstack.size);
|
||||
}
|
||||
}
|
||||
tagCompound.setObjectList("Inventory", this.inventory.writeToNBT(new TagObjectList()));
|
||||
tagCompound.setList("Inventory", this.inventory.writeToNBT(Lists.newArrayList()));
|
||||
tagCompound.setInt("SelectedItemSlot", this.inventory.currentItem);
|
||||
// tagCompound.setBoolean("Sleeping", this.sleeping);
|
||||
// tagCompound.setShort("SleepTimer", (short)this.sleepTimer);
|
||||
|
@ -3624,7 +3624,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// tagCompound.setBoolean("alwaysFly", this.allowFlyingPersist);
|
||||
tagCompound.setBool("noClip", this.noclip);
|
||||
|
||||
tagCompound.setObjectList("WarpItems", this.warpChest.writeTags());
|
||||
tagCompound.setList("WarpItems", this.warpChest.writeTags());
|
||||
ItemStack itemstack = this.inventory.getCurrentItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() != null)
|
||||
|
|
|
@ -58,7 +58,6 @@ import common.potion.PotionEffect;
|
|||
import common.potion.PotionHelper;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.ExtMath;
|
||||
|
@ -557,7 +556,7 @@ public abstract class EntityLiving extends Entity
|
|||
}
|
||||
}
|
||||
|
||||
tagCompound.setObjectList("Attributes", Attributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));
|
||||
tagCompound.setList("Attributes", Attributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));
|
||||
|
||||
for (ItemStack itemstack1 : this.getInventory())
|
||||
{
|
||||
|
@ -569,14 +568,14 @@ public abstract class EntityLiving extends Entity
|
|||
|
||||
if (!this.effects.isEmpty())
|
||||
{
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (PotionEffect potioneffect : this.effects.values())
|
||||
{
|
||||
nbttaglist.add(potioneffect.toTags());
|
||||
}
|
||||
|
||||
tagCompound.setObjectList("ActiveEffects", nbttaglist);
|
||||
tagCompound.setList("ActiveEffects", nbttaglist);
|
||||
}
|
||||
|
||||
tagCompound.setBool("Leashed", this.leashed);
|
||||
|
@ -613,14 +612,14 @@ public abstract class EntityLiving extends Entity
|
|||
{
|
||||
this.setAbsorptionAmount(tagCompund.getInt("Absorption"));
|
||||
|
||||
if (tagCompund.hasObjectList("Attributes") && this.worldObj != null && !this.worldObj.client)
|
||||
if (tagCompund.hasList("Attributes") && this.worldObj != null && !this.worldObj.client)
|
||||
{
|
||||
Attributes.setAttributeModifiers(this.getAttributeMap(), tagCompund.getObjectList("Attributes"));
|
||||
Attributes.setAttributeModifiers(this.getAttributeMap(), tagCompund.getList("Attributes"));
|
||||
}
|
||||
|
||||
if (tagCompund.hasObjectList("ActiveEffects"))
|
||||
if (tagCompund.hasList("ActiveEffects"))
|
||||
{
|
||||
TagObjectList nbttaglist = tagCompund.getObjectList("ActiveEffects");
|
||||
List<TagObject> nbttaglist = tagCompund.getList("ActiveEffects");
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,6 @@ import common.item.ItemArmor;
|
|||
import common.item.ItemDye;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.tileentity.TileEntityBanner;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -617,16 +616,16 @@ public abstract class CraftingRegistry
|
|||
}
|
||||
|
||||
TagObject tag = itemstack.getSubCompound("BlockEntityTag", true);
|
||||
TagObjectList list = null;
|
||||
List<TagObject> list = null;
|
||||
|
||||
if (tag.hasObjectList("Patterns"))
|
||||
if (tag.hasList("Patterns"))
|
||||
{
|
||||
list = tag.getObjectList("Patterns");
|
||||
list = tag.getList("Patterns");
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new TagObjectList();
|
||||
tag.setObjectList("Patterns", list);
|
||||
list = Lists.newArrayList();
|
||||
tag.setList("Patterns", list);
|
||||
}
|
||||
|
||||
TagObject pattern = new TagObject();
|
||||
|
@ -971,7 +970,7 @@ public abstract class CraftingRegistry
|
|||
{
|
||||
TagObject tag = new TagObject();
|
||||
TagObject data = new TagObject();
|
||||
TagObjectList list = new TagObjectList();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
|
||||
for (int k2 = 0; k2 < inv.getSizeInventory(); ++k2)
|
||||
{
|
||||
|
@ -983,7 +982,7 @@ public abstract class CraftingRegistry
|
|||
}
|
||||
}
|
||||
|
||||
data.setObjectList("Explosions", list);
|
||||
data.setList("Explosions", list);
|
||||
data.setByte("Flight", (byte)j);
|
||||
tag.setObject("Fireworks", data);
|
||||
this.field_92102_a.setTagCompound(tag);
|
||||
|
@ -1552,7 +1551,7 @@ public abstract class CraftingRegistry
|
|||
|
||||
if (itemstack1 != null && itemstack1.hasTagCompound())
|
||||
{
|
||||
itemstack.setTagCompound((TagObject)itemstack1.getTagCompound().copy());
|
||||
itemstack.setTagCompound(itemstack1.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,7 @@ import common.dimension.Dimension.GeneratorType;
|
|||
import common.dimension.Dimension.ReplacerType;
|
||||
import common.log.Log;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagException;
|
||||
import common.tags.TagInterpreter;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.util.PortalType;
|
||||
import common.world.State;
|
||||
import common.world.Weather;
|
||||
|
@ -93,14 +90,14 @@ public abstract class UniverseRegistry {
|
|||
}
|
||||
|
||||
public static void fromTags(TagObject tag) {
|
||||
TagObjectList list = tag.getObjectList("Dimensions");
|
||||
List<TagObject> list = tag.getList("Dimensions");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
Dimension dim = Dimension.getByTag(list.get(z));
|
||||
if(!REGISTRY.containsKey(dim.getDimensionId()) && !ALIASES.containsKey(dim.getDimensionName()))
|
||||
register(dim);
|
||||
}
|
||||
|
||||
list = tag.getObjectList("Names");
|
||||
list = tag.getList("Names");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject data = list.get(z);
|
||||
String id = data.getString("ID");
|
||||
|
@ -111,7 +108,7 @@ public abstract class UniverseRegistry {
|
|||
// }
|
||||
}
|
||||
|
||||
list = tag.getObjectList("Sectors");
|
||||
list = tag.getList("Sectors");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject data = list.get(z);
|
||||
String id = data.getString("ID");
|
||||
|
@ -121,7 +118,7 @@ public abstract class UniverseRegistry {
|
|||
sector.readTags(data);
|
||||
}
|
||||
|
||||
list = tag.getObjectList("Galaxies");
|
||||
list = tag.getList("Galaxies");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject data = list.get(z);
|
||||
String id = data.getString("ID");
|
||||
|
@ -131,7 +128,7 @@ public abstract class UniverseRegistry {
|
|||
galaxy.readTags(data);
|
||||
}
|
||||
|
||||
list = tag.getObjectList("Domains");
|
||||
list = tag.getList("Domains");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject data = list.get(z);
|
||||
String id = data.getString("ID");
|
||||
|
@ -141,7 +138,7 @@ public abstract class UniverseRegistry {
|
|||
domain.readTags(data);
|
||||
}
|
||||
|
||||
list = tag.getObjectList("Barycenters");
|
||||
list = tag.getList("Barycenters");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject link = list.get(z);
|
||||
if(!assign(link.getString("Celestial"), link.getString("Center")))
|
||||
|
@ -152,15 +149,15 @@ public abstract class UniverseRegistry {
|
|||
public static TagObject toTags() {
|
||||
TagObject tag = new TagObject();
|
||||
|
||||
TagObjectList list = new TagObjectList();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Dimension dim : DIMENSIONS) {
|
||||
if(!BASE_REGISTRY.containsKey(dim.getDimensionId()) && dim != Space.INSTANCE)
|
||||
list.add(dim.toTags());
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setObjectList("Dimensions", list);
|
||||
tag.setList("Dimensions", list);
|
||||
|
||||
list = new TagObjectList();
|
||||
list = Lists.newArrayList();
|
||||
for(Dimension dim : DIMENSIONS) {
|
||||
if(/* BASE_REGISTRY.containsKey(dim.getDimensionId()) */ dim != Space.INSTANCE) {
|
||||
TagObject data = new TagObject();
|
||||
|
@ -172,9 +169,9 @@ public abstract class UniverseRegistry {
|
|||
}
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setObjectList("Names", list);
|
||||
tag.setList("Names", list);
|
||||
|
||||
list = new TagObjectList();
|
||||
list = Lists.newArrayList();
|
||||
for(Sector sector : SECTORS.values()) {
|
||||
TagObject data = new TagObject();
|
||||
sector.writeTags(data);
|
||||
|
@ -184,9 +181,9 @@ public abstract class UniverseRegistry {
|
|||
}
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setObjectList("Sectors", list);
|
||||
tag.setList("Sectors", list);
|
||||
|
||||
list = new TagObjectList();
|
||||
list = Lists.newArrayList();
|
||||
for(Galaxy galaxy : GALAXIES.values()) {
|
||||
TagObject data = new TagObject();
|
||||
galaxy.writeTags(data);
|
||||
|
@ -196,9 +193,9 @@ public abstract class UniverseRegistry {
|
|||
}
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setObjectList("Galaxies", list);
|
||||
tag.setList("Galaxies", list);
|
||||
|
||||
list = new TagObjectList();
|
||||
list = Lists.newArrayList();
|
||||
for(Domain domain : DOMAINS.values()) {
|
||||
TagObject data = new TagObject();
|
||||
domain.writeTags(data);
|
||||
|
@ -208,9 +205,9 @@ public abstract class UniverseRegistry {
|
|||
}
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setObjectList("Domains", list);
|
||||
tag.setList("Domains", list);
|
||||
|
||||
list = new TagObjectList();
|
||||
list = Lists.newArrayList();
|
||||
for(Entry<Moon, Planet> entry : MOON_MAP.entrySet()) {
|
||||
if(BASE_REGISTRY.containsKey(entry.getKey().getDimensionId()))
|
||||
continue;
|
||||
|
@ -252,7 +249,7 @@ public abstract class UniverseRegistry {
|
|||
list.add(link);
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setObjectList("Barycenters", list);
|
||||
tag.setList("Barycenters", list);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
@ -703,9 +700,9 @@ public abstract class UniverseRegistry {
|
|||
Dimension dim = BASE_ALIASES.get(base).copy(UniverseRegistry.MORE_DIM_ID, "preset");
|
||||
TagObject ptag;
|
||||
try {
|
||||
ptag = TagInterpreter.parseTag("{" + data + "}");
|
||||
ptag = TagObject.parse("{" + data + "}");
|
||||
}
|
||||
catch(TagException e) {
|
||||
catch(IllegalArgumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
TagObject dtag = dim.toTags(true);
|
||||
|
|
|
@ -4,7 +4,6 @@ import common.entity.Entity;
|
|||
import common.entity.item.EntityItem;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.util.BlockPos;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -55,7 +54,7 @@ public class InventoryHelper
|
|||
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((TagObject)stack.getTagCompound().copy());
|
||||
entityitem.getEntityItem().setTagCompound(stack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
|
|
|
@ -6,7 +6,7 @@ import common.item.Item;
|
|||
import common.item.ItemArmor;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
|
||||
public class InventoryPlayer implements IInventory
|
||||
{
|
||||
|
@ -216,7 +216,7 @@ public class InventoryPlayer implements IInventory
|
|||
|
||||
if (itemStackIn.hasTagCompound())
|
||||
{
|
||||
this.mainInventory[j].setTagCompound((TagObject)itemStackIn.getTagCompound().copy());
|
||||
this.mainInventory[j].setTagCompound(itemStackIn.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ public class InventoryPlayer implements IInventory
|
|||
*
|
||||
* @param nbtTagListIn List to append tags to
|
||||
*/
|
||||
public TagObjectList writeToNBT(TagObjectList nbtTagListIn)
|
||||
public List<TagObject> writeToNBT(List<TagObject> nbtTagListIn)
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
|
@ -482,7 +482,7 @@ public class InventoryPlayer implements IInventory
|
|||
*
|
||||
* @param nbtTagListIn tagList to read from
|
||||
*/
|
||||
public void readFromNBT(TagObjectList nbtTagListIn)
|
||||
public void readFromNBT(List<TagObject> nbtTagListIn)
|
||||
{
|
||||
this.mainInventory = new ItemStack[36];
|
||||
this.armorInventory = new ItemStack[4];
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package common.inventory;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.Blocks;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
import common.util.BlockPos;
|
||||
|
||||
public class InventoryWarpChest extends InventoryBasic
|
||||
|
@ -21,7 +22,7 @@ public class InventoryWarpChest extends InventoryBasic
|
|||
this.associatedChest = chestTileEntity;
|
||||
}
|
||||
|
||||
public void readTags(TagObjectList list)
|
||||
public void readTags(List<TagObject> list)
|
||||
{
|
||||
for (int i = 0; i < this.getSizeInventory(); ++i)
|
||||
{
|
||||
|
@ -40,9 +41,9 @@ public class InventoryWarpChest extends InventoryBasic
|
|||
}
|
||||
}
|
||||
|
||||
public TagObjectList writeTags()
|
||||
public List<TagObject> writeTags()
|
||||
{
|
||||
TagObjectList list = new TagObjectList();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.getSizeInventory(); ++i)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,6 @@ import common.model.ItemMeshDefinition;
|
|||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityBanner;
|
||||
import common.util.BlockPos;
|
||||
|
@ -98,9 +97,9 @@ public class ItemBanner extends ItemBlock
|
|||
{
|
||||
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.hasObjectList("Patterns"))
|
||||
if (nbttagcompound != null && nbttagcompound.hasList("Patterns"))
|
||||
{
|
||||
TagObjectList nbttaglist = nbttagcompound.getObjectList("Patterns");
|
||||
List<TagObject> nbttaglist = nbttagcompound.getList("Patterns");
|
||||
|
||||
for (int i = 0; i < nbttaglist.size() && i < 6; ++i)
|
||||
{
|
||||
|
|
|
@ -119,9 +119,9 @@ public class ItemBlock extends Item
|
|||
}
|
||||
|
||||
TagObject nbttagcompound = new TagObject();
|
||||
TagObject nbttagcompound1 = (TagObject)nbttagcompound.copy();
|
||||
TagObject nbttagcompound1 = nbttagcompound.copy();
|
||||
tileentity.writeTags(nbttagcompound);
|
||||
TagObject nbttagcompound2 = (TagObject)p_179224_3_.getTagCompound().get("BlockEntityTag");
|
||||
TagObject nbttagcompound2 = p_179224_3_.getTagCompound().getObject("BlockEntityTag");
|
||||
nbttagcompound.merge(nbttagcompound2);
|
||||
nbttagcompound.setInt("x", stack.getX());
|
||||
nbttagcompound.setInt("y", stack.getY());
|
||||
|
|
|
@ -2,6 +2,7 @@ package common.item;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.color.TextColor;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
|
@ -11,7 +12,6 @@ import common.init.Items;
|
|||
import common.model.ItemMeshDefinition;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
|
||||
public class ItemEnchantedBook extends Item
|
||||
{
|
||||
|
@ -48,10 +48,10 @@ public class ItemEnchantedBook extends Item
|
|||
// return this.getEnchantments(stack).tagCount() > 0 ? ChatFormat.YELLOW : super.getColor(stack);
|
||||
// }
|
||||
|
||||
public TagObjectList getEnchantments(ItemStack stack)
|
||||
public List<TagObject> getEnchantments(ItemStack stack)
|
||||
{
|
||||
TagObject nbttagcompound = stack.getTagCompound();
|
||||
return nbttagcompound != null && nbttagcompound.hasObjectList("StoredEnchantments") ? nbttagcompound.getObjectList("StoredEnchantments") : new TagObjectList();
|
||||
return nbttagcompound != null && nbttagcompound.hasList("StoredEnchantments") ? nbttagcompound.getList("StoredEnchantments") : Lists.newArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ public class ItemEnchantedBook extends Item
|
|||
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
|
||||
{
|
||||
super.addInformation(stack, playerIn, tooltip);
|
||||
TagObjectList nbttaglist = this.getEnchantments(stack);
|
||||
List<TagObject> nbttaglist = this.getEnchantments(stack);
|
||||
|
||||
if (nbttaglist != null)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ public class ItemEnchantedBook extends Item
|
|||
*/
|
||||
public void addEnchantment(ItemStack stack, RngEnchantment enchantment)
|
||||
{
|
||||
TagObjectList nbttaglist = this.getEnchantments(stack);
|
||||
List<TagObject> nbttaglist = this.getEnchantments(stack);
|
||||
boolean flag = true;
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
|
@ -114,7 +114,7 @@ public class ItemEnchantedBook extends Item
|
|||
stack.setTagCompound(new TagObject());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setObjectList("StoredEnchantments", nbttaglist);
|
||||
stack.getTagCompound().setList("StoredEnchantments", nbttaglist);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@ import common.collect.Lists;
|
|||
import common.entity.item.EntityFireworks;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.World;
|
||||
|
@ -52,7 +51,7 @@ public class ItemFirework extends Item
|
|||
tooltip.add("Flugdauer: " + nbttagcompound.getByte("Flight"));
|
||||
}
|
||||
|
||||
TagObjectList nbttaglist = nbttagcompound.getObjectList("Explosions");
|
||||
List<TagObject> nbttaglist = nbttagcompound.getList("Explosions");
|
||||
|
||||
if (nbttaglist != null && nbttaglist.size() > 0)
|
||||
{
|
||||
|
|
|
@ -20,9 +20,7 @@ import common.entity.types.EntityLiving;
|
|||
import common.init.BlockRegistry;
|
||||
import common.init.ItemRegistry;
|
||||
import common.rng.Random;
|
||||
import common.tags.Tag;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.World;
|
||||
|
@ -121,7 +119,7 @@ public final class ItemStack
|
|||
|
||||
if (this.tag != null)
|
||||
{
|
||||
itemstack.tag = (TagObject)this.tag.copy();
|
||||
itemstack.tag = this.tag.copy();
|
||||
}
|
||||
|
||||
this.size -= amount;
|
||||
|
@ -433,7 +431,7 @@ public final class ItemStack
|
|||
|
||||
if (this.tag != null)
|
||||
{
|
||||
itemstack.tag = (TagObject)this.tag.copy();
|
||||
itemstack.tag = this.tag.copy();
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
|
@ -580,9 +578,9 @@ public final class ItemStack
|
|||
}
|
||||
}
|
||||
|
||||
public TagObjectList getEnchantmentTagList()
|
||||
public List<TagObject> getEnchantmentTagList()
|
||||
{
|
||||
return this.tag == null ? null : this.tag.getObjectList("ench");
|
||||
return this.tag == null ? null : this.tag.getList("ench");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -825,7 +823,7 @@ public final class ItemStack
|
|||
{
|
||||
// if ((i1 & 1) == 0)
|
||||
// {
|
||||
TagObjectList nbttaglist = this.getEnchantmentTagList();
|
||||
List<TagObject> nbttaglist = this.getEnchantmentTagList();
|
||||
|
||||
if (nbttaglist != null)
|
||||
{
|
||||
|
@ -984,7 +982,7 @@ public final class ItemStack
|
|||
|
||||
if (this.hasTagCompound())
|
||||
{
|
||||
list.add(TextColor.GRAY + String.format("NBT-Tags: %d", this.getTagCompound().getKeySet().size()));
|
||||
list.add(TextColor.GRAY + String.format("NBT-Tags: %d", this.getTagCompound().keySet().size()));
|
||||
}
|
||||
// }
|
||||
|
||||
|
@ -1019,12 +1017,12 @@ public final class ItemStack
|
|||
this.setTagCompound(new TagObject());
|
||||
}
|
||||
|
||||
if (!this.tag.hasObjectList("ench"))
|
||||
if (!this.tag.hasList("ench"))
|
||||
{
|
||||
this.tag.setObjectList("ench", new TagObjectList());
|
||||
this.tag.setList("ench", Lists.newArrayList());
|
||||
}
|
||||
|
||||
TagObjectList nbttaglist = this.tag.getObjectList("ench");
|
||||
List<TagObject> nbttaglist = this.tag.getList("ench");
|
||||
TagObject nbttagcompound = new TagObject();
|
||||
nbttagcompound.setShort("id", (short)ench.effectId);
|
||||
nbttagcompound.setShort("lvl", (short)(/* (byte) */ level));
|
||||
|
@ -1038,11 +1036,11 @@ public final class ItemStack
|
|||
if(this.tag == null) {
|
||||
return false;
|
||||
}
|
||||
if(!this.tag.hasObjectList("ench")) {
|
||||
if(!this.tag.hasList("ench")) {
|
||||
return false;
|
||||
}
|
||||
TagObjectList oldEnch = this.tag.getObjectList("ench");
|
||||
TagObjectList newEnch = new TagObjectList();
|
||||
List<TagObject> oldEnch = this.tag.getList("ench");
|
||||
List<TagObject> newEnch = Lists.newArrayList();
|
||||
boolean changed = false;
|
||||
TagObject tag;
|
||||
for(int z = 0; z < oldEnch.size(); z++) {
|
||||
|
@ -1064,7 +1062,7 @@ public final class ItemStack
|
|||
}
|
||||
}
|
||||
else {
|
||||
this.tag.setObjectList("ench", newEnch);
|
||||
this.tag.setList("ench", newEnch);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1076,7 +1074,7 @@ public final class ItemStack
|
|||
if(this.tag == null) {
|
||||
return false;
|
||||
}
|
||||
if(!this.tag.hasObjectList("ench")) {
|
||||
if(!this.tag.hasList("ench")) {
|
||||
return false;
|
||||
}
|
||||
this.tag.remove("ench");
|
||||
|
@ -1091,17 +1089,27 @@ public final class ItemStack
|
|||
*/
|
||||
public boolean isItemEnchanted()
|
||||
{
|
||||
return this.tag != null && this.tag.hasObjectList("ench");
|
||||
return this.tag != null && this.tag.hasList("ench");
|
||||
}
|
||||
|
||||
public void setTagInfo(String key, Tag value)
|
||||
public void setTagInfo(String key, TagObject value)
|
||||
{
|
||||
if (this.tag == null)
|
||||
{
|
||||
this.setTagCompound(new TagObject());
|
||||
}
|
||||
|
||||
this.tag.set(key, value);
|
||||
this.tag.setObject(key, value);
|
||||
}
|
||||
|
||||
public void setTagInfo(String key, List<TagObject> value)
|
||||
{
|
||||
if (this.tag == null)
|
||||
{
|
||||
this.setTagCompound(new TagObject());
|
||||
}
|
||||
|
||||
this.tag.setList(key, value);
|
||||
}
|
||||
|
||||
// public boolean canEditBlocks()
|
||||
|
|
|
@ -10,8 +10,6 @@ import common.net.buffer.ByteBufInputStream;
|
|||
import common.net.buffer.ByteBufOutputStream;
|
||||
import common.net.handler.codec.DecoderException;
|
||||
import common.net.handler.codec.EncoderException;
|
||||
import common.tags.SizeTracker;
|
||||
import common.tags.TagLoader;
|
||||
import common.tags.TagObject;
|
||||
import common.util.BlockPos;
|
||||
|
||||
|
@ -98,7 +96,7 @@ public class PacketBuffer {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
TagLoader.write(tag, new ByteBufOutputStream(this.buf));
|
||||
TagObject.write(tag, new ByteBufOutputStream(this.buf));
|
||||
}
|
||||
catch(IOException e) {
|
||||
throw new EncoderException(e);
|
||||
|
@ -111,7 +109,7 @@ public class PacketBuffer {
|
|||
if(b == 0)
|
||||
return null;
|
||||
this.buf.readerIndex(i);
|
||||
return TagLoader.read(new ByteBufInputStream(this.buf), new SizeTracker(2097152));
|
||||
return TagObject.read(new ByteBufInputStream(this.buf), 2097152);
|
||||
}
|
||||
|
||||
public void writeItemStack(ItemStack stack) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package common.tags;
|
||||
|
||||
public class SizeTracker {
|
||||
class SizeTracker {
|
||||
public static final SizeTracker INFINITE = new SizeTracker(0) {
|
||||
public void read(int bytes) {
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class Tag {
|
||||
abstract class Tag {
|
||||
abstract void write(DataOutput output) throws IOException;
|
||||
abstract void read(DataInput input, int depth, SizeTracker tracker) throws IOException;
|
||||
public abstract String toString();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package common.tags;
|
||||
|
||||
public class TagException extends Exception {
|
||||
class TagException extends IllegalArgumentException {
|
||||
public TagException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ class TagIntArray extends Tag {
|
|||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeInt(this.data.length);
|
||||
for(int i = 0; i < this.data.length; ++i) {
|
||||
output.writeInt(this.data[i]);
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
output.writeInt(this.data[z]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,10 @@ class TagIntArray extends Tag {
|
|||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
for(int i : this.data) {
|
||||
sb.append(i + ",");
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
if(z != 0)
|
||||
sb.append(',');
|
||||
sb.append(this.data[z]);
|
||||
}
|
||||
return sb.append("]").toString();
|
||||
}
|
||||
|
|
|
@ -1,29 +1,28 @@
|
|||
package common.tags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Stack;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import common.collect.Lists;
|
||||
|
||||
public class TagInterpreter
|
||||
class TagInterpreter
|
||||
{
|
||||
private static final Pattern PATTERN = Pattern.compile("\\[[-+\\d|,\\s]+\\]");
|
||||
|
||||
public static TagObject parseTag(String jsonString) throws TagException
|
||||
static TagObject parseTag(String tag) throws TagException
|
||||
{
|
||||
jsonString = jsonString.trim();
|
||||
|
||||
if (!jsonString.startsWith("{"))
|
||||
if (!tag.startsWith("{"))
|
||||
{
|
||||
throw new TagException("Invalid tag encountered, expected \'{\' as first char.");
|
||||
}
|
||||
else if (func_150310_b(jsonString) != 1)
|
||||
else if (func_150310_b(tag) != 1)
|
||||
{
|
||||
throw new TagException("Encountered multiple top tags, only one expected");
|
||||
}
|
||||
else
|
||||
{
|
||||
return (TagObject)func_150316_a("tag", jsonString).parse();
|
||||
return (TagObject)func_150316_a("tag", tag).parse();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +143,7 @@ public class TagInterpreter
|
|||
if (s.length() > 0)
|
||||
{
|
||||
boolean flag = true;
|
||||
list.field_150492_b.add(func_179270_a(s, flag));
|
||||
list.data.add(func_179270_a(s, flag));
|
||||
}
|
||||
|
||||
if (p_150316_1_.length() < s.length() + 1)
|
||||
|
@ -405,7 +404,7 @@ public class TagInterpreter
|
|||
|
||||
static class List extends TagInterpreter.Any
|
||||
{
|
||||
protected java.util.List<TagInterpreter.Any> field_150492_b = Lists.<TagInterpreter.Any>newArrayList();
|
||||
protected java.util.List<TagInterpreter.Any> data = Lists.<TagInterpreter.Any>newArrayList();
|
||||
|
||||
public List(String json)
|
||||
{
|
||||
|
@ -415,24 +414,31 @@ public class TagInterpreter
|
|||
public Tag parse() throws TagException
|
||||
{
|
||||
TagList list = null;
|
||||
java.util.List<String> strs = null;
|
||||
|
||||
for (TagInterpreter.Any any : this.field_150492_b)
|
||||
for (TagInterpreter.Any any : this.data)
|
||||
{
|
||||
Tag tag = any.parse();
|
||||
if(list == null) {
|
||||
switch(tag.getType()) {
|
||||
case STRING_LIST:
|
||||
list = new TagStringList();
|
||||
case OBJECT_LIST:
|
||||
list = new TagObjectList();
|
||||
default:
|
||||
throw new TagException("Type cannot be put in a list: " + any.json);
|
||||
}
|
||||
if(tag.getType() == TagType.STRING) {
|
||||
if(list != null)
|
||||
throw new TagException("Cannot use mixed types for list: " + any.json);
|
||||
if(strs == null)
|
||||
strs = new ArrayList<String>(this.data.size());
|
||||
strs.add(((TagString)tag).getString());
|
||||
}
|
||||
else if(tag.getType() == TagType.OBJECT) {
|
||||
if(strs != null)
|
||||
throw new TagException("Cannot use mixed types for list: " + any.json);
|
||||
if(list == null)
|
||||
list = new TagList(new ArrayList<TagObject>(this.data.size()));
|
||||
list.getList().add(((TagObject)tag));
|
||||
}
|
||||
else {
|
||||
throw new TagException("Type cannot be put in a list: " + any.json);
|
||||
}
|
||||
list.addElem(tag);
|
||||
}
|
||||
|
||||
return list;
|
||||
return strs != null ? new TagStringArray(strs.toArray(new String[strs.size()])) : (list != null ? list : new TagList(Lists.newArrayList()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
63
common/src/main/java/common/tags/TagList.java
Executable file → Normal file
63
common/src/main/java/common/tags/TagList.java
Executable file → Normal file
|
@ -6,11 +6,15 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.log.Log;
|
||||
|
||||
abstract class TagList<K extends Tag> extends Tag {
|
||||
private List<K> list = Lists.newArrayList();
|
||||
class TagList extends Tag {
|
||||
private List<TagObject> list;
|
||||
|
||||
TagList() {
|
||||
}
|
||||
|
||||
public TagList(List<TagObject> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeInt(this.list.size());
|
||||
|
@ -25,18 +29,17 @@ abstract class TagList<K extends Tag> extends Tag {
|
|||
throw new RuntimeException("Objekt ist zu komplex, die Tiefe ist größer als 512");
|
||||
int len = input.readInt();
|
||||
tracker.read(4 * len);
|
||||
this.list = new ArrayList<K>(len);
|
||||
this.list = new ArrayList<TagObject>(len);
|
||||
for(int z = 0; z < len; z++) {
|
||||
K tag = (K)this.getElemType().createTag();
|
||||
TagObject tag = new TagObject();
|
||||
tag.read(input, depth + 1, tracker);
|
||||
this.list.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract TagType getType();
|
||||
protected abstract TagType getElemType();
|
||||
protected abstract TagList<K> createInstance();
|
||||
protected abstract K getDefault();
|
||||
protected TagType getType() {
|
||||
return TagType.LIST;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
|
@ -48,38 +51,10 @@ abstract class TagList<K extends Tag> extends Tag {
|
|||
return sb.append(']').toString();
|
||||
}
|
||||
|
||||
protected void addElem(K tag) {
|
||||
this.list.add(tag);
|
||||
}
|
||||
|
||||
protected void set(int index, K tag) {
|
||||
if(index < 0 || index >= this.list.size()) {
|
||||
Log.IO.error("Index außerhalb des Bereiches um Tag in Tag-Liste zu setzen");
|
||||
return;
|
||||
}
|
||||
this.list.set(index, tag);
|
||||
}
|
||||
|
||||
public void remove(int index) {
|
||||
this.list.remove(index);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.list.isEmpty();
|
||||
}
|
||||
|
||||
protected K getElem(int index) {
|
||||
return index >= 0 && index < this.list.size() ? this.list.get(index) : this.getDefault();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.list.size();
|
||||
}
|
||||
|
||||
public Tag copy() {
|
||||
TagList<K> list = this.createInstance();
|
||||
for(K tag : this.list) {
|
||||
list.list.add((K)tag.copy());
|
||||
TagList list = new TagList(new ArrayList<TagObject>(this.list.size()));
|
||||
for(TagObject tag : this.list) {
|
||||
list.list.add(tag.copy());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -91,4 +66,8 @@ abstract class TagList<K extends Tag> extends Tag {
|
|||
public int hashCode() {
|
||||
return super.hashCode() ^ this.list.hashCode();
|
||||
}
|
||||
|
||||
public List<TagObject> getList() {
|
||||
return this.list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package common.tags;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* compressed data tree / CDT loader
|
||||
* (ids 0..15)
|
||||
*/
|
||||
public class TagLoader {
|
||||
public static TagObject readGZip(File file) throws IOException {
|
||||
DataInputStream in = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file))));
|
||||
TagObject tag;
|
||||
try {
|
||||
tag = read(in, SizeTracker.INFINITE);
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void writeGZip(TagObject tag, File file) throws IOException {
|
||||
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file))));
|
||||
try {
|
||||
write(tag, out);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static TagObject read(DataInput in, SizeTracker tracker) throws IOException {
|
||||
TagObject tag = new TagObject();
|
||||
tag.read(in, 0, tracker);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void write(TagObject tag, DataOutput out) throws IOException {
|
||||
tag.write(out);
|
||||
}
|
||||
}
|
|
@ -1,15 +1,30 @@
|
|||
package common.tags;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* compressed data tree / CDT
|
||||
* (ids 0..15)
|
||||
*/
|
||||
public class TagObject extends Tag {
|
||||
private Map<String, Tag> tags = Maps.<String, Tag>newHashMap();
|
||||
|
||||
|
@ -41,7 +56,7 @@ public class TagObject extends Tag {
|
|||
}
|
||||
}
|
||||
|
||||
public Set<String> getKeySet() {
|
||||
public Set<String> keySet() {
|
||||
return this.tags.keySet();
|
||||
}
|
||||
|
||||
|
@ -49,7 +64,7 @@ public class TagObject extends Tag {
|
|||
return TagType.OBJECT;
|
||||
}
|
||||
|
||||
public void set(String key, Tag value) {
|
||||
void set(String key, Tag value) {
|
||||
this.tags.put(key, value);
|
||||
}
|
||||
|
||||
|
@ -57,12 +72,12 @@ public class TagObject extends Tag {
|
|||
this.tags.put(key, value);
|
||||
}
|
||||
|
||||
public void setStringList(String key, TagStringList value) {
|
||||
this.tags.put(key, value);
|
||||
public void setStringArray(String key, String[] value) {
|
||||
this.tags.put(key, new TagStringArray(value));
|
||||
}
|
||||
|
||||
public void setObjectList(String key, TagObjectList value) {
|
||||
this.tags.put(key, value);
|
||||
public void setList(String key, List<TagObject> value) {
|
||||
this.tags.put(key, new TagList(value));
|
||||
}
|
||||
|
||||
public void setBool(String key, boolean value) {
|
||||
|
@ -109,7 +124,7 @@ public class TagObject extends Tag {
|
|||
this.tags.put(key, new TagIntArray(value));
|
||||
}
|
||||
|
||||
public Tag get(String key) {
|
||||
Tag get(String key) {
|
||||
return this.tags.get(key);
|
||||
}
|
||||
|
||||
|
@ -166,12 +181,12 @@ public class TagObject extends Tag {
|
|||
return this.has(key, TagType.OBJECT);
|
||||
}
|
||||
|
||||
public boolean hasStringList(String key) {
|
||||
return this.has(key, TagType.STRING_LIST);
|
||||
public boolean hasStringArray(String key) {
|
||||
return this.has(key, TagType.STRING_ARRAY);
|
||||
}
|
||||
|
||||
public boolean hasObjectList(String key) {
|
||||
return this.has(key, TagType.OBJECT_LIST);
|
||||
public boolean hasList(String key) {
|
||||
return this.has(key, TagType.LIST);
|
||||
}
|
||||
|
||||
public boolean getBool(String key) {
|
||||
|
@ -199,11 +214,11 @@ public class TagObject extends Tag {
|
|||
}
|
||||
|
||||
public float getFloat(String key) {
|
||||
return !this.has(key, TagType.FLOAT) ? 0.0F : ((TagFloat)this.tags.get(key)).getFloat();
|
||||
return !this.has(key, TagType.FLOAT) ? 0.0f : ((TagFloat)this.tags.get(key)).getFloat();
|
||||
}
|
||||
|
||||
public double getDouble(String key) {
|
||||
return !this.has(key, TagType.DOUBLE) ? 0.0D : ((TagDouble)this.tags.get(key)).getDouble();
|
||||
return !this.has(key, TagType.DOUBLE) ? 0.0 : ((TagDouble)this.tags.get(key)).getDouble();
|
||||
}
|
||||
|
||||
public String getString(String key) {
|
||||
|
@ -222,12 +237,12 @@ public class TagObject extends Tag {
|
|||
return !this.has(key, TagType.OBJECT) ? new TagObject() : (TagObject)this.tags.get(key);
|
||||
}
|
||||
|
||||
public TagStringList getStringList(String key) {
|
||||
return !this.has(key, TagType.STRING_LIST) ? new TagStringList() : (TagStringList)this.tags.get(key);
|
||||
public String[] getStringArray(String key) {
|
||||
return !this.has(key, TagType.STRING_ARRAY) ? new String[0] : ((TagStringArray)this.tags.get(key)).getStringArray();
|
||||
}
|
||||
|
||||
public TagObjectList getObjectList(String key) {
|
||||
return !this.has(key, TagType.OBJECT_LIST) ? new TagObjectList() : (TagObjectList)this.tags.get(key);
|
||||
public List<TagObject> getList(String key) {
|
||||
return !this.has(key, TagType.LIST) ? Lists.newArrayList() : ((TagList)this.tags.get(key)).getList();
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
|
@ -248,7 +263,7 @@ public class TagObject extends Tag {
|
|||
return this.tags.isEmpty();
|
||||
}
|
||||
|
||||
public Tag copy() {
|
||||
public TagObject copy() {
|
||||
TagObject tag = new TagObject();
|
||||
for(String s : this.tags.keySet()) {
|
||||
tag.set(s, this.tags.get(s).copy());
|
||||
|
@ -286,4 +301,70 @@ public class TagObject extends Tag {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(TagObject tag, DataOutput out) throws IOException {
|
||||
tag.write(out);
|
||||
}
|
||||
|
||||
public static TagObject read(DataInput in) throws IOException {
|
||||
return read(in, SizeTracker.INFINITE);
|
||||
}
|
||||
|
||||
public static TagObject read(DataInput in, int limit) throws IOException {
|
||||
return read(in, new SizeTracker(limit));
|
||||
}
|
||||
|
||||
private static TagObject read(DataInput in, SizeTracker tracker) throws IOException {
|
||||
TagObject tag = new TagObject();
|
||||
tag.read(in, 0, tracker);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void writeGZip(TagObject tag, File file) throws IOException {
|
||||
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file))));
|
||||
try {
|
||||
TagObject.write(tag, out);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static TagObject readGZip(File file) throws IOException {
|
||||
DataInputStream in = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file))));
|
||||
TagObject tag;
|
||||
try {
|
||||
tag = TagObject.read(in, SizeTracker.INFINITE);
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static boolean compare(TagObject tag1, TagObject tag2) {
|
||||
return compareTags(tag1, tag2);
|
||||
}
|
||||
|
||||
private static boolean compareTags(Tag tag1, Tag tag2) {
|
||||
if(tag1 == tag2 || tag1 == null)
|
||||
return true;
|
||||
else if(tag2 == null || !tag1.getClass().equals(tag2.getClass()))
|
||||
return false;
|
||||
else if(tag1 instanceof TagObject) {
|
||||
TagObject comp1 = (TagObject)tag1;
|
||||
TagObject comp2 = (TagObject)tag2;
|
||||
for(String key : comp1.keySet()) {
|
||||
Tag tag = comp1.get(key);
|
||||
if(!compareTags(tag, comp2.get(key)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return tag1.equals(tag2);
|
||||
}
|
||||
|
||||
public static TagObject parse(String tag) throws IllegalArgumentException {
|
||||
return TagInterpreter.parseTag(tag.trim());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package common.tags;
|
||||
|
||||
public class TagObjectList extends TagList<TagObject> {
|
||||
protected TagType getType() {
|
||||
return TagType.OBJECT_LIST;
|
||||
}
|
||||
|
||||
protected TagType getElemType() {
|
||||
return TagType.OBJECT;
|
||||
}
|
||||
|
||||
protected TagList<TagObject> createInstance() {
|
||||
return new TagObjectList();
|
||||
}
|
||||
|
||||
protected TagObject getDefault() {
|
||||
return new TagObject();
|
||||
}
|
||||
|
||||
public TagObject get(int index) {
|
||||
return this.getElem(index);
|
||||
}
|
||||
|
||||
public void add(TagObject value) {
|
||||
this.addElem(value);
|
||||
}
|
||||
}
|
66
common/src/main/java/common/tags/TagStringArray.java
Normal file
66
common/src/main/java/common/tags/TagStringArray.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package common.tags;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
class TagStringArray extends Tag {
|
||||
private String[] data;
|
||||
|
||||
TagStringArray() {
|
||||
}
|
||||
|
||||
public TagStringArray(String[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeInt(this.data.length);
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
output.writeUTF(this.data[z]);
|
||||
}
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||
tracker.read(24);
|
||||
int len = input.readInt();
|
||||
this.data = new String[len];
|
||||
for(int z = 0; z < len; z++) {
|
||||
this.data[z] = input.readUTF();
|
||||
tracker.read(2 * this.data[z].length());
|
||||
}
|
||||
}
|
||||
|
||||
protected TagType getType() {
|
||||
return TagType.STRING_ARRAY;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
if(z != 0)
|
||||
sb.append(',');
|
||||
sb.append("\"" + this.data[z].replace("\"", "\\\"") + "\"");
|
||||
}
|
||||
return sb.append("]").toString();
|
||||
}
|
||||
|
||||
public Tag copy() {
|
||||
String[] data = new String[this.data.length];
|
||||
System.arraycopy(this.data, 0, data, 0, this.data.length);
|
||||
return new TagStringArray(data);
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
return super.equals(other) && Arrays.equals(this.data, ((TagStringArray)other).data);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return super.hashCode() ^ Arrays.hashCode(this.data);
|
||||
}
|
||||
|
||||
public String[] getStringArray() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package common.tags;
|
||||
|
||||
public class TagStringList extends TagList<TagString> {
|
||||
protected TagType getType() {
|
||||
return TagType.STRING_LIST;
|
||||
}
|
||||
|
||||
protected TagType getElemType() {
|
||||
return TagType.STRING;
|
||||
}
|
||||
|
||||
protected TagList<TagString> createInstance() {
|
||||
return new TagStringList();
|
||||
}
|
||||
|
||||
protected TagString getDefault() {
|
||||
return new TagString("");
|
||||
}
|
||||
|
||||
public String get(int index) {
|
||||
return this.getElem(index).getString();
|
||||
}
|
||||
|
||||
public void add(String value) {
|
||||
this.addElem(new TagString(value));
|
||||
}
|
||||
}
|
|
@ -4,80 +4,80 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public enum TagType {
|
||||
enum TagType {
|
||||
NULL { // 0
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagNull();
|
||||
}
|
||||
},
|
||||
OBJECT { // 1
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagObject();
|
||||
}
|
||||
},
|
||||
BOOLEAN { // 2
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagBool();
|
||||
}
|
||||
},
|
||||
BYTE { // 3
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagByte();
|
||||
}
|
||||
},
|
||||
SHORT { // 4
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagShort();
|
||||
}
|
||||
},
|
||||
CHAR { // 5
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagChar();
|
||||
}
|
||||
},
|
||||
INT { // 6
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagInt();
|
||||
}
|
||||
},
|
||||
LONG { // 7
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagLong();
|
||||
}
|
||||
},
|
||||
FLOAT { // 8
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagFloat();
|
||||
}
|
||||
},
|
||||
DOUBLE { // 9
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagDouble();
|
||||
}
|
||||
},
|
||||
STRING { // 10
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagString();
|
||||
}
|
||||
},
|
||||
OBJECT_LIST { // 11
|
||||
public Tag createTag() {
|
||||
return new TagObjectList();
|
||||
LIST { // 11
|
||||
protected Tag createTag() {
|
||||
return new TagList();
|
||||
}
|
||||
},
|
||||
BYTE_ARRAY { // 12
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagByteArray();
|
||||
}
|
||||
},
|
||||
INT_ARRAY { // 13
|
||||
public Tag createTag() {
|
||||
protected Tag createTag() {
|
||||
return new TagIntArray();
|
||||
}
|
||||
},
|
||||
STRING_LIST { // 14
|
||||
public Tag createTag() {
|
||||
return new TagStringList();
|
||||
STRING_ARRAY { // 14
|
||||
protected Tag createTag() {
|
||||
return new TagStringArray();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -117,7 +117,7 @@ public enum TagType {
|
|||
this.id = (byte)this.ordinal();
|
||||
}
|
||||
|
||||
public abstract Tag createTag();
|
||||
protected abstract Tag createTag();
|
||||
|
||||
public byte getId() {
|
||||
return this.id;
|
||||
|
|
|
@ -11,14 +11,13 @@ import common.item.ItemStack;
|
|||
import common.network.Packet;
|
||||
import common.packet.SPacketUpdateTileEntity;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
|
||||
public class TileEntityBanner extends TileEntity
|
||||
{
|
||||
private int baseColor;
|
||||
|
||||
/** A list of all the banner patterns. */
|
||||
private TagObjectList patterns;
|
||||
private List<TagObject> patterns;
|
||||
private boolean field_175119_g;
|
||||
private List<TileEntityBanner.EnumBannerPattern> patternList;
|
||||
private List<DyeColor> colorList;
|
||||
|
@ -36,9 +35,12 @@ public class TileEntityBanner extends TileEntity
|
|||
{
|
||||
TagObject nbttagcompound = stack.getTagCompound().getObject("BlockEntityTag");
|
||||
|
||||
if (nbttagcompound.hasObjectList("Patterns"))
|
||||
if (nbttagcompound.hasList("Patterns"))
|
||||
{
|
||||
this.patterns = (TagObjectList)nbttagcompound.getObjectList("Patterns").copy();
|
||||
this.patterns = Lists.newArrayList();
|
||||
for(TagObject pattern : nbttagcompound.getList("Patterns")) {
|
||||
this.patterns.add(pattern.copy());
|
||||
}
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasInt("Base"))
|
||||
|
@ -67,13 +69,13 @@ public class TileEntityBanner extends TileEntity
|
|||
setBaseColorAndPatterns(compound, this.baseColor, this.patterns);
|
||||
}
|
||||
|
||||
public static void setBaseColorAndPatterns(TagObject compound, int baseColorIn, TagObjectList patternsIn)
|
||||
public static void setBaseColorAndPatterns(TagObject compound, int baseColorIn, List<TagObject> patternsIn)
|
||||
{
|
||||
compound.setInt("Base", baseColorIn);
|
||||
|
||||
if (patternsIn != null)
|
||||
{
|
||||
compound.setObjectList("Patterns", patternsIn);
|
||||
compound.setList("Patterns", patternsIn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +83,7 @@ public class TileEntityBanner extends TileEntity
|
|||
{
|
||||
super.readTags(compound);
|
||||
this.baseColor = compound.getInt("Base");
|
||||
this.patterns = compound.getObjectList("Patterns");
|
||||
this.patterns = compound.getList("Patterns");
|
||||
this.patternList = null;
|
||||
this.colorList = null;
|
||||
this.patternResourceLocation = null;
|
||||
|
@ -114,7 +116,7 @@ public class TileEntityBanner extends TileEntity
|
|||
public static int getPatterns(ItemStack stack)
|
||||
{
|
||||
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
|
||||
return nbttagcompound != null && nbttagcompound.hasObjectList("Patterns") ? nbttagcompound.getObjectList("Patterns").size() : 0;
|
||||
return nbttagcompound != null && nbttagcompound.hasList("Patterns") ? nbttagcompound.getList("Patterns").size() : 0;
|
||||
}
|
||||
|
||||
public List<TileEntityBanner.EnumBannerPattern> getPatternList()
|
||||
|
@ -123,7 +125,7 @@ public class TileEntityBanner extends TileEntity
|
|||
return this.patternList;
|
||||
}
|
||||
|
||||
public TagObjectList getPatterns()
|
||||
public List<TagObject> getPatterns()
|
||||
{
|
||||
return this.patterns;
|
||||
}
|
||||
|
@ -191,9 +193,9 @@ public class TileEntityBanner extends TileEntity
|
|||
{
|
||||
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.hasObjectList("Patterns"))
|
||||
if (nbttagcompound != null && nbttagcompound.hasList("Patterns"))
|
||||
{
|
||||
TagObjectList nbttaglist = nbttagcompound.getObjectList("Patterns");
|
||||
List<TagObject> nbttaglist = nbttagcompound.getList("Patterns");
|
||||
|
||||
if (nbttaglist.size() > 0)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import common.block.tech.BlockBrewingStand;
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.Items;
|
||||
import common.inventory.Container;
|
||||
|
@ -16,7 +17,6 @@ import common.item.ItemStack;
|
|||
import common.potion.PotionEffect;
|
||||
import common.potion.PotionHelper;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.util.Facing;
|
||||
import common.world.State;
|
||||
|
||||
|
@ -230,7 +230,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
|
|||
public void readTags(TagObject compound)
|
||||
{
|
||||
super.readTags(compound);
|
||||
TagObjectList nbttaglist = compound.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = compound.getList("Items");
|
||||
this.brewingItemStacks = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
|
@ -256,7 +256,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
|
|||
{
|
||||
super.writeTags(compound);
|
||||
compound.setShort("BrewTime", (short)this.brewTime);
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.brewingItemStacks.length; ++i)
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
|
|||
}
|
||||
}
|
||||
|
||||
compound.setObjectList("Items", nbttaglist);
|
||||
compound.setList("Items", nbttaglist);
|
||||
|
||||
if (this.hasCustomName())
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@ package common.tileentity;
|
|||
|
||||
import common.block.Block;
|
||||
import common.block.tech.BlockChest;
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.SoundEvent;
|
||||
import common.inventory.Container;
|
||||
|
@ -11,7 +12,7 @@ import common.inventory.InventoryLargeChest;
|
|||
import common.inventory.InventoryPlayer;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.Facing;
|
||||
|
@ -164,7 +165,7 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
|
|||
public void readTags(TagObject compound)
|
||||
{
|
||||
super.readTags(compound);
|
||||
TagObjectList nbttaglist = compound.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = compound.getList("Items");
|
||||
this.chestContents = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
if (compound.hasString("CustomName"))
|
||||
|
@ -187,7 +188,7 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
|
|||
public void writeTags(TagObject compound)
|
||||
{
|
||||
super.writeTags(compound);
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.chestContents.length; ++i)
|
||||
{
|
||||
|
@ -200,7 +201,7 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
|
|||
}
|
||||
}
|
||||
|
||||
compound.setObjectList("Items", nbttaglist);
|
||||
compound.setList("Items", nbttaglist);
|
||||
|
||||
if (this.hasCustomName())
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package common.tileentity;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerDispenser;
|
||||
|
@ -8,7 +9,7 @@ import common.inventory.InventoryPlayer;
|
|||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityDispenser extends TileEntityLockable implements IInventory
|
||||
{
|
||||
|
@ -155,7 +156,7 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
|
|||
public void readTags(TagObject compound)
|
||||
{
|
||||
super.readTags(compound);
|
||||
TagObjectList nbttaglist = compound.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = compound.getList("Items");
|
||||
this.stacks = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
|
@ -178,7 +179,7 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
|
|||
public void writeTags(TagObject compound)
|
||||
{
|
||||
super.writeTags(compound);
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.stacks.length; ++i)
|
||||
{
|
||||
|
@ -191,7 +192,7 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
|
|||
}
|
||||
}
|
||||
|
||||
compound.setObjectList("Items", nbttaglist);
|
||||
compound.setList("Items", nbttaglist);
|
||||
|
||||
if (this.hasCustomName())
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ import common.block.Material;
|
|||
import common.block.artificial.BlockSlab;
|
||||
import common.block.foliage.BlockSapling;
|
||||
import common.block.tech.BlockFurnace;
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.Blocks;
|
||||
import common.init.Items;
|
||||
|
@ -24,7 +25,7 @@ import common.item.ItemStack;
|
|||
import common.item.ItemSword;
|
||||
import common.item.ItemTool;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
|
||||
|
@ -159,7 +160,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
|
|||
public void readTags(TagObject compound)
|
||||
{
|
||||
super.readTags(compound);
|
||||
TagObjectList nbttaglist = compound.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = compound.getList("Items");
|
||||
this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
|
@ -190,7 +191,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
|
|||
compound.setShort("BurnTime", (short)this.furnaceBurnTime);
|
||||
compound.setShort("CookTime", (short)this.cookTime);
|
||||
compound.setShort("CookTimeTotal", (short)this.totalCookTime);
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.furnaceItemStacks.length; ++i)
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
|
|||
}
|
||||
}
|
||||
|
||||
compound.setObjectList("Items", nbttaglist);
|
||||
compound.setList("Items", nbttaglist);
|
||||
|
||||
if (this.hasCustomName())
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.function.Predicate;
|
|||
import common.block.Block;
|
||||
import common.block.tech.BlockChest;
|
||||
import common.block.tech.BlockHopper;
|
||||
import common.collect.Lists;
|
||||
import common.entity.Entity;
|
||||
import common.entity.item.EntityItem;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
@ -17,7 +18,6 @@ import common.inventory.ISidedInventory;
|
|||
import common.inventory.InventoryPlayer;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.ExtMath;
|
||||
|
@ -33,7 +33,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
|
|||
public void readTags(TagObject compound)
|
||||
{
|
||||
super.readTags(compound);
|
||||
TagObjectList nbttaglist = compound.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = compound.getList("Items");
|
||||
this.inventory = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
if (compound.hasString("CustomName"))
|
||||
|
@ -58,7 +58,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
|
|||
public void writeTags(TagObject compound)
|
||||
{
|
||||
super.writeTags(compound);
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.inventory.length; ++i)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
|
|||
}
|
||||
}
|
||||
|
||||
compound.setObjectList("Items", nbttaglist);
|
||||
compound.setList("Items", nbttaglist);
|
||||
compound.setInt("TransferCooldown", this.transferCooldown);
|
||||
|
||||
if (this.hasCustomName())
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package common.tileentity;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.color.TextColor;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.Container;
|
||||
|
@ -10,7 +11,7 @@ import common.network.Packet;
|
|||
import common.packet.SPacketUpdateTileEntity;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public abstract class TileEntityMachine extends TileEntityLockable implements IHopper, ITickable {
|
||||
|
@ -82,7 +83,7 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
|
|||
public void readTags(TagObject compound) {
|
||||
super.readTags(compound);
|
||||
|
||||
TagObjectList nbttaglist = compound.getObjectList("Items");
|
||||
List<TagObject> nbttaglist = compound.getList("Items");
|
||||
this.clear();
|
||||
for(int i = 0; i < nbttaglist.size(); ++i) {
|
||||
TagObject nbttagcompound = nbttaglist.get(i);
|
||||
|
@ -93,7 +94,7 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
|
|||
}
|
||||
}
|
||||
|
||||
nbttaglist = compound.getObjectList("Resources");
|
||||
nbttaglist = compound.getList("Resources");
|
||||
for(MachineResource res : this.resources) {
|
||||
res.reset();
|
||||
}
|
||||
|
@ -109,7 +110,7 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
|
|||
public void writeTags(TagObject compound) {
|
||||
super.writeTags(compound);
|
||||
|
||||
TagObjectList nbttaglist = new TagObjectList();
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
for(int i = 0; i < this.inventory.length; ++i) {
|
||||
if(this.inventory[i] != null) {
|
||||
TagObject nbttagcompound = new TagObject();
|
||||
|
@ -118,15 +119,15 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
|
|||
nbttaglist.add(nbttagcompound);
|
||||
}
|
||||
}
|
||||
compound.setObjectList("Items", nbttaglist);
|
||||
compound.setList("Items", nbttaglist);
|
||||
|
||||
nbttaglist = new TagObjectList();
|
||||
nbttaglist = Lists.newArrayList();
|
||||
for(int z = 0; z < this.resources.length; z++) {
|
||||
TagObject res = new TagObject();
|
||||
this.resources[z].writeToNbt(res);
|
||||
nbttaglist.add(res);
|
||||
}
|
||||
compound.setObjectList("Resources", nbttaglist);
|
||||
compound.setList("Resources", nbttaglist);
|
||||
|
||||
// compound.setBoolean("Creative", this.isCreative);
|
||||
compound.setInt("Temperature", this.temperature);
|
||||
|
|
|
@ -2,10 +2,10 @@ package common.village;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.Tag;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import java.util.List;
|
||||
|
||||
public class MerchantRecipeList extends ArrayList<MerchantRecipe> {
|
||||
public MerchantRecipe canUse(ItemStack stack1, ItemStack stack2, int index) {
|
||||
|
@ -33,36 +33,18 @@ public class MerchantRecipeList extends ArrayList<MerchantRecipe> {
|
|||
|
||||
private static boolean areItemsSimilar(ItemStack stack1, ItemStack stack2) {
|
||||
return ItemStack.areItemsEqual(stack1, stack2)
|
||||
&& (!stack2.hasTagCompound() || stack1.hasTagCompound() && compareTags(stack2.getTagCompound(), stack1.getTagCompound()));
|
||||
}
|
||||
|
||||
private static boolean compareTags(Tag tag1, Tag tag2) {
|
||||
if(tag1 == tag2 || tag1 == null)
|
||||
return true;
|
||||
else if(tag2 == null || !tag1.getClass().equals(tag2.getClass()))
|
||||
return false;
|
||||
else if(tag1 instanceof TagObject) {
|
||||
TagObject comp1 = (TagObject)tag1;
|
||||
TagObject comp2 = (TagObject)tag2;
|
||||
for(String key : comp1.getKeySet()) {
|
||||
Tag tag = comp1.get(key);
|
||||
if(!compareTags(tag, comp2.get(key)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return tag1.equals(tag2);
|
||||
&& (!stack2.hasTagCompound() || stack1.hasTagCompound() && TagObject.compare(stack2.getTagCompound(), stack1.getTagCompound()));
|
||||
}
|
||||
|
||||
public void fromTags(TagObjectList list) {
|
||||
public void fromTags(List<TagObject> list) {
|
||||
this.clear();
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
this.add(new MerchantRecipe(list.get(z)));
|
||||
}
|
||||
}
|
||||
|
||||
public TagObjectList toTags() {
|
||||
TagObjectList list = new TagObjectList();
|
||||
public List<TagObject> toTags() {
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(int z = 0; z < this.size(); z++) {
|
||||
list.add(this.get(z).toTags());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import common.block.Material;
|
|||
import common.block.artificial.BlockDoor;
|
||||
import common.collect.Lists;
|
||||
import common.tags.TagObject;
|
||||
import common.tags.TagObjectList;
|
||||
import common.util.BlockPos;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
|
@ -214,7 +213,7 @@ public class Village
|
|||
this.radius = tag.getInt("Radius");
|
||||
this.center = new BlockPos(tag.getInt("CX"), tag.getInt("CY"), tag.getInt("CZ"));
|
||||
this.doorRange = new BlockPos(tag.getInt("ACX"), tag.getInt("ACY"), tag.getInt("ACZ"));
|
||||
TagObjectList doors = tag.getObjectList("Doors");
|
||||
List<TagObject> doors = tag.getList("Doors");
|
||||
|
||||
for (int i = 0; i < doors.size(); ++i)
|
||||
{
|
||||
|
@ -233,7 +232,7 @@ public class Village
|
|||
tag.setInt("ACX", this.doorRange.getX());
|
||||
tag.setInt("ACY", this.doorRange.getY());
|
||||
tag.setInt("ACZ", this.doorRange.getZ());
|
||||
TagObjectList doors = new TagObjectList();
|
||||
List<TagObject> doors = Lists.newArrayList();
|
||||
|
||||
for (VillageDoorInfo info : this.doors)
|
||||
{
|
||||
|
@ -247,6 +246,6 @@ public class Village
|
|||
doors.add(door);
|
||||
}
|
||||
|
||||
tag.setObjectList("Doors", doors);
|
||||
tag.setList("Doors", doors);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue