change nbt format

This commit is contained in:
Sen 2025-05-27 21:25:11 +02:00
parent ad4949af16
commit 17aad1f023
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
124 changed files with 2063 additions and 2986 deletions

View file

@ -81,9 +81,9 @@ public class GuiMerchant extends GuiContainer
if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) {
int k = this.selectedMerchantRecipe;
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
ItemStack itemstack = merchantrecipe.getItemToBuy();
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
ItemStack itemstack2 = merchantrecipe.getItemToSell();
ItemStack itemstack = merchantrecipe.getBuying();
ItemStack itemstack1 = merchantrecipe.getSecondBuy();
ItemStack itemstack2 = merchantrecipe.getSelling();
this.renderItemOverlayIntoGUI(itemstack, 36, 24, null);
if(itemstack1 != null)
this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null);
@ -180,9 +180,9 @@ public class GuiMerchant extends GuiContainer
// int j = (this.height - this.ySize) / 2;
int k = this.selectedMerchantRecipe;
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
ItemStack itemstack = merchantrecipe.getItemToBuy();
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
ItemStack itemstack2 = merchantrecipe.getItemToSell();
ItemStack itemstack = merchantrecipe.getBuying();
ItemStack itemstack1 = merchantrecipe.getSecondBuy();
ItemStack itemstack2 = merchantrecipe.getSelling();
GL11.glPushMatrix();
ItemRenderer.enableGUIStandardItemLighting();
GlState.disableLighting();

View file

@ -7,7 +7,7 @@ import common.entity.Entity;
import common.init.SoundEvent;
import common.item.ItemDye;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.util.BoundingBox;
import common.util.ExtMath;
import common.world.World;
@ -192,7 +192,7 @@ public class EntityFirework
{
private int fireworkAge;
private final EffectRenderer theEffectRenderer;
private NBTTagList fireworkExplosions;
private NBTTagTagList fireworkExplosions;
boolean twinkle;
public StarterFX(World p_i46464_1_, double p_i46464_2_, double p_i46464_4_, double p_i46464_6_, double p_i46464_8_, double p_i46464_10_, double p_i46464_12_, EffectRenderer p_i46464_14_, NBTTagCompound p_i46464_15_)
@ -206,21 +206,21 @@ public class EntityFirework
if (p_i46464_15_ != null)
{
this.fireworkExplosions = p_i46464_15_.getTagList("Explosions", 10);
this.fireworkExplosions = p_i46464_15_.getTagList("Explosions");
if (this.fireworkExplosions.tagCount() == 0)
if (this.fireworkExplosions.size() == 0)
{
this.fireworkExplosions = null;
}
else
{
this.particleMaxAge = this.fireworkExplosions.tagCount() * 2 - 1;
this.particleMaxAge = this.fireworkExplosions.size() * 2 - 1;
for (int i = 0; i < this.fireworkExplosions.tagCount(); ++i)
for (int i = 0; i < this.fireworkExplosions.size(); ++i)
{
NBTTagCompound nbttagcompound = this.fireworkExplosions.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = this.fireworkExplosions.getTag(i);
if (nbttagcompound.getBoolean("Flicker"))
if (nbttagcompound.getBool("Flicker"))
{
this.twinkle = true;
this.particleMaxAge += 15;
@ -242,15 +242,15 @@ public class EntityFirework
boolean flag = this.isFarAway();
boolean flag1 = false;
if (this.fireworkExplosions.tagCount() >= 3)
if (this.fireworkExplosions.size() >= 3)
{
flag1 = true;
}
else
{
for (int i = 0; i < this.fireworkExplosions.tagCount(); ++i)
for (int i = 0; i < this.fireworkExplosions.size(); ++i)
{
NBTTagCompound nbttagcompound = this.fireworkExplosions.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = this.fireworkExplosions.getTag(i);
if (nbttagcompound.getByte("Type") == 1)
{
@ -265,13 +265,13 @@ public class EntityFirework
((WorldClient)this.worldObj).playSound(this.posX, this.posY, this.posZ, s1, 20.0F);
}
if (this.fireworkAge % 2 == 0 && this.fireworkExplosions != null && this.fireworkAge / 2 < this.fireworkExplosions.tagCount())
if (this.fireworkAge % 2 == 0 && this.fireworkExplosions != null && this.fireworkAge / 2 < this.fireworkExplosions.size())
{
int k = this.fireworkAge / 2;
NBTTagCompound nbttagcompound1 = this.fireworkExplosions.getCompoundTagAt(k);
NBTTagCompound nbttagcompound1 = this.fireworkExplosions.getTag(k);
int l = nbttagcompound1.getByte("Type");
boolean flag4 = nbttagcompound1.getBoolean("Trail");
boolean flag2 = nbttagcompound1.getBoolean("Flicker");
boolean flag4 = nbttagcompound1.getBool("Trail");
boolean flag2 = nbttagcompound1.getBool("Flicker");
int[] aint = nbttagcompound1.getIntArray("Colors");
int[] aint1 = nbttagcompound1.getIntArray("FadeColors");

View file

@ -36,7 +36,7 @@ public class TileEntityItemStackRenderer
// {
// NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();
//
// if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
// if (nbttagcompound.hasString("SkullOwner") && nbttagcompound.getString("SkullOwner").length() > 0)
// {
// user = nbttagcompound.getString("SkullOwner");
// }

View file

@ -4,7 +4,7 @@ import java.util.Collection;
import common.log.Log;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
public class Attributes
{
@ -40,13 +40,13 @@ public class Attributes
/**
* Creates an NBTTagList from a BaseAttributeMap, including all its AttributeInstances
*/
public static NBTTagList writeBaseAttributeMapToNBT(AttributeMap map)
public static NBTTagTagList writeBaseAttributeMapToNBT(AttributeMap map)
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (AttributeInstance iattributeinstance : map.getAllAttributes())
{
nbttaglist.appendTag(writeAttributeInstanceToNBT(iattributeinstance));
nbttaglist.add(writeAttributeInstanceToNBT(iattributeinstance));
}
return nbttaglist;
@ -65,17 +65,17 @@ public class Attributes
if (collection != null && !collection.isEmpty())
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (AttributeModifier attributemodifier : collection)
{
if (attributemodifier.isSaved())
{
nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
nbttaglist.add(writeAttributeModifierToNBT(attributemodifier));
}
}
nbttagcompound.setTag("Modifiers", nbttaglist);
nbttagcompound.setTagList("Modifiers", nbttaglist);
}
return nbttagcompound;
@ -89,16 +89,16 @@ public class Attributes
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Name", modifier.getName());
nbttagcompound.setDouble("Amount", modifier.getAmount());
nbttagcompound.setBoolean("Multiply", modifier.isMultiplied());
nbttagcompound.setBool("Multiply", modifier.isMultiplied());
nbttagcompound.setLong("AttrId", modifier.getID());
return nbttagcompound;
}
public static void setAttributeModifiers(AttributeMap map, NBTTagList list)
public static void setAttributeModifiers(AttributeMap map, NBTTagTagList list)
{
for (int i = 0; i < list.tagCount(); ++i)
for (int i = 0; i < list.size(); ++i)
{
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = list.getTag(i);
AttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name"));
if (iattributeinstance != null)
@ -116,13 +116,13 @@ public class Attributes
{
instance.setBaseValue(compound.getDouble("Base"));
if (compound.hasKey("Modifiers", 9))
if (compound.hasTagList("Modifiers"))
{
NBTTagList nbttaglist = compound.getTagList("Modifiers", 10);
NBTTagTagList nbttaglist = compound.getTagList("Modifiers");
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i));
AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getTag(i));
if (attributemodifier != null)
{
@ -150,7 +150,7 @@ public class Attributes
try
{
return new AttributeModifier(id, compound.getString("Name"), compound.getDouble("Amount"), compound.getBoolean("Multiply"));
return new AttributeModifier(id, compound.getString("Name"), compound.getDouble("Amount"), compound.getBool("Multiply"));
}
catch (Exception exception)
{

View file

@ -127,10 +127,10 @@ public class BlockBanner extends BlockContainer
ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)tileentity).getBaseColor());
NBTTagCompound nbttagcompound = new NBTTagCompound();
tileentity.writeToNBT(nbttagcompound);
nbttagcompound.removeTag("x");
nbttagcompound.removeTag("y");
nbttagcompound.removeTag("z");
nbttagcompound.removeTag("id");
nbttagcompound.remove("x");
nbttagcompound.remove("y");
nbttagcompound.remove("z");
nbttagcompound.remove("id");
itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
spawnAsEntity(worldIn, pos, itemstack);
}

View file

@ -12,8 +12,8 @@ import common.init.Blocks;
import common.init.MetalType;
import common.init.UniverseRegistry;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagString;
import common.nbt.NBTTagStringList;
import common.nbt.NBTTagTagList;
import common.util.ExtMath;
import common.util.Vec3;
import common.world.State;
@ -813,7 +813,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
private static Dimension getByNbt(NBTTagCompound tag, boolean mapOnly, boolean generator, boolean partialGen, boolean all) {
Dimension dim;
DimType type = DimType.getByName(tag.getString("Type"));
int id = tag.getInteger("ID");
int id = tag.getInt("ID");
String name = tag.getString("Name");
switch(type) {
case STAR:
@ -848,7 +848,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
public final Dimension copy(int id, String name) {
NBTTagCompound tag = this.toNbt(true, false, true);
tag.setInteger("ID", id);
tag.setInt("ID", id);
tag.setString("Name", name);
return getByNbt(tag, false, true, false, true);
}
@ -866,7 +866,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
if(generator || partialGen) {
this.seed = tag.getLong("Seed");
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
this.seaLevel = tag.getInteger("SeaLevel");
this.seaLevel = tag.getInt("SeaLevel");
this.filler = BlockRegistry.getFromIdName(tag.getString("FillerBlock"), Blocks.stone.getState());
this.liquid = BlockRegistry.getFromIdName(tag.getString("LiquidBlock"), Blocks.water.getState());
}
@ -891,26 +891,26 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.noiseGen.biomeScaleOffset = tag.getFloat("BScaleOffset");
this.generatorType = GeneratorType.getByName(tag.getString("Generator"));
this.replacerType = ReplacerType.getByName(tag.getString("Replacer"));
this.mobs = tag.getBoolean("MobGen");
this.snow = tag.getBoolean("SnowGen");
this.ceiling = tag.getBoolean("Ceiling");
this.caves = tag.getBoolean("Caves");
this.ravines = tag.getBoolean("Ravines");
this.strideCaves = tag.getBoolean("AltCaves");
this.useStrongholds = tag.getBoolean("Strongholds");
this.useVillages = tag.getBoolean("Villages");
this.useMineshafts = tag.getBoolean("Mineshafts");
this.useScattered = tag.getBoolean("Scattered");
this.useFortresses = tag.getBoolean("Fortresses");
this.dungeons = tag.getInteger("Dungeons");
this.biomeSize = tag.getInteger("BiomeSize");
this.riverSize = tag.getInteger("RiverSize");
this.snowRarity = tag.getInteger("SnowRarity");
this.seaRarity = tag.getInteger("SeaRarity");
this.addRarity = tag.getInteger("AddRarity");
this.mobs = tag.getBool("MobGen");
this.snow = tag.getBool("SnowGen");
this.ceiling = tag.getBool("Ceiling");
this.caves = tag.getBool("Caves");
this.ravines = tag.getBool("Ravines");
this.strideCaves = tag.getBool("AltCaves");
this.useStrongholds = tag.getBool("Strongholds");
this.useVillages = tag.getBool("Villages");
this.useMineshafts = tag.getBool("Mineshafts");
this.useScattered = tag.getBool("Scattered");
this.useFortresses = tag.getBool("Fortresses");
this.dungeons = tag.getInt("Dungeons");
this.biomeSize = tag.getInt("BiomeSize");
this.riverSize = tag.getInt("RiverSize");
this.snowRarity = tag.getInt("SnowRarity");
this.seaRarity = tag.getInt("SeaRarity");
this.addRarity = tag.getInt("AddRarity");
// this.biomeRarity = tag.getInteger("BiomeRarity");
this.defaultBiome = Biome.findByName(tag.getString("DefaultBiome"));
this.semiFixed = tag.getBoolean("SemiFixed");
this.semiFixed = tag.getBool("SemiFixed");
this.defaultWeather = Weather.getByName(tag.getString("DefaultWeather"));
this.defaultWeather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather;
this.defaultLeaves = LeavesType.getByName(tag.getString("DefaultLeaves"));
@ -920,85 +920,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.hasKey("Layers", 9)) {
NBTTagList list = tag.getTagList("Layers", 8);
this.layers = new State[list.tagCount()];
if(tag.hasStringList("Layers")) {
NBTTagStringList list = tag.getStringList("Layers");
this.layers = new State[list.size()];
for(int z = 0; z < this.layers.length; z++) {
this.layers[z] = BlockRegistry.getFromIdName(list.getStringTagAt(z), Blocks.stone.getState());
this.layers[z] = BlockRegistry.getFromIdName(list.getString(z), Blocks.stone.getState());
}
}
else {
this.layers = null;
}
if(tag.hasKey("AddBiomes", 9)) {
NBTTagList list = tag.getTagList("AddBiomes", 8);
if(list.hasNoTags()) {
if(tag.hasStringList("AddBiomes")) {
NBTTagStringList list = tag.getStringList("AddBiomes");
if(list.isEmpty()) {
this.addBiomes = null;
}
else {
this.addBiomes = new Biome[list.tagCount()];
this.addBiomes = new Biome[list.size()];
for(int z = 0; z < this.addBiomes.length; z++) {
this.addBiomes[z] = Biome.findByName(list.getStringTagAt(z));
this.addBiomes[z] = Biome.findByName(list.getString(z));
}
}
}
else {
this.addBiomes = null;
}
if(tag.hasKey("FrostBiomes", 9)) {
NBTTagList list = tag.getTagList("FrostBiomes", 8);
if(list.hasNoTags()) {
if(tag.hasStringList("FrostBiomes")) {
NBTTagStringList list = tag.getStringList("FrostBiomes");
if(list.isEmpty()) {
this.frostBiomes = null;
}
else {
this.frostBiomes = new Biome[list.tagCount()];
this.frostBiomes = new Biome[list.size()];
for(int z = 0; z < this.frostBiomes.length; z++) {
this.frostBiomes[z] = Biome.findByName(list.getStringTagAt(z));
this.frostBiomes[z] = Biome.findByName(list.getString(z));
}
}
}
else {
this.frostBiomes = null;
}
if(tag.hasKey("ColdBiomes", 9)) {
NBTTagList list = tag.getTagList("ColdBiomes", 8);
if(list.hasNoTags()) {
if(tag.hasStringList("ColdBiomes")) {
NBTTagStringList list = tag.getStringList("ColdBiomes");
if(list.isEmpty()) {
this.coldBiomes = null;
}
else {
this.coldBiomes = new Biome[list.tagCount()];
this.coldBiomes = new Biome[list.size()];
for(int z = 0; z < this.coldBiomes.length; z++) {
this.coldBiomes[z] = Biome.findByName(list.getStringTagAt(z));
this.coldBiomes[z] = Biome.findByName(list.getString(z));
}
}
}
else {
this.coldBiomes = null;
}
if(tag.hasKey("MediumBiomes", 9)) {
NBTTagList list = tag.getTagList("MediumBiomes", 8);
if(list.hasNoTags()) {
if(tag.hasStringList("MediumBiomes")) {
NBTTagStringList list = tag.getStringList("MediumBiomes");
if(list.isEmpty()) {
this.mediumBiomes = null;
}
else {
this.mediumBiomes = new Biome[list.tagCount()];
this.mediumBiomes = new Biome[list.size()];
for(int z = 0; z < this.mediumBiomes.length; z++) {
this.mediumBiomes[z] = Biome.findByName(list.getStringTagAt(z));
this.mediumBiomes[z] = Biome.findByName(list.getString(z));
}
}
}
else {
this.mediumBiomes = null;
}
if(tag.hasKey("HotBiomes", 9)) {
NBTTagList list = tag.getTagList("HotBiomes", 8);
if(list.hasNoTags()) {
if(tag.hasStringList("HotBiomes")) {
NBTTagStringList list = tag.getStringList("HotBiomes");
if(list.isEmpty()) {
this.hotBiomes = null;
}
else {
this.hotBiomes = new Biome[list.tagCount()];
this.hotBiomes = new Biome[list.size()];
for(int z = 0; z < this.hotBiomes.length; z++) {
this.hotBiomes[z] = Biome.findByName(list.getStringTagAt(z));
this.hotBiomes[z] = Biome.findByName(list.getString(z));
}
}
}
@ -1006,38 +1006,38 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.hotBiomes = null;
}
this.ores.clear();
if(tag.hasKey("Ores", 9)) {
NBTTagList list = tag.getTagList("Ores", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound gen = list.getCompoundTagAt(z);
if(tag.hasTagList("Ores")) {
NBTTagTagList list = tag.getTagList("Ores");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound gen = list.getTag(z);
this.ores.add(new Ore(BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
gen.getInteger("Count"), gen.getInteger("Add"), gen.getInteger("Size"),
gen.getInteger("MinC"), gen.getInteger("MaxS"), gen.getBoolean("Distrib")));
gen.getInt("Count"), gen.getInt("Add"), gen.getInt("Size"),
gen.getInt("MinC"), gen.getInt("MaxS"), gen.getBool("Distrib")));
}
}
this.lakes.clear();
if(tag.hasKey("Lakes", 9)) {
NBTTagList list = tag.getTagList("Lakes", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound gen = list.getCompoundTagAt(z);
if(tag.hasTagList("Lakes")) {
NBTTagTagList list = tag.getTagList("Lakes");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound gen = list.getTag(z);
this.lakes.add(new Lake(
BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
gen.hasKey("Filler", 8) ? BlockRegistry.getFromIdName(gen.getString("Filler"), null) : null,
gen.hasKey("Top", 8) ? BlockRegistry.getFromIdName(gen.getString("Top"), null) : null,
gen.getInteger("Chance"), gen.getInteger("Min"), gen.getInteger("Max"), gen.getBoolean("Ratiod")));
gen.hasString("Filler") ? BlockRegistry.getFromIdName(gen.getString("Filler"), null) : null,
gen.hasString("Top") ? BlockRegistry.getFromIdName(gen.getString("Top"), null) : null,
gen.getInt("Chance"), gen.getInt("Min"), gen.getInt("Max"), gen.getBool("Ratiod")));
}
}
this.liquids.clear();
if(tag.hasKey("Liquids", 9)) {
NBTTagList list = tag.getTagList("Liquids", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound gen = list.getCompoundTagAt(z);
if(tag.hasTagList("Liquids")) {
NBTTagTagList list = tag.getTagList("Liquids");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound gen = list.getTag(z);
this.liquids.add(new Liquid(
BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
gen.getInteger("Chance"), gen.getInteger("Min"), gen.getInteger("Max"), gen.getBoolean("Lower")));
gen.getInt("Chance"), gen.getInt("Min"), gen.getInt("Max"), gen.getBool("Lower")));
}
}
this.populated = !tag.hasKey("NoPopulation", 1) || !tag.getBoolean("NoPopulation");
this.populated = !tag.hasBool("NoPopulation") || !tag.getBool("NoPopulation");
}
}
else {
@ -1045,14 +1045,14 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.readNbt(tag);
}
// this.readNbt(tag);
// this.customName = tag.hasKey("CustomName", 8) ? tag.getString("CustomName") : null;
// this.customName = tag.hasString("CustomName") ? tag.getString("CustomName") : null;
if(all || !generator || this.id >= UniverseRegistry.MORE_DIM_ID) {
this.denseFog = tag.getBoolean("DenseFog");
this.timeQualifier = tag.getInteger("ImperialTime");
this.brightness = tag.getInteger("Brightness");
this.skyColor = tag.getInteger("SkyColor");
this.fogColor = tag.getInteger("FogColor");
this.cloudColor = tag.getInteger("CloudColor");
this.denseFog = tag.getBool("DenseFog");
this.timeQualifier = tag.getInt("ImperialTime");
this.brightness = tag.getInt("Brightness");
this.skyColor = tag.getInt("SkyColor");
this.fogColor = tag.getInt("FogColor");
this.cloudColor = tag.getInt("CloudColor");
this.gravity = tag.getFloat("Gravity");
this.temperature = tag.getFloat("Temperature");
this.orbitOffset = tag.getFloat("OrbitOffset");
@ -1062,26 +1062,26 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.orbitalPeriod = tag.getLong("OrbitalPeriod");
this.rotationPeriod = tag.getLong("RotationPeriod");
this.cloudTexture = CloudType.getByName(tag.getString("CloudTexture"));
this.skyboxTexture = tag.hasKey("SkyBoxTexture", 8) ?
this.skyboxTexture = tag.hasString("SkyBoxTexture") ?
SkyboxType.getByName(tag.getString("SkyBoxTexture")) : null;
if(tag.hasKey("StarColor", 3)) {
this.setStarColor(tag.getInteger("StarColor"));
if(tag.hasInt("StarColor")) {
this.setStarColor(tag.getInt("StarColor"));
}
else if(tag.hasKey("StarColorFnc", 10)) {
NBTTagCompound fnc = tag.getCompoundTag("StarColorFnc");
else if(tag.hasTag("StarColorFnc")) {
NBTTagCompound fnc = tag.getTag("StarColorFnc");
this.setStarColorSin(fnc.getFloat("Period"), fnc.getFloat("Det"), fnc.getFloat("Dist"),
fnc.getInteger("Color"), fnc.getByte("DetChn"), fnc.getByte("DistChn"));
fnc.getInt("Color"), fnc.getByte("DetChn"), fnc.getByte("DistChn"));
}
else {
this.starColorFunc = null;
}
if(tag.hasKey("DStarColor", 3)) {
this.setDeepStarColor(tag.getInteger("DStarColor"));
if(tag.hasInt("DStarColor")) {
this.setDeepStarColor(tag.getInt("DStarColor"));
}
else if(tag.hasKey("DStarColorFnc", 10)) {
NBTTagCompound fnc = tag.getCompoundTag("DStarColorFnc");
else if(tag.hasTag("DStarColorFnc")) {
NBTTagCompound fnc = tag.getTag("DStarColorFnc");
this.setDeepStarColorSin(fnc.getFloat("Period"), fnc.getFloat("Det"), fnc.getFloat("Dist"),
fnc.getInteger("Color"), fnc.getByte("DetChn"), fnc.getByte("DistChn"));
fnc.getInt("Color"), fnc.getByte("DetChn"), fnc.getByte("DistChn"));
}
else {
this.deepstarColorFunc = null;
@ -1103,7 +1103,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
if(generator || partialGen) {
tag.setLong("Seed", this.seed);
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
tag.setInteger("SeaLevel", this.seaLevel);
tag.setInt("SeaLevel", this.seaLevel);
tag.setString("FillerBlock", BlockRegistry.toIdName(this.filler));
tag.setString("LiquidBlock", BlockRegistry.toIdName(this.liquid));
}
@ -1128,28 +1128,28 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
tag.setFloat("BScaleOffset", this.noiseGen.biomeScaleOffset);
tag.setString("Generator", this.generatorType.getName());
tag.setString("Replacer", this.replacerType.getName());
tag.setBoolean("MobGen", this.mobs);
tag.setBoolean("SnowGen", this.snow);
tag.setBoolean("Ceiling", this.ceiling);
tag.setBoolean("Caves", this.caves);
tag.setBoolean("Ravines", this.ravines);
tag.setBoolean("AltCaves", this.strideCaves);
tag.setBoolean("Strongholds", this.useStrongholds);
tag.setBoolean("Villages", this.useVillages);
tag.setBoolean("Mineshafts", this.useMineshafts);
tag.setBoolean("Scattered", this.useScattered);
tag.setBoolean("Fortresses", this.useFortresses);
tag.setInteger("Dungeons", this.dungeons);
tag.setInteger("BiomeSize", this.biomeSize);
tag.setInteger("RiverSize", this.riverSize);
tag.setInteger("SnowRarity", this.snowRarity);
tag.setInteger("SeaRarity", this.seaRarity);
tag.setInteger("AddRarity", this.addRarity);
tag.setBool("MobGen", this.mobs);
tag.setBool("SnowGen", this.snow);
tag.setBool("Ceiling", this.ceiling);
tag.setBool("Caves", this.caves);
tag.setBool("Ravines", this.ravines);
tag.setBool("AltCaves", this.strideCaves);
tag.setBool("Strongholds", this.useStrongholds);
tag.setBool("Villages", this.useVillages);
tag.setBool("Mineshafts", this.useMineshafts);
tag.setBool("Scattered", this.useScattered);
tag.setBool("Fortresses", this.useFortresses);
tag.setInt("Dungeons", this.dungeons);
tag.setInt("BiomeSize", this.biomeSize);
tag.setInt("RiverSize", this.riverSize);
tag.setInt("SnowRarity", this.snowRarity);
tag.setInt("SeaRarity", this.seaRarity);
tag.setInt("AddRarity", this.addRarity);
// tag.setInteger("BiomeRarity", this.biomeRarity);
// if(this.defaultBiome != null)
tag.setString("DefaultBiome", this.defaultBiome.name.toLowerCase());
// if(this.mainBiome != null)
tag.setBoolean("SemiFixed", this.semiFixed);
tag.setBool("SemiFixed", this.semiFixed);
tag.setString("DefaultWeather", this.defaultWeather.getName());
tag.setString("DefaultLeaves", this.defaultLeaves.getName());
tag.setString("TopBlock", BlockRegistry.toIdName(this.top));
@ -1158,64 +1158,64 @@ 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) {
NBTTagList list = new NBTTagList();
NBTTagStringList list = new NBTTagStringList();
for(State gen : this.layers) {
list.appendTag(new NBTTagString(BlockRegistry.toIdName(gen)));
list.add(BlockRegistry.toIdName(gen));
}
tag.setTag("Layers", list);
tag.setStringList("Layers", list);
}
if(this.addBiomes != null) {
NBTTagList list = new NBTTagList();
NBTTagStringList list = new NBTTagStringList();
for(Biome biome : this.addBiomes) {
list.appendTag(new NBTTagString(biome.name.toLowerCase()));
list.add(biome.name.toLowerCase());
}
tag.setTag("AddBiomes", list);
tag.setStringList("AddBiomes", list);
}
if(this.frostBiomes != null) {
NBTTagList list = new NBTTagList();
NBTTagStringList list = new NBTTagStringList();
for(Biome biome : this.frostBiomes) {
list.appendTag(new NBTTagString(biome.name.toLowerCase()));
list.add(biome.name.toLowerCase());
}
tag.setTag("FrostBiomes", list);
tag.setStringList("FrostBiomes", list);
}
if(this.coldBiomes != null) {
NBTTagList list = new NBTTagList();
NBTTagStringList list = new NBTTagStringList();
for(Biome biome : this.coldBiomes) {
list.appendTag(new NBTTagString(biome.name.toLowerCase()));
list.add(biome.name.toLowerCase());
}
tag.setTag("ColdBiomes", list);
tag.setStringList("ColdBiomes", list);
}
if(this.mediumBiomes != null) {
NBTTagList list = new NBTTagList();
NBTTagStringList list = new NBTTagStringList();
for(Biome biome : this.mediumBiomes) {
list.appendTag(new NBTTagString(biome.name.toLowerCase()));
list.add(biome.name.toLowerCase());
}
tag.setTag("MediumBiomes", list);
tag.setStringList("MediumBiomes", list);
}
if(this.hotBiomes != null) {
NBTTagList list = new NBTTagList();
NBTTagStringList list = new NBTTagStringList();
for(Biome biome : this.hotBiomes) {
list.appendTag(new NBTTagString(biome.name.toLowerCase()));
list.add(biome.name.toLowerCase());
}
tag.setTag("HotBiomes", list);
tag.setStringList("HotBiomes", list);
}
if(!this.ores.isEmpty()) {
NBTTagList list = new NBTTagList();
NBTTagTagList list = new NBTTagTagList();
for(Ore gen : this.ores) {
NBTTagCompound ore = new NBTTagCompound();
ore.setString("Block", BlockRegistry.toIdName(gen.state));
ore.setBoolean("Distrib", gen.dist);
ore.setInteger("Size", gen.size);
ore.setInteger("Count", gen.count);
ore.setInteger("Add", gen.more);
ore.setInteger("MinC", gen.min);
ore.setInteger("MaxS", gen.max);
list.appendTag(ore);
ore.setBool("Distrib", gen.dist);
ore.setInt("Size", gen.size);
ore.setInt("Count", gen.count);
ore.setInt("Add", gen.more);
ore.setInt("MinC", gen.min);
ore.setInt("MaxS", gen.max);
list.add(ore);
}
tag.setTag("Ores", list);
tag.setTagList("Ores", list);
}
if(!this.lakes.isEmpty()) {
NBTTagList list = new NBTTagList();
NBTTagTagList list = new NBTTagTagList();
for(Lake gen : this.lakes) {
NBTTagCompound lake = new NBTTagCompound();
lake.setString("Block", BlockRegistry.toIdName(gen.state));
@ -1223,29 +1223,29 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
lake.setString("Filler", BlockRegistry.toIdName(gen.filler));
if(gen.top != null)
lake.setString("Top", BlockRegistry.toIdName(gen.top));
lake.setBoolean("Ratiod", gen.ratiod);
lake.setInteger("Chance", gen.chance);
lake.setInteger("Min", gen.minHeight);
lake.setInteger("Max", gen.maxHeight);
list.appendTag(lake);
lake.setBool("Ratiod", gen.ratiod);
lake.setInt("Chance", gen.chance);
lake.setInt("Min", gen.minHeight);
lake.setInt("Max", gen.maxHeight);
list.add(lake);
}
tag.setTag("Lakes", list);
tag.setTagList("Lakes", list);
}
if(!this.liquids.isEmpty()) {
NBTTagList list = new NBTTagList();
NBTTagTagList list = new NBTTagTagList();
for(Liquid gen : this.liquids) {
NBTTagCompound liquid = new NBTTagCompound();
liquid.setString("Block", BlockRegistry.toIdName(gen.state));
liquid.setBoolean("Lower", gen.lower);
liquid.setInteger("Chance", gen.chance);
liquid.setInteger("Min", gen.minHeight);
liquid.setInteger("Max", gen.maxHeight);
list.appendTag(liquid);
liquid.setBool("Lower", gen.lower);
liquid.setInt("Chance", gen.chance);
liquid.setInt("Min", gen.minHeight);
liquid.setInt("Max", gen.maxHeight);
list.add(liquid);
}
tag.setTag("Liquids", list);
tag.setTagList("Liquids", list);
}
if(!this.populated)
tag.setBoolean("NoPopulation", true);
tag.setBool("NoPopulation", true);
}
}
else {
@ -1256,12 +1256,12 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
// if(this.customName != null)
// tag.setString("CustomName", this.customName);
if(all || !generator || this.id >= UniverseRegistry.MORE_DIM_ID) {
tag.setBoolean("DenseFog", this.denseFog);
tag.setInteger("ImperialTime", this.timeQualifier);
tag.setInteger("Brightness", this.brightness);
tag.setInteger("SkyColor", this.skyColor);
tag.setInteger("FogColor", this.fogColor);
tag.setInteger("CloudColor", this.cloudColor);
tag.setBool("DenseFog", this.denseFog);
tag.setInt("ImperialTime", this.timeQualifier);
tag.setInt("Brightness", this.brightness);
tag.setInt("SkyColor", this.skyColor);
tag.setInt("FogColor", this.fogColor);
tag.setInt("CloudColor", this.cloudColor);
tag.setFloat("Gravity", this.gravity);
tag.setFloat("Temperature", this.temperature);
tag.setFloat("OrbitOffset", this.orbitOffset);
@ -1274,27 +1274,27 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
if(this.skyboxTexture != null)
tag.setString("SkyBoxTexture", this.skyboxTexture.toString());
if(this.starColorFunc instanceof SingleColorGen) {
tag.setInteger("StarColor", ((SingleColorGen)this.starColorFunc).color);
tag.setInt("StarColor", ((SingleColorGen)this.starColorFunc).color);
}
else if(this.starColorFunc instanceof SinusColorGen) {
NBTTagCompound fnc = new NBTTagCompound();
fnc.setFloat("Period", ((SinusColorGen)this.starColorFunc).period);
fnc.setFloat("Det", ((SinusColorGen)this.starColorFunc).det);
fnc.setFloat("Dist", ((SinusColorGen)this.starColorFunc).dist);
fnc.setInteger("Color", ((SinusColorGen)this.starColorFunc).color);
fnc.setInt("Color", ((SinusColorGen)this.starColorFunc).color);
fnc.setByte("DetChn", (byte)((SinusColorGen)this.starColorFunc).detChn);
fnc.setByte("DistChn", (byte)((SinusColorGen)this.starColorFunc).distChn);
tag.setTag("StarColorFnc", fnc);
}
if(this.deepstarColorFunc instanceof SingleColorGen) {
tag.setInteger("DStarColor", ((SingleColorGen)this.deepstarColorFunc).color);
tag.setInt("DStarColor", ((SingleColorGen)this.deepstarColorFunc).color);
}
else if(this.deepstarColorFunc instanceof SinusColorGen) {
NBTTagCompound fnc = new NBTTagCompound();
fnc.setFloat("Period", ((SinusColorGen)this.deepstarColorFunc).period);
fnc.setFloat("Det", ((SinusColorGen)this.deepstarColorFunc).det);
fnc.setFloat("Dist", ((SinusColorGen)this.deepstarColorFunc).dist);
fnc.setInteger("Color", ((SinusColorGen)this.deepstarColorFunc).color);
fnc.setInt("Color", ((SinusColorGen)this.deepstarColorFunc).color);
fnc.setByte("DetChn", (byte)((SinusColorGen)this.deepstarColorFunc).detChn);
fnc.setByte("DistChn", (byte)((SinusColorGen)this.deepstarColorFunc).distChn);
tag.setTag("DStarColorFnc", fnc);
@ -1305,7 +1305,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
public final NBTTagCompound toNbt() {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("ID", this.id);
tag.setInt("ID", this.id);
tag.setString("Name", this.name);
tag.setString("Type", this.getType().getName());
return tag;

View file

@ -14,7 +14,7 @@ public abstract class Nameable {
}
public void readNbt(NBTTagCompound tag) {
this.customName = tag.hasKey("CustomName", 8) ? tag.getString("CustomName") : null;
this.customName = tag.hasString("CustomName") ? tag.getString("CustomName") : null;
}
public void writeNbt(NBTTagCompound tag) {

View file

@ -13,7 +13,7 @@ import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.rng.Random;
import common.rng.WeightedList;
@ -45,7 +45,7 @@ public class EnchantmentHelper
}
else
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
NBTTagTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist == null)
{
@ -53,10 +53,10 @@ public class EnchantmentHelper
}
else
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
int j = nbttaglist.getTag(i).getShort("id");
int k = nbttaglist.getTag(i).getShort("lvl");
if (j == enchID)
{
@ -72,14 +72,14 @@ public class EnchantmentHelper
public static Map<Integer, Integer> getEnchantments(ItemStack stack)
{
Map<Integer, Integer> map = Maps.<Integer, Integer>newLinkedHashMap();
NBTTagList nbttaglist = stack.getItem() == Items.enchanted_book ? Items.enchanted_book.getEnchantments(stack) : stack.getEnchantmentTagList();
NBTTagTagList nbttaglist = stack.getItem() == Items.enchanted_book ? Items.enchanted_book.getEnchantments(stack) : stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
int j = nbttaglist.getTag(i).getShort("id");
int k = nbttaglist.getTag(i).getShort("lvl");
map.put(j, k);
}
}
@ -92,7 +92,7 @@ public class EnchantmentHelper
*/
public static void setEnchantments(Map<Integer, Integer> enchMap, ItemStack stack)
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
Iterator iterator = enchMap.keySet().iterator();
while (iterator.hasNext())
@ -105,7 +105,7 @@ public class EnchantmentHelper
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setShort("id", (short)i);
nbttagcompound.setShort("lvl", (short)enchMap.get(i).intValue());
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
if (stack.getItem() == Items.enchanted_book)
{
@ -114,7 +114,7 @@ public class EnchantmentHelper
}
}
if (nbttaglist.tagCount() > 0)
if (nbttaglist.size() > 0)
{
if (stack.getItem() != Items.enchanted_book)
{
@ -123,7 +123,7 @@ public class EnchantmentHelper
}
else if (stack.hasTagCompound())
{
stack.getTagCompound().removeTag("ench");
stack.getTagCompound().remove("ench");
}
}
@ -161,14 +161,14 @@ public class EnchantmentHelper
{
if (stack != null)
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
NBTTagTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
int j = nbttaglist.getTag(i).getShort("id");
int k = nbttaglist.getTag(i).getShort("lvl");
if (Enchantment.getEnchantmentById(j) != null)
{

View file

@ -28,9 +28,8 @@ import common.item.Item;
import common.item.ItemStack;
import common.model.ParticleType;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagDouble;
import common.nbt.NBTTagFloat;
import common.nbt.NBTTagList;
import common.nbt.NBTTagDoubleList;
import common.nbt.NBTTagFloatList;
import common.rng.Random;
import common.util.BlockPos;
import common.util.BoundingBox;
@ -1498,13 +1497,13 @@ public abstract class Entity
// tagCompund.setString("ObjectTag", this.tag);
// }
tagCompund.setTag("Pos", this.newDoubleNBTList(this.posX, this.posY, this.posZ));
tagCompund.setTag("Motion", this.newDoubleNBTList(this.motionX, this.motionY, this.motionZ));
tagCompund.setTag("Rotation", this.newFloatNBTList(this.rotYaw, this.rotPitch));
tagCompund.setDoubleList("Pos", this.newDoubleNBTList(this.posX, this.posY, this.posZ));
tagCompund.setDoubleList("Motion", this.newDoubleNBTList(this.motionX, this.motionY, this.motionZ));
tagCompund.setFloatList("Rotation", this.newFloatNBTList(this.rotYaw, this.rotPitch));
tagCompund.setFloat("FallDistance", this.fallDistance);
tagCompund.setShort("Fire", (short)this.fire);
// tagCompund.setShort("Air", (short)this.getAir());
tagCompund.setBoolean("OnGround", this.onGround);
tagCompund.setBool("OnGround", this.onGround);
// tagCompund.setBoolean("Invulnerable", this.invulnerable);
// tagCompund.setInteger("PortalCooldown", this.portalTimer);
@ -1520,7 +1519,7 @@ public abstract class Entity
// }
if(this.ignoreFall)
tagCompund.setBoolean("IgnoreFall", this.ignoreFall);
tagCompund.setBool("IgnoreFall", this.ignoreFall);
this.writeEntityToNBT(tagCompund);
@ -1540,16 +1539,16 @@ public abstract class Entity
*/
public void readFromNBT(NBTTagCompound tagCompund)
{
// if(tagCompund.hasKey("PersistID", 4))
// if(tagCompund.hasLong("PersistID"))
// this.setPersistentId(tagCompund.getLong("PersistID"));
// this.setTag(tagCompund.getString("ObjectTag"));
NBTTagList nbttaglist = tagCompund.getTagList("Pos", 6);
NBTTagList nbttaglist1 = tagCompund.getTagList("Motion", 6);
NBTTagList nbttaglist2 = tagCompund.getTagList("Rotation", 5);
this.motionX = nbttaglist1.getDoubleAt(0);
this.motionY = nbttaglist1.getDoubleAt(1);
this.motionZ = nbttaglist1.getDoubleAt(2);
NBTTagDoubleList nbttaglist = tagCompund.getDoubleList("Pos");
NBTTagDoubleList nbttaglist1 = tagCompund.getDoubleList("Motion");
NBTTagFloatList nbttaglist2 = tagCompund.getFloatList("Rotation");
this.motionX = nbttaglist1.getDouble(0);
this.motionY = nbttaglist1.getDouble(1);
this.motionZ = nbttaglist1.getDouble(2);
if (Math.abs(this.motionX) > 10.0D)
{
@ -1566,31 +1565,31 @@ public abstract class Entity
this.motionZ = 0.0D;
}
this.prevX = this.lastTickPosX = this.posX = nbttaglist.getDoubleAt(0);
this.prevY = this.lastTickPosY = this.posY = nbttaglist.getDoubleAt(1);
this.prevZ = this.lastTickPosZ = this.posZ = nbttaglist.getDoubleAt(2);
this.prevYaw = this.rotYaw = nbttaglist2.getFloatAt(0);
this.prevPitch = this.rotPitch = nbttaglist2.getFloatAt(1);
this.prevX = this.lastTickPosX = this.posX = nbttaglist.getDouble(0);
this.prevY = this.lastTickPosY = this.posY = nbttaglist.getDouble(1);
this.prevZ = this.lastTickPosZ = this.posZ = nbttaglist.getDouble(2);
this.prevYaw = this.rotYaw = nbttaglist2.getFloat(0);
this.prevPitch = this.rotPitch = nbttaglist2.getFloat(1);
this.setRotationYawHead(this.rotYaw);
this.setRenderYawOffset(this.rotYaw);
this.fallDistance = tagCompund.getFloat("FallDistance");
this.fire = tagCompund.getShort("Fire");
// this.setAir(tagCompund.getShort("Air"));
this.onGround = tagCompund.getBoolean("OnGround");
this.onGround = tagCompund.getBool("OnGround");
// this.invulnerable = tagCompund.getBoolean("Invulnerable");
// this.portalTimer = tagCompund.getInteger("PortalCooldown");
this.setPosition(this.posX, this.posY, this.posZ);
this.setRotation(this.rotYaw, this.rotPitch);
if (tagCompund.hasKey("CustomName", 8) && tagCompund.getString("CustomName").length() > 0)
if (tagCompund.hasString("CustomName") && tagCompund.getString("CustomName").length() > 0)
{
this.setCustomNameTag(tagCompund.getString("CustomName"));
}
// this.setAlwaysRenderNameTag(tagCompund.getBoolean("CustomNameVisible"));
// this.setSilent(tagCompund.getBoolean("Silent"));
this.ignoreFall = tagCompund.getBoolean("IgnoreFall");
this.ignoreFall = tagCompund.getBool("IgnoreFall");
this.readEntityFromNBT(tagCompund);
if (this.shouldSetPosAfterLoading())
@ -1629,13 +1628,13 @@ public abstract class Entity
/**
* creates a NBT list from the array of doubles passed to this function
*/
protected NBTTagList newDoubleNBTList(double... numbers)
protected NBTTagDoubleList newDoubleNBTList(double... numbers)
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagDoubleList nbttaglist = new NBTTagDoubleList();
for (double d0 : numbers)
{
nbttaglist.appendTag(new NBTTagDouble(d0));
nbttaglist.add(d0);
}
return nbttaglist;
@ -1644,13 +1643,13 @@ public abstract class Entity
/**
* Returns a new NBTTagList filled with the specified floats
*/
protected NBTTagList newFloatNBTList(float... numbers)
protected NBTTagFloatList newFloatNBTList(float... numbers)
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagFloatList nbttaglist = new NBTTagFloatList();
for (float f : numbers)
{
nbttaglist.appendTag(new NBTTagFloat(f));
nbttaglist.add(f);
}
return nbttaglist;

View file

@ -178,12 +178,8 @@ public class EntityChicken extends EntityAnimal
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.chickenJockey = tagCompund.getBoolean("IsChickenJockey");
if (tagCompund.hasKey("EggLayTime"))
{
this.timeUntilNextEgg = tagCompund.getInteger("EggLayTime");
}
this.chickenJockey = tagCompund.getBool("IsChickenJockey");
this.timeUntilNextEgg = tagCompund.getInt("EggLayTime");
}
/**
@ -200,8 +196,8 @@ public class EntityChicken extends EntityAnimal
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setBoolean("IsChickenJockey", this.chickenJockey);
tagCompound.setInteger("EggLayTime", this.timeUntilNextEgg);
tagCompound.setBool("IsChickenJockey", this.chickenJockey);
tagCompound.setInt("EggLayTime", this.timeUntilNextEgg);
}
// /**

View file

@ -32,7 +32,7 @@ import common.item.ItemMonsterPlacer;
import common.item.ItemStack;
import common.model.ParticleType;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.pathfinding.PathNavigateGround;
import common.potion.Potion;
import common.util.BlockPos;
@ -1390,19 +1390,19 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setBoolean("EatingHaystack", this.isEatingHaystack());
tagCompound.setBoolean("ChestedHorse", this.isChested());
tagCompound.setBoolean("HasReproduced", this.getHasReproduced());
tagCompound.setBoolean("Bred", this.isBreeding());
tagCompound.setInteger("Type", this.getHorseType());
tagCompound.setInteger("Variant", this.getHorseVariant());
tagCompound.setInteger("Temper", this.getTemper());
tagCompound.setBoolean("Tame", this.isTame());
tagCompound.setBool("EatingHaystack", this.isEatingHaystack());
tagCompound.setBool("ChestedHorse", this.isChested());
tagCompound.setBool("HasReproduced", this.getHasReproduced());
tagCompound.setBool("Bred", this.isBreeding());
tagCompound.setInt("Type", this.getHorseType());
tagCompound.setInt("Variant", this.getHorseVariant());
tagCompound.setInt("Temper", this.getTemper());
tagCompound.setBool("Tame", this.isTame());
// tagCompound.setString("Owner", this.getOwnerId());
if (this.isChested())
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 2; i < this.horseChest.getSizeInventory(); ++i)
{
@ -1413,11 +1413,11 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
tagCompound.setTag("Items", nbttaglist);
tagCompound.setTagList("Items", nbttaglist);
}
if (this.horseChest.getStackInSlot(1) != null)
@ -1437,17 +1437,17 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setEatingHaystack(tagCompund.getBoolean("EatingHaystack"));
this.setBreeding(tagCompund.getBoolean("Bred"));
this.setChested(tagCompund.getBoolean("ChestedHorse"));
this.setHasReproduced(tagCompund.getBoolean("HasReproduced"));
this.setHorseType(tagCompund.getInteger("Type"));
this.setHorseVariant(tagCompund.getInteger("Variant"));
this.setTemper(tagCompund.getInteger("Temper"));
this.setHorseTamed(tagCompund.getBoolean("Tame"));
this.setEatingHaystack(tagCompund.getBool("EatingHaystack"));
this.setBreeding(tagCompund.getBool("Bred"));
this.setChested(tagCompund.getBool("ChestedHorse"));
this.setHasReproduced(tagCompund.getBool("HasReproduced"));
this.setHorseType(tagCompund.getInt("Type"));
this.setHorseVariant(tagCompund.getInt("Variant"));
this.setTemper(tagCompund.getInt("Temper"));
this.setHorseTamed(tagCompund.getBool("Tame"));
// String s = "";
//
// if (tagCompund.hasKey("Owner", 8))
// if (tagCompund.hasString("Owner"))
// {
// s = tagCompund.getString("Owner");
// }
@ -1466,12 +1466,12 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (this.isChested())
{
NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
NBTTagTagList nbttaglist = tagCompund.getTagList("Items");
this.initHorseChest();
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 2 && j < this.horseChest.getSizeInventory())
@ -1481,9 +1481,9 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
}
}
if (tagCompund.hasKey("ArmorItem", 10))
if (tagCompund.hasTag("ArmorItem"))
{
ItemStack itemstack = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("ArmorItem"));
ItemStack itemstack = ItemStack.loadItemStackFromNBT(tagCompund.getTag("ArmorItem"));
if (itemstack != null && isArmorItem(itemstack.getItem()))
{
@ -1491,16 +1491,16 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
}
}
if (tagCompund.hasKey("SaddleItem", 10))
if (tagCompund.hasTag("SaddleItem"))
{
ItemStack itemstack1 = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("SaddleItem"));
ItemStack itemstack1 = ItemStack.loadItemStackFromNBT(tagCompund.getTag("SaddleItem"));
if (itemstack1 != null && itemstack1.getItem() == Items.saddle)
{
this.horseChest.setInventorySlotContents(0, itemstack1);
}
}
else if (tagCompund.getBoolean("Saddle"))
else if (tagCompund.getBool("Saddle"))
{
this.horseChest.setInventorySlotContents(0, new ItemStack(Items.saddle));
}

View file

@ -126,7 +126,7 @@ public class EntityOcelot extends EntityTameable
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("CatType", this.getTameSkin());
tagCompound.setInt("CatType", this.getTameSkin());
}
/**
@ -135,7 +135,7 @@ public class EntityOcelot extends EntityTameable
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setTameSkin(tagCompund.getInteger("CatType"));
this.setTameSkin(tagCompund.getInt("CatType"));
}
/**

View file

@ -72,7 +72,7 @@ public class EntityPig extends EntityAnimal
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setBoolean("Saddle", this.getSaddled());
tagCompound.setBool("Saddle", this.getSaddled());
}
/**
@ -81,7 +81,7 @@ public class EntityPig extends EntityAnimal
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setSaddled(tagCompund.getBoolean("Saddle"));
this.setSaddled(tagCompund.getBool("Saddle"));
}
/**

View file

@ -200,14 +200,14 @@ public class EntityRabbit extends EntityAnimal {
public void writeEntityToNBT(NBTTagCompound tagCompound) {
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("RabbitType", this.getRabbitType());
tagCompound.setInteger("MoreCarrotTicks", this.foodCooldown);
tagCompound.setInt("RabbitType", this.getRabbitType());
tagCompound.setInt("MoreCarrotTicks", this.foodCooldown);
}
public void readEntityFromNBT(NBTTagCompound tagCompund) {
super.readEntityFromNBT(tagCompund);
this.setRabbitType(tagCompund.getInteger("RabbitType"));
this.foodCooldown = tagCompund.getInteger("MoreCarrotTicks");
this.setRabbitType(tagCompund.getInt("RabbitType"));
this.foodCooldown = tagCompund.getInt("MoreCarrotTicks");
}
// protected String getJumpingSound() {

View file

@ -213,7 +213,7 @@ public class EntitySheep extends EntityAnimal
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setBoolean("Sheared", this.getSheared());
tagCompound.setBool("Sheared", this.getSheared());
tagCompound.setByte("Color", (byte)this.getFleeceColor().getMetadata());
}
@ -223,7 +223,7 @@ public class EntitySheep extends EntityAnimal
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setSheared(tagCompund.getBoolean("Sheared"));
this.setSheared(tagCompund.getBool("Sheared"));
this.setFleeceColor(DyeColor.byMetadata(tagCompund.getByte("Color")));
}

View file

@ -142,7 +142,7 @@ public class EntityWolf extends EntityTameable
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setBoolean("Angry", this.isAngry());
tagCompound.setBool("Angry", this.isAngry());
tagCompound.setByte("CollarColor", (byte)this.getCollarColor().getDyeDamage());
}
@ -152,9 +152,9 @@ public class EntityWolf extends EntityTameable
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setAngry(tagCompund.getBoolean("Angry"));
this.setAngry(tagCompund.getBool("Angry"));
if (tagCompund.hasKey("CollarColor", 99))
if (tagCompund.hasByte("CollarColor"))
{
this.setCollarColor(DyeColor.byDyeDamage(tagCompund.getByte("CollarColor")));
}

View file

@ -755,11 +755,11 @@ public abstract class EntityCart extends Entity implements IWorldNameable
*/
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
if (tagCompund.getBoolean("CustomDisplayTile"))
if (tagCompund.getBool("CustomDisplayTile"))
{
int i = tagCompund.getInteger("DisplayData");
int i = tagCompund.getInt("DisplayData");
if (tagCompund.hasKey("DisplayTile", 8))
if (tagCompund.hasString("DisplayTile"))
{
Block block = BlockRegistry.getByIdFallback(tagCompund.getString("DisplayTile"));
@ -774,7 +774,7 @@ public abstract class EntityCart extends Entity implements IWorldNameable
}
else
{
Block block1 = BlockRegistry.getBlockById(tagCompund.getInteger("DisplayTile"));
Block block1 = BlockRegistry.getBlockById(tagCompund.getInt("DisplayTile"));
if (block1 == null)
{
@ -786,10 +786,10 @@ public abstract class EntityCart extends Entity implements IWorldNameable
}
}
this.setDisplayTileOffset(tagCompund.getInteger("DisplayOffset"));
this.setDisplayTileOffset(tagCompund.getInt("DisplayOffset"));
}
if (tagCompund.hasKey("CustomName", 8) && tagCompund.getString("CustomName").length() > 0)
if (tagCompund.hasString("CustomName") && tagCompund.getString("CustomName").length() > 0)
{
this.entityName = tagCompund.getString("CustomName");
}
@ -802,12 +802,12 @@ public abstract class EntityCart extends Entity implements IWorldNameable
{
if (this.hasDisplayTile())
{
tagCompound.setBoolean("CustomDisplayTile", true);
tagCompound.setBool("CustomDisplayTile", true);
State iblockstate = this.getDisplayTile();
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(iblockstate.getBlock());
tagCompound.setString("DisplayTile", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setInteger("DisplayData", iblockstate.getBlock().getMetaFromState(iblockstate));
tagCompound.setInteger("DisplayOffset", this.getDisplayTileOffset());
tagCompound.setInt("DisplayData", iblockstate.getBlock().getMetaFromState(iblockstate));
tagCompound.setInt("DisplayOffset", this.getDisplayTileOffset());
}
if (this.entityName != null && this.entityName.length() > 0)

View file

@ -8,7 +8,7 @@ import common.inventory.Container;
import common.inventory.InventoryHelper;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.tileentity.ILockableContainer;
import common.tileentity.LockCode;
import common.util.BlockPos;
@ -190,7 +190,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
protected void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.minecartContainerItems.length; ++i)
{
@ -199,11 +199,11 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.minecartContainerItems[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
tagCompound.setTag("Items", nbttaglist);
tagCompound.setTagList("Items", nbttaglist);
}
/**
@ -212,12 +212,12 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
NBTTagTagList nbttaglist = tagCompund.getTagList("Items");
this.minecartContainerItems = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.minecartContainerItems.length)

View file

@ -64,14 +64,14 @@ public class EntityExplosion extends Entity
protected void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("Progress", this.progress);
tagCompound.setInteger("Radius", this.radius);
tagCompound.setInt("Progress", this.progress);
tagCompound.setInt("Radius", this.radius);
}
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.progress = tagCompund.getInteger("Progress");
this.radius = tagCompund.getInteger("Radius");
this.progress = tagCompund.getInt("Progress");
this.radius = tagCompund.getInt("Radius");
}
public float getEyeHeight()

View file

@ -153,11 +153,11 @@ public class EntityFalling extends Entity implements IObjectData
for (String s : this.tileEntityData.getKeySet())
{
NBTBase nbtbase = this.tileEntityData.getTag(s);
NBTBase nbtbase = this.tileEntityData.get(s);
if (!s.equals("x") && !s.equals("y") && !s.equals("z"))
{
nbttagcompound.setTag(s, nbtbase.copy());
nbttagcompound.set(s, nbtbase.copy());
}
}
@ -235,10 +235,10 @@ public class EntityFalling extends Entity implements IObjectData
tagCompound.setString("Block", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setByte("Data", (byte)block.getMetaFromState(this.fallTile));
tagCompound.setByte("Time", (byte)this.fallTime);
tagCompound.setBoolean("DropItem", this.shouldDropItem);
tagCompound.setBoolean("HurtEntities", this.hurtEntities);
tagCompound.setBool("DropItem", this.shouldDropItem);
tagCompound.setBool("HurtEntities", this.hurtEntities);
tagCompound.setFloat("FallHurtAmount", this.fallHurtAmount);
tagCompound.setInteger("FallHurtMax", this.fallHurtMax);
tagCompound.setInt("FallHurtMax", this.fallHurtMax);
if (this.tileEntityData != null)
{
@ -253,41 +253,27 @@ public class EntityFalling extends Entity implements IObjectData
{
int i = tagCompund.getByte("Data") & 255;
if (tagCompund.hasKey("Block", 8))
if (tagCompund.hasString("Block"))
{
this.fallTile = BlockRegistry.getByIdFallback(tagCompund.getString("Block")).getStateFromMeta(i);
}
else if (tagCompund.hasKey("TileID", 99))
{
this.fallTile = BlockRegistry.getBlockById(tagCompund.getInteger("TileID")).getStateFromMeta(i);
}
else
{
this.fallTile = BlockRegistry.getBlockById(tagCompund.getByte("Tile") & 255).getStateFromMeta(i);
this.fallTile = Blocks.sand.getState();
}
this.fallTime = tagCompund.getByte("Time") & 255;
Block block = this.fallTile.getBlock();
if (tagCompund.hasKey("HurtEntities", 99))
{
this.hurtEntities = tagCompund.getBoolean("HurtEntities");
this.hurtEntities = tagCompund.getBool("HurtEntities");
this.fallHurtAmount = tagCompund.getFloat("FallHurtAmount");
this.fallHurtMax = tagCompund.getInteger("FallHurtMax");
}
else if (block == Blocks.anvil)
{
this.hurtEntities = true;
}
this.fallHurtMax = tagCompund.getInt("FallHurtMax");
if (tagCompund.hasKey("DropItem", 99))
{
this.shouldDropItem = tagCompund.getBoolean("DropItem");
}
this.shouldDropItem = tagCompund.getBool("DropItem");
if (tagCompund.hasKey("TileEntityData", 10))
if (tagCompund.hasTag("TileEntityData"))
{
this.tileEntityData = tagCompund.getCompoundTag("TileEntityData");
this.tileEntityData = tagCompund.getTag("TileEntityData");
}
if (block == null || block == Blocks.air)

View file

@ -52,7 +52,7 @@ public class EntityFireworks extends Entity
{
this.dataWatcher.updateObject(8, givenItem);
NBTTagCompound nbttagcompound = givenItem.getTagCompound();
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Fireworks");
NBTTagCompound nbttagcompound1 = nbttagcompound.getTag("Fireworks");
if (nbttagcompound1 != null)
{
@ -155,7 +155,7 @@ public class EntityFireworks extends Entity
if (itemstack != null && itemstack.hasTagCompound())
{
nbttagcompound = itemstack.getTagCompound().getCompoundTag("Fireworks");
nbttagcompound = itemstack.getTagCompound().getTag("Fireworks");
}
((AWorldClient)this.worldObj).makeFireworks(this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
@ -169,8 +169,8 @@ public class EntityFireworks extends Entity
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("Life", this.fireworkAge);
tagCompound.setInteger("LifeTime", this.lifetime);
tagCompound.setInt("Life", this.fireworkAge);
tagCompound.setInt("LifeTime", this.lifetime);
ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8);
if (itemstack != null)
@ -186,9 +186,9 @@ public class EntityFireworks extends Entity
*/
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.fireworkAge = tagCompund.getInteger("Life");
this.lifetime = tagCompund.getInteger("LifeTime");
NBTTagCompound nbttagcompound = tagCompund.getCompoundTag("FireworksItem");
this.fireworkAge = tagCompund.getInt("Life");
this.lifetime = tagCompund.getInt("LifeTime");
NBTTagCompound nbttagcompound = tagCompund.getTag("FireworksItem");
if (nbttagcompound != null)
{

View file

@ -204,7 +204,7 @@ public class EntityHopperCart extends EntityCartContainer implements IHopper
protected void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("TransferCooldown", this.transferTicker);
tagCompound.setInt("TransferCooldown", this.transferTicker);
}
/**
@ -213,7 +213,7 @@ public class EntityHopperCart extends EntityCartContainer implements IHopper
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.transferTicker = tagCompund.getInteger("TransferCooldown");
this.transferTicker = tagCompund.getInt("TransferCooldown");
}
/**

View file

@ -372,10 +372,7 @@ public class EntityItem extends Entity
this.health = tagCompund.getShort("Health") & 255;
this.age = tagCompund.getShort("Age");
if (tagCompund.hasKey("PickupDelay"))
{
this.delayBeforeCanPickup = tagCompund.getShort("PickupDelay");
}
// if (tagCompund.hasKey("Owner"))
// {
@ -387,7 +384,7 @@ public class EntityItem extends Entity
// this.thrower = tagCompund.getString("Thrower");
// }
NBTTagCompound nbttagcompound = tagCompund.getCompoundTag("Item");
NBTTagCompound nbttagcompound = tagCompund.getTag("Item");
this.setEntityItemStack(ItemStack.loadItemStackFromNBT(nbttagcompound));
if (this.getEntityItem() == null)

View file

@ -95,12 +95,12 @@ public class EntityNuke extends Entity
protected void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("Fuse", this.fuse);
tagCompound.setInt("Fuse", this.fuse);
}
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.fuse = tagCompund.getInteger("Fuse");
this.fuse = tagCompund.getInt("Fuse");
}
public float getEyeHeight()

View file

@ -209,11 +209,7 @@ public class EntityTntCart extends EntityCart
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
if (tagCompund.hasKey("TNTFuse", 99))
{
this.minecartTNTFuse = tagCompund.getInteger("TNTFuse");
}
this.minecartTNTFuse = tagCompund.getInt("TNTFuse");
}
/**
@ -222,6 +218,6 @@ public class EntityTntCart extends EntityCart
protected void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("TNTFuse", this.minecartTNTFuse);
tagCompound.setInt("TNTFuse", this.minecartTNTFuse);
}
}

View file

@ -38,13 +38,13 @@ public class EntityGargoyle extends EntityFlyingNPC
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("Invul", this.getInvulTime());
tagCompound.setInt("Invul", this.getInvulTime());
}
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setInvulTime(tagCompund.getInteger("Invul"));
this.setInvulTime(tagCompund.getInt("Invul"));
}
public void onLivingUpdate()

View file

@ -64,11 +64,11 @@ public class EntityHaunter extends EntityNPC {
if (this.isCharged())
{
tagCompound.setBoolean("Charge", true);
tagCompound.setBool("Charge", true);
}
tagCompound.setShort("Fuse", (short)this.fuseTime);
tagCompound.setBoolean("ignited", this.hasIgnited());
tagCompound.setBool("ignited", this.hasIgnited());
}
/**
@ -77,14 +77,11 @@ public class EntityHaunter extends EntityNPC {
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setCharged(tagCompund.getBoolean("Charge"));
this.setCharged(tagCompund.getBool("Charge"));
if (tagCompund.hasKey("Fuse", 99))
{
this.fuseTime = tagCompund.getShort("Fuse");
}
if (tagCompund.getBoolean("ignited"))
if (tagCompund.getBool("ignited"))
{
this.ignite();
}

View file

@ -68,7 +68,7 @@ import common.item.ItemSword;
import common.item.ItemTool;
import common.model.ParticleType;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.network.IClientPlayer;
import common.network.IPlayer;
import common.packet.CPacketPlayerPosition;
@ -3385,22 +3385,22 @@ public abstract class EntityNPC extends EntityLiving
// super.readEntityFromNBT(tagCompund);
super.readEntityFromNBT(tagCompund);
// if(tagCompund.hasKey("CanPickUpLoot", 1)) {
// if(tagCompund.hasBoolean("CanPickUpLoot")) {
// this.setCanPickUpLoot(tagCompund.getBoolean("CanPickUpLoot"));
// }
if(tagCompund.hasKey("Equipment", 9)) {
NBTTagList nbttaglist = tagCompund.getTagList("Equipment", 10);
if(tagCompund.hasTagList("Equipment")) {
NBTTagTagList nbttaglist = tagCompund.getTagList("Equipment");
for(int i = 0; i < this.equipment.length; ++i) {
this.equipment[i] = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));
this.equipment[i] = ItemStack.loadItemStackFromNBT(nbttaglist.getTag(i));
}
}
// this.setSpecies(tagCompund.getString("Species"));
this.setChar(tagCompund.getString("Char"));
this.setCape(tagCompund.getString("Cape"));
this.isWilling = tagCompund.getBoolean("Willing");
this.setMating(tagCompund.getBoolean("Mating"));
this.isWilling = tagCompund.getBool("Willing");
this.setMating(tagCompund.getBool("Mating"));
Alignment // align;
// try {
align = Alignment.getByName(tagCompund.getString("Align"));
@ -3409,9 +3409,9 @@ public abstract class EntityNPC extends EntityLiving
// align = this.getNaturalAlign(this.rand);
// }
this.setAlignment(align);
this.setManaPoints(tagCompund.getInteger("Mana"));
this.setManaPoints(tagCompund.getInt("Mana"));
Enum type = null;
if(tagCompund.hasKey("ClassType", 8) && this.species != null && this.species.classEnum != null) {
if(tagCompund.hasString("ClassType") && this.species != null && this.species.classEnum != null) {
type = this.species.classnames.get(tagCompund.getString("ClassType"));
// try {
// type = Enum.valueOf(this.species.classEnum, tagCompund.getString("ClassType").toUpperCase());
@ -3421,13 +3421,13 @@ public abstract class EntityNPC extends EntityLiving
// }
}
this.setNpcClass(type);
this.setHeight(tagCompund.hasKey("Height", 5) ? tagCompund.getFloat("Height") : this.getBaseSize());
this.setHeight(tagCompund.hasFloat("Height") ? tagCompund.getFloat("Height") : this.getBaseSize());
NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
NBTTagTagList nbttaglist = tagCompund.getTagList("Items");
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttaglist.getTag(i));
if (itemstack != null)
{
@ -3435,10 +3435,12 @@ public abstract class EntityNPC extends EntityLiving
}
}
if(tagCompund.hasKey("Offers", 10))
this.trades = new MerchantRecipeList(tagCompund.getCompoundTag("Offers"));
this.healTimer = tagCompund.getInteger("healTimer");
if(tagCompund.hasKey("Skin", 7))
if(tagCompund.hasTagList("Offers")) {
this.trades = new MerchantRecipeList();
this.trades.fromNbt(tagCompund.getTagList("Offers"));
}
this.healTimer = tagCompund.getInt("healTimer");
if(tagCompund.hasByteArray("Skin"))
this.skin = tagCompund.getByteArray("Skin");
// this.setCanPickUpLoot(true);
@ -3446,15 +3448,15 @@ public abstract class EntityNPC extends EntityLiving
if(this.isPlayer()) {
// this.entityUniqueID = getOfflineUUID(this.user);
NBTTagList nbttaglist0 = tagCompund.getTagList("Inventory", 10);
NBTTagTagList nbttaglist0 = tagCompund.getTagList("Inventory");
this.inventory.readFromNBT(nbttaglist0);
this.inventory.currentItem = tagCompund.getInteger("SelectedItemSlot");
this.inventory.currentItem = tagCompund.getInt("SelectedItemSlot");
// this.sleeping = tagCompund.getBoolean("Sleeping");
// this.sleepTimer = tagCompund.getShort("SleepTimer");
this.experience = tagCompund.getFloat("XpP");
this.experienceLevel = tagCompund.getInteger("XpLevel");
this.experienceTotal = tagCompund.getInteger("XpTotal");
this.xpSeed = tagCompund.getInteger("XpSeed");
this.experienceLevel = tagCompund.getInt("XpLevel");
this.experienceTotal = tagCompund.getInt("XpTotal");
this.xpSeed = tagCompund.getInt("XpSeed");
if (this.xpSeed == 0)
{
@ -3470,32 +3472,32 @@ public abstract class EntityNPC extends EntityLiving
// this.wakeUpPlayer();
// }
if (tagCompund.hasKey("SpawnX", 99) && tagCompund.hasKey("SpawnY", 99) && tagCompund.hasKey("SpawnZ", 99))
if (tagCompund.hasInt("SpawnX") && tagCompund.hasInt("SpawnY") && tagCompund.hasInt("SpawnZ"))
{
this.spawnPos = new WorldPos(tagCompund.getInteger("SpawnX"), tagCompund.getInteger("SpawnY"),
tagCompund.getInteger("SpawnZ"), tagCompund.getInteger("SpawnDim"));
this.spawnPos = new WorldPos(tagCompund.getInt("SpawnX"), tagCompund.getInt("SpawnY"),
tagCompund.getInt("SpawnZ"), tagCompund.getInt("SpawnDim"));
// this.spawnForced = tagCompund.getBoolean("SpawnForced");
}
if (tagCompund.hasKey("OriginX", 99) && tagCompund.hasKey("OriginY", 99) && tagCompund.hasKey("OriginZ", 99))
if (tagCompund.hasInt("OriginX") && tagCompund.hasInt("OriginY") && tagCompund.hasInt("OriginZ"))
{
this.originPos = new WorldPos(tagCompund.getInteger("OriginX"), tagCompund.getInteger("OriginY"),
tagCompund.getInteger("OriginZ"), tagCompund.getInteger("OriginDim"));
this.originPos = new WorldPos(tagCompund.getInt("OriginX"), tagCompund.getInt("OriginY"),
tagCompund.getInt("OriginZ"), tagCompund.getInt("OriginDim"));
}
// this.foodStats.readNBT(tagCompund);
// this.readCapabilitiesFromNBT(tagCompund);
this.flying = tagCompund.getBoolean("flying") && (this.hasEffect(Potion.FLYING) || this.canNaturallyFly());
this.flying = tagCompund.getBool("flying") && (this.hasEffect(Potion.FLYING) || this.canNaturallyFly());
// if(tagCompund.hasKey("speed", 99))
// this.speed = tagCompund.getFloat("speed");
// this.disableDamagePersist = tagCompund.getBoolean("alwaysInvulnerable");
// this.disableTargetPersist = tagCompund.getBoolean("neverTarget");
// this.allowFlyingPersist = tagCompund.getBoolean("alwaysFly");
this.noclip = tagCompund.getBoolean("noClip");
this.noclip = tagCompund.getBool("noClip");
if (tagCompund.hasKey("WarpItems", 9))
if (tagCompund.hasTagList("WarpItems"))
{
NBTTagList nbttaglist1 = tagCompund.getTagList("WarpItems", 10);
NBTTagTagList nbttaglist1 = tagCompund.getTagList("WarpItems");
this.warpChest.loadInventoryFromNBT(nbttaglist1);
}
@ -3507,8 +3509,8 @@ public abstract class EntityNPC extends EntityLiving
// model = ModelType.HUMANOID;
// }
// this.setModel(model);
// this.setModelParts(tagCompund.hasKey("PartFlags", 3) ? tagCompund.getInteger("PartFlags") : ~ModelPart.ARMS_SLIM.getMask());
// if(tagCompund.hasKey("PlayerScale", 5))
// this.setModelParts(tagCompund.hasInt("PartFlags") ? tagCompund.getInteger("PartFlags") : ~ModelPart.ARMS_SLIM.getMask());
// if(tagCompund.hasFloat("PlayerScale"))
// this.setPlayerHeight(tagCompund.getFloat("PlayerScale"));
}
}
@ -3532,7 +3534,7 @@ public abstract class EntityNPC extends EntityLiving
super.writeEntityToNBT(tagCompound);
// tagCompound.setBoolean("CanPickUpLoot", this.canPickUpLoot());
NBTTagList nbttaglist0 = new NBTTagList();
NBTTagTagList nbttaglist0 = new NBTTagTagList();
for(int i = 0; i < this.equipment.length; ++i) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
@ -3541,23 +3543,23 @@ public abstract class EntityNPC extends EntityLiving
this.equipment[i].writeToNBT(nbttagcompound);
}
nbttaglist0.appendTag(nbttagcompound);
nbttaglist0.add(nbttagcompound);
}
tagCompound.setTag("Equipment", nbttaglist0);
tagCompound.setTagList("Equipment", nbttaglist0);
// tagCompound.setString("Species", this.getSpecies());
tagCompound.setString("Char", this.getChar());
tagCompound.setString("Cape", this.getCape());
tagCompound.setBoolean("Willing", this.isWilling);
tagCompound.setBoolean("Mating", this.isMating());
tagCompound.setBool("Willing", this.isWilling);
tagCompound.setBool("Mating", this.isMating());
tagCompound.setString("Align", this.alignment.name);
tagCompound.setFloat("Height", this.getHeight());
tagCompound.setInteger("Mana", this.getManaPoints());
tagCompound.setInt("Mana", this.getManaPoints());
Enum type = this.getNpcClass();
if(type != null)
tagCompound.setString("ClassType", this.species.classnames.inverse().get(type));
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.extraInventory.getSizeInventory(); ++i)
{
@ -3565,14 +3567,14 @@ public abstract class EntityNPC extends EntityLiving
if (itemstack != null)
{
nbttaglist.appendTag(itemstack.writeToNBT(new NBTTagCompound()));
nbttaglist.add(itemstack.writeToNBT(new NBTTagCompound()));
}
}
tagCompound.setTag("Items", nbttaglist);
tagCompound.setTagList("Items", nbttaglist);
if(this.trades != null)
tagCompound.setTag("Offers", this.trades.getRecipiesAsTags());
tagCompound.setInteger("healTimer", this.healTimer);
tagCompound.setTagList("Offers", this.trades.toNbt());
tagCompound.setInt("healTimer", this.healTimer);
if(this.skin != null)
tagCompound.setByteArray("Skin", this.skin);
@ -3585,44 +3587,44 @@ public abstract class EntityNPC extends EntityLiving
this.getAttributeMap().applyAttributeModifiers(itemstack.getAttributeModifiers(2), z, itemstack.stackSize);
}
}
tagCompound.setTag("Inventory", this.inventory.writeToNBT(new NBTTagList()));
tagCompound.setInteger("SelectedItemSlot", this.inventory.currentItem);
tagCompound.setTagList("Inventory", this.inventory.writeToNBT(new NBTTagTagList()));
tagCompound.setInt("SelectedItemSlot", this.inventory.currentItem);
// tagCompound.setBoolean("Sleeping", this.sleeping);
// tagCompound.setShort("SleepTimer", (short)this.sleepTimer);
tagCompound.setFloat("XpP", this.experience);
tagCompound.setInteger("XpLevel", this.experienceLevel);
tagCompound.setInteger("XpTotal", this.experienceTotal);
tagCompound.setInteger("XpSeed", this.xpSeed);
tagCompound.setInt("XpLevel", this.experienceLevel);
tagCompound.setInt("XpTotal", this.experienceTotal);
tagCompound.setInt("XpSeed", this.xpSeed);
// tagCompound.setInteger("Score", this.getScore());
// tagCompound.setInteger("Mana", this.getManaPoints());
if (this.spawnPos != null)
{
tagCompound.setInteger("SpawnX", this.spawnPos.getX());
tagCompound.setInteger("SpawnY", this.spawnPos.getY());
tagCompound.setInteger("SpawnZ", this.spawnPos.getZ());
tagCompound.setInteger("SpawnDim", this.spawnPos.getDimension());
tagCompound.setInt("SpawnX", this.spawnPos.getX());
tagCompound.setInt("SpawnY", this.spawnPos.getY());
tagCompound.setInt("SpawnZ", this.spawnPos.getZ());
tagCompound.setInt("SpawnDim", this.spawnPos.getDimension());
// tagCompound.setBoolean("SpawnForced", this.spawnForced);
}
if (this.originPos != null)
{
tagCompound.setInteger("OriginX", this.originPos.getX());
tagCompound.setInteger("OriginY", this.originPos.getY());
tagCompound.setInteger("OriginZ", this.originPos.getZ());
tagCompound.setInteger("OriginDim", this.originPos.getDimension());
tagCompound.setInt("OriginX", this.originPos.getX());
tagCompound.setInt("OriginY", this.originPos.getY());
tagCompound.setInt("OriginZ", this.originPos.getZ());
tagCompound.setInt("OriginDim", this.originPos.getDimension());
}
// this.foodStats.writeNBT(tagCompound);
// this.writeCapabilitiesToNBT(tagCompound);
tagCompound.setBoolean("flying", this.flying);
tagCompound.setBool("flying", this.flying);
// tagCompound.setFloat("speed", this.speed);
// tagCompound.setBoolean("alwaysInvulnerable", this.disableDamagePersist);
// tagCompound.setBoolean("neverTarget", this.disableTargetPersist);
// tagCompound.setBoolean("alwaysFly", this.allowFlyingPersist);
tagCompound.setBoolean("noClip", this.noclip);
tagCompound.setBool("noClip", this.noclip);
tagCompound.setTag("WarpItems", this.warpChest.saveInventoryToNBT());
tagCompound.setTagList("WarpItems", this.warpChest.saveInventoryToNBT());
ItemStack itemstack = this.inventory.getCurrentItem();
if (itemstack != null && itemstack.getItem() != null)

View file

@ -138,7 +138,7 @@ public class EntitySlime extends EntityNPC
{
super.writeEntityToNBT(tagCompound);
// tagCompound.setInteger("Size", this.getSlimeSize() - 1);
tagCompound.setBoolean("wasOnGround", this.wasOnGround);
tagCompound.setBool("wasOnGround", this.wasOnGround);
}
/**
@ -155,7 +155,7 @@ public class EntitySlime extends EntityNPC
// }
//
// this.setSlimeSize(i + 1);
this.wasOnGround = tagCompund.getBoolean("wasOnGround");
this.wasOnGround = tagCompund.getBool("wasOnGround");
}
protected ParticleType getParticleType()

View file

@ -477,8 +477,10 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
tagCompound.setShort("life", (short)this.ticksInGround);
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
if(this.inTile != null) {
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", id == null ? "" : id.toString());
}
tagCompound.setByte("inData", (byte)this.inData);
tagCompound.setByte("shake", (byte)this.arrowShake);
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
@ -496,33 +498,23 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
this.zTile = tagCompund.getShort("zTile");
this.ticksInGround = tagCompund.getShort("life");
if (tagCompund.hasKey("inTile", 8))
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
}
else
{
this.inTile = BlockRegistry.getBlockById(tagCompund.getByte("inTile") & 255);
this.inTile = null;
}
this.inData = tagCompund.getByte("inData") & 255;
this.arrowShake = tagCompund.getByte("shake") & 255;
this.inGround = tagCompund.getByte("inGround") == 1;
if (tagCompund.hasKey("damage", 99))
{
this.damage = tagCompund.getDouble("damage");
}
if (tagCompund.hasKey("pickup", 99))
{
this.canBePickedUp = tagCompund.getByte("pickup");
}
else if (tagCompund.hasKey("player", 99))
{
this.canBePickedUp = tagCompund.getBoolean("player") ? 1 : 0;
}
}
/**
* Called by a player entity when they collide with an entity

View file

@ -349,15 +349,14 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("damage", this.damage);
tagCompound.setInteger("age", this.age);
tagCompound.setInt("damage", this.damage);
tagCompound.setInt("age", this.age);
}
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
if(tagCompund.hasKey("damage", 99))
this.damage = tagCompund.getInteger("damage");
this.age = tagCompund.getInteger("age");
this.damage = tagCompund.getInt("damage");
this.age = tagCompund.getInt("age");
}
protected boolean canTriggerWalking()

View file

@ -67,17 +67,17 @@ public class EntityDie extends EntityThrowable implements IObjectData
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("Sides", this.sides);
tagCompound.setInteger("Value", this.getValue());
tagCompound.setBoolean("NoPickup", this.noPickup);
tagCompound.setInt("Sides", this.sides);
tagCompound.setInt("Value", this.getValue());
tagCompound.setBool("NoPickup", this.noPickup);
}
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.sides = tagCompund.getInteger("Sides");
this.setValue(tagCompund.getInteger("Value"));
this.noPickup = tagCompund.getBoolean("NoPickup");
this.sides = tagCompund.getInt("Sides");
this.setValue(tagCompund.getInt("Value"));
this.noPickup = tagCompund.getBool("NoPickup");
}
public int getPacketData() {

View file

@ -59,7 +59,7 @@ public class EntityFireball extends EntityProjectile
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("ExplosionPower", this.explosionPower);
tagCompound.setInt("ExplosionPower", this.explosionPower);
}
/**
@ -68,10 +68,6 @@ public class EntityFireball extends EntityProjectile
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
if (tagCompund.hasKey("ExplosionPower", 99))
{
this.explosionPower = tagCompund.getInteger("ExplosionPower");
}
this.explosionPower = tagCompund.getInt("ExplosionPower");
}
}

View file

@ -522,8 +522,10 @@ public class EntityHook extends Entity implements IObjectData
tagCompound.setShort("xTile", (short)this.xTile);
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
if(this.inTile != null) {
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", id == null ? "" : id.toString());
}
tagCompound.setByte("shake", (byte)this.shake);
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
}
@ -537,13 +539,13 @@ public class EntityHook extends Entity implements IObjectData
this.yTile = tagCompund.getShort("yTile");
this.zTile = tagCompund.getShort("zTile");
if (tagCompund.hasKey("inTile", 8))
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
}
else
{
this.inTile = BlockRegistry.getBlockById(tagCompund.getByte("inTile") & 255);
this.inTile = null;
}
this.shake = tagCompund.getByte("shake") & 255;

View file

@ -162,13 +162,13 @@ public class EntityPotion extends EntityThrowable implements IObjectData
{
super.readEntityFromNBT(tagCompund);
if (tagCompund.hasKey("Potion", 10))
if (tagCompund.hasTag("Potion"))
{
this.potionDamage = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("Potion"));
this.potionDamage = ItemStack.loadItemStackFromNBT(tagCompund.getTag("Potion"));
}
else
{
this.setPotionDamage(tagCompund.getInteger("potionValue"));
this.setPotionDamage(tagCompund.getInt("potionValue"));
}
if (this.potionDamage == null)

View file

@ -10,7 +10,7 @@ import common.entity.types.EntityLiving;
import common.init.BlockRegistry;
import common.model.ParticleType;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagDoubleList;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.ExtMath;
@ -262,8 +262,8 @@ public abstract class EntityProjectile extends Entity
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
tagCompound.setTag("direction", this.newDoubleNBTList(this.motionX, this.motionY, this.motionZ));
tagCompound.setInteger("Age", this.age);
tagCompound.setDoubleList("direction", this.newDoubleNBTList(this.motionX, this.motionY, this.motionZ));
tagCompound.setInt("Age", this.age);
}
/**
@ -275,7 +275,7 @@ public abstract class EntityProjectile extends Entity
this.yTile = tagCompund.getShort("yTile");
this.zTile = tagCompund.getShort("zTile");
if (tagCompund.hasKey("inTile", 8))
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
}
@ -286,18 +286,18 @@ public abstract class EntityProjectile extends Entity
this.inGround = tagCompund.getByte("inGround") == 1;
if (tagCompund.hasKey("direction", 9))
if (tagCompund.hasDoubleList("direction"))
{
NBTTagList nbttaglist = tagCompund.getTagList("direction", 6);
this.motionX = nbttaglist.getDoubleAt(0);
this.motionY = nbttaglist.getDoubleAt(1);
this.motionZ = nbttaglist.getDoubleAt(2);
NBTTagDoubleList nbttaglist = tagCompund.getDoubleList("direction");
this.motionX = nbttaglist.getDouble(0);
this.motionY = nbttaglist.getDouble(1);
this.motionZ = nbttaglist.getDouble(2);
}
else
{
this.setDead();
}
this.age = tagCompund.getInteger("Age");
this.age = tagCompund.getInt("Age");
}
/**

View file

@ -103,7 +103,7 @@ public abstract class EntityAnimal extends EntityLiving
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setInteger("InLove", this.inLove);
tagCompound.setInt("InLove", this.inLove);
}
/**
@ -112,7 +112,7 @@ public abstract class EntityAnimal extends EntityLiving
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.setInLove(tagCompund.getInteger("InLove"), true);
this.setInLove(tagCompund.getInt("InLove"), true);
}
/**

View file

@ -48,7 +48,7 @@ import common.item.ItemMonsterPlacer;
import common.item.ItemStack;
import common.model.ParticleType;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.network.IPlayer;
import common.packet.SPacketEntityAttach;
import common.packet.SPacketAnimation;
@ -541,13 +541,13 @@ public abstract class EntityLiving extends Entity
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("Health", this.getHealth());
tagCompound.setInt("Health", this.getHealth());
// tagCompound.setShort("Health", (short)((int)Math.ceil((double)this.getHealth())));
tagCompound.setShort("HurtTime", (short)this.hurtTime);
tagCompound.setInteger("HurtByTimestamp", this.lastAttacked);
tagCompound.setInt("HurtByTimestamp", this.lastAttacked);
tagCompound.setFloat("Radiation", this.radiation);
tagCompound.setShort("DeathTime", (short)this.deathTime);
tagCompound.setInteger("Absorption", this.getAbsorptionAmount());
tagCompound.setInt("Absorption", this.getAbsorptionAmount());
for (ItemStack itemstack : this.getInventory())
{
@ -557,7 +557,7 @@ public abstract class EntityLiving extends Entity
}
}
tagCompound.setTag("Attributes", Attributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));
tagCompound.setTagList("Attributes", Attributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));
for (ItemStack itemstack1 : this.getInventory())
{
@ -569,17 +569,17 @@ public abstract class EntityLiving extends Entity
if (!this.effects.isEmpty())
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (PotionEffect potioneffect : this.effects.values())
{
nbttaglist.appendTag(potioneffect.toNbt());
nbttaglist.add(potioneffect.toNbt());
}
tagCompound.setTag("ActiveEffects", nbttaglist);
tagCompound.setTagList("ActiveEffects", nbttaglist);
}
tagCompound.setBoolean("Leashed", this.leashed);
tagCompound.setBool("Leashed", this.leashed);
if(this.leashedTo != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
@ -590,9 +590,9 @@ public abstract class EntityLiving extends Entity
// else
if(this.leashedTo instanceof EntityLeashKnot) {
BlockPos blockpos = ((EntityLeashKnot)this.leashedTo).getHangingPosition();
nbttagcompound1.setInteger("X", blockpos.getX());
nbttagcompound1.setInteger("Y", blockpos.getY());
nbttagcompound1.setInteger("Z", blockpos.getZ());
nbttagcompound1.setInt("X", blockpos.getX());
nbttagcompound1.setInt("Y", blockpos.getY());
nbttagcompound1.setInt("Z", blockpos.getZ());
}
tagCompound.setTag("Leash", nbttagcompound1);
@ -601,7 +601,7 @@ public abstract class EntityLiving extends Entity
// if(this.isAIDisabled()) {
// tagCompound.setBoolean("NoAI", this.isAIDisabled());
// }
tagCompound.setInteger("Age", this.getGrowingAge());
tagCompound.setInt("Age", this.getGrowingAge());
if(this.description != null)
tagCompound.setString("Description", this.description);
}
@ -611,20 +611,20 @@ public abstract class EntityLiving extends Entity
*/
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.setAbsorptionAmount(tagCompund.getInteger("Absorption"));
this.setAbsorptionAmount(tagCompund.getInt("Absorption"));
if (tagCompund.hasKey("Attributes", 9) && this.worldObj != null && !this.worldObj.client)
if (tagCompund.hasTagList("Attributes") && this.worldObj != null && !this.worldObj.client)
{
Attributes.setAttributeModifiers(this.getAttributeMap(), tagCompund.getTagList("Attributes", 10));
Attributes.setAttributeModifiers(this.getAttributeMap(), tagCompund.getTagList("Attributes"));
}
if (tagCompund.hasKey("ActiveEffects", 9))
if (tagCompund.hasTagList("ActiveEffects"))
{
NBTTagList nbttaglist = tagCompund.getTagList("ActiveEffects", 10);
NBTTagTagList nbttaglist = tagCompund.getTagList("ActiveEffects");
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
PotionEffect potioneffect = PotionEffect.fromNbt(nbttagcompound);
if (potioneffect != null && !potioneffect.getPotion().isInstant())
@ -634,9 +634,9 @@ public abstract class EntityLiving extends Entity
}
}
if (tagCompund.hasKey("Health", 3))
if (tagCompund.hasInt("Health"))
{
this.setHealth(tagCompund.getInteger("Health"));
this.setHealth(tagCompund.getInt("Health"));
}
else
{
@ -658,20 +658,20 @@ public abstract class EntityLiving extends Entity
this.hurtTime = tagCompund.getShort("HurtTime");
this.deathTime = tagCompund.getShort("DeathTime");
this.lastAttacked = tagCompund.getInteger("HurtByTimestamp");
this.lastAttacked = tagCompund.getInt("HurtByTimestamp");
this.radiation = tagCompund.getFloat("Radiation");
if(!(this.isPlayer())) {
this.leashed = tagCompund.getBoolean("Leashed");
this.leashed = tagCompund.getBool("Leashed");
if(this.leashed && tagCompund.hasKey("Leash", 10)) {
this.leashTag = tagCompund.getCompoundTag("Leash");
if(this.leashed && tagCompund.hasTag("Leash")) {
this.leashTag = tagCompund.getTag("Leash");
}
}
// this.setNoAI(tagCompund.getBoolean("NoAI"));
this.setGrowingAge(tagCompund.getInteger("Age"));
this.description = tagCompund.hasKey("Description", 8) ? tagCompund.getString("Description") : null;
this.setGrowingAge(tagCompund.getInt("Age"));
this.description = tagCompund.hasString("Description") ? tagCompund.getString("Description") : null;
if(this.description != null && this.description.isEmpty())
this.description = null;
}
@ -3121,7 +3121,7 @@ public abstract class EntityLiving extends Entity
private void recreateLeash() {
if(this.leashed && this.leashTag != null) {
// if(this.leashTag.hasKey("PlayerName", 8)) {
// if(this.leashTag.hasString("PlayerName")) {
// String id = this.leashTag.getString("PlayerName");
// if(!id.isEmpty()) {
// for(EntityNPC entitylivingbase : this.worldObj.getEntitiesWithinAABB(EntityNPC.class,
@ -3134,9 +3134,9 @@ public abstract class EntityLiving extends Entity
// }
// }
// else
if(this.leashTag.hasKey("X", 99) && this.leashTag.hasKey("Y", 99) && this.leashTag.hasKey("Z", 99)) {
BlockPos blockpos = new BlockPos(this.leashTag.getInteger("X"), this.leashTag.getInteger("Y"),
this.leashTag.getInteger("Z"));
if(this.leashTag.hasInt("X") && this.leashTag.hasInt("Y") && this.leashTag.hasInt("Z")) {
BlockPos blockpos = new BlockPos(this.leashTag.getInt("X"), this.leashTag.getInt("Y"),
this.leashTag.getInt("Z"));
EntityLeashKnot entityleashknot = EntityLeashKnot.getKnotForPosition(this.worldObj, blockpos);
if(entityleashknot == null) {

View file

@ -38,8 +38,8 @@ public abstract class EntityTameable extends EntityAnimal implements IEntityOwna
// tagCompound.setString("Owner", this.getOwnerId());
// }
tagCompound.setBoolean("Tame", this.isTamed());
tagCompound.setBoolean("Sitting", this.isSitting());
tagCompound.setBool("Tame", this.isTamed());
tagCompound.setBool("Sitting", this.isSitting());
}
/**
@ -50,7 +50,7 @@ public abstract class EntityTameable extends EntityAnimal implements IEntityOwna
super.readEntityFromNBT(tagCompund);
// String s = "";
//
// if (tagCompund.hasKey("Owner", 8))
// if (tagCompund.hasString("Owner"))
// {
// s = tagCompund.getString("Owner");
// }
@ -61,9 +61,9 @@ public abstract class EntityTameable extends EntityAnimal implements IEntityOwna
// this.setTamed(true);
// }
this.setTamed(tagCompund.getBoolean("Tame"));
this.aiSit.setSitting(tagCompund.getBoolean("Sitting"));
this.setSitting(tagCompund.getBoolean("Sitting"));
this.setTamed(tagCompund.getBool("Tame"));
this.aiSit.setSitting(tagCompund.getBool("Sitting"));
this.setSitting(tagCompund.getBool("Sitting"));
}
/**

View file

@ -308,8 +308,10 @@ public abstract class EntityThrowable extends Entity implements IProjectile
tagCompound.setShort("xTile", (short)this.xTile);
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
if(this.inTile != null) {
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", id == null ? "" : id.toString());
}
tagCompound.setByte("shake", (byte)this.throwableShake);
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
@ -330,13 +332,13 @@ public abstract class EntityThrowable extends Entity implements IProjectile
this.yTile = tagCompund.getShort("yTile");
this.zTile = tagCompund.getShort("zTile");
if (tagCompund.hasKey("inTile", 8))
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
}
else
{
this.inTile = BlockRegistry.getBlockById(tagCompund.getByte("inTile") & 255);
this.inTile = null;
}
this.throwableShake = tagCompund.getByte("shake") & 255;

View file

@ -26,7 +26,7 @@ import common.item.ItemArmor;
import common.item.ItemDye;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.tileentity.TileEntityBanner;
import common.world.World;
@ -617,22 +617,22 @@ public abstract class CraftingRegistry
}
NBTTagCompound nbttagcompound1 = itemstack.getSubCompound("BlockEntityTag", true);
NBTTagList nbttaglist = null;
NBTTagTagList nbttaglist = null;
if (nbttagcompound1.hasKey("Patterns", 9))
if (nbttagcompound1.hasTagList("Patterns"))
{
nbttaglist = nbttagcompound1.getTagList("Patterns", 10);
nbttaglist = nbttagcompound1.getTagList("Patterns");
}
else
{
nbttaglist = new NBTTagList();
nbttagcompound1.setTag("Patterns", nbttaglist);
nbttaglist = new NBTTagTagList();
nbttagcompound1.setTagList("Patterns", nbttaglist);
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Pattern", tileentitybanner$enumbannerpattern.getPatternID());
nbttagcompound.setInteger("Color", k);
nbttaglist.appendTag(nbttagcompound);
nbttagcompound.setInt("Color", k);
nbttaglist.add(nbttagcompound);
}
return itemstack;
@ -971,19 +971,19 @@ public abstract class CraftingRegistry
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int k2 = 0; k2 < inv.getSizeInventory(); ++k2)
{
ItemStack itemstack3 = inv.getStackInSlot(k2);
if (itemstack3 != null && itemstack3.getItem() == Items.firework_charge && itemstack3.hasTagCompound() && itemstack3.getTagCompound().hasKey("Explosion", 10))
if (itemstack3 != null && itemstack3.getItem() == Items.firework_charge && itemstack3.hasTagCompound() && itemstack3.getTagCompound().hasTag("Explosion"))
{
nbttaglist.appendTag(itemstack3.getTagCompound().getCompoundTag("Explosion"));
nbttaglist.add(itemstack3.getTagCompound().getTag("Explosion"));
}
}
nbttagcompound3.setTag("Explosions", nbttaglist);
nbttagcompound3.setTagList("Explosions", nbttaglist);
nbttagcompound3.setByte("Flight", (byte)j);
nbttagcompound1.setTag("Fireworks", nbttagcompound3);
this.field_92102_a.setTagCompound(nbttagcompound1);
@ -1011,11 +1011,11 @@ public abstract class CraftingRegistry
}
else if (itemstack2.getItem() == Items.glowstone_dust)
{
nbttagcompound2.setBoolean("Flicker", true);
nbttagcompound2.setBool("Flicker", true);
}
else if (itemstack2.getItem() == Items.diamond)
{
nbttagcompound2.setBoolean("Trail", true);
nbttagcompound2.setBool("Trail", true);
}
else if (itemstack2.getItem() == Items.fire_charge)
{
@ -1080,7 +1080,7 @@ public abstract class CraftingRegistry
if (this.field_92102_a != null && this.field_92102_a.hasTagCompound())
{
NBTTagCompound nbttagcompound4 = this.field_92102_a.getTagCompound().getCompoundTag("Explosion");
NBTTagCompound nbttagcompound4 = this.field_92102_a.getTagCompound().getTag("Explosion");
if (nbttagcompound4 == null)
{

View file

@ -435,7 +435,7 @@ public abstract class DispenserRegistry {
// {
// NBTTagCompound nbttagcompound = stack.getTagCompound();
//
// if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
// if (nbttagcompound.hasString("SkullOwner") && nbttagcompound.getString("SkullOwner").length() > 0)
// {
// user = nbttagcompound.getString("SkullOwner");
// }

View file

@ -30,7 +30,7 @@ import common.log.Log;
import common.nbt.NBTException;
import common.nbt.NBTParser;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.rng.Random;
import common.util.PortalType;
import common.world.State;
@ -93,16 +93,16 @@ public abstract class UniverseRegistry {
}
public static void loadNbt(NBTTagCompound tag) {
NBTTagList list = tag.getTagList("Dimensions", 10);
for(int z = 0; z < list.tagCount(); z++) {
Dimension dim = Dimension.getByNbt(list.getCompoundTagAt(z));
NBTTagTagList list = tag.getTagList("Dimensions");
for(int z = 0; z < list.size(); z++) {
Dimension dim = Dimension.getByNbt(list.getTag(z));
if(!REGISTRY.containsKey(dim.getDimensionId()) && !ALIASES.containsKey(dim.getDimensionName()))
register(dim);
}
list = tag.getTagList("Names", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound data = list.getCompoundTagAt(z);
list = tag.getTagList("Names");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound data = list.getTag(z);
String id = data.getString("ID");
// if(BASE_ALIASES.containsKey(id)) {
Dimension dim = ALIASES.get(id);
@ -111,9 +111,9 @@ public abstract class UniverseRegistry {
// }
}
list = tag.getTagList("Sectors", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound data = list.getCompoundTagAt(z);
list = tag.getTagList("Sectors");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound data = list.getTag(z);
String id = data.getString("ID");
Sector sector = SECTORS.get(id);
if(sector == null)
@ -121,9 +121,9 @@ public abstract class UniverseRegistry {
sector.readNbt(data);
}
list = tag.getTagList("Galaxies", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound data = list.getCompoundTagAt(z);
list = tag.getTagList("Galaxies");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound data = list.getTag(z);
String id = data.getString("ID");
Galaxy galaxy = GALAXIES.get(id);
if(galaxy == null)
@ -131,9 +131,9 @@ public abstract class UniverseRegistry {
galaxy.readNbt(data);
}
list = tag.getTagList("Domains", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound data = list.getCompoundTagAt(z);
list = tag.getTagList("Domains");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound data = list.getTag(z);
String id = data.getString("ID");
Domain domain = DOMAINS.get(id);
if(domain == null)
@ -141,9 +141,9 @@ public abstract class UniverseRegistry {
domain.readNbt(data);
}
list = tag.getTagList("Barycenters", 10);
for(int z = 0; z < list.tagCount(); z++) {
NBTTagCompound link = list.getCompoundTagAt(z);
list = tag.getTagList("Barycenters");
for(int z = 0; z < list.size(); z++) {
NBTTagCompound link = list.getTag(z);
if(!assign(link.getString("Celestial"), link.getString("Center")))
Log.TICK.warn("Konnte '" + link.getString("Celestial") + "' nicht zu '" + link.getString("Center") + "' zuweisen");
}
@ -152,72 +152,72 @@ public abstract class UniverseRegistry {
public static NBTTagCompound saveNbt() {
NBTTagCompound tag = new NBTTagCompound();
NBTTagList list = new NBTTagList();
NBTTagTagList list = new NBTTagTagList();
for(Dimension dim : DIMENSIONS) {
if(!BASE_REGISTRY.containsKey(dim.getDimensionId()) && dim != Space.INSTANCE)
list.appendTag(dim.toNbt());
list.add(dim.toNbt());
}
if(!list.hasNoTags())
tag.setTag("Dimensions", list);
if(!list.isEmpty())
tag.setTagList("Dimensions", list);
list = new NBTTagList();
list = new NBTTagTagList();
for(Dimension dim : DIMENSIONS) {
if(/* BASE_REGISTRY.containsKey(dim.getDimensionId()) */ dim != Space.INSTANCE) {
NBTTagCompound data = new NBTTagCompound();
dim.writeNbt(data);
if(!data.hasNoTags()) {
if(!data.isEmpty()) {
data.setString("ID", dim.getDimensionName());
list.appendTag(data);
list.add(data);
}
}
}
if(!list.hasNoTags())
tag.setTag("Names", list);
if(!list.isEmpty())
tag.setTagList("Names", list);
list = new NBTTagList();
list = new NBTTagTagList();
for(Sector sector : SECTORS.values()) {
NBTTagCompound data = new NBTTagCompound();
sector.writeNbt(data);
if(!data.hasNoTags()) {
if(!data.isEmpty()) {
data.setString("ID", sector.id);
list.appendTag(data);
list.add(data);
}
}
if(!list.hasNoTags())
tag.setTag("Sectors", list);
if(!list.isEmpty())
tag.setTagList("Sectors", list);
list = new NBTTagList();
list = new NBTTagTagList();
for(Galaxy galaxy : GALAXIES.values()) {
NBTTagCompound data = new NBTTagCompound();
galaxy.writeNbt(data);
if(!data.hasNoTags()) {
if(!data.isEmpty()) {
data.setString("ID", galaxy.id);
list.appendTag(data);
list.add(data);
}
}
if(!list.hasNoTags())
tag.setTag("Galaxies", list);
if(!list.isEmpty())
tag.setTagList("Galaxies", list);
list = new NBTTagList();
list = new NBTTagTagList();
for(Domain domain : DOMAINS.values()) {
NBTTagCompound data = new NBTTagCompound();
domain.writeNbt(data);
if(!data.hasNoTags()) {
if(!data.isEmpty()) {
data.setString("ID", domain.id);
list.appendTag(data);
list.add(data);
}
}
if(!list.hasNoTags())
tag.setTag("Domains", list);
if(!list.isEmpty())
tag.setTagList("Domains", list);
list = new NBTTagList();
list = new NBTTagTagList();
for(Entry<Moon, Planet> entry : MOON_MAP.entrySet()) {
if(BASE_REGISTRY.containsKey(entry.getKey().getDimensionId()))
continue;
NBTTagCompound link = new NBTTagCompound();
link.setString("Celestial", entry.getKey().getDimensionName());
link.setString("Center", entry.getValue().getDimensionName());
list.appendTag(link);
list.add(link);
}
for(Entry<Planet, Star> entry : PLANET_MAP.entrySet()) {
if(BASE_REGISTRY.containsKey(entry.getKey().getDimensionId()))
@ -225,7 +225,7 @@ public abstract class UniverseRegistry {
NBTTagCompound link = new NBTTagCompound();
link.setString("Celestial", entry.getKey().getDimensionName());
link.setString("Center", entry.getValue().getDimensionName());
list.appendTag(link);
list.add(link);
}
for(Entry<Star, Sector> entry : STAR_MAP.entrySet()) {
if(BASE_REGISTRY.containsKey(entry.getKey().getDimensionId()))
@ -233,7 +233,7 @@ public abstract class UniverseRegistry {
NBTTagCompound link = new NBTTagCompound();
link.setString("Celestial", entry.getKey().getDimensionName());
link.setString("Center", entry.getValue().id);
list.appendTag(link);
list.add(link);
}
for(Entry<Sector, Galaxy> entry : SECTOR_MAP.entrySet()) {
if(BASE_MAP.containsKey(entry.getKey().id))
@ -241,7 +241,7 @@ public abstract class UniverseRegistry {
NBTTagCompound link = new NBTTagCompound();
link.setString("Celestial", entry.getKey().id);
link.setString("Center", entry.getValue().id);
list.appendTag(link);
list.add(link);
}
for(Entry<Area, Domain> entry : AREA_MAP.entrySet()) {
if(BASE_REGISTRY.containsKey(entry.getKey().getDimensionId()))
@ -249,10 +249,10 @@ public abstract class UniverseRegistry {
NBTTagCompound link = new NBTTagCompound();
link.setString("Celestial", entry.getKey().getDimensionName());
link.setString("Center", entry.getValue().id);
list.appendTag(link);
list.add(link);
}
if(!list.hasNoTags())
tag.setTag("Barycenters", list);
if(!list.isEmpty())
tag.setTagList("Barycenters", list);
return tag;
}
@ -709,40 +709,40 @@ public abstract class UniverseRegistry {
throw new RuntimeException(e);
}
NBTTagCompound dtag = dim.toNbt(true);
if(ptag.getBoolean("ClearGenerator")) {
ptag.removeTag("ClearGenerator");
dtag.removeTag("FloorBlock");
dtag.removeTag("CeilingBlock");
dtag.removeTag("Layers");
dtag.removeTag("AddBiomes");
dtag.removeTag("FrostBiomes");
dtag.removeTag("ColdBiomes");
dtag.removeTag("MediumBiomes");
dtag.removeTag("HotBiomes");
dtag.removeTag("Ores");
dtag.removeTag("Lakes");
dtag.removeTag("Liquids");
if(ptag.getBool("ClearGenerator")) {
ptag.remove("ClearGenerator");
dtag.remove("FloorBlock");
dtag.remove("CeilingBlock");
dtag.remove("Layers");
dtag.remove("AddBiomes");
dtag.remove("FrostBiomes");
dtag.remove("ColdBiomes");
dtag.remove("MediumBiomes");
dtag.remove("HotBiomes");
dtag.remove("Ores");
dtag.remove("Lakes");
dtag.remove("Liquids");
dtag.setString("Generator", GeneratorType.FLAT.getName());
dtag.setString("Replacer", ReplacerType.NONE.getName());
// dtag.setBoolean("MobGen", false);
// dtag.setBoolean("SnowGen", false);
dtag.setBoolean("Caves", false);
dtag.setBoolean("Ravines", false);
dtag.setBoolean("AltCaves", false);
dtag.setBoolean("Strongholds", false);
dtag.setBoolean("Villages", false);
dtag.setBoolean("Mineshafts", false);
dtag.setBoolean("Scattered", false);
dtag.setBoolean("Fortresses", false);
dtag.setInteger("Dungeons", 0);
dtag.setInteger("BiomeSize", 0);
dtag.setInteger("RiverSize", 4);
dtag.setInteger("SnowRarity", 6);
dtag.setInteger("SeaRarity", 50);
dtag.setInteger("AddRarity", 50);
dtag.setInteger("SeaLevel", 0);
dtag.setBool("Caves", false);
dtag.setBool("Ravines", false);
dtag.setBool("AltCaves", false);
dtag.setBool("Strongholds", false);
dtag.setBool("Villages", false);
dtag.setBool("Mineshafts", false);
dtag.setBool("Scattered", false);
dtag.setBool("Fortresses", false);
dtag.setInt("Dungeons", 0);
dtag.setInt("BiomeSize", 0);
dtag.setInt("RiverSize", 4);
dtag.setInt("SnowRarity", 6);
dtag.setInt("SeaRarity", 50);
dtag.setInt("AddRarity", 50);
dtag.setInt("SeaLevel", 0);
dtag.setString("DefaultBiome", Biome.NONE.name.toLowerCase());
dtag.setBoolean("SemiFixed", false);
dtag.setBool("SemiFixed", false);
// dtag.setString("DefaultWeather", Weather.CLEAR.getName());
dtag.setString("DefaultLeaves", LeavesType.SPRING.getName());
dtag.setString("FillerBlock", BlockRegistry.toIdName(Blocks.air.getState()));

View file

@ -183,7 +183,7 @@ public class ContainerRepair extends Container
if (repStack != null)
{
isBook = repStack.getItem() == Items.enchanted_book && Items.enchanted_book.getEnchantments(repStack).tagCount() > 0;
isBook = repStack.getItem() == Items.enchanted_book && Items.enchanted_book.getEnchantments(repStack).size() > 0;
if (newStack.isItemStackDamageable() && newStack.getItem().getIsRepairable(stack, repStack))
{

View file

@ -224,21 +224,21 @@ public class InventoryMerchant implements IInventory
if (merchantrecipelist != null)
{
MerchantRecipe merchantrecipe = merchantrecipelist.canRecipeBeUsed(itemstack, itemstack1, this.currentRecipeIndex);
MerchantRecipe merchantrecipe = merchantrecipelist.canUse(itemstack, itemstack1, this.currentRecipeIndex);
if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled())
{
this.currentRecipe = merchantrecipe;
this.setInventorySlotContents(2, merchantrecipe.getItemToSell().copy());
this.setInventorySlotContents(2, merchantrecipe.getSelling().copy());
}
else if (itemstack1 != null)
{
merchantrecipe = merchantrecipelist.canRecipeBeUsed(itemstack1, itemstack, this.currentRecipeIndex);
merchantrecipe = merchantrecipelist.canUse(itemstack1, itemstack, this.currentRecipeIndex);
if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled())
{
this.currentRecipe = merchantrecipe;
this.setInventorySlotContents(2, merchantrecipe.getItemToSell().copy());
this.setInventorySlotContents(2, merchantrecipe.getSelling().copy());
}
else
{

View file

@ -6,7 +6,7 @@ import common.item.Item;
import common.item.ItemArmor;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
public class InventoryPlayer implements IInventory
{
@ -450,7 +450,7 @@ public class InventoryPlayer implements IInventory
*
* @param nbtTagListIn List to append tags to
*/
public NBTTagList writeToNBT(NBTTagList nbtTagListIn)
public NBTTagTagList writeToNBT(NBTTagTagList nbtTagListIn)
{
for (int i = 0; i < this.mainInventory.length; ++i)
{
@ -459,7 +459,7 @@ public class InventoryPlayer implements IInventory
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.mainInventory[i].writeToNBT(nbttagcompound);
nbtTagListIn.appendTag(nbttagcompound);
nbtTagListIn.add(nbttagcompound);
}
}
@ -470,7 +470,7 @@ public class InventoryPlayer implements IInventory
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)(j + 100));
this.armorInventory[j].writeToNBT(nbttagcompound1);
nbtTagListIn.appendTag(nbttagcompound1);
nbtTagListIn.add(nbttagcompound1);
}
}
@ -482,14 +482,14 @@ public class InventoryPlayer implements IInventory
*
* @param nbtTagListIn tagList to read from
*/
public void readFromNBT(NBTTagList nbtTagListIn)
public void readFromNBT(NBTTagTagList nbtTagListIn)
{
this.mainInventory = new ItemStack[36];
this.armorInventory = new ItemStack[4];
for (int i = 0; i < nbtTagListIn.tagCount(); ++i)
for (int i = 0; i < nbtTagListIn.size(); ++i)
{
NBTTagCompound nbttagcompound = nbtTagListIn.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbtTagListIn.getTag(i);
int j = nbttagcompound.getByte("Slot") & 255;
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);

View file

@ -4,7 +4,7 @@ import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.util.BlockPos;
public class InventoryWarpChest extends InventoryBasic
@ -21,16 +21,16 @@ public class InventoryWarpChest extends InventoryBasic
this.associatedChest = chestTileEntity;
}
public void loadInventoryFromNBT(NBTTagList p_70486_1_)
public void loadInventoryFromNBT(NBTTagTagList p_70486_1_)
{
for (int i = 0; i < this.getSizeInventory(); ++i)
{
this.setInventorySlotContents(i, (ItemStack)null);
}
for (int k = 0; k < p_70486_1_.tagCount(); ++k)
for (int k = 0; k < p_70486_1_.size(); ++k)
{
NBTTagCompound nbttagcompound = p_70486_1_.getCompoundTagAt(k);
NBTTagCompound nbttagcompound = p_70486_1_.getTag(k);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.getSizeInventory())
@ -40,9 +40,9 @@ public class InventoryWarpChest extends InventoryBasic
}
}
public NBTTagList saveInventoryToNBT()
public NBTTagTagList saveInventoryToNBT()
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.getSizeInventory(); ++i)
{
@ -53,7 +53,7 @@ public class InventoryWarpChest extends InventoryBasic
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}

View file

@ -94,8 +94,8 @@ public class SlotMerchantResult extends Slot
private boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem)
{
ItemStack itemstack = trade.getItemToBuy();
ItemStack itemstack1 = trade.getSecondItemToBuy();
ItemStack itemstack = trade.getBuying();
ItemStack itemstack1 = trade.getSecondBuy();
if (firstItem != null && firstItem.getItem() == itemstack.getItem())
{

View file

@ -470,14 +470,14 @@ public class Item
// return false;
// }
//// if(tag.hasKey("display")) {
//// if(!tag.hasKey("display", 10)) {
//// if(!tag.hasTag("display")) {
//// return false;
//// }
//// NBTTagCompound display = tag.getCompoundTag("display");
//// keys = display.getKeySet();
//// z = keys.size();
// if(tag.hasKey("Name")) {
// if(!tag.hasKey("Name", 8)) {
// if(!tag.hasString("Name")) {
// return false;
// }
// if(tag.getString("Name").length() > 64) {
@ -497,7 +497,7 @@ public class Item
//// }
//// }
//// else {
//// if(!display.hasKey("Lore", 9)) {
//// if(!display.hasList("Lore")) {
//// return false;
//// }
//// NBTTagList lore = display.getTagList("Lore", 8);
@ -508,7 +508,7 @@ public class Item
//// z--;
//// }
//// if(display.hasKey("color")) {
//// if(!display.hasKey("color", 3)) {
//// if(!display.hasInt("color")) {
//// return false;
//// }
//// if(!this.canBeDyed()) {
@ -521,7 +521,7 @@ public class Item
//// }
//// }
// if(tag.hasKey("RepairCost")) {
// if(!tag.hasKey("RepairCost", 3)) {
// if(!tag.hasInt("RepairCost")) {
// return false;
// }
// if(tag.getInteger("RepairCost") < 1) {
@ -529,7 +529,7 @@ public class Item
// }
// }
// if(tag.hasKey("ench")) {
// if(!tag.hasKey("ench", 9)) {
// if(!tag.hasList("ench")) {
// return false;
// }
// NBTTagList ench = tag.getTagList("ench", 10);
@ -542,7 +542,7 @@ public class Item
// Enchantment[] ecn = new Enchantment[ench.tagCount()];
// for(int e = 0; e < ench.tagCount(); e++) {
// NBTTagCompound ec = ench.getCompoundTagAt(e);
// if(ec.getKeySet().size() != 2 || !ec.hasKey("id", 2) || !ec.hasKey("lvl", 2)) {
// if(ec.getKeySet().size() != 2 || !ec.hasShort("id") || !ec.hasShort("lvl")) {
// return false;
// }
// int id = ec.getShort("id");
@ -569,12 +569,12 @@ public class Item
// }
//// if(adv) {
//// if(tag.hasKey("Unbreakable")) {
//// if(!tag.hasKey("Unbreakable", 1)) {
//// if(!tag.hasBoolean("Unbreakable")) {
//// return false;
//// }
//// }
//// if(tag.hasKey("HideFlags")) {
//// if(!tag.hasKey("HideFlags", 3)) {
//// if(!tag.hasInt("HideFlags")) {
//// return false;
//// }
//// }

View file

@ -144,7 +144,7 @@ public class ItemArmor extends Item
*/
public boolean hasColor(ItemStack stack)
{
return this.material.canBeDyed() && stack.hasTagCompound() && stack.getTagCompound().hasKey("color", 3);
return this.material.canBeDyed() && stack.hasTagCompound() && stack.getTagCompound().hasInt("color");
}
/**
@ -160,13 +160,13 @@ public class ItemArmor extends Item
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
if (nbttagcompound != null && nbttagcompound.hasKey("color", 3))
if (nbttagcompound != null && nbttagcompound.hasInt("color"))
{
// NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
//
// if (nbttagcompound1 != null && nbttagcompound1.hasKey("color", 3))
// if (nbttagcompound1 != null && nbttagcompound1.hasInt("color"))
// {
return nbttagcompound.getInteger("color");
return nbttagcompound.getInt("color");
// }
}
@ -187,10 +187,10 @@ public class ItemArmor extends Item
{
// NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
if (nbttagcompound.hasKey("color"))
if (nbttagcompound.hasInt("color"))
{
nbttagcompound.removeTag("color");
if(nbttagcompound.hasNoTags())
nbttagcompound.remove("color");
if(nbttagcompound.isEmpty())
stack.setTagCompound(null);
}
}
@ -218,12 +218,12 @@ public class ItemArmor extends Item
// NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
//
// if (!nbttagcompound.hasKey("display", 10))
// if (!nbttagcompound.hasTag("display"))
// {
// nbttagcompound.setTag("display", nbttagcompound1);
// }
nbttagcompound.setInteger("color", color);
nbttagcompound.setInt("color", color);
}
}
@ -289,8 +289,8 @@ public class ItemArmor extends Item
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip) {
if(this.material.canBeDyed()) {
int color = this.material.getDefaultColor();
if(stack.hasTagCompound() && stack.getTagCompound().hasKey("color", 3))
color = stack.getTagCompound().getInteger("color");
if(stack.hasTagCompound() && stack.getTagCompound().hasInt("color"))
color = stack.getTagCompound().getInt("color");
tooltip.add("Farbe: #" + Integer.toHexString(color).toUpperCase());
}
}

View file

@ -11,7 +11,7 @@ import common.model.ItemMeshDefinition;
import common.model.Model;
import common.model.ModelProvider;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityBanner;
import common.util.BlockPos;
@ -98,14 +98,14 @@ public class ItemBanner extends ItemBlock
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
if (nbttagcompound != null && nbttagcompound.hasKey("Patterns"))
if (nbttagcompound != null && nbttagcompound.hasTagList("Patterns"))
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);
NBTTagTagList nbttaglist = nbttagcompound.getTagList("Patterns");
for (int i = 0; i < nbttaglist.tagCount() && i < 6; ++i)
for (int i = 0; i < nbttaglist.size() && i < 6; ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
DyeColor enumdyecolor = DyeColor.byDyeDamage(nbttagcompound1.getInteger("Color"));
NBTTagCompound nbttagcompound1 = nbttaglist.getTag(i);
DyeColor enumdyecolor = DyeColor.byDyeDamage(nbttagcompound1.getInt("Color"));
TileEntityBanner.EnumBannerPattern pattern = TileEntityBanner.EnumBannerPattern.getPatternByID(nbttagcompound1.getString("Pattern"));
if (pattern != null)
@ -138,7 +138,7 @@ public class ItemBanner extends ItemBlock
for (DyeColor enumdyecolor : DyeColor.values())
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
TileEntityBanner.setBaseColorAndPatterns(nbttagcompound, enumdyecolor.getDyeDamage(), (NBTTagList)null);
TileEntityBanner.setBaseColorAndPatterns(nbttagcompound, enumdyecolor.getDyeDamage(), null);
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setTag("BlockEntityTag", nbttagcompound);
ItemStack itemstack = new ItemStack(itemIn, 1, enumdyecolor.getDyeDamage());
@ -160,9 +160,9 @@ public class ItemBanner extends ItemBlock
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
DyeColor enumdyecolor = null;
if (nbttagcompound != null && nbttagcompound.hasKey("Base"))
if (nbttagcompound != null && nbttagcompound.hasInt("Base"))
{
enumdyecolor = DyeColor.byDyeDamage(nbttagcompound.getInteger("Base"));
enumdyecolor = DyeColor.byDyeDamage(nbttagcompound.getInt("Base"));
}
else
{
@ -174,12 +174,12 @@ public class ItemBanner extends ItemBlock
// protected boolean validateNbt(NBTTagCompound tag) {
// if(tag.hasKey("BlockEntityTag")) {
// if(!tag.hasKey("BlockEntityTag", 10)) {
// if(!tag.hasTag("BlockEntityTag")) {
// return false;
// }
// NBTTagCompound etag = tag.getCompoundTag("BlockEntityTag");
// if(etag.hasKey("Patterns")) {
// if(!etag.hasKey("Patterns", 9)) {
// if(!etag.hasList("Patterns")) {
// return false;
// }
// NBTTagList patterns = etag.getTagList("Patterns", 10);
@ -192,7 +192,7 @@ public class ItemBanner extends ItemBlock
// }
// }
// if(etag.hasKey("Base")) {
// if(!etag.hasKey("Base", 3)) {
// if(!etag.hasInt("Base")) {
// return false;
// }
// }

View file

@ -107,7 +107,7 @@ public class ItemBlock extends Item
// }
// else
// {
if (p_179224_3_.hasTagCompound() && p_179224_3_.getTagCompound().hasKey("BlockEntityTag", 10))
if (p_179224_3_.hasTagCompound() && p_179224_3_.getTagCompound().hasTag("BlockEntityTag"))
{
TileEntity tileentity = worldIn.getTileEntity(stack);
@ -121,11 +121,11 @@ public class ItemBlock extends Item
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.copy();
tileentity.writeToNBT(nbttagcompound);
NBTTagCompound nbttagcompound2 = (NBTTagCompound)p_179224_3_.getTagCompound().getTag("BlockEntityTag");
NBTTagCompound nbttagcompound2 = (NBTTagCompound)p_179224_3_.getTagCompound().get("BlockEntityTag");
nbttagcompound.merge(nbttagcompound2);
nbttagcompound.setInteger("x", stack.getX());
nbttagcompound.setInteger("y", stack.getY());
nbttagcompound.setInteger("z", stack.getZ());
nbttagcompound.setInt("x", stack.getX());
nbttagcompound.setInt("y", stack.getY());
nbttagcompound.setInt("z", stack.getZ());
if (!nbttagcompound.equals(nbttagcompound1))
{
@ -200,7 +200,7 @@ public class ItemBlock extends Item
//
// protected boolean validateNbt(NBTTagCompound tag) {
// if(tag.hasKey("BlockEntityTag")) {
// if(!tag.hasKey("BlockEntityTag", 10)) {
// if(!tag.hasTag("BlockEntityTag")) {
// return false;
// }
// }

View file

@ -10,7 +10,7 @@ import common.entity.npc.EntityNPC;
import common.init.Items;
import common.model.ItemMeshDefinition;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.rng.Random;
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 NBTTagList getEnchantments(ItemStack stack)
public NBTTagTagList getEnchantments(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
return nbttagcompound != null && nbttagcompound.hasKey("StoredEnchantments", 9) ? (NBTTagList)nbttagcompound.getTag("StoredEnchantments") : new NBTTagList();
return nbttagcompound != null && nbttagcompound.hasTagList("StoredEnchantments") ? nbttagcompound.getTagList("StoredEnchantments") : new NBTTagTagList();
}
/**
@ -60,14 +60,14 @@ public class ItemEnchantedBook extends Item
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
{
super.addInformation(stack, playerIn, tooltip);
NBTTagList nbttaglist = this.getEnchantments(stack);
NBTTagTagList nbttaglist = this.getEnchantments(stack);
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
int j = nbttaglist.getTag(i).getShort("id");
int k = nbttaglist.getTag(i).getShort("lvl");
if (Enchantment.getEnchantmentById(j) != null)
{
@ -82,12 +82,12 @@ public class ItemEnchantedBook extends Item
*/
public void addEnchantment(ItemStack stack, RngEnchantment enchantment)
{
NBTTagList nbttaglist = this.getEnchantments(stack);
NBTTagTagList nbttaglist = this.getEnchantments(stack);
boolean flag = true;
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
if (nbttagcompound.getShort("id") == enchantment.enchantmentobj.effectId)
{
@ -106,7 +106,7 @@ public class ItemEnchantedBook extends Item
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setShort("id", (short)enchantment.enchantmentobj.effectId);
nbttagcompound1.setShort("lvl", (short)enchantment.enchantmentLevel);
nbttaglist.appendTag(nbttagcompound1);
nbttaglist.add(nbttagcompound1);
}
if (!stack.hasTagCompound())
@ -114,7 +114,7 @@ public class ItemEnchantedBook extends Item
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setTag("StoredEnchantments", nbttaglist);
stack.getTagCompound().setTagList("StoredEnchantments", nbttaglist);
}
/**
@ -153,7 +153,7 @@ public class ItemEnchantedBook extends Item
//
// protected boolean validateNbt(NBTTagCompound tag) {
// if(tag.hasKey("StoredEnchantments")) {
// if(!tag.hasKey("StoredEnchantments", 9)) {
// if(!tag.hasList("StoredEnchantments")) {
// return false;
// }
// NBTTagList ench = tag.getTagList("StoredEnchantments", 10);
@ -166,7 +166,7 @@ public class ItemEnchantedBook extends Item
// Enchantment[] ecn = new Enchantment[ench.tagCount()];
// for(int e = 0; e < ench.tagCount(); e++) {
// NBTTagCompound ec = ench.getCompoundTagAt(e);
// if(ec.getKeySet().size() != 2 || !ec.hasKey("id", 2) || !ec.hasKey("lvl", 2)) {
// if(ec.getKeySet().size() != 2 || !ec.hasShort("id") || !ec.hasShort("lvl")) {
// return false;
// }
// int id = ec.getShort("id");

View file

@ -6,7 +6,7 @@ import common.collect.Lists;
import common.entity.item.EntityFireworks;
import common.entity.npc.EntityNPC;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.util.BlockPos;
import common.util.Facing;
import common.world.World;
@ -43,22 +43,22 @@ public class ItemFirework extends Item
{
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Fireworks");
NBTTagCompound nbttagcompound = stack.getTagCompound().getTag("Fireworks");
if (nbttagcompound != null)
{
if (nbttagcompound.hasKey("Flight", 99))
if (nbttagcompound.hasByte("Flight"))
{
tooltip.add("Flugdauer: " + nbttagcompound.getByte("Flight"));
}
NBTTagList nbttaglist = nbttagcompound.getTagList("Explosions", 10);
NBTTagTagList nbttaglist = nbttagcompound.getTagList("Explosions");
if (nbttaglist != null && nbttaglist.tagCount() > 0)
if (nbttaglist != null && nbttaglist.size() > 0)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound1 = nbttaglist.getTag(i);
List<String> list = Lists.<String>newArrayList();
ItemFireworkCharge.addExplosionInfo(nbttagcompound1, list);

View file

@ -6,9 +6,7 @@ import common.color.DyeColor;
import common.entity.npc.EntityNPC;
import common.model.Model;
import common.model.ModelProvider;
import common.nbt.NBTBase;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagIntArray;
public class ItemFireworkCharge extends Item
{
@ -22,16 +20,14 @@ public class ItemFireworkCharge extends Item
}
else
{
NBTBase nbtbase = getExplosionTag(stack, "Colors");
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound().getTag("Explosion");
if (!(nbtbase instanceof NBTTagIntArray))
if (nbttagcompound != null)
{
return 9079434;
}
else
{
NBTTagIntArray nbttagintarray = (NBTTagIntArray)nbtbase;
int[] aint = nbttagintarray.getIntArray();
if(nbttagcompound.hasIntArray("Colors")) {
int[] aint = nbttagcompound.getIntArray("Colors");
if (aint.length == 1)
{
@ -58,22 +54,10 @@ public class ItemFireworkCharge extends Item
}
}
}
public static NBTBase getExplosionTag(ItemStack stack, String key)
{
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Explosion");
if (nbttagcompound != null)
{
return nbttagcompound.getTag(key);
return 9079434;
}
}
return null;
}
/**
* allows items to add custom lines of information to the mouseover description
*/
@ -81,7 +65,7 @@ public class ItemFireworkCharge extends Item
{
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Explosion");
NBTTagCompound nbttagcompound = stack.getTagCompound().getTag("Explosion");
if (nbttagcompound != null)
{
@ -175,14 +159,14 @@ public class ItemFireworkCharge extends Item
tooltip.add(s1);
}
boolean flag3 = nbt.getBoolean("Trail");
boolean flag3 = nbt.getBool("Trail");
if (flag3)
{
tooltip.add("Schweif");
}
boolean flag4 = nbt.getBoolean("Flicker");
boolean flag4 = nbt.getBool("Flicker");
if (flag4)
{

View file

@ -40,7 +40,7 @@ public class ItemPotion extends Item
public List<PotionEffect> getEffects(ItemStack stack)
{
// if (stack.hasTagCompound() && stack.getTagCompound().hasKey("CustomPotionEffects", 9))
// if (stack.hasTagCompound() && stack.getTagCompound().hasList("CustomPotionEffects"))
// {
// List<PotionEffect> list1 = Lists.<PotionEffect>newArrayList();
// NBTTagList nbttaglist = stack.getTagCompound().getTagList("CustomPotionEffects", 10);
@ -414,7 +414,7 @@ public class ItemPotion extends Item
// if(!adv) {
// return false;
// }
// if(!tag.hasKey("CustomPotionEffects", 9)) {
// if(!tag.hasList("CustomPotionEffects")) {
// return false;
// }
// NBTTagList effects = tag.getTagList("CustomPotionEffects", 10);

View file

@ -84,7 +84,7 @@ public class ItemSign extends Item
//
// protected boolean validateNbt(NBTTagCompound tag) {
// if(tag.hasKey("BlockEntityTag")) {
// if(!tag.hasKey("BlockEntityTag", 10)) {
// if(!tag.hasTag("BlockEntityTag")) {
// return false;
// }
// }

View file

@ -88,7 +88,7 @@ public class ItemSkull extends Item
// {
// NBTTagCompound nbttagcompound = stack.getTagCompound();
//
// if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
// if (nbttagcompound.hasString("SkullOwner") && nbttagcompound.getString("SkullOwner").length() > 0)
// {
// user = nbttagcompound.getString("SkullOwner");
// }
@ -153,7 +153,7 @@ public class ItemSkull extends Item
// {
// if (stack.hasTagCompound())
// {
// if (stack.getTagCompound().hasKey("SkullOwner", 8))
// if (stack.getTagCompound().hasString("SkullOwner"))
// {
// return super.getDisplay(stack) + " von " + stack.getTagCompound().getString("SkullOwner");
// }
@ -171,7 +171,7 @@ public class ItemSkull extends Item
//// if(!adv) {
//// return false;
//// }
// if(!tag.hasKey("SkullOwner", 8)) {
// if(!tag.hasString("SkullOwner")) {
// return false;
// }
// }

View file

@ -21,7 +21,7 @@ import common.init.BlockRegistry;
import common.init.ItemRegistry;
import common.nbt.NBTBase;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
@ -198,7 +198,7 @@ public final class ItemStack
{
String resourcelocation = ItemRegistry.REGISTRY.getNameForObject(this.item);
nbt.setString("id", resourcelocation == null ? "air" : resourcelocation.toString());
nbt.setInteger("Count", this.stackSize);
nbt.setInt("Count", this.stackSize);
nbt.setShort("Damage", (short)this.itemDamage);
if (this.stackTagCompound != null)
@ -214,7 +214,7 @@ public final class ItemStack
*/
public void readFromNBT(NBTTagCompound nbt)
{
if (nbt.hasKey("id", 8))
if (nbt.hasString("id"))
{
this.item = ItemRegistry.getRegisteredItem(nbt.getString("id"));
}
@ -223,7 +223,7 @@ public final class ItemStack
this.item = ItemRegistry.getItemById(nbt.getShort("id"));
}
this.stackSize = nbt.getInteger("Count");
this.stackSize = nbt.getInt("Count");
this.itemDamage = nbt.getShort("Damage");
if (this.itemDamage < 0)
@ -231,9 +231,9 @@ public final class ItemStack
this.itemDamage = 0;
}
if (nbt.hasKey("tag", 10))
if (nbt.hasTag("tag"))
{
this.stackTagCompound = nbt.getCompoundTag("tag");
this.stackTagCompound = nbt.getTag("tag");
if (this.item != null)
{
@ -581,9 +581,9 @@ public final class ItemStack
*/
public NBTTagCompound getSubCompound(String key, boolean create)
{
if (this.stackTagCompound != null && this.stackTagCompound.hasKey(key, 10))
if (this.stackTagCompound != null && this.stackTagCompound.hasTag(key))
{
return this.stackTagCompound.getCompoundTag(key);
return this.stackTagCompound.getTag(key);
}
else if (create)
{
@ -597,9 +597,9 @@ public final class ItemStack
}
}
public NBTTagList getEnchantmentTagList()
public NBTTagTagList getEnchantmentTagList()
{
return this.stackTagCompound == null ? null : this.stackTagCompound.getTagList("ench", 10);
return this.stackTagCompound == null ? null : this.stackTagCompound.getTagList("ench");
}
/**
@ -617,11 +617,11 @@ public final class ItemStack
{
String s = this.getItem().getDisplay(this);
if (this.stackTagCompound != null && this.stackTagCompound.hasKey("Name", 8))
if (this.stackTagCompound != null && this.stackTagCompound.hasString("Name"))
{
// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display");
//
// if (nbttagcompound.hasKey("Name", 8))
// if (nbttagcompound.hasString("Name"))
// {
s = this.stackTagCompound.getString("Name");
// }
@ -645,7 +645,7 @@ public final class ItemStack
this.stackTagCompound = new NBTTagCompound();
}
// if (!this.stackTagCompound.hasKey("display", 10))
// if (!this.stackTagCompound.hasTag("display"))
// {
// this.stackTagCompound.setTag("display", new NBTTagCompound());
// }
@ -661,7 +661,7 @@ public final class ItemStack
// this.stackTagCompound = new NBTTagCompound();
// }
//
// if (!this.stackTagCompound.hasKey("display", 10))
// if (!this.stackTagCompound.hasTag("display"))
// {
// this.stackTagCompound.setTag("display", new NBTTagCompound());
// }
@ -681,7 +681,7 @@ public final class ItemStack
// return null;
// }
//
// if (!this.stackTagCompound.hasKey("display", 10))
// if (!this.stackTagCompound.hasTag("display"))
// {
// return null;
// }
@ -727,12 +727,12 @@ public final class ItemStack
{
if (this.stackTagCompound != null)
{
if (this.stackTagCompound.hasKey("Name", 8))
if (this.stackTagCompound.hasString("Name"))
{
// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display");
this.stackTagCompound.removeTag("Name");
this.stackTagCompound.remove("Name");
if (this.stackTagCompound.hasNoTags())
if (this.stackTagCompound.isEmpty())
{
// this.stackTagCompound.removeTag("display");
//
@ -749,7 +749,7 @@ public final class ItemStack
// {
// if (this.stackTagCompound != null)
// {
// if (this.stackTagCompound.hasKey("display", 10))
// if (this.stackTagCompound.hasTag("display"))
// {
// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display");
// nbttagcompound.removeTag("Lore");
@ -772,7 +772,7 @@ public final class ItemStack
*/
public boolean hasDisplayName()
{
return this.stackTagCompound != null && this.stackTagCompound.hasKey("Name", 8);
return this.stackTagCompound != null && this.stackTagCompound.hasString("Name");
}
public List<String> getTooltip(EntityNPC playerIn)
@ -842,14 +842,14 @@ public final class ItemStack
{
// if ((i1 & 1) == 0)
// {
NBTTagList nbttaglist = this.getEnchantmentTagList();
NBTTagTagList nbttaglist = this.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int j = 0; j < nbttaglist.tagCount(); ++j)
for (int j = 0; j < nbttaglist.size(); ++j)
{
int k = nbttaglist.getCompoundTagAt(j).getShort("id");
int l = nbttaglist.getCompoundTagAt(j).getShort("lvl");
int k = nbttaglist.getTag(j).getShort("id");
int l = nbttaglist.getTag(j).getShort("lvl");
if (Enchantment.getEnchantmentById(k) != null)
{
@ -859,11 +859,11 @@ public final class ItemStack
}
// }
// if (this.stackTagCompound.hasKey("display", 10))
// if (this.stackTagCompound.hasTag("display"))
// {
// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display");
//
// if (nbttagcompound.hasKey("color", 3))
// if (nbttagcompound.hasInt("color"))
// {
// if (advanced)
// {
@ -934,12 +934,12 @@ public final class ItemStack
}
}
if (this.hasTagCompound() && this.getTagCompound().getBoolean("Unbreakable")) // && (i1 & 4) == 0)
if (this.hasTagCompound() && this.getTagCompound().getBool("Unbreakable")) // && (i1 & 4) == 0)
{
list.add(TextColor.BLUE + "Unzerstörbar");
}
// if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanDestroy", 9) && (i1 & 8) == 0)
// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanDestroy") && (i1 & 8) == 0)
// {
// NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8);
//
@ -964,7 +964,7 @@ public final class ItemStack
// }
// }
//
// if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanPlaceOn", 9) && (i1 & 16) == 0)
// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanPlaceOn") && (i1 & 16) == 0)
// {
// NBTTagList nbttaglist3 = this.stackTagCompound.getTagList("CanPlaceOn", 8);
//
@ -1036,16 +1036,16 @@ public final class ItemStack
this.setTagCompound(new NBTTagCompound());
}
if (!this.stackTagCompound.hasKey("ench", 9))
if (!this.stackTagCompound.hasTagList("ench"))
{
this.stackTagCompound.setTag("ench", new NBTTagList());
this.stackTagCompound.setTagList("ench", new NBTTagTagList());
}
NBTTagList nbttaglist = this.stackTagCompound.getTagList("ench", 10);
NBTTagTagList nbttaglist = this.stackTagCompound.getTagList("ench");
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setShort("id", (short)ench.effectId);
nbttagcompound.setShort("lvl", (short)(/* (byte) */ level));
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
/**
@ -1055,17 +1055,17 @@ public final class ItemStack
if(this.stackTagCompound == null) {
return false;
}
if(!this.stackTagCompound.hasKey("ench", 9)) {
if(!this.stackTagCompound.hasTagList("ench")) {
return false;
}
NBTTagList oldEnch = this.stackTagCompound.getTagList("ench", 10);
NBTTagList newEnch = new NBTTagList();
NBTTagTagList oldEnch = this.stackTagCompound.getTagList("ench");
NBTTagTagList newEnch = new NBTTagTagList();
boolean changed = false;
NBTTagCompound tag;
for(int z = 0; z < oldEnch.tagCount(); z++) {
tag = oldEnch.getCompoundTagAt(z);
for(int z = 0; z < oldEnch.size(); z++) {
tag = oldEnch.getTag(z);
if(tag.getShort("id") != ench.effectId) {
newEnch.appendTag(tag);
newEnch.add(tag);
}
else {
changed = true;
@ -1074,14 +1074,14 @@ public final class ItemStack
if(!changed) {
return false;
}
if(newEnch.tagCount() == 0) {
this.stackTagCompound.removeTag("ench");
if(this.stackTagCompound.hasNoTags()) {
if(newEnch.size() == 0) {
this.stackTagCompound.remove("ench");
if(this.stackTagCompound.isEmpty()) {
this.stackTagCompound = null;
}
}
else {
this.stackTagCompound.setTag("ench", newEnch);
this.stackTagCompound.setTagList("ench", newEnch);
}
return true;
}
@ -1093,11 +1093,11 @@ public final class ItemStack
if(this.stackTagCompound == null) {
return false;
}
if(!this.stackTagCompound.hasKey("ench", 9)) {
if(!this.stackTagCompound.hasTagList("ench")) {
return false;
}
this.stackTagCompound.removeTag("ench");
if(this.stackTagCompound.hasNoTags()) {
this.stackTagCompound.remove("ench");
if(this.stackTagCompound.isEmpty()) {
this.stackTagCompound = null;
}
return true;
@ -1108,7 +1108,7 @@ public final class ItemStack
*/
public boolean isItemEnchanted()
{
return this.stackTagCompound != null && this.stackTagCompound.hasKey("ench", 9);
return this.stackTagCompound != null && this.stackTagCompound.hasTagList("ench");
}
public void setTagInfo(String key, NBTBase value)
@ -1118,7 +1118,7 @@ public final class ItemStack
this.setTagCompound(new NBTTagCompound());
}
this.stackTagCompound.setTag(key, value);
this.stackTagCompound.set(key, value);
}
// public boolean canEditBlocks()
@ -1155,7 +1155,7 @@ public final class ItemStack
*/
public int getRepairCost()
{
return this.hasTagCompound() && this.stackTagCompound.hasKey("RepairCost", 3) ? this.stackTagCompound.getInteger("RepairCost") : 0;
return this.hasTagCompound() && this.stackTagCompound.hasInt("RepairCost") ? this.stackTagCompound.getInt("RepairCost") : 0;
}
/**
@ -1167,11 +1167,11 @@ public final class ItemStack
if(this.stackTagCompound == null) {
return;
}
if(!this.stackTagCompound.hasKey("RepairCost", 3)) {
if(!this.stackTagCompound.hasInt("RepairCost")) {
return;
}
this.stackTagCompound.removeTag("RepairCost");
if(this.stackTagCompound.hasNoTags()) {
this.stackTagCompound.remove("RepairCost");
if(this.stackTagCompound.isEmpty()) {
this.stackTagCompound = null;
}
return;
@ -1182,14 +1182,14 @@ public final class ItemStack
this.stackTagCompound = new NBTTagCompound();
}
this.stackTagCompound.setInteger("RepairCost", cost);
this.stackTagCompound.setInt("RepairCost", cost);
}
public Map<Attribute, Set<AttributeModifier>> getAttributeModifiers(int type)
{
Map<Attribute, Set<AttributeModifier>> multimap;
// if ((type & 1) == 1 && this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9))
// if ((type & 1) == 1 && this.hasTagCompound() && this.stackTagCompound.hasList("AttributeModifiers"))
// {
// multimap = HashMultimap.<String, AttributeModifier>create();
// NBTTagList nbttaglist = this.stackTagCompound.getTagList("AttributeModifiers", 10);
@ -1236,7 +1236,7 @@ public final class ItemStack
// {
// this.canDestroyCacheBlock = blockIn;
//
// if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanDestroy", 9))
// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanDestroy"))
// {
// NBTTagList nbttaglist = this.stackTagCompound.getTagList("CanDestroy", 8);
//
@ -1267,7 +1267,7 @@ public final class ItemStack
// {
// this.canPlaceOnCacheBlock = blockIn;
//
// if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanPlaceOn", 9))
// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanPlaceOn"))
// {
// NBTTagList nbttaglist = this.stackTagCompound.getTagList("CanPlaceOn", 8);
//

View file

@ -4,120 +4,57 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public abstract class NBTBase
{
public static final String[] NBT_TYPES = new String[] {"END", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", "BYTE[]", "STRING", "LIST", "COMPOUND", "INT[]"};
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
abstract void write(DataOutput output) throws IOException;
abstract void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException;
public abstract String toString();
/**
* Gets the type byte for the tag.
*/
public abstract byte getId();
/**
* Creates a new NBTBase object that corresponds with the passed in id.
*/
protected static NBTBase createNewByType(byte id)
{
switch (id)
{
public abstract class NBTBase {
protected static NBTBase createNewByType(byte id) {
switch(id) {
case 0:
return new NBTTagEnd();
case 1:
return new NBTTagByte();
case 2:
return new NBTTagShort();
case 3:
return new NBTTagInt();
case 4:
return new NBTTagLong();
case 5:
return new NBTTagFloat();
case 6:
return new NBTTagDouble();
case 7:
return new NBTTagByteArray();
case 8:
return new NBTTagString();
case 9:
return new NBTTagList();
return new NBTTagStringList();
case 10:
return new NBTTagCompound();
case 11:
return new NBTTagIntArray();
case 12:
return new NBTTagTagList();
case 13:
return new NBTTagFloatList();
case 14:
return new NBTTagDoubleList();
case 15:
return new NBTTagIntArrayList();
default:
return null;
}
}
/**
* Creates a clone of the tag.
*/
abstract void write(DataOutput output) throws IOException;
abstract void read(DataInput input, int depth, SizeTracker tracker) throws IOException;
public abstract String toString();
public abstract byte getId();
public abstract NBTBase copy();
/**
* Return whether this compound has no tags.
*/
public boolean hasNoTags()
{
return false;
public boolean equals(Object other) {
return other instanceof NBTBase && this.getId() == ((NBTBase)other).getId();
}
public boolean equals(Object p_equals_1_)
{
if (!(p_equals_1_ instanceof NBTBase))
{
return false;
}
else
{
NBTBase nbtbase = (NBTBase)p_equals_1_;
return this.getId() == nbtbase.getId();
}
}
public int hashCode()
{
public int hashCode() {
return this.getId();
}
protected String getString()
{
return this.toString();
}
public abstract static class NBTPrimitive extends NBTBase
{
public abstract long getLong();
public abstract int getInt();
public abstract short getShort();
public abstract byte getByte();
public abstract double getDouble();
public abstract float getFloat();
}
}

View file

@ -1,9 +1,7 @@
package common.nbt;
public class NBTException extends Exception
{
public NBTException(String p_i45136_1_)
{
super(p_i45136_1_);
public class NBTException extends Exception {
public NBTException(String message) {
super(message);
}
}

View file

@ -17,20 +17,17 @@ public class NBTLoader {
public static NBTTagCompound readGZip(File file) throws IOException {
DataInputStream in = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file))));
NBTTagCompound tag;
try {
tag = read(in, NBTSizeTracker.INFINITE);
tag = read(in, SizeTracker.INFINITE);
}
finally {
in.close();
}
return tag;
}
public static void writeGZip(NBTTagCompound tag, File file) throws IOException {
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file))));
try {
write(tag, out);
}
@ -39,110 +36,13 @@ public class NBTLoader {
}
}
// public static void safeWrite(NBTTagCompound p_74793_0_, File p_74793_1_) throws IOException
// {
// File file1 = new File(p_74793_1_.getAbsolutePath() + "_tmp");
//
// if (file1.exists())
// {
// file1.delete();
// }
//
// write(p_74793_0_, file1);
//
// if (p_74793_1_.exists())
// {
// p_74793_1_.delete();
// }
//
// if (p_74793_1_.exists())
// {
// throw new IOException("Failed to delete " + p_74793_1_);
// }
// else
// {
// file1.renameTo(p_74793_1_);
// }
// }
// public static void write(NBTTagCompound p_74795_0_, File p_74795_1_) throws IOException
// {
// DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(p_74795_1_));
//
// try
// {
// write(p_74795_0_, dataoutputstream);
// }
// finally
// {
// dataoutputstream.close();
// }
// }
// public static NBTTagCompound read(File p_74797_0_) throws IOException
// {
// if (!p_74797_0_.exists())
// {
// return null;
// }
// else
// {
// DataInputStream datainputstream = new DataInputStream(new FileInputStream(p_74797_0_));
// NBTTagCompound nbttagcompound;
//
// try
// {
// nbttagcompound = read(datainputstream, NBTSizeTracker.INFINITE);
// }
// finally
// {
// datainputstream.close();
// }
//
// return nbttagcompound;
// }
// }
public static NBTTagCompound read(DataInputStream in) throws IOException {
return read(in, NBTSizeTracker.INFINITE);
}
public static NBTTagCompound read(DataInput in, NBTSizeTracker tracker) throws IOException {
NBTBase tag = readType(in, 0, tracker);
if(tag instanceof NBTTagCompound) {
return (NBTTagCompound)tag;
}
else {
throw new IOException("Root tag must be a named compound tag");
}
public static NBTTagCompound read(DataInput in, SizeTracker tracker) throws IOException {
NBTTagCompound tag = new NBTTagCompound();
tag.read(in, 0, tracker);
return tag;
}
public static void write(NBTTagCompound tag, DataOutput out) throws IOException {
writeTag(tag, out);
}
private static void writeTag(NBTBase tag, DataOutput out) throws IOException {
out.writeByte(tag.getId());
if(tag.getId() != 0) {
out.writeUTF("");
tag.write(out);
}
}
private static NBTBase readType(DataInput in, int depth, NBTSizeTracker tracker) throws IOException {
byte type = in.readByte();
if(type == 0) {
return new NBTTagEnd();
}
else {
in.readUTF();
NBTBase tag = NBTBase.createNewByType(type);
tag.read(in, depth, tracker);
return tag;
}
}
}

View file

@ -401,7 +401,7 @@ public class NBTParser
for (NBTParser.Any jsontonbt$any : this.field_150491_b)
{
nbttagcompound.setTag(jsontonbt$any.json, jsontonbt$any.parse());
nbttagcompound.set(jsontonbt$any.json, jsontonbt$any.parse());
}
return nbttagcompound;
@ -419,11 +419,28 @@ public class NBTParser
public NBTBase parse() throws NBTException
{
NBTTagList nbttaglist = new NBTTagList();
NBTTagList nbttaglist = null;
for (NBTParser.Any jsontonbt$any : this.field_150492_b)
{
nbttaglist.appendTag(jsontonbt$any.parse());
NBTBase tag = jsontonbt$any.parse();
if(nbttaglist == null) {
switch(tag.getId()) {
case 8:
nbttaglist = new NBTTagStringList();
case 10:
nbttaglist = new NBTTagTagList();
case 5:
nbttaglist = new NBTTagFloatList();
case 6:
nbttaglist = new NBTTagDoubleList();
case 11:
nbttaglist = new NBTTagIntArrayList();
default:
throw new NBTException("Type cannot be put in a list: " + jsontonbt$any.json);
}
}
nbttaglist.add(tag);
}
return nbttaglist;

View file

@ -1,31 +0,0 @@
package common.nbt;
public class NBTSizeTracker
{
public static final NBTSizeTracker INFINITE = new NBTSizeTracker(0L)
{
public void read(long bits)
{
}
};
private final long max;
private long read;
public NBTSizeTracker(long max)
{
this.max = max;
}
/**
* Tracks the reading of the given amount of bits(!)
*/
public void read(long bits)
{
this.read += bits / 8L;
if (this.read > this.max)
{
throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.read + "bytes where max allowed: " + this.max);
}
}
}

View file

@ -4,9 +4,8 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class NBTTagByte extends NBTBase.NBTPrimitive
class NBTTagByte extends NBTBase
{
/** The byte value for the tag. */
private byte data;
NBTTagByte()
@ -18,23 +17,17 @@ public class NBTTagByte extends NBTBase.NBTPrimitive
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
output.writeByte(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
{
sizeTracker.read(72L);
sizeTracker.read(9);
this.data = input.readByte();
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
return (byte)1;
@ -45,19 +38,16 @@ public class NBTTagByte extends NBTBase.NBTPrimitive
return "" + this.data + "b";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
return new NBTTagByte(this.data);
}
public boolean equals(Object p_equals_1_)
public boolean equals(Object other)
{
if (super.equals(p_equals_1_))
if (super.equals(other))
{
NBTTagByte nbttagbyte = (NBTTagByte)p_equals_1_;
NBTTagByte nbttagbyte = (NBTTagByte)other;
return this.data == nbttagbyte.data;
}
else
@ -71,33 +61,8 @@ public class NBTTagByte extends NBTBase.NBTPrimitive
return super.hashCode() ^ this.data;
}
public long getLong()
{
return (long)this.data;
}
public int getInt()
{
return this.data;
}
public short getShort()
{
return (short)this.data;
}
public byte getByte()
{
return this.data;
}
public double getDouble()
{
return (double)this.data;
}
public float getFloat()
{
return (float)this.data;
}
}

View file

@ -5,73 +5,52 @@ import java.io.DataOutput;
import java.io.IOException;
import java.util.Arrays;
public class NBTTagByteArray extends NBTBase
{
/** The byte array stored in the tag. */
class NBTTagByteArray extends NBTBase {
private byte[] data;
NBTTagByteArray()
{
NBTTagByteArray() {
}
public NBTTagByteArray(byte[] data)
{
public NBTTagByteArray(byte[] data) {
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
void write(DataOutput output) throws IOException {
output.writeInt(this.data.length);
output.write(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
sizeTracker.read(192L);
int i = input.readInt();
sizeTracker.read((long)(8 * i));
this.data = new byte[i];
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
tracker.read(24);
int len = input.readInt();
tracker.read(len);
this.data = new byte[len];
input.readFully(this.data);
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
public byte getId() {
return (byte)7;
}
public String toString()
{
public String toString() {
return "[" + this.data.length + " bytes]";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
byte[] abyte = new byte[this.data.length];
System.arraycopy(this.data, 0, abyte, 0, this.data.length);
return new NBTTagByteArray(abyte);
public NBTBase copy() {
byte[] data = new byte[this.data.length];
System.arraycopy(this.data, 0, data, 0, this.data.length);
return new NBTTagByteArray(data);
}
public boolean equals(Object p_equals_1_)
{
return super.equals(p_equals_1_) ? Arrays.equals(this.data, ((NBTTagByteArray)p_equals_1_).data) : false;
public boolean equals(Object other) {
return super.equals(other) && Arrays.equals(this.data, ((NBTTagByteArray)other).data);
}
public int hashCode()
{
public int hashCode() {
return super.hashCode() ^ Arrays.hashCode(this.data);
}
public byte[] getByteArray()
{
public byte[] getByteArray() {
return this.data;
}
}

View file

@ -10,475 +10,308 @@ import common.collect.Maps;
import java.util.Set;
public class NBTTagCompound extends NBTBase
{
private Map<String, NBTBase> tagMap = Maps.<String, NBTBase>newHashMap();
public class NBTTagCompound extends NBTBase {
private Map<String, NBTBase> tags = Maps.<String, NBTBase>newHashMap();
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
for (String s : this.tagMap.keySet())
{
NBTBase nbtbase = (NBTBase)this.tagMap.get(s);
writeEntry(s, nbtbase, output);
void write(DataOutput output) throws IOException {
for(String key : this.tags.keySet()) {
NBTBase tag = this.tags.get(key);
output.writeByte(tag.getId());
if(tag.getId() != 0) {
output.writeUTF(key);
tag.write(output);
}
}
output.writeByte(0);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
sizeTracker.read(384L);
if (depth > 512)
{
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
tracker.read(48);
if(depth > 512)
throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512");
}
else
{
this.tagMap.clear();
byte b0;
while ((b0 = readType(input, sizeTracker)) != 0)
{
String s = readKey(input, sizeTracker);
sizeTracker.read((long)(224 + 16 * s.length()));
NBTBase nbtbase = readNBT(b0, s, input, depth + 1, sizeTracker);
if (this.tagMap.put(s, nbtbase) != null)
{
sizeTracker.read(288L);
}
}
this.tags.clear();
byte id;
while((id = input.readByte()) != 0) {
String key = input.readUTF();
tracker.read(28 + 2 * key.length());
NBTBase tag = NBTBase.createNewByType(id);
tag.read(input, depth + 1, tracker);
if(this.tags.put(key, tag) != null)
tracker.read(36);
}
}
public Set<String> getKeySet()
{
return this.tagMap.keySet();
public Set<String> getKeySet() {
return this.tags.keySet();
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
public byte getId() {
return (byte)10;
}
/**
* Stores the given tag into the map with the given string key. This is mostly used to store tag lists.
*/
public void setTag(String key, NBTBase value)
{
this.tagMap.put(key, value);
public void set(String key, NBTBase value) {
this.tags.put(key, value);
}
/**
* Stores a new NBTTagByte with the given byte value into the map with the given string key.
*/
public void setByte(String key, byte value)
{
this.tagMap.put(key, new NBTTagByte(value));
public void setTag(String key, NBTTagCompound value) {
this.tags.put(key, value);
}
/**
* Stores a new NBTTagShort with the given short value into the map with the given string key.
*/
public void setShort(String key, short value)
{
this.tagMap.put(key, new NBTTagShort(value));
public void setFloatList(String key, NBTTagFloatList value) {
this.tags.put(key, value);
}
/**
* Stores a new NBTTagInt with the given integer value into the map with the given string key.
*/
public void setInteger(String key, int value)
{
this.tagMap.put(key, new NBTTagInt(value));
public void setDoubleList(String key, NBTTagDoubleList value) {
this.tags.put(key, value);
}
/**
* Stores a new NBTTagLong with the given long value into the map with the given string key.
*/
public void setLong(String key, long value)
{
this.tagMap.put(key, new NBTTagLong(value));
public void setStringList(String key, NBTTagStringList value) {
this.tags.put(key, value);
}
/**
* Stores a new NBTTagFloat with the given float value into the map with the given string key.
*/
public void setFloat(String key, float value)
{
this.tagMap.put(key, new NBTTagFloat(value));
public void setIntArrayList(String key, NBTTagIntArrayList value) {
this.tags.put(key, value);
}
/**
* Stores a new NBTTagDouble with the given double value into the map with the given string key.
*/
public void setDouble(String key, double value)
{
this.tagMap.put(key, new NBTTagDouble(value));
public void setTagList(String key, NBTTagTagList value) {
this.tags.put(key, value);
}
/**
* Stores a new NBTTagString with the given string value into the map with the given string key.
*/
public void setString(String key, String value)
{
this.tagMap.put(key, new NBTTagString(value));
public void setByte(String key, byte value) {
this.tags.put(key, new NBTTagByte(value));
}
/**
* Stores a new NBTTagByteArray with the given array as data into the map with the given string key.
*/
public void setByteArray(String key, byte[] value)
{
this.tagMap.put(key, new NBTTagByteArray(value));
public void setShort(String key, short value) {
this.tags.put(key, new NBTTagShort(value));
}
/**
* Stores a new NBTTagIntArray with the given array as data into the map with the given string key.
*/
public void setIntArray(String key, int[] value)
{
this.tagMap.put(key, new NBTTagIntArray(value));
public void setInt(String key, int value) {
this.tags.put(key, new NBTTagInt(value));
}
/**
* Stores the given boolean value as a NBTTagByte, storing 1 for true and 0 for false, using the given string key.
*/
public void setBoolean(String key, boolean value)
{
public void setLong(String key, long value) {
this.tags.put(key, new NBTTagLong(value));
}
public void setFloat(String key, float value) {
this.tags.put(key, new NBTTagFloat(value));
}
public void setDouble(String key, double value) {
this.tags.put(key, new NBTTagDouble(value));
}
public void setString(String key, String value) {
this.tags.put(key, new NBTTagString(value));
}
public void setByteArray(String key, byte[] value) {
this.tags.put(key, new NBTTagByteArray(value));
}
public void setIntArray(String key, int[] value) {
this.tags.put(key, new NBTTagIntArray(value));
}
public void setBool(String key, boolean value) {
this.setByte(key, (byte)(value ? 1 : 0));
}
/**
* gets a generic tag with the specified name
*/
public NBTBase getTag(String key)
{
return (NBTBase)this.tagMap.get(key);
public NBTBase get(String key) {
return this.tags.get(key);
}
/**
* Gets the ID byte for the given tag key
*/
public byte getTagId(String key)
{
NBTBase nbtbase = (NBTBase)this.tagMap.get(key);
return nbtbase != null ? nbtbase.getId() : 0;
public byte getTagId(String key) {
NBTBase tag = this.tags.get(key);
return tag != null ? tag.getId() : 0;
}
/**
* Returns whether the given string has been previously stored as a key in the map.
*/
public boolean hasKey(String key)
{
return this.tagMap.containsKey(key);
private boolean hasKey(String key, int type) {
int id = this.getTagId(key);
return id == type || (type == 99 && id >= 1 && id <= 6);
}
public boolean hasKey(String key, int type)
{
int i = this.getTagId(key);
if (i == type)
{
return true;
}
else if (type != 99)
{
if (i > 0)
{
;
public boolean hasBool(String key) {
return this.hasByte(key);
}
return false;
}
else
{
return i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i == 6;
}
public boolean hasByte(String key) {
return this.hasKey(key, 1);
}
/**
* Retrieves a byte value using the specified key, or 0 if no such key was stored.
*/
public byte getByte(String key)
{
try
{
return !this.hasKey(key, 99) ? 0 : ((NBTBase.NBTPrimitive)this.tagMap.get(key)).getByte();
}
catch (ClassCastException var3)
{
return (byte)0;
}
public boolean hasShort(String key) {
return this.hasKey(key, 2);
}
/**
* Retrieves a short value using the specified key, or 0 if no such key was stored.
*/
public short getShort(String key)
{
try
{
return !this.hasKey(key, 99) ? 0 : ((NBTBase.NBTPrimitive)this.tagMap.get(key)).getShort();
}
catch (ClassCastException var3)
{
return (short)0;
}
public boolean hasInt(String key) {
return this.hasKey(key, 3);
}
/**
* Retrieves an integer value using the specified key, or 0 if no such key was stored.
*/
public int getInteger(String key)
{
try
{
return !this.hasKey(key, 99) ? 0 : ((NBTBase.NBTPrimitive)this.tagMap.get(key)).getInt();
}
catch (ClassCastException var3)
{
return 0;
}
public boolean hasLong(String key) {
return this.hasKey(key, 4);
}
/**
* Retrieves a long value using the specified key, or 0 if no such key was stored.
*/
public long getLong(String key)
{
try
{
return !this.hasKey(key, 99) ? 0L : ((NBTBase.NBTPrimitive)this.tagMap.get(key)).getLong();
}
catch (ClassCastException var3)
{
return 0L;
}
public boolean hasFloat(String key) {
return this.hasKey(key, 5);
}
/**
* Retrieves a float value using the specified key, or 0 if no such key was stored.
*/
public float getFloat(String key)
{
try
{
return !this.hasKey(key, 99) ? 0.0F : ((NBTBase.NBTPrimitive)this.tagMap.get(key)).getFloat();
}
catch (ClassCastException var3)
{
return 0.0F;
}
public boolean hasDouble(String key) {
return this.hasKey(key, 6);
}
/**
* Retrieves a double value using the specified key, or 0 if no such key was stored.
*/
public double getDouble(String key)
{
try
{
return !this.hasKey(key, 99) ? 0.0D : ((NBTBase.NBTPrimitive)this.tagMap.get(key)).getDouble();
}
catch (ClassCastException var3)
{
return 0.0D;
}
public boolean hasString(String key) {
return this.hasKey(key, 8);
}
/**
* Retrieves a string value using the specified key, or an empty string if no such key was stored.
*/
public String getString(String key)
{
try
{
return !this.hasKey(key, 8) ? "" : ((NBTBase)this.tagMap.get(key)).getString();
}
catch (ClassCastException var3)
{
return "";
}
public boolean hasByteArray(String key) {
return this.hasKey(key, 7);
}
/**
* Retrieves a byte array using the specified key, or a zero-length array if no such key was stored.
*/
public byte[] getByteArray(String key)
{
return !this.hasKey(key, 7) ? new byte[0] : ((NBTTagByteArray)this.tagMap.get(key)).getByteArray();
public boolean hasIntArray(String key) {
return this.hasKey(key, 11);
}
/**
* Retrieves an int array using the specified key, or a zero-length array if no such key was stored.
*/
public int[] getIntArray(String key)
{
return !this.hasKey(key, 11) ? new int[0] : ((NBTTagIntArray)this.tagMap.get(key)).getIntArray();
public boolean hasTag(String key) {
return this.hasKey(key, 10);
}
/**
* Retrieves a NBTTagCompound subtag matching the specified key, or a new empty NBTTagCompound if no such key was
* stored.
*/
public NBTTagCompound getCompoundTag(String key)
{
return !this.hasKey(key, 10) ? new NBTTagCompound() : (NBTTagCompound)this.tagMap.get(key);
public boolean hasFloatList(String key) {
return this.hasKey(key, 13);
}
/**
* Gets the NBTTagList object with the given name. Args: name, NBTBase type
*/
public NBTTagList getTagList(String key, int type)
{
if (this.getTagId(key) != 9)
{
return new NBTTagList();
}
else
{
NBTTagList nbttaglist = (NBTTagList)this.tagMap.get(key);
return nbttaglist.tagCount() > 0 && nbttaglist.getTagType() != type ? new NBTTagList() : nbttaglist;
}
public boolean hasDoubleList(String key) {
return this.hasKey(key, 14);
}
/**
* Retrieves a boolean value using the specified key, or false if no such key was stored. This uses the getByte
* method.
*/
public boolean getBoolean(String key)
{
public boolean hasStringList(String key) {
return this.hasKey(key, 9);
}
public boolean hasIntArrayList(String key) {
return this.hasKey(key, 15);
}
public boolean hasTagList(String key) {
return this.hasKey(key, 12);
}
public byte getByte(String key) {
return !this.hasKey(key, 1) ? 0 : ((NBTTagByte)this.tags.get(key)).getByte();
}
public short getShort(String key) {
return !this.hasKey(key, 2) ? 0 : ((NBTTagShort)this.tags.get(key)).getShort();
}
public int getInt(String key) {
return !this.hasKey(key, 3) ? 0 : ((NBTTagInt)this.tags.get(key)).getInt();
}
public long getLong(String key) {
return !this.hasKey(key, 4) ? 0L : ((NBTTagLong)this.tags.get(key)).getLong();
}
public float getFloat(String key) {
return !this.hasKey(key, 5) ? 0.0F : ((NBTTagFloat)this.tags.get(key)).getFloat();
}
public double getDouble(String key) {
return !this.hasKey(key, 6) ? 0.0D : ((NBTTagDouble)this.tags.get(key)).getDouble();
}
public String getString(String key) {
return !this.hasKey(key, 8) ? "" : ((NBTTagString)this.tags.get(key)).getString();
}
public byte[] getByteArray(String key) {
return !this.hasKey(key, 7) ? new byte[0] : ((NBTTagByteArray)this.tags.get(key)).getByteArray();
}
public int[] getIntArray(String key) {
return !this.hasKey(key, 11) ? new int[0] : ((NBTTagIntArray)this.tags.get(key)).getIntArray();
}
public NBTTagCompound getTag(String key) {
return !this.hasKey(key, 10) ? new NBTTagCompound() : (NBTTagCompound)this.tags.get(key);
}
public NBTTagFloatList getFloatList(String key) {
return !this.hasKey(key, 13) ? new NBTTagFloatList() : (NBTTagFloatList)this.tags.get(key);
}
public NBTTagDoubleList getDoubleList(String key) {
return !this.hasKey(key, 14) ? new NBTTagDoubleList() : (NBTTagDoubleList)this.tags.get(key);
}
public NBTTagStringList getStringList(String key) {
return !this.hasKey(key, 9) ? new NBTTagStringList() : (NBTTagStringList)this.tags.get(key);
}
public NBTTagIntArrayList getIntArrayList(String key) {
return !this.hasKey(key, 15) ? new NBTTagIntArrayList() : (NBTTagIntArrayList)this.tags.get(key);
}
public NBTTagTagList getTagList(String key) {
return !this.hasKey(key, 12) ? new NBTTagTagList() : (NBTTagTagList)this.tags.get(key);
}
public boolean getBool(String key) {
return this.getByte(key) != 0;
}
/**
* Remove the specified tag.
*/
public void removeTag(String key)
{
this.tagMap.remove(key);
public void remove(String key) {
this.tags.remove(key);
}
public String toString()
{
StringBuilder stringbuilder = new StringBuilder("{");
for (Entry<String, NBTBase> entry : this.tagMap.entrySet())
{
if (stringbuilder.length() != 1)
{
stringbuilder.append(',');
public String toString() {
StringBuilder sb = new StringBuilder("{");
for(Entry<String, NBTBase> entry : this.tags.entrySet()) {
if(sb.length() != 1)
sb.append(',');
sb.append(entry.getKey()).append(':').append(entry.getValue());
}
return sb.append('}').toString();
}
stringbuilder.append((String)entry.getKey()).append(':').append(entry.getValue());
public boolean isEmpty() {
return this.tags.isEmpty();
}
return stringbuilder.append('}').toString();
public NBTBase copy() {
NBTTagCompound tag = new NBTTagCompound();
for(String s : this.tags.keySet()) {
tag.set(s, this.tags.get(s).copy());
}
return tag;
}
public boolean equals(Object other) {
return super.equals(other) && this.tags.entrySet().equals(((NBTTagCompound)other).tags.entrySet());
}
public int hashCode() {
return super.hashCode() ^ this.tags.hashCode();
}
/**
* Return whether this compound has no tags.
* Merges this NBTTagCompound with the given compound. Any sub-compounds are
* merged using the same methods, other types of tags are overwritten from the
* given compound.
*/
public boolean hasNoTags()
{
return this.tagMap.isEmpty();
public void merge(NBTTagCompound other) {
for(String key : other.tags.keySet()) {
NBTBase tag = other.tags.get(key);
if(tag.getId() == 10) {
if(this.hasKey(key, 10)) {
NBTTagCompound comp = this.getTag(key);
comp.merge((NBTTagCompound)tag);
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
for (String s : this.tagMap.keySet())
{
nbttagcompound.setTag(s, ((NBTBase)this.tagMap.get(s)).copy());
}
return nbttagcompound;
}
public boolean equals(Object p_equals_1_)
{
if (super.equals(p_equals_1_))
{
NBTTagCompound nbttagcompound = (NBTTagCompound)p_equals_1_;
return this.tagMap.entrySet().equals(nbttagcompound.tagMap.entrySet());
}
else
{
return false;
else {
this.set(key, tag.copy());
}
}
public int hashCode()
{
return super.hashCode() ^ this.tagMap.hashCode();
}
private static void writeEntry(String name, NBTBase data, DataOutput output) throws IOException
{
output.writeByte(data.getId());
if (data.getId() != 0)
{
output.writeUTF(name);
data.write(output);
}
}
private static byte readType(DataInput input, NBTSizeTracker sizeTracker) throws IOException
{
return input.readByte();
}
private static String readKey(DataInput input, NBTSizeTracker sizeTracker) throws IOException
{
return input.readUTF();
}
static NBTBase readNBT(byte id, String key, DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
NBTBase nbtbase = NBTBase.createNewByType(id);
nbtbase.read(input, depth, sizeTracker);
return nbtbase;
}
/**
* Merges this NBTTagCompound with the given compound. Any sub-compounds are merged using the same methods, other
* types of tags are overwritten from the given compound.
*/
public void merge(NBTTagCompound other)
{
for (String s : other.tagMap.keySet())
{
NBTBase nbtbase = (NBTBase)other.tagMap.get(s);
if (nbtbase.getId() == 10)
{
if (this.hasKey(s, 10))
{
NBTTagCompound nbttagcompound = this.getCompoundTag(s);
nbttagcompound.merge((NBTTagCompound)nbtbase);
}
else
{
this.setTag(s, nbtbase.copy());
}
}
else
{
this.setTag(s, nbtbase.copy());
else {
this.set(key, tag.copy());
}
}
}

View file

@ -4,11 +4,8 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import common.util.ExtMath;
public class NBTTagDouble extends NBTBase.NBTPrimitive
class NBTTagDouble extends NBTBase
{
/** The double value for the tag. */
private double data;
NBTTagDouble()
@ -20,23 +17,17 @@ public class NBTTagDouble extends NBTBase.NBTPrimitive
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
output.writeDouble(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
{
sizeTracker.read(128L);
sizeTracker.read(16);
this.data = input.readDouble();
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
return (byte)6;
@ -47,19 +38,16 @@ public class NBTTagDouble extends NBTBase.NBTPrimitive
return "" + this.data + "d";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
return new NBTTagDouble(this.data);
}
public boolean equals(Object p_equals_1_)
public boolean equals(Object other)
{
if (super.equals(p_equals_1_))
if (super.equals(other))
{
NBTTagDouble nbttagdouble = (NBTTagDouble)p_equals_1_;
NBTTagDouble nbttagdouble = (NBTTagDouble)other;
return this.data == nbttagdouble.data;
}
else
@ -74,33 +62,8 @@ public class NBTTagDouble extends NBTBase.NBTPrimitive
return super.hashCode() ^ (int)(i ^ i >>> 32);
}
public long getLong()
{
return (long)Math.floor(this.data);
}
public int getInt()
{
return ExtMath.floord(this.data);
}
public short getShort()
{
return (short)(ExtMath.floord(this.data) & 65535);
}
public byte getByte()
{
return (byte)(ExtMath.floord(this.data) & 255);
}
public double getDouble()
{
return this.data;
}
public float getFloat()
{
return (float)this.data;
}
}

View file

@ -0,0 +1,27 @@
package common.nbt;
public class NBTTagDoubleList extends NBTTagList<NBTTagDouble> {
public byte getId() {
return 14;
}
public byte getType() {
return 6;
}
public NBTTagList<NBTTagDouble> createInstance() {
return new NBTTagDoubleList();
}
public NBTTagDouble getDefault() {
return new NBTTagDouble(0.0);
}
public double getDouble(int index) {
return this.get(index).getDouble();
}
public void add(double value) {
this.add(new NBTTagDouble(value));
}
}

View file

@ -4,38 +4,23 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class NBTTagEnd extends NBTBase
{
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
sizeTracker.read(64L);
class NBTTagEnd extends NBTBase {
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
tracker.read(8);
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
void write(DataOutput output) throws IOException {
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
public byte getId() {
return (byte)0;
}
public String toString()
{
public String toString() {
return "END";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
public NBTBase copy() {
return new NBTTagEnd();
}
}

View file

@ -4,11 +4,8 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import common.util.ExtMath;
public class NBTTagFloat extends NBTBase.NBTPrimitive
class NBTTagFloat extends NBTBase
{
/** The float value for the tag. */
private float data;
NBTTagFloat()
@ -20,23 +17,17 @@ public class NBTTagFloat extends NBTBase.NBTPrimitive
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
output.writeFloat(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
{
sizeTracker.read(96L);
sizeTracker.read(12);
this.data = input.readFloat();
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
return (byte)5;
@ -47,19 +38,16 @@ public class NBTTagFloat extends NBTBase.NBTPrimitive
return "" + this.data + "f";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
return new NBTTagFloat(this.data);
}
public boolean equals(Object p_equals_1_)
public boolean equals(Object other)
{
if (super.equals(p_equals_1_))
if (super.equals(other))
{
NBTTagFloat nbttagfloat = (NBTTagFloat)p_equals_1_;
NBTTagFloat nbttagfloat = (NBTTagFloat)other;
return this.data == nbttagfloat.data;
}
else
@ -73,31 +61,6 @@ public class NBTTagFloat extends NBTBase.NBTPrimitive
return super.hashCode() ^ Float.floatToIntBits(this.data);
}
public long getLong()
{
return (long)this.data;
}
public int getInt()
{
return ExtMath.floorf(this.data);
}
public short getShort()
{
return (short)(ExtMath.floorf(this.data) & 65535);
}
public byte getByte()
{
return (byte)(ExtMath.floorf(this.data) & 255);
}
public double getDouble()
{
return (double)this.data;
}
public float getFloat()
{
return this.data;

View file

@ -0,0 +1,27 @@
package common.nbt;
public class NBTTagFloatList extends NBTTagList<NBTTagFloat> {
public byte getId() {
return 13;
}
public byte getType() {
return 5;
}
public NBTTagList<NBTTagFloat> createInstance() {
return new NBTTagFloatList();
}
public NBTTagFloat getDefault() {
return new NBTTagFloat(0.0f);
}
public float getFloat(int index) {
return this.get(index).getFloat();
}
public void add(float value) {
this.add(new NBTTagFloat(value));
}
}

View file

@ -4,9 +4,8 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class NBTTagInt extends NBTBase.NBTPrimitive
class NBTTagInt extends NBTBase
{
/** The integer value for the tag. */
private int data;
NBTTagInt()
@ -18,23 +17,17 @@ public class NBTTagInt extends NBTBase.NBTPrimitive
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
output.writeInt(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
{
sizeTracker.read(96L);
sizeTracker.read(12);
this.data = input.readInt();
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
return (byte)3;
@ -45,19 +38,16 @@ public class NBTTagInt extends NBTBase.NBTPrimitive
return "" + this.data;
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
return new NBTTagInt(this.data);
}
public boolean equals(Object p_equals_1_)
public boolean equals(Object other)
{
if (super.equals(p_equals_1_))
if (super.equals(other))
{
NBTTagInt nbttagint = (NBTTagInt)p_equals_1_;
NBTTagInt nbttagint = (NBTTagInt)other;
return this.data == nbttagint.data;
}
else
@ -71,33 +61,8 @@ public class NBTTagInt extends NBTBase.NBTPrimitive
return super.hashCode() ^ this.data;
}
public long getLong()
{
return (long)this.data;
}
public int getInt()
{
return this.data;
}
public short getShort()
{
return (short)(this.data & 65535);
}
public byte getByte()
{
return (byte)(this.data & 255);
}
public double getDouble()
{
return (double)this.data;
}
public float getFloat()
{
return (float)this.data;
}
}

View file

@ -5,88 +5,60 @@ import java.io.DataOutput;
import java.io.IOException;
import java.util.Arrays;
public class NBTTagIntArray extends NBTBase
{
/** The array of saved integers */
private int[] intArray;
class NBTTagIntArray extends NBTBase {
private int[] data;
NBTTagIntArray()
{
NBTTagIntArray() {
}
public NBTTagIntArray(int[] p_i45132_1_)
{
this.intArray = p_i45132_1_;
public NBTTagIntArray(int[] data) {
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
output.writeInt(this.intArray.length);
for (int i = 0; i < this.intArray.length; ++i)
{
output.writeInt(this.intArray[i]);
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]);
}
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
sizeTracker.read(192L);
int i = input.readInt();
sizeTracker.read((long)(32 * i));
this.intArray = new int[i];
for (int j = 0; j < i; ++j)
{
this.intArray[j] = input.readInt();
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
tracker.read(24);
int len = input.readInt();
tracker.read(4 * len);
this.data = new int[len];
for(int z = 0; z < len; z++) {
this.data[z] = input.readInt();
}
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
public byte getId() {
return (byte)11;
}
public String toString()
{
String s = "[";
for (int i : this.intArray)
{
s = s + i + ",";
public String toString() {
StringBuilder sb = new StringBuilder("[");
for(int i : this.data) {
sb.append(i + ",");
}
return sb.append("]").toString();
}
return s + "]";
public NBTBase copy() {
int[] data = new int[this.data.length];
System.arraycopy(this.data, 0, data, 0, this.data.length);
return new NBTTagIntArray(data);
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
int[] aint = new int[this.intArray.length];
System.arraycopy(this.intArray, 0, aint, 0, this.intArray.length);
return new NBTTagIntArray(aint);
public boolean equals(Object other) {
return super.equals(other) && Arrays.equals(this.data, ((NBTTagIntArray)other).data);
}
public boolean equals(Object p_equals_1_)
{
return super.equals(p_equals_1_) ? Arrays.equals(this.intArray, ((NBTTagIntArray)p_equals_1_).intArray) : false;
public int hashCode() {
return super.hashCode() ^ Arrays.hashCode(this.data);
}
public int hashCode()
{
return super.hashCode() ^ Arrays.hashCode(this.intArray);
}
public int[] getIntArray()
{
return this.intArray;
public int[] getIntArray() {
return this.data;
}
}

View file

@ -0,0 +1,27 @@
package common.nbt;
public class NBTTagIntArrayList extends NBTTagList<NBTTagIntArray> {
public byte getId() {
return 15;
}
public byte getType() {
return 11;
}
public NBTTagList<NBTTagIntArray> createInstance() {
return new NBTTagIntArrayList();
}
public NBTTagIntArray getDefault() {
return new NBTTagIntArray(new int[0]);
}
public int[] getIntArray(int index) {
return this.get(index).getIntArray();
}
public void add(int[] value) {
this.add(new NBTTagIntArray(value));
}
}

View file

@ -9,292 +9,86 @@ import java.util.List;
import common.collect.Lists;
import common.log.Log;
public class NBTTagList extends NBTBase
{
private List<NBTBase> tagList = Lists.<NBTBase>newArrayList();
abstract class NBTTagList<K extends NBTBase> extends NBTBase {
private List<K> list = Lists.newArrayList();
/**
* The type byte for the tags in the list - they must all be of the same type.
*/
private byte tagType = 0;
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
if (!this.tagList.isEmpty())
{
this.tagType = ((NBTBase)this.tagList.get(0)).getId();
}
else
{
this.tagType = 0;
}
output.writeByte(this.tagType);
output.writeInt(this.tagList.size());
for (int i = 0; i < this.tagList.size(); ++i)
{
((NBTBase)this.tagList.get(i)).write(output);
void write(DataOutput output) throws IOException {
output.writeInt(this.list.size());
for(int z = 0; z < this.list.size(); z++) {
this.list.get(z).write(output);
}
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
sizeTracker.read(296L);
if (depth > 512)
{
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
tracker.read(36);
if(depth > 512)
throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512");
}
else
{
this.tagType = input.readByte();
int i = input.readInt();
if (this.tagType == 0 && i > 0)
{
throw new RuntimeException("Missing type on ListTag");
}
else
{
sizeTracker.read(32L * (long)i);
this.tagList = new ArrayList<NBTBase>(i);
for (int j = 0; j < i; ++j)
{
NBTBase nbtbase = NBTBase.createNewByType(this.tagType);
nbtbase.read(input, depth + 1, sizeTracker);
this.tagList.add(nbtbase);
}
}
int len = input.readInt();
tracker.read(4 * len);
this.list = new ArrayList<K>(len);
for(int z = 0; z < len; z++) {
K tag = (K)NBTBase.createNewByType(this.getType());
tag.read(input, depth + 1, tracker);
this.list.add(tag);
}
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
return (byte)9;
public abstract byte getId();
public abstract byte getType();
public abstract NBTTagList<K> createInstance();
public abstract K getDefault();
public String toString() {
StringBuilder sb = new StringBuilder("[");
for(int z = 0; z < this.list.size(); z++) {
if(z != 0)
sb.append(',');
sb.append(z).append(':').append(this.list.get(z));
}
return sb.append(']').toString();
}
public String toString()
{
StringBuilder stringbuilder = new StringBuilder("[");
for (int i = 0; i < this.tagList.size(); ++i)
{
if (i != 0)
{
stringbuilder.append(',');
protected void add(K tag) {
this.list.add(tag);
}
stringbuilder.append(i).append(':').append(this.tagList.get(i));
}
return stringbuilder.append(']').toString();
}
/**
* Adds the provided tag to the end of the list. There is no check to verify this tag is of the same type as any
* previous tag.
*/
public void appendTag(NBTBase nbt)
{
if (nbt.getId() == 0)
{
Log.IO.warn("Ungültiger End-Tag zu Tag-Liste hinzugefügt");
}
else
{
if (this.tagType == 0)
{
this.tagType = nbt.getId();
}
else if (this.tagType != nbt.getId())
{
Log.IO.warn("Füge ungleiche Tag-Typen zu Tag-Liste hinzu");
public 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.tagList.add(nbt);
}
this.list.set(index, tag);
}
/**
* Set the given index to the given tag
*/
public void set(int idx, NBTBase nbt)
{
if (nbt.getId() == 0)
{
Log.IO.warn("Ungültiger End-Tag zu Tag-Liste hinzugefügt");
}
else if (idx >= 0 && idx < this.tagList.size())
{
if (this.tagType == 0)
{
this.tagType = nbt.getId();
}
else if (this.tagType != nbt.getId())
{
Log.IO.warn("Füge ungleiche Tag-Typen zu Tag-Liste hinzu");
return;
public K remove(int index) {
return this.list.remove(index);
}
this.tagList.set(idx, nbt);
}
else
{
Log.IO.warn("Index außerhalb des Bereiches um Tag in Tag-Liste zu setzen");
}
public boolean isEmpty() {
return this.list.isEmpty();
}
/**
* Removes a tag at the given index.
*/
public NBTBase removeTag(int i)
{
return (NBTBase)this.tagList.remove(i);
protected K get(int index) {
return index >= 0 && index < this.list.size() ? this.list.get(index) : this.getDefault();
}
/**
* Return whether this compound has no tags.
*/
public boolean hasNoTags()
{
return this.tagList.isEmpty();
public int size() {
return this.list.size();
}
/**
* Retrieves the NBTTagCompound at the specified index in the list
*/
public NBTTagCompound getCompoundTagAt(int i)
{
if (i >= 0 && i < this.tagList.size())
{
NBTBase nbtbase = (NBTBase)this.tagList.get(i);
return nbtbase.getId() == 10 ? (NBTTagCompound)nbtbase : new NBTTagCompound();
}
else
{
return new NBTTagCompound();
public NBTBase copy() {
NBTTagList<K> list = this.createInstance();
for(K tag : this.list) {
list.list.add((K)tag.copy());
}
return list;
}
public int[] getIntArrayAt(int i)
{
if (i >= 0 && i < this.tagList.size())
{
NBTBase nbtbase = (NBTBase)this.tagList.get(i);
return nbtbase.getId() == 11 ? ((NBTTagIntArray)nbtbase).getIntArray() : new int[0];
}
else
{
return new int[0];
}
public boolean equals(Object other) {
return super.equals(other) && this.list.equals(((NBTTagList)other).list);
}
public double getDoubleAt(int i)
{
if (i >= 0 && i < this.tagList.size())
{
NBTBase nbtbase = (NBTBase)this.tagList.get(i);
return nbtbase.getId() == 6 ? ((NBTTagDouble)nbtbase).getDouble() : 0.0D;
}
else
{
return 0.0D;
}
}
public float getFloatAt(int i)
{
if (i >= 0 && i < this.tagList.size())
{
NBTBase nbtbase = (NBTBase)this.tagList.get(i);
return nbtbase.getId() == 5 ? ((NBTTagFloat)nbtbase).getFloat() : 0.0F;
}
else
{
return 0.0F;
}
}
/**
* Retrieves the tag String value at the specified index in the list
*/
public String getStringTagAt(int i)
{
if (i >= 0 && i < this.tagList.size())
{
NBTBase nbtbase = (NBTBase)this.tagList.get(i);
return nbtbase.getId() == 8 ? nbtbase.getString() : nbtbase.toString();
}
else
{
return "";
}
}
/**
* Get the tag at the given position
*/
public NBTBase get(int idx)
{
return (NBTBase)(idx >= 0 && idx < this.tagList.size() ? (NBTBase)this.tagList.get(idx) : new NBTTagEnd());
}
/**
* Returns the number of tags in the list.
*/
public int tagCount()
{
return this.tagList.size();
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
NBTTagList nbttaglist = new NBTTagList();
nbttaglist.tagType = this.tagType;
for (NBTBase nbtbase : this.tagList)
{
NBTBase nbtbase1 = nbtbase.copy();
nbttaglist.tagList.add(nbtbase1);
}
return nbttaglist;
}
public boolean equals(Object p_equals_1_)
{
if (super.equals(p_equals_1_))
{
NBTTagList nbttaglist = (NBTTagList)p_equals_1_;
if (this.tagType == nbttaglist.tagType)
{
return this.tagList.equals(nbttaglist.tagList);
}
}
return false;
}
public int hashCode()
{
return super.hashCode() ^ this.tagList.hashCode();
}
public int getTagType()
{
return this.tagType;
public int hashCode() {
return super.hashCode() ^ this.list.hashCode();
}
}

View file

@ -4,9 +4,8 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class NBTTagLong extends NBTBase.NBTPrimitive
class NBTTagLong extends NBTBase
{
/** The long value for the tag. */
private long data;
NBTTagLong()
@ -18,23 +17,17 @@ public class NBTTagLong extends NBTBase.NBTPrimitive
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
output.writeLong(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
{
sizeTracker.read(128L);
sizeTracker.read(16);
this.data = input.readLong();
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
return (byte)4;
@ -45,19 +38,16 @@ public class NBTTagLong extends NBTBase.NBTPrimitive
return "" + this.data + "L";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
return new NBTTagLong(this.data);
}
public boolean equals(Object p_equals_1_)
public boolean equals(Object other)
{
if (super.equals(p_equals_1_))
if (super.equals(other))
{
NBTTagLong nbttaglong = (NBTTagLong)p_equals_1_;
NBTTagLong nbttaglong = (NBTTagLong)other;
return this.data == nbttaglong.data;
}
else
@ -75,29 +65,4 @@ public class NBTTagLong extends NBTBase.NBTPrimitive
{
return this.data;
}
public int getInt()
{
return (int)(this.data & -1L);
}
public short getShort()
{
return (short)((int)(this.data & 65535L));
}
public byte getByte()
{
return (byte)((int)(this.data & 255L));
}
public double getDouble()
{
return (double)this.data;
}
public float getFloat()
{
return (float)this.data;
}
}

View file

@ -4,9 +4,8 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class NBTTagShort extends NBTBase.NBTPrimitive
class NBTTagShort extends NBTBase
{
/** The short value for the tag. */
private short data;
public NBTTagShort()
@ -18,23 +17,17 @@ public class NBTTagShort extends NBTBase.NBTPrimitive
this.data = data;
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
output.writeShort(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
{
sizeTracker.read(80L);
sizeTracker.read(10);
this.data = input.readShort();
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
return (byte)2;
@ -45,19 +38,16 @@ public class NBTTagShort extends NBTBase.NBTPrimitive
return "" + this.data + "s";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
return new NBTTagShort(this.data);
}
public boolean equals(Object p_equals_1_)
public boolean equals(Object other)
{
if (super.equals(p_equals_1_))
if (super.equals(other))
{
NBTTagShort nbttagshort = (NBTTagShort)p_equals_1_;
NBTTagShort nbttagshort = (NBTTagShort)other;
return this.data == nbttagshort.data;
}
else
@ -71,33 +61,8 @@ public class NBTTagShort extends NBTBase.NBTPrimitive
return super.hashCode() ^ this.data;
}
public long getLong()
{
return (long)this.data;
}
public int getInt()
{
return this.data;
}
public short getShort()
{
return this.data;
}
public byte getByte()
{
return (byte)(this.data & 255);
}
public double getDouble()
{
return (double)this.data;
}
public float getFloat()
{
return (float)this.data;
}
}

View file

@ -4,90 +4,53 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class NBTTagString extends NBTBase
{
/** The string value for the tag (cannot be empty). */
class NBTTagString extends NBTBase {
private String data;
public NBTTagString()
{
public NBTTagString() {
this.data = "";
}
public NBTTagString(String data)
{
public NBTTagString(String data) {
if(data == null)
throw new IllegalArgumentException("null is not allowed");
this.data = data;
if (data == null)
{
throw new IllegalArgumentException("Empty string not allowed");
}
}
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
void write(DataOutput output) throws IOException {
output.writeUTF(this.data);
}
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
sizeTracker.read(288L);
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
tracker.read(36);
this.data = input.readUTF();
sizeTracker.read((long)(16 * this.data.length()));
tracker.read(2 * this.data.length());
}
/**
* Gets the type byte for the tag.
*/
public byte getId()
{
public byte getId() {
return (byte)8;
}
public String toString()
{
public String toString() {
return "\"" + this.data.replace("\"", "\\\"") + "\"";
}
/**
* Creates a clone of the tag.
*/
public NBTBase copy()
{
public NBTBase copy() {
return new NBTTagString(this.data);
}
/**
* Return whether this compound has no tags.
*/
public boolean hasNoTags()
{
return this.data.isEmpty();
}
public boolean equals(Object p_equals_1_)
{
if (!super.equals(p_equals_1_))
{
public boolean equals(Object other) {
if(!super.equals(other))
return false;
}
else
{
NBTTagString nbttagstring = (NBTTagString)p_equals_1_;
return this.data == null && nbttagstring.data == null || this.data != null && this.data.equals(nbttagstring.data);
}
NBTTagString tag = (NBTTagString)other;
return this.data == null && tag.data == null || this.data != null && this.data.equals(tag.data);
}
public int hashCode()
{
public int hashCode() {
return super.hashCode() ^ this.data.hashCode();
}
public String getString()
{
public String getString() {
return this.data;
}
}

View file

@ -0,0 +1,27 @@
package common.nbt;
public class NBTTagStringList extends NBTTagList<NBTTagString> {
public byte getId() {
return 9;
}
public byte getType() {
return 8;
}
public NBTTagList<NBTTagString> createInstance() {
return new NBTTagStringList();
}
public NBTTagString getDefault() {
return new NBTTagString("");
}
public String getString(int index) {
return this.get(index).getString();
}
public void add(String value) {
this.add(new NBTTagString(value));
}
}

View file

@ -0,0 +1,27 @@
package common.nbt;
public class NBTTagTagList extends NBTTagList<NBTTagCompound> {
public byte getId() {
return 12;
}
public byte getType() {
return 10;
}
public NBTTagList<NBTTagCompound> createInstance() {
return new NBTTagTagList();
}
public NBTTagCompound getDefault() {
return new NBTTagCompound();
}
public NBTTagCompound getTag(int index) {
return this.get(index);
}
public void add(NBTTagCompound value) {
super.add(value);
}
}

View file

@ -1,79 +0,0 @@
package common.nbt;
public final class NBTUtil
{
public static boolean compareTags(NBTBase tag1, NBTBase tag2, boolean lists)
{
if (tag1 == tag2)
{
return true;
}
else if (tag1 == null)
{
return true;
}
else if (tag2 == null)
{
return false;
}
else if (!tag1.getClass().equals(tag2.getClass()))
{
return false;
}
else if (tag1 instanceof NBTTagCompound)
{
NBTTagCompound nbttagcompound = (NBTTagCompound)tag1;
NBTTagCompound nbttagcompound1 = (NBTTagCompound)tag2;
for (String s : nbttagcompound.getKeySet())
{
NBTBase nbtbase1 = nbttagcompound.getTag(s);
if (!compareTags(nbtbase1, nbttagcompound1.getTag(s), lists))
{
return false;
}
}
return true;
}
else if (tag1 instanceof NBTTagList && lists)
{
NBTTagList nbttaglist = (NBTTagList)tag1;
NBTTagList nbttaglist1 = (NBTTagList)tag2;
if (nbttaglist.tagCount() == 0)
{
return nbttaglist1.tagCount() == 0;
}
else
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTBase nbtbase = nbttaglist.get(i);
boolean flag = false;
for (int j = 0; j < nbttaglist1.tagCount(); ++j)
{
if (compareTags(nbtbase, nbttaglist1.get(j), lists))
{
flag = true;
break;
}
}
if (!flag)
{
return false;
}
}
return true;
}
}
else
{
return tag1.equals(tag2);
}
}
}

View file

@ -0,0 +1,22 @@
package common.nbt;
public class SizeTracker {
public static final SizeTracker INFINITE = new SizeTracker(0) {
public void read(int bytes) {
}
};
private final int max;
private int read;
public SizeTracker(int max) {
this.max = max;
}
public void read(int bytes) {
this.read += bytes;
if(this.read > this.max)
throw new RuntimeException("Versuchte einen Tag zu lesen, der zu groß war: Habe " + this.read + " Bytes, " + this.max + " Bytes maximal erlaubt");
}
}

View file

@ -6,7 +6,7 @@ import java.nio.charset.Charset;
import common.init.ItemRegistry;
import common.item.ItemStack;
import common.nbt.NBTLoader;
import common.nbt.NBTSizeTracker;
import common.nbt.SizeTracker;
import common.nbt.NBTTagCompound;
import common.net.buffer.ByteBuf;
import common.net.buffer.ByteBufInputStream;
@ -111,7 +111,7 @@ public class PacketBuffer {
if(b == 0)
return null;
this.buf.readerIndex(i);
return NBTLoader.read(new ByteBufInputStream(this.buf), new NBTSizeTracker(2097152L));
return NBTLoader.read(new ByteBufInputStream(this.buf), new SizeTracker(2097152));
}
public void writeItemStack(ItemStack stack) {

View file

@ -69,9 +69,9 @@ public class SPacketTrades implements Packet<IClientPlayer>
for (int i = 0; i < this.recipes.size(); ++i)
{
MerchantRecipe merchantrecipe = (MerchantRecipe)this.recipes.get(i);
buf.writeItemStack(merchantrecipe.getItemToBuy());
buf.writeItemStack(merchantrecipe.getItemToSell());
ItemStack itemstack = merchantrecipe.getSecondItemToBuy();
buf.writeItemStack(merchantrecipe.getBuying());
buf.writeItemStack(merchantrecipe.getSelling());
ItemStack itemstack = merchantrecipe.getSecondBuy();
buf.writeBoolean(itemstack != null);
if (itemstack != null)

View file

@ -139,16 +139,16 @@ public class PotionEffect {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("Type", this.potion.getName());
nbt.setByte("Amplifier", (byte)this.amplifier);
nbt.setInteger("Duration", this.duration);
nbt.setInteger("Remaining", this.remaining);
nbt.setBoolean("Ambient", this.ambient);
nbt.setBoolean("Particles", this.particles);
nbt.setInt("Duration", this.duration);
nbt.setInt("Remaining", this.remaining);
nbt.setBool("Ambient", this.ambient);
nbt.setBool("Particles", this.particles);
return nbt;
}
public static PotionEffect fromNbt(NBTTagCompound nbt) {
Potion potion = Potion.getByName(nbt.getString("Type"));
return potion == null ? null : new PotionEffect(potion, nbt.getInteger("Duration"), (int)(nbt.getByte("Amplifier") & 255), nbt.getBoolean("Ambient"), nbt.getBoolean("Particles"))
.setRemaining(nbt.getInteger("Remaining"));
return potion == null ? null : new PotionEffect(potion, nbt.getInt("Duration"), (int)(nbt.getByte("Amplifier") & 255), nbt.getBool("Ambient"), nbt.getBool("Particles"))
.setRemaining(nbt.getInt("Remaining"));
}
}

View file

@ -29,7 +29,7 @@ public class LockCode
public static LockCode fromNBT(NBTTagCompound nbt)
{
if (nbt.hasKey("Lock", 8))
if (nbt.hasString("Lock"))
{
String s = nbt.getString("Lock");
return new LockCode(s);

View file

@ -24,19 +24,19 @@ public class MachineResource {
}
public void readFromNbt(NBTTagCompound tag) {
this.amount = tag.getInteger("Amount");
this.capacity = tag.getInteger("Capacity");
this.undercharge = tag.getInteger("Under");
this.overcharge = tag.getInteger("Over");
this.entropy = tag.getInteger("Entropy");
this.amount = tag.getInt("Amount");
this.capacity = tag.getInt("Capacity");
this.undercharge = tag.getInt("Under");
this.overcharge = tag.getInt("Over");
this.entropy = tag.getInt("Entropy");
}
public void writeToNbt(NBTTagCompound tag) {
tag.setInteger("Amount", this.amount);
tag.setInteger("Capacity", this.capacity);
tag.setInteger("Under", this.undercharge);
tag.setInteger("Over", this.overcharge);
tag.setInteger("Entropy", this.entropy);
tag.setInt("Amount", this.amount);
tag.setInt("Capacity", this.capacity);
tag.setInt("Under", this.undercharge);
tag.setInt("Over", this.overcharge);
tag.setInt("Entropy", this.entropy);
}
public void setValue(int value) {

View file

@ -55,7 +55,7 @@ public abstract class TileEntity
public void readFromNBT(NBTTagCompound compound)
{
this.pos = new BlockPos(compound.getInteger("x"), compound.getInteger("y"), compound.getInteger("z"));
this.pos = new BlockPos(compound.getInt("x"), compound.getInt("y"), compound.getInt("z"));
}
public void writeToNBT(NBTTagCompound compound)
@ -69,9 +69,9 @@ public abstract class TileEntity
else
{
compound.setString("id", s);
compound.setInteger("x", this.pos.getX());
compound.setInteger("y", this.pos.getY());
compound.setInteger("z", this.pos.getZ());
compound.setInt("x", this.pos.getX());
compound.setInt("y", this.pos.getY());
compound.setInt("z", this.pos.getZ());
}
}

View file

@ -9,7 +9,7 @@ import common.init.Blocks;
import common.init.Items;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.network.Packet;
import common.packet.SPacketUpdateTileEntity;
@ -18,7 +18,7 @@ public class TileEntityBanner extends TileEntity
private int baseColor;
/** A list of all the banner patterns. */
private NBTTagList patterns;
private NBTTagTagList patterns;
private boolean field_175119_g;
private List<TileEntityBanner.EnumBannerPattern> patternList;
private List<DyeColor> colorList;
@ -32,18 +32,18 @@ public class TileEntityBanner extends TileEntity
{
this.patterns = null;
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("BlockEntityTag", 10))
if (stack.hasTagCompound() && stack.getTagCompound().hasTag("BlockEntityTag"))
{
NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("BlockEntityTag");
NBTTagCompound nbttagcompound = stack.getTagCompound().getTag("BlockEntityTag");
if (nbttagcompound.hasKey("Patterns"))
if (nbttagcompound.hasTagList("Patterns"))
{
this.patterns = (NBTTagList)nbttagcompound.getTagList("Patterns", 10).copy();
this.patterns = (NBTTagTagList)nbttagcompound.getTagList("Patterns").copy();
}
if (nbttagcompound.hasKey("Base", 99))
if (nbttagcompound.hasInt("Base"))
{
this.baseColor = nbttagcompound.getInteger("Base");
this.baseColor = nbttagcompound.getInt("Base");
}
else
{
@ -67,21 +67,21 @@ public class TileEntityBanner extends TileEntity
setBaseColorAndPatterns(compound, this.baseColor, this.patterns);
}
public static void setBaseColorAndPatterns(NBTTagCompound compound, int baseColorIn, NBTTagList patternsIn)
public static void setBaseColorAndPatterns(NBTTagCompound compound, int baseColorIn, NBTTagTagList patternsIn)
{
compound.setInteger("Base", baseColorIn);
compound.setInt("Base", baseColorIn);
if (patternsIn != null)
{
compound.setTag("Patterns", patternsIn);
compound.setTagList("Patterns", patternsIn);
}
}
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
this.baseColor = compound.getInteger("Base");
this.patterns = compound.getTagList("Patterns", 10);
this.baseColor = compound.getInt("Base");
this.patterns = compound.getTagList("Patterns");
this.patternList = null;
this.colorList = null;
this.patternResourceLocation = null;
@ -105,7 +105,7 @@ public class TileEntityBanner extends TileEntity
public static int getBaseColor(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
return nbttagcompound != null && nbttagcompound.hasKey("Base") ? nbttagcompound.getInteger("Base") : stack.getMetadata();
return nbttagcompound != null && nbttagcompound.hasInt("Base") ? nbttagcompound.getInt("Base") : stack.getMetadata();
}
/**
@ -114,7 +114,7 @@ public class TileEntityBanner extends TileEntity
public static int getPatterns(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
return nbttagcompound != null && nbttagcompound.hasKey("Patterns") ? nbttagcompound.getTagList("Patterns", 10).tagCount() : 0;
return nbttagcompound != null && nbttagcompound.hasTagList("Patterns") ? nbttagcompound.getTagList("Patterns").size() : 0;
}
public List<TileEntityBanner.EnumBannerPattern> getPatternList()
@ -123,7 +123,7 @@ public class TileEntityBanner extends TileEntity
return this.patternList;
}
public NBTTagList getPatterns()
public NBTTagTagList getPatterns()
{
return this.patterns;
}
@ -162,15 +162,15 @@ public class TileEntityBanner extends TileEntity
if (this.patterns != null)
{
for (int i = 0; i < this.patterns.tagCount(); ++i)
for (int i = 0; i < this.patterns.size(); ++i)
{
NBTTagCompound nbttagcompound = this.patterns.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = this.patterns.getTag(i);
TileEntityBanner.EnumBannerPattern tileentitybanner$enumbannerpattern = TileEntityBanner.EnumBannerPattern.getPatternByID(nbttagcompound.getString("Pattern"));
if (tileentitybanner$enumbannerpattern != null)
{
this.patternList.add(tileentitybanner$enumbannerpattern);
int j = nbttagcompound.getInteger("Color");
int j = nbttagcompound.getInt("Color");
this.colorList.add(DyeColor.byDyeDamage(j));
this.patternResourceLocation = this.patternResourceLocation + tileentitybanner$enumbannerpattern.getPatternID() + j;
}
@ -191,19 +191,19 @@ public class TileEntityBanner extends TileEntity
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
if (nbttagcompound != null && nbttagcompound.hasTagList("Patterns"))
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);
NBTTagTagList nbttaglist = nbttagcompound.getTagList("Patterns");
if (nbttaglist.tagCount() > 0)
if (nbttaglist.size() > 0)
{
nbttaglist.removeTag(nbttaglist.tagCount() - 1);
nbttaglist.remove(nbttaglist.size() - 1);
if (nbttaglist.hasNoTags())
if (nbttaglist.isEmpty())
{
stack.getTagCompound().removeTag("BlockEntityTag");
stack.getTagCompound().remove("BlockEntityTag");
if (stack.getTagCompound().hasNoTags())
if (stack.getTagCompound().isEmpty())
{
stack.setTagCompound((NBTTagCompound)null);
}

View file

@ -304,9 +304,9 @@ public class TileEntityBeacon extends TileEntity implements ITickable
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
this.primaryEffect = compound.hasKey("Primary", 8) ? this.getEffect(compound.getString("Primary")) : null;
this.secondaryEffect = compound.hasKey("Secondary", 8) ? this.getEffect(compound.getString("Secondary")) : null;
this.levels = compound.getInteger("Levels");
this.primaryEffect = compound.hasString("Primary") ? this.getEffect(compound.getString("Primary")) : null;
this.secondaryEffect = compound.hasString("Secondary") ? this.getEffect(compound.getString("Secondary")) : null;
this.levels = compound.getInt("Levels");
// try {
this.beamColor = DyeColor.getByName(compound.getString("Color"));
// }
@ -322,7 +322,7 @@ public class TileEntityBeacon extends TileEntity implements ITickable
compound.setString("Primary", this.primaryEffect.getName());
if(this.secondaryEffect != null)
compound.setString("Secondary", this.secondaryEffect.getName());
compound.setInteger("Levels", this.levels);
compound.setInt("Levels", this.levels);
compound.setString("Color", this.beamColor.getName());
}

View file

@ -14,7 +14,7 @@ import common.item.Item;
import common.item.ItemPotion;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.potion.PotionEffect;
import common.potion.PotionHelper;
import common.util.Facing;
@ -230,12 +230,12 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
NBTTagTagList nbttaglist = compound.getTagList("Items");
this.brewingItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot");
if (j >= 0 && j < this.brewingItemStacks.length)
@ -246,7 +246,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
this.brewTime = compound.getShort("BrewTime");
if (compound.hasKey("CustomName", 8))
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
@ -256,7 +256,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
{
super.writeToNBT(compound);
compound.setShort("BrewTime", (short)this.brewTime);
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.brewingItemStacks.length; ++i)
{
@ -265,11 +265,11 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.brewingItemStacks[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
compound.setTagList("Items", nbttaglist);
if (this.hasCustomName())
{

View file

@ -11,7 +11,7 @@ import common.inventory.InventoryLargeChest;
import common.inventory.InventoryPlayer;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
@ -164,17 +164,17 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
NBTTagTagList nbttaglist = compound.getTagList("Items");
this.chestContents = new ItemStack[this.getSizeInventory()];
if (compound.hasKey("CustomName", 8))
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.chestContents.length)
@ -187,7 +187,7 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.chestContents.length; ++i)
{
@ -196,11 +196,11 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.chestContents[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
compound.setTagList("Items", nbttaglist);
if (this.hasCustomName())
{

View file

@ -9,13 +9,13 @@ public class TileEntityComparator extends TileEntity
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
compound.setInteger("OutputSignal", this.outputSignal);
compound.setInt("OutputSignal", this.outputSignal);
}
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
this.outputSignal = compound.getInteger("OutputSignal");
this.outputSignal = compound.getInt("OutputSignal");
}
public int getOutputSignal()

View file

@ -7,7 +7,7 @@ import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.rng.Random;
public class TileEntityDispenser extends TileEntityLockable implements IInventory
@ -155,12 +155,12 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
NBTTagTagList nbttaglist = compound.getTagList("Items");
this.stacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.stacks.length)
@ -169,7 +169,7 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
}
}
if (compound.hasKey("CustomName", 8))
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
@ -178,7 +178,7 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.stacks.length; ++i)
{
@ -187,11 +187,11 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.stacks[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
compound.setTagList("Items", nbttaglist);
if (this.hasCustomName())
{

View file

@ -37,7 +37,7 @@ public class TileEntityEnchantmentTable extends TileEntity implements ITickable,
{
super.readFromNBT(compound);
if (compound.hasKey("CustomName", 8))
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}

View file

@ -24,7 +24,7 @@ import common.item.ItemStack;
import common.item.ItemSword;
import common.item.ItemTool;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.util.ExtMath;
import common.util.Facing;
@ -159,12 +159,12 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
NBTTagTagList nbttaglist = compound.getTagList("Items");
this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot");
if (j >= 0 && j < this.furnaceItemStacks.length)
@ -178,7 +178,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
this.totalCookTime = compound.getShort("CookTimeTotal");
this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
if (compound.hasKey("CustomName", 8))
if (compound.hasString("CustomName"))
{
this.furnaceCustomName = compound.getString("CustomName");
}
@ -190,7 +190,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);
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.furnaceItemStacks.length; ++i)
{
@ -199,11 +199,11 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.furnaceItemStacks[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
compound.setTagList("Items", nbttaglist);
if (this.hasCustomName())
{

View file

@ -17,7 +17,7 @@ import common.inventory.ISidedInventory;
import common.inventory.InventoryPlayer;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.ExtMath;
@ -33,19 +33,19 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
NBTTagTagList nbttaglist = compound.getTagList("Items");
this.inventory = new ItemStack[this.getSizeInventory()];
if (compound.hasKey("CustomName", 8))
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
this.transferCooldown = compound.getInteger("TransferCooldown");
this.transferCooldown = compound.getInt("TransferCooldown");
for (int i = 0; i < nbttaglist.tagCount(); ++i)
for (int i = 0; i < nbttaglist.size(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot");
if (j >= 0 && j < this.inventory.length)
@ -58,7 +58,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for (int i = 0; i < this.inventory.length; ++i)
{
@ -67,12 +67,12 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.inventory[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
compound.setInteger("TransferCooldown", this.transferCooldown);
compound.setTagList("Items", nbttaglist);
compound.setInt("TransferCooldown", this.transferCooldown);
if (this.hasCustomName())
{

View file

@ -7,7 +7,7 @@ import common.inventory.ContainerMachine;
import common.inventory.InventoryPlayer;
import common.item.ItemStack;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagTagList;
import common.network.Packet;
import common.packet.SPacketUpdateTileEntity;
import common.rng.Random;
@ -82,10 +82,10 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
NBTTagTagList nbttaglist = compound.getTagList("Items");
this.clear();
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
for(int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound = nbttaglist.getTag(i);
int j = nbttagcompound.getByte("Slot");
if(j >= 0 && j < this.inventory.length) {
@ -93,43 +93,43 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
}
}
nbttaglist = compound.getTagList("Resources", 10);
nbttaglist = compound.getTagList("Resources");
for(MachineResource res : this.resources) {
res.reset();
}
for(int i = 0; i < nbttaglist.tagCount() && i < this.inventory.length; ++i) {
this.resources[i].readFromNbt(nbttaglist.getCompoundTagAt(i));
for(int i = 0; i < nbttaglist.size() && i < this.inventory.length; ++i) {
this.resources[i].readFromNbt(nbttaglist.getTag(i));
}
// this.isCreative = compound.getBoolean("Creative");
this.temperature = compound.getInteger("Temperature");
this.temperature = compound.getInt("Temperature");
this.status = Status.values()[(int)compound.getByte("Status") % Status.values().length];
}
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
NBTTagTagList nbttaglist = new NBTTagTagList();
for(int i = 0; i < this.inventory.length; ++i) {
if(this.inventory[i] != null) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.inventory[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
compound.setTagList("Items", nbttaglist);
nbttaglist = new NBTTagList();
nbttaglist = new NBTTagTagList();
for(int z = 0; z < this.resources.length; z++) {
NBTTagCompound res = new NBTTagCompound();
this.resources[z].writeToNbt(res);
nbttaglist.appendTag(res);
nbttaglist.add(res);
}
compound.setTag("Resources", nbttaglist);
compound.setTagList("Resources", nbttaglist);
// compound.setBoolean("Creative", this.isCreative);
compound.setInteger("Temperature", this.temperature);
compound.setInt("Temperature", this.temperature);
compound.setByte("Status", (byte)this.status.ordinal());
}

View file

@ -168,20 +168,20 @@ public class TileEntityMobSpawner extends TileEntity implements ITickable
this.mobID = nbt.getString("EntityId");
this.spawnDelay = nbt.getShort("Delay");
if (nbt.hasKey("MinSpawnDelay", 99))
if (nbt.hasShort("MinSpawnDelay"))
{
this.minSpawnDelay = nbt.getShort("MinSpawnDelay");
this.maxSpawnDelay = nbt.getShort("MaxSpawnDelay");
this.spawnCount = nbt.getShort("SpawnCount");
}
if (nbt.hasKey("MaxNearbyEntities", 99))
if (nbt.hasShort("MaxNearbyEntities"))
{
this.maxNearbyEntities = nbt.getShort("MaxNearbyEntities");
this.activatingRangeFromPlayer = nbt.getShort("RequiredPlayerRange");
}
if (nbt.hasKey("SpawnRange", 99))
if (nbt.hasShort("SpawnRange"))
{
this.spawnRange = nbt.getShort("SpawnRange");
}

Some files were not shown because too many files have changed in this diff Show more