From 17aad1f023ab4ba84771667dccc94ea988836184 Mon Sep 17 00:00:00 2001 From: Sen Date: Tue, 27 May 2025 21:25:11 +0200 Subject: [PATCH] change nbt format --- .../client/gui/container/GuiMerchant.java | 12 +- .../renderer/particle/EntityFirework.java | 30 +- .../TileEntityItemStackRenderer.java | 2 +- .../java/common/attributes/Attributes.java | 32 +- .../java/common/block/tile/BlockBanner.java | 8 +- .../main/java/common/dimension/Dimension.java | 322 ++++----- .../main/java/common/dimension/Nameable.java | 2 +- .../common/enchantment/EnchantmentHelper.java | 34 +- .../src/main/java/common/entity/Entity.java | 57 +- .../common/entity/animal/EntityChicken.java | 12 +- .../common/entity/animal/EntityHorse.java | 58 +- .../common/entity/animal/EntityOcelot.java | 4 +- .../java/common/entity/animal/EntityPig.java | 4 +- .../common/entity/animal/EntityRabbit.java | 8 +- .../common/entity/animal/EntitySheep.java | 4 +- .../java/common/entity/animal/EntityWolf.java | 6 +- .../java/common/entity/item/EntityCart.java | 18 +- .../entity/item/EntityCartContainer.java | 14 +- .../common/entity/item/EntityExplosion.java | 8 +- .../common/entity/item/EntityFalling.java | 40 +- .../common/entity/item/EntityFireworks.java | 14 +- .../common/entity/item/EntityHopperCart.java | 4 +- .../java/common/entity/item/EntityItem.java | 7 +- .../java/common/entity/item/EntityNuke.java | 4 +- .../common/entity/item/EntityTntCart.java | 8 +- .../common/entity/npc/EntityGargoyle.java | 4 +- .../java/common/entity/npc/EntityHaunter.java | 13 +- .../java/common/entity/npc/EntityNPC.java | 124 ++-- .../java/common/entity/npc/EntitySlime.java | 4 +- .../common/entity/projectile/EntityArrow.java | 24 +- .../entity/projectile/EntityBullet.java | 9 +- .../common/entity/projectile/EntityDie.java | 12 +- .../entity/projectile/EntityFireball.java | 8 +- .../common/entity/projectile/EntityHook.java | 10 +- .../entity/projectile/EntityPotion.java | 6 +- .../entity/projectile/EntityProjectile.java | 20 +- .../common/entity/types/EntityAnimal.java | 4 +- .../common/entity/types/EntityLiving.java | 64 +- .../common/entity/types/EntityTameable.java | 12 +- .../common/entity/types/EntityThrowable.java | 10 +- .../java/common/init/CraftingRegistry.java | 30 +- .../java/common/init/DispenserRegistry.java | 2 +- .../java/common/init/UniverseRegistry.java | 160 ++--- .../common/inventory/ContainerRepair.java | 2 +- .../common/inventory/InventoryMerchant.java | 8 +- .../common/inventory/InventoryPlayer.java | 14 +- .../common/inventory/InventoryWarpChest.java | 14 +- .../common/inventory/SlotMerchantResult.java | 4 +- common/src/main/java/common/item/Item.java | 18 +- .../src/main/java/common/item/ItemArmor.java | 22 +- .../src/main/java/common/item/ItemBanner.java | 24 +- .../src/main/java/common/item/ItemBlock.java | 12 +- .../java/common/item/ItemEnchantedBook.java | 28 +- .../main/java/common/item/ItemFirework.java | 14 +- .../java/common/item/ItemFireworkCharge.java | 78 +- .../src/main/java/common/item/ItemPotion.java | 4 +- .../src/main/java/common/item/ItemSign.java | 2 +- .../src/main/java/common/item/ItemSkull.java | 6 +- .../src/main/java/common/item/ItemStack.java | 112 +-- common/src/main/java/common/nbt/NBTBase.java | 163 ++--- .../main/java/common/nbt/NBTException.java | 10 +- .../src/main/java/common/nbt/NBTLoader.java | 112 +-- .../src/main/java/common/nbt/NBTParser.java | 23 +- .../main/java/common/nbt/NBTSizeTracker.java | 31 - .../src/main/java/common/nbt/NBTTagByte.java | 47 +- .../main/java/common/nbt/NBTTagByteArray.java | 97 +-- .../main/java/common/nbt/NBTTagCompound.java | 665 +++++++----------- .../main/java/common/nbt/NBTTagDouble.java | 49 +- .../java/common/nbt/NBTTagDoubleList.java | 27 + .../src/main/java/common/nbt/NBTTagEnd.java | 45 +- .../src/main/java/common/nbt/NBTTagFloat.java | 49 +- .../main/java/common/nbt/NBTTagFloatList.java | 27 + .../src/main/java/common/nbt/NBTTagInt.java | 47 +- .../main/java/common/nbt/NBTTagIntArray.java | 120 ++-- .../java/common/nbt/NBTTagIntArrayList.java | 27 + .../src/main/java/common/nbt/NBTTagList.java | 344 ++------- .../src/main/java/common/nbt/NBTTagLong.java | 47 +- .../src/main/java/common/nbt/NBTTagShort.java | 47 +- .../main/java/common/nbt/NBTTagString.java | 115 +-- .../java/common/nbt/NBTTagStringList.java | 27 + .../main/java/common/nbt/NBTTagTagList.java | 27 + common/src/main/java/common/nbt/NBTUtil.java | 79 --- .../src/main/java/common/nbt/SizeTracker.java | 22 + .../java/common/network/PacketBuffer.java | 4 +- .../java/common/packet/SPacketTrades.java | 6 +- .../main/java/common/potion/PotionEffect.java | 12 +- .../main/java/common/tileentity/LockCode.java | 2 +- .../common/tileentity/MachineResource.java | 20 +- .../java/common/tileentity/TileEntity.java | 8 +- .../common/tileentity/TileEntityBanner.java | 52 +- .../common/tileentity/TileEntityBeacon.java | 8 +- .../tileentity/TileEntityBrewingStand.java | 16 +- .../common/tileentity/TileEntityChest.java | 16 +- .../tileentity/TileEntityComparator.java | 4 +- .../tileentity/TileEntityDispenser.java | 16 +- .../TileEntityEnchantmentTable.java | 2 +- .../common/tileentity/TileEntityFurnace.java | 16 +- .../common/tileentity/TileEntityHopper.java | 20 +- .../common/tileentity/TileEntityMachine.java | 30 +- .../tileentity/TileEntityMobSpawner.java | 6 +- .../common/tileentity/TileEntityPiston.java | 14 +- .../common/tileentity/TileEntitySign.java | 2 +- .../common/tileentity/TileEntitySkull.java | 2 +- .../java/common/village/MerchantRecipe.java | 108 ++- .../common/village/MerchantRecipeList.java | 181 ++--- .../src/main/java/common/village/Village.java | 48 +- server/src/main/java/server/Server.java | 35 +- .../server/command/commands/CommandBlock.java | 6 +- .../server/command/commands/CommandSpawn.java | 10 +- .../src/main/java/server/network/Player.java | 51 +- .../server/village/VillageCollection.java | 18 +- .../src/main/java/server/world/Converter.java | 64 +- server/src/main/java/server/world/Region.java | 101 +-- .../main/java/server/world/WorldServer.java | 65 +- .../worldgen/structure/MapGenStructure.java | 8 +- .../worldgen/structure/MapGenVillage.java | 4 +- .../structure/StructureBoundingBox.java | 5 +- .../worldgen/structure/StructureBridge.java | 16 +- .../structure/StructureComponent.java | 12 +- .../structure/StructureMineshaft.java | 38 +- .../structure/StructureScattered.java | 52 +- .../worldgen/structure/StructureStart.java | 26 +- .../structure/StructureStronghold.java | 48 +- .../worldgen/structure/StructureVillage.java | 60 +- 124 files changed, 2063 insertions(+), 2986 deletions(-) delete mode 100755 common/src/main/java/common/nbt/NBTSizeTracker.java create mode 100644 common/src/main/java/common/nbt/NBTTagDoubleList.java create mode 100644 common/src/main/java/common/nbt/NBTTagFloatList.java create mode 100644 common/src/main/java/common/nbt/NBTTagIntArrayList.java create mode 100644 common/src/main/java/common/nbt/NBTTagStringList.java create mode 100644 common/src/main/java/common/nbt/NBTTagTagList.java delete mode 100755 common/src/main/java/common/nbt/NBTUtil.java create mode 100755 common/src/main/java/common/nbt/SizeTracker.java diff --git a/client/src/main/java/client/gui/container/GuiMerchant.java b/client/src/main/java/client/gui/container/GuiMerchant.java index 0b1543e..1cf557a 100755 --- a/client/src/main/java/client/gui/container/GuiMerchant.java +++ b/client/src/main/java/client/gui/container/GuiMerchant.java @@ -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(); diff --git a/client/src/main/java/client/renderer/particle/EntityFirework.java b/client/src/main/java/client/renderer/particle/EntityFirework.java index b3f3072..8d2a306 100755 --- a/client/src/main/java/client/renderer/particle/EntityFirework.java +++ b/client/src/main/java/client/renderer/particle/EntityFirework.java @@ -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"); diff --git a/client/src/main/java/client/renderer/tileentity/TileEntityItemStackRenderer.java b/client/src/main/java/client/renderer/tileentity/TileEntityItemStackRenderer.java index df617b0..d7e24b3 100755 --- a/client/src/main/java/client/renderer/tileentity/TileEntityItemStackRenderer.java +++ b/client/src/main/java/client/renderer/tileentity/TileEntityItemStackRenderer.java @@ -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"); // } diff --git a/common/src/main/java/common/attributes/Attributes.java b/common/src/main/java/common/attributes/Attributes.java index 3705099..08da00b 100755 --- a/common/src/main/java/common/attributes/Attributes.java +++ b/common/src/main/java/common/attributes/Attributes.java @@ -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) { diff --git a/common/src/main/java/common/block/tile/BlockBanner.java b/common/src/main/java/common/block/tile/BlockBanner.java index cec3815..aefc2f3 100755 --- a/common/src/main/java/common/block/tile/BlockBanner.java +++ b/common/src/main/java/common/block/tile/BlockBanner.java @@ -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); } diff --git a/common/src/main/java/common/dimension/Dimension.java b/common/src/main/java/common/dimension/Dimension.java index c4ac4e0..ce8d256 100755 --- a/common/src/main/java/common/dimension/Dimension.java +++ b/common/src/main/java/common/dimension/Dimension.java @@ -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= 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= 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= 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= 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 getEnchantments(ItemStack stack) { Map map = Maps.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 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) { diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index d8bd638..717cf69 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -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; diff --git a/common/src/main/java/common/entity/animal/EntityChicken.java b/common/src/main/java/common/entity/animal/EntityChicken.java index aaec6ab..5e9bc8d 100755 --- a/common/src/main/java/common/entity/animal/EntityChicken.java +++ b/common/src/main/java/common/entity/animal/EntityChicken.java @@ -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); } // /** diff --git a/common/src/main/java/common/entity/animal/EntityHorse.java b/common/src/main/java/common/entity/animal/EntityHorse.java index 458f30a..9452e88 100755 --- a/common/src/main/java/common/entity/animal/EntityHorse.java +++ b/common/src/main/java/common/entity/animal/EntityHorse.java @@ -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)); } diff --git a/common/src/main/java/common/entity/animal/EntityOcelot.java b/common/src/main/java/common/entity/animal/EntityOcelot.java index 12d53c2..4cce764 100755 --- a/common/src/main/java/common/entity/animal/EntityOcelot.java +++ b/common/src/main/java/common/entity/animal/EntityOcelot.java @@ -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")); } /** diff --git a/common/src/main/java/common/entity/animal/EntityPig.java b/common/src/main/java/common/entity/animal/EntityPig.java index 52e04b3..91e9307 100755 --- a/common/src/main/java/common/entity/animal/EntityPig.java +++ b/common/src/main/java/common/entity/animal/EntityPig.java @@ -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")); } /** diff --git a/common/src/main/java/common/entity/animal/EntityRabbit.java b/common/src/main/java/common/entity/animal/EntityRabbit.java index 40e1c34..caef843 100755 --- a/common/src/main/java/common/entity/animal/EntityRabbit.java +++ b/common/src/main/java/common/entity/animal/EntityRabbit.java @@ -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() { diff --git a/common/src/main/java/common/entity/animal/EntitySheep.java b/common/src/main/java/common/entity/animal/EntitySheep.java index 2ef3341..22dd349 100755 --- a/common/src/main/java/common/entity/animal/EntitySheep.java +++ b/common/src/main/java/common/entity/animal/EntitySheep.java @@ -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"))); } diff --git a/common/src/main/java/common/entity/animal/EntityWolf.java b/common/src/main/java/common/entity/animal/EntityWolf.java index caa4b4a..932f1da 100755 --- a/common/src/main/java/common/entity/animal/EntityWolf.java +++ b/common/src/main/java/common/entity/animal/EntityWolf.java @@ -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"))); } diff --git a/common/src/main/java/common/entity/item/EntityCart.java b/common/src/main/java/common/entity/item/EntityCart.java index 6c58128..8f3580b 100755 --- a/common/src/main/java/common/entity/item/EntityCart.java +++ b/common/src/main/java/common/entity/item/EntityCart.java @@ -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) diff --git a/common/src/main/java/common/entity/item/EntityCartContainer.java b/common/src/main/java/common/entity/item/EntityCartContainer.java index 4afb8f5..e717b90 100755 --- a/common/src/main/java/common/entity/item/EntityCartContainer.java +++ b/common/src/main/java/common/entity/item/EntityCartContainer.java @@ -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) diff --git a/common/src/main/java/common/entity/item/EntityExplosion.java b/common/src/main/java/common/entity/item/EntityExplosion.java index e8892bf..48263e9 100755 --- a/common/src/main/java/common/entity/item/EntityExplosion.java +++ b/common/src/main/java/common/entity/item/EntityExplosion.java @@ -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() diff --git a/common/src/main/java/common/entity/item/EntityFalling.java b/common/src/main/java/common/entity/item/EntityFalling.java index b130c2d..866f929 100755 --- a/common/src/main/java/common/entity/item/EntityFalling.java +++ b/common/src/main/java/common/entity/item/EntityFalling.java @@ -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.fallHurtAmount = tagCompund.getFloat("FallHurtAmount"); - this.fallHurtMax = tagCompund.getInteger("FallHurtMax"); - } - else if (block == Blocks.anvil) - { - this.hurtEntities = true; - } + this.hurtEntities = tagCompund.getBool("HurtEntities"); + this.fallHurtAmount = tagCompund.getFloat("FallHurtAmount"); + 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) diff --git a/common/src/main/java/common/entity/item/EntityFireworks.java b/common/src/main/java/common/entity/item/EntityFireworks.java index 56951a5..cf0707a 100755 --- a/common/src/main/java/common/entity/item/EntityFireworks.java +++ b/common/src/main/java/common/entity/item/EntityFireworks.java @@ -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) { diff --git a/common/src/main/java/common/entity/item/EntityHopperCart.java b/common/src/main/java/common/entity/item/EntityHopperCart.java index 398eccf..fe75575 100755 --- a/common/src/main/java/common/entity/item/EntityHopperCart.java +++ b/common/src/main/java/common/entity/item/EntityHopperCart.java @@ -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"); } /** diff --git a/common/src/main/java/common/entity/item/EntityItem.java b/common/src/main/java/common/entity/item/EntityItem.java index 513df22..75f90dc 100755 --- a/common/src/main/java/common/entity/item/EntityItem.java +++ b/common/src/main/java/common/entity/item/EntityItem.java @@ -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"); - } + 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) diff --git a/common/src/main/java/common/entity/item/EntityNuke.java b/common/src/main/java/common/entity/item/EntityNuke.java index 75ee50c..e7af37c 100755 --- a/common/src/main/java/common/entity/item/EntityNuke.java +++ b/common/src/main/java/common/entity/item/EntityNuke.java @@ -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() diff --git a/common/src/main/java/common/entity/item/EntityTntCart.java b/common/src/main/java/common/entity/item/EntityTntCart.java index 4d59b8e..345cf77 100755 --- a/common/src/main/java/common/entity/item/EntityTntCart.java +++ b/common/src/main/java/common/entity/item/EntityTntCart.java @@ -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); } } diff --git a/common/src/main/java/common/entity/npc/EntityGargoyle.java b/common/src/main/java/common/entity/npc/EntityGargoyle.java index 6b5e72a..294c450 100755 --- a/common/src/main/java/common/entity/npc/EntityGargoyle.java +++ b/common/src/main/java/common/entity/npc/EntityGargoyle.java @@ -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() diff --git a/common/src/main/java/common/entity/npc/EntityHaunter.java b/common/src/main/java/common/entity/npc/EntityHaunter.java index 4f5165d..17d7d53 100755 --- a/common/src/main/java/common/entity/npc/EntityHaunter.java +++ b/common/src/main/java/common/entity/npc/EntityHaunter.java @@ -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"); - } + this.fuseTime = tagCompund.getShort("Fuse"); - if (tagCompund.getBoolean("ignited")) + if (tagCompund.getBool("ignited")) { this.ignite(); } diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index 80ece57..1acd05d 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -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) diff --git a/common/src/main/java/common/entity/npc/EntitySlime.java b/common/src/main/java/common/entity/npc/EntitySlime.java index da33477..5adfed1 100755 --- a/common/src/main/java/common/entity/npc/EntitySlime.java +++ b/common/src/main/java/common/entity/npc/EntitySlime.java @@ -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() diff --git a/common/src/main/java/common/entity/projectile/EntityArrow.java b/common/src/main/java/common/entity/projectile/EntityArrow.java index 1b8fd19..f2fade8 100755 --- a/common/src/main/java/common/entity/projectile/EntityArrow.java +++ b/common/src/main/java/common/entity/projectile/EntityArrow.java @@ -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,32 +498,22 @@ 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"); - } + 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; - } + this.canBePickedUp = tagCompund.getByte("pickup"); } /** diff --git a/common/src/main/java/common/entity/projectile/EntityBullet.java b/common/src/main/java/common/entity/projectile/EntityBullet.java index 51f2f9a..2fa707f 100755 --- a/common/src/main/java/common/entity/projectile/EntityBullet.java +++ b/common/src/main/java/common/entity/projectile/EntityBullet.java @@ -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() diff --git a/common/src/main/java/common/entity/projectile/EntityDie.java b/common/src/main/java/common/entity/projectile/EntityDie.java index 1407ba2..d02fcb1 100755 --- a/common/src/main/java/common/entity/projectile/EntityDie.java +++ b/common/src/main/java/common/entity/projectile/EntityDie.java @@ -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() { diff --git a/common/src/main/java/common/entity/projectile/EntityFireball.java b/common/src/main/java/common/entity/projectile/EntityFireball.java index 04ad023..056e3b0 100755 --- a/common/src/main/java/common/entity/projectile/EntityFireball.java +++ b/common/src/main/java/common/entity/projectile/EntityFireball.java @@ -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"); } } diff --git a/common/src/main/java/common/entity/projectile/EntityHook.java b/common/src/main/java/common/entity/projectile/EntityHook.java index 8e51dd4..5e1f9d1 100755 --- a/common/src/main/java/common/entity/projectile/EntityHook.java +++ b/common/src/main/java/common/entity/projectile/EntityHook.java @@ -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; diff --git a/common/src/main/java/common/entity/projectile/EntityPotion.java b/common/src/main/java/common/entity/projectile/EntityPotion.java index 3d477f6..e8aad19 100755 --- a/common/src/main/java/common/entity/projectile/EntityPotion.java +++ b/common/src/main/java/common/entity/projectile/EntityPotion.java @@ -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) diff --git a/common/src/main/java/common/entity/projectile/EntityProjectile.java b/common/src/main/java/common/entity/projectile/EntityProjectile.java index 32dd6d5..06b7e30 100755 --- a/common/src/main/java/common/entity/projectile/EntityProjectile.java +++ b/common/src/main/java/common/entity/projectile/EntityProjectile.java @@ -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"); } /** diff --git a/common/src/main/java/common/entity/types/EntityAnimal.java b/common/src/main/java/common/entity/types/EntityAnimal.java index 3cfde3a..67889f7 100755 --- a/common/src/main/java/common/entity/types/EntityAnimal.java +++ b/common/src/main/java/common/entity/types/EntityAnimal.java @@ -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); } /** diff --git a/common/src/main/java/common/entity/types/EntityLiving.java b/common/src/main/java/common/entity/types/EntityLiving.java index 57174bf..f8417ef 100755 --- a/common/src/main/java/common/entity/types/EntityLiving.java +++ b/common/src/main/java/common/entity/types/EntityLiving.java @@ -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) { diff --git a/common/src/main/java/common/entity/types/EntityTameable.java b/common/src/main/java/common/entity/types/EntityTameable.java index 877b9c9..f67ca74 100755 --- a/common/src/main/java/common/entity/types/EntityTameable.java +++ b/common/src/main/java/common/entity/types/EntityTameable.java @@ -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")); } /** diff --git a/common/src/main/java/common/entity/types/EntityThrowable.java b/common/src/main/java/common/entity/types/EntityThrowable.java index babb6a8..1faa87d 100755 --- a/common/src/main/java/common/entity/types/EntityThrowable.java +++ b/common/src/main/java/common/entity/types/EntityThrowable.java @@ -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; diff --git a/common/src/main/java/common/init/CraftingRegistry.java b/common/src/main/java/common/init/CraftingRegistry.java index b248c5b..deb5830 100755 --- a/common/src/main/java/common/init/CraftingRegistry.java +++ b/common/src/main/java/common/init/CraftingRegistry.java @@ -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) { diff --git a/common/src/main/java/common/init/DispenserRegistry.java b/common/src/main/java/common/init/DispenserRegistry.java index 7b1fcb2..e5c776c 100755 --- a/common/src/main/java/common/init/DispenserRegistry.java +++ b/common/src/main/java/common/init/DispenserRegistry.java @@ -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"); // } diff --git a/common/src/main/java/common/init/UniverseRegistry.java b/common/src/main/java/common/init/UniverseRegistry.java index f68be9a..4f2ffce 100755 --- a/common/src/main/java/common/init/UniverseRegistry.java +++ b/common/src/main/java/common/init/UniverseRegistry.java @@ -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 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 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 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 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 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())); diff --git a/common/src/main/java/common/inventory/ContainerRepair.java b/common/src/main/java/common/inventory/ContainerRepair.java index 505cd44..a73a24d 100755 --- a/common/src/main/java/common/inventory/ContainerRepair.java +++ b/common/src/main/java/common/inventory/ContainerRepair.java @@ -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)) { diff --git a/common/src/main/java/common/inventory/InventoryMerchant.java b/common/src/main/java/common/inventory/InventoryMerchant.java index 223bf4d..10cc4c6 100755 --- a/common/src/main/java/common/inventory/InventoryMerchant.java +++ b/common/src/main/java/common/inventory/InventoryMerchant.java @@ -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 { diff --git a/common/src/main/java/common/inventory/InventoryPlayer.java b/common/src/main/java/common/inventory/InventoryPlayer.java index 6dd9243..ec7adf3 100755 --- a/common/src/main/java/common/inventory/InventoryPlayer.java +++ b/common/src/main/java/common/inventory/InventoryPlayer.java @@ -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); diff --git a/common/src/main/java/common/inventory/InventoryWarpChest.java b/common/src/main/java/common/inventory/InventoryWarpChest.java index 4d83f60..a1202e3 100755 --- a/common/src/main/java/common/inventory/InventoryWarpChest.java +++ b/common/src/main/java/common/inventory/InventoryWarpChest.java @@ -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); } } diff --git a/common/src/main/java/common/inventory/SlotMerchantResult.java b/common/src/main/java/common/inventory/SlotMerchantResult.java index 01998ee..11032f2 100755 --- a/common/src/main/java/common/inventory/SlotMerchantResult.java +++ b/common/src/main/java/common/inventory/SlotMerchantResult.java @@ -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()) { diff --git a/common/src/main/java/common/item/Item.java b/common/src/main/java/common/item/Item.java index b144b84..71c9535 100755 --- a/common/src/main/java/common/item/Item.java +++ b/common/src/main/java/common/item/Item.java @@ -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; //// } //// } diff --git a/common/src/main/java/common/item/ItemArmor.java b/common/src/main/java/common/item/ItemArmor.java index 20723b5..b2cb3d2 100755 --- a/common/src/main/java/common/item/ItemArmor.java +++ b/common/src/main/java/common/item/ItemArmor.java @@ -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 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()); } } diff --git a/common/src/main/java/common/item/ItemBanner.java b/common/src/main/java/common/item/ItemBanner.java index fd76926..323bb66 100755 --- a/common/src/main/java/common/item/ItemBanner.java +++ b/common/src/main/java/common/item/ItemBanner.java @@ -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; // } // } diff --git a/common/src/main/java/common/item/ItemBlock.java b/common/src/main/java/common/item/ItemBlock.java index b6f4928..2a0e781 100755 --- a/common/src/main/java/common/item/ItemBlock.java +++ b/common/src/main/java/common/item/ItemBlock.java @@ -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; // } // } diff --git a/common/src/main/java/common/item/ItemEnchantedBook.java b/common/src/main/java/common/item/ItemEnchantedBook.java index c923726..a5d8d38 100755 --- a/common/src/main/java/common/item/ItemEnchantedBook.java +++ b/common/src/main/java/common/item/ItemEnchantedBook.java @@ -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 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"); diff --git a/common/src/main/java/common/item/ItemFirework.java b/common/src/main/java/common/item/ItemFirework.java index 24450e4..261fa15 100755 --- a/common/src/main/java/common/item/ItemFirework.java +++ b/common/src/main/java/common/item/ItemFirework.java @@ -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 list = Lists.newArrayList(); ItemFireworkCharge.addExplosionInfo(nbttagcompound1, list); diff --git a/common/src/main/java/common/item/ItemFireworkCharge.java b/common/src/main/java/common/item/ItemFireworkCharge.java index 9d0a7f8..04a24a3 100755 --- a/common/src/main/java/common/item/ItemFireworkCharge.java +++ b/common/src/main/java/common/item/ItemFireworkCharge.java @@ -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,58 +20,44 @@ public class ItemFireworkCharge extends Item } else { - NBTBase nbtbase = getExplosionTag(stack, "Colors"); - - if (!(nbtbase instanceof NBTTagIntArray)) + if (stack.hasTagCompound()) { - return 9079434; - } - else - { - NBTTagIntArray nbttagintarray = (NBTTagIntArray)nbtbase; - int[] aint = nbttagintarray.getIntArray(); + NBTTagCompound nbttagcompound = stack.getTagCompound().getTag("Explosion"); - if (aint.length == 1) + if (nbttagcompound != null) { - return aint[0]; - } - else - { - int i = 0; - int j = 0; - int k = 0; + if(nbttagcompound.hasIntArray("Colors")) { + int[] aint = nbttagcompound.getIntArray("Colors"); - for (int l : aint) - { - i += (l & 16711680) >> 16; - j += (l & 65280) >> 8; - k += (l & 255) >> 0; - } + if (aint.length == 1) + { + return aint[0]; + } + else + { + int i = 0; + int j = 0; + int k = 0; - i = i / aint.length; - j = j / aint.length; - k = k / aint.length; - return i << 16 | j << 8 | k; + for (int l : aint) + { + i += (l & 16711680) >> 16; + j += (l & 65280) >> 8; + k += (l & 255) >> 0; + } + + i = i / aint.length; + j = j / aint.length; + k = k / aint.length; + return i << 16 | j << 8 | k; + } + } } } + return 9079434; } } - 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 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) { diff --git a/common/src/main/java/common/item/ItemPotion.java b/common/src/main/java/common/item/ItemPotion.java index c7dcbe1..a6ecbc8 100755 --- a/common/src/main/java/common/item/ItemPotion.java +++ b/common/src/main/java/common/item/ItemPotion.java @@ -40,7 +40,7 @@ public class ItemPotion extends Item public List getEffects(ItemStack stack) { -// if (stack.hasTagCompound() && stack.getTagCompound().hasKey("CustomPotionEffects", 9)) +// if (stack.hasTagCompound() && stack.getTagCompound().hasList("CustomPotionEffects")) // { // List list1 = Lists.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); diff --git a/common/src/main/java/common/item/ItemSign.java b/common/src/main/java/common/item/ItemSign.java index b8e8cdc..b38240f 100755 --- a/common/src/main/java/common/item/ItemSign.java +++ b/common/src/main/java/common/item/ItemSign.java @@ -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; // } // } diff --git a/common/src/main/java/common/item/ItemSkull.java b/common/src/main/java/common/item/ItemSkull.java index ac039ad..1147790 100755 --- a/common/src/main/java/common/item/ItemSkull.java +++ b/common/src/main/java/common/item/ItemSkull.java @@ -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; // } // } diff --git a/common/src/main/java/common/item/ItemStack.java b/common/src/main/java/common/item/ItemStack.java index 0088c3c..4d65c37 100755 --- a/common/src/main/java/common/item/ItemStack.java +++ b/common/src/main/java/common/item/ItemStack.java @@ -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 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> getAttributeModifiers(int type) { Map> multimap; -// if ((type & 1) == 1 && this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9)) +// if ((type & 1) == 1 && this.hasTagCompound() && this.stackTagCompound.hasList("AttributeModifiers")) // { // multimap = HashMultimap.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); // diff --git a/common/src/main/java/common/nbt/NBTBase.java b/common/src/main/java/common/nbt/NBTBase.java index 4fe8be1..4db0708 100755 --- a/common/src/main/java/common/nbt/NBTBase.java +++ b/common/src/main/java/common/nbt/NBTBase.java @@ -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[]"}; +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 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; + } + } - /** - * Write the actual data contents of the tag, implemented in NBT extension classes - */ - abstract void write(DataOutput output) throws IOException; + 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(); - abstract void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException; + public boolean equals(Object other) { + return other instanceof NBTBase && this.getId() == ((NBTBase)other).getId(); + } - 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) - { - 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(); - - case 10: - return new NBTTagCompound(); - - case 11: - return new NBTTagIntArray(); - - default: - return null; - } - } - - /** - * Creates a clone of the tag. - */ - public abstract NBTBase copy(); - - /** - * Return whether this compound has no tags. - */ - public boolean hasNoTags() - { - return false; - } - - 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() - { - 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(); - } + public int hashCode() { + return this.getId(); + } } diff --git a/common/src/main/java/common/nbt/NBTException.java b/common/src/main/java/common/nbt/NBTException.java index 0290c39..4accf8a 100755 --- a/common/src/main/java/common/nbt/NBTException.java +++ b/common/src/main/java/common/nbt/NBTException.java @@ -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); + } } diff --git a/common/src/main/java/common/nbt/NBTLoader.java b/common/src/main/java/common/nbt/NBTLoader.java index a1d0073..230b932 100755 --- a/common/src/main/java/common/nbt/NBTLoader.java +++ b/common/src/main/java/common/nbt/NBTLoader.java @@ -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; - } + tag.write(out); } } diff --git a/common/src/main/java/common/nbt/NBTParser.java b/common/src/main/java/common/nbt/NBTParser.java index 8bb650f..c29527f 100755 --- a/common/src/main/java/common/nbt/NBTParser.java +++ b/common/src/main/java/common/nbt/NBTParser.java @@ -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; diff --git a/common/src/main/java/common/nbt/NBTSizeTracker.java b/common/src/main/java/common/nbt/NBTSizeTracker.java deleted file mode 100755 index 140df95..0000000 --- a/common/src/main/java/common/nbt/NBTSizeTracker.java +++ /dev/null @@ -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); - } - } -} diff --git a/common/src/main/java/common/nbt/NBTTagByte.java b/common/src/main/java/common/nbt/NBTTagByte.java index b5a0644..9cb7267 100755 --- a/common/src/main/java/common/nbt/NBTTagByte.java +++ b/common/src/main/java/common/nbt/NBTTagByte.java @@ -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; - } } diff --git a/common/src/main/java/common/nbt/NBTTagByteArray.java b/common/src/main/java/common/nbt/NBTTagByteArray.java index c5c0417..06b9853 100755 --- a/common/src/main/java/common/nbt/NBTTagByteArray.java +++ b/common/src/main/java/common/nbt/NBTTagByteArray.java @@ -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. */ - private byte[] data; +class NBTTagByteArray extends NBTBase { + private byte[] data; - NBTTagByteArray() - { - } + NBTTagByteArray() { + } - public NBTTagByteArray(byte[] data) - { - this.data = 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 - { - output.writeInt(this.data.length); - output.write(this.data); - } + 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]; - input.readFully(this.data); - } + 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() - { - return (byte)7; - } + public byte getId() { + return (byte)7; + } - public String toString() - { - return "[" + this.data.length + " bytes]"; - } + 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() - { - return super.hashCode() ^ Arrays.hashCode(this.data); - } + public int hashCode() { + return super.hashCode() ^ Arrays.hashCode(this.data); + } - public byte[] getByteArray() - { - return this.data; - } + public byte[] getByteArray() { + return this.data; + } } diff --git a/common/src/main/java/common/nbt/NBTTagCompound.java b/common/src/main/java/common/nbt/NBTTagCompound.java index b64ce1c..71e68dc 100755 --- a/common/src/main/java/common/nbt/NBTTagCompound.java +++ b/common/src/main/java/common/nbt/NBTTagCompound.java @@ -10,476 +10,309 @@ import common.collect.Maps; import java.util.Set; -public class NBTTagCompound extends NBTBase -{ - private Map tagMap = Maps.newHashMap(); +public class NBTTagCompound extends NBTBase { + private Map tags = Maps.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); + } - output.writeByte(0); - } + 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"); + 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); + } + } - void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException - { - sizeTracker.read(384L); + public Set getKeySet() { + return this.tags.keySet(); + } - if (depth > 512) - { - throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512"); - } - else - { - this.tagMap.clear(); - byte b0; + public byte getId() { + return (byte)10; + } - 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); + public void set(String key, NBTBase value) { + this.tags.put(key, value); + } - if (this.tagMap.put(s, nbtbase) != null) - { - sizeTracker.read(288L); - } - } - } - } + public void setTag(String key, NBTTagCompound value) { + this.tags.put(key, value); + } - public Set getKeySet() - { - return this.tagMap.keySet(); - } + public void setFloatList(String key, NBTTagFloatList value) { + this.tags.put(key, value); + } - /** - * Gets the type byte for the tag. - */ - public byte getId() - { - return (byte)10; - } + public void setDoubleList(String key, NBTTagDoubleList value) { + this.tags.put(key, value); + } - /** - * 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 setStringList(String key, NBTTagStringList 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 setIntArrayList(String key, NBTTagIntArrayList 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 setTagList(String key, NBTTagTagList 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 setByte(String key, byte value) { + this.tags.put(key, new NBTTagByte(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 setShort(String key, short value) { + this.tags.put(key, new NBTTagShort(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 setInt(String key, int value) { + this.tags.put(key, new NBTTagInt(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 setLong(String key, long value) { + this.tags.put(key, new NBTTagLong(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 setFloat(String key, float value) { + this.tags.put(key, new NBTTagFloat(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 setDouble(String key, double value) { + this.tags.put(key, new NBTTagDouble(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 setString(String key, String value) { + this.tags.put(key, new NBTTagString(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) - { - this.setByte(key, (byte)(value ? 1 : 0)); - } + public void setByteArray(String key, byte[] value) { + this.tags.put(key, new NBTTagByteArray(value)); + } - /** - * gets a generic tag with the specified name - */ - public NBTBase getTag(String key) - { - return (NBTBase)this.tagMap.get(key); - } + public void setIntArray(String key, int[] value) { + this.tags.put(key, new NBTTagIntArray(value)); + } - /** - * 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 void setBool(String key, boolean value) { + this.setByte(key, (byte)(value ? 1 : 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); - } + public NBTBase get(String key) { + return this.tags.get(key); + } - public boolean hasKey(String key, int type) - { - int i = this.getTagId(key); + public byte getTagId(String key) { + NBTBase tag = this.tags.get(key); + return tag != null ? tag.getId() : 0; + } - if (i == type) - { - return true; - } - else if (type != 99) - { - if (i > 0) - { - ; - } + private boolean hasKey(String key, int type) { + int id = this.getTagId(key); + return id == type || (type == 99 && id >= 1 && id <= 6); + } - return false; - } - else - { - return i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i == 6; - } - } + public boolean hasBool(String key) { + return this.hasByte(key); + } - /** - * 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 hasByte(String key) { + return this.hasKey(key, 1); + } - /** - * 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 hasShort(String key) { + return this.hasKey(key, 2); + } - /** - * 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 hasInt(String key) { + return this.hasKey(key, 3); + } - /** - * 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 hasLong(String key) { + return this.hasKey(key, 4); + } - /** - * 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 hasFloat(String key) { + return this.hasKey(key, 5); + } - /** - * 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 hasDouble(String key) { + return this.hasKey(key, 6); + } - /** - * 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 hasString(String key) { + return this.hasKey(key, 8); + } - /** - * 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 hasByteArray(String key) { + return this.hasKey(key, 7); + } - /** - * 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 hasIntArray(String key) { + return this.hasKey(key, 11); + } - /** - * 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 hasTag(String key) { + return this.hasKey(key, 10); + } - /** - * 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 hasFloatList(String key) { + return this.hasKey(key, 13); + } - /** - * 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) - { - return this.getByte(key) != 0; - } + public boolean hasDoubleList(String key) { + return this.hasKey(key, 14); + } - /** - * Remove the specified tag. - */ - public void removeTag(String key) - { - this.tagMap.remove(key); - } + public boolean hasStringList(String key) { + return this.hasKey(key, 9); + } - public String toString() - { - StringBuilder stringbuilder = new StringBuilder("{"); + public boolean hasIntArrayList(String key) { + return this.hasKey(key, 15); + } - for (Entry entry : this.tagMap.entrySet()) - { - if (stringbuilder.length() != 1) - { - stringbuilder.append(','); - } + public boolean hasTagList(String key) { + return this.hasKey(key, 12); + } - stringbuilder.append((String)entry.getKey()).append(':').append(entry.getValue()); - } + public byte getByte(String key) { + return !this.hasKey(key, 1) ? 0 : ((NBTTagByte)this.tags.get(key)).getByte(); + } - return stringbuilder.append('}').toString(); - } + public short getShort(String key) { + return !this.hasKey(key, 2) ? 0 : ((NBTTagShort)this.tags.get(key)).getShort(); + } - /** - * Return whether this compound has no tags. - */ - public boolean hasNoTags() - { - return this.tagMap.isEmpty(); - } + public int getInt(String key) { + return !this.hasKey(key, 3) ? 0 : ((NBTTagInt)this.tags.get(key)).getInt(); + } - /** - * Creates a clone of the tag. - */ - public NBTBase copy() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); + public long getLong(String key) { + return !this.hasKey(key, 4) ? 0L : ((NBTTagLong)this.tags.get(key)).getLong(); + } - for (String s : this.tagMap.keySet()) - { - nbttagcompound.setTag(s, ((NBTBase)this.tagMap.get(s)).copy()); - } + public float getFloat(String key) { + return !this.hasKey(key, 5) ? 0.0F : ((NBTTagFloat)this.tags.get(key)).getFloat(); + } - return nbttagcompound; - } + public double getDouble(String key) { + return !this.hasKey(key, 6) ? 0.0D : ((NBTTagDouble)this.tags.get(key)).getDouble(); + } - 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; - } - } + public String getString(String key) { + return !this.hasKey(key, 8) ? "" : ((NBTTagString)this.tags.get(key)).getString(); + } - public int hashCode() - { - return super.hashCode() ^ this.tagMap.hashCode(); - } + public byte[] getByteArray(String key) { + return !this.hasKey(key, 7) ? new byte[0] : ((NBTTagByteArray)this.tags.get(key)).getByteArray(); + } - private static void writeEntry(String name, NBTBase data, DataOutput output) throws IOException - { - output.writeByte(data.getId()); + public int[] getIntArray(String key) { + return !this.hasKey(key, 11) ? new int[0] : ((NBTTagIntArray)this.tags.get(key)).getIntArray(); + } - if (data.getId() != 0) - { - output.writeUTF(name); - data.write(output); - } - } + public NBTTagCompound getTag(String key) { + return !this.hasKey(key, 10) ? new NBTTagCompound() : (NBTTagCompound)this.tags.get(key); + } - private static byte readType(DataInput input, NBTSizeTracker sizeTracker) throws IOException - { - return input.readByte(); - } + public NBTTagFloatList getFloatList(String key) { + return !this.hasKey(key, 13) ? new NBTTagFloatList() : (NBTTagFloatList)this.tags.get(key); + } - private static String readKey(DataInput input, NBTSizeTracker sizeTracker) throws IOException - { - return input.readUTF(); - } + public NBTTagDoubleList getDoubleList(String key) { + return !this.hasKey(key, 14) ? new NBTTagDoubleList() : (NBTTagDoubleList)this.tags.get(key); + } - static NBTBase readNBT(byte id, String key, DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException - { - NBTBase nbtbase = NBTBase.createNewByType(id); + public NBTTagStringList getStringList(String key) { + return !this.hasKey(key, 9) ? new NBTTagStringList() : (NBTTagStringList)this.tags.get(key); + } - nbtbase.read(input, depth, sizeTracker); - return nbtbase; - } + public NBTTagIntArrayList getIntArrayList(String key) { + return !this.hasKey(key, 15) ? new NBTTagIntArrayList() : (NBTTagIntArrayList)this.tags.get(key); + } - /** - * 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); + public NBTTagTagList getTagList(String key) { + return !this.hasKey(key, 12) ? new NBTTagTagList() : (NBTTagTagList)this.tags.get(key); + } - 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()); - } - } - } + public boolean getBool(String key) { + return this.getByte(key) != 0; + } + + public void remove(String key) { + this.tags.remove(key); + } + + public String toString() { + StringBuilder sb = new StringBuilder("{"); + for(Entry entry : this.tags.entrySet()) { + if(sb.length() != 1) + sb.append(','); + sb.append(entry.getKey()).append(':').append(entry.getValue()); + } + return sb.append('}').toString(); + } + + public boolean isEmpty() { + return this.tags.isEmpty(); + } + + 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(); + } + + /** + * 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 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); + } + else { + this.set(key, tag.copy()); + } + } + else { + this.set(key, tag.copy()); + } + } + } } diff --git a/common/src/main/java/common/nbt/NBTTagDouble.java b/common/src/main/java/common/nbt/NBTTagDouble.java index 2a711b3..7463b1c 100755 --- a/common/src/main/java/common/nbt/NBTTagDouble.java +++ b/common/src/main/java/common/nbt/NBTTagDouble.java @@ -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; - } } diff --git a/common/src/main/java/common/nbt/NBTTagDoubleList.java b/common/src/main/java/common/nbt/NBTTagDoubleList.java new file mode 100644 index 0000000..4cdc868 --- /dev/null +++ b/common/src/main/java/common/nbt/NBTTagDoubleList.java @@ -0,0 +1,27 @@ +package common.nbt; + +public class NBTTagDoubleList extends NBTTagList { + public byte getId() { + return 14; + } + + public byte getType() { + return 6; + } + + public NBTTagList 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)); + } +} diff --git a/common/src/main/java/common/nbt/NBTTagEnd.java b/common/src/main/java/common/nbt/NBTTagEnd.java index 69fc4a7..167c8b2 100755 --- a/common/src/main/java/common/nbt/NBTTagEnd.java +++ b/common/src/main/java/common/nbt/NBTTagEnd.java @@ -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() - { - return (byte)0; - } + public byte getId() { + return (byte)0; + } - public String toString() - { - return "END"; - } + public String toString() { + return "END"; + } - /** - * Creates a clone of the tag. - */ - public NBTBase copy() - { - return new NBTTagEnd(); - } + public NBTBase copy() { + return new NBTTagEnd(); + } } diff --git a/common/src/main/java/common/nbt/NBTTagFloat.java b/common/src/main/java/common/nbt/NBTTagFloat.java index a51869e..80e5904 100755 --- a/common/src/main/java/common/nbt/NBTTagFloat.java +++ b/common/src/main/java/common/nbt/NBTTagFloat.java @@ -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; diff --git a/common/src/main/java/common/nbt/NBTTagFloatList.java b/common/src/main/java/common/nbt/NBTTagFloatList.java new file mode 100644 index 0000000..db6f005 --- /dev/null +++ b/common/src/main/java/common/nbt/NBTTagFloatList.java @@ -0,0 +1,27 @@ +package common.nbt; + +public class NBTTagFloatList extends NBTTagList { + public byte getId() { + return 13; + } + + public byte getType() { + return 5; + } + + public NBTTagList 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)); + } +} diff --git a/common/src/main/java/common/nbt/NBTTagInt.java b/common/src/main/java/common/nbt/NBTTagInt.java index 50dc226..99d38ee 100755 --- a/common/src/main/java/common/nbt/NBTTagInt.java +++ b/common/src/main/java/common/nbt/NBTTagInt.java @@ -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; - } } diff --git a/common/src/main/java/common/nbt/NBTTagIntArray.java b/common/src/main/java/common/nbt/NBTTagIntArray.java index 657abbe..ffd9259 100755 --- a/common/src/main/java/common/nbt/NBTTagIntArray.java +++ b/common/src/main/java/common/nbt/NBTTagIntArray.java @@ -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); + void write(DataOutput output) throws IOException { + output.writeInt(this.data.length); + for(int i = 0; i < this.data.length; ++i) { + output.writeInt(this.data[i]); + } + } - for (int i = 0; i < this.intArray.length; ++i) - { - output.writeInt(this.intArray[i]); - } - } + 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(); + } + } - 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]; + public byte getId() { + return (byte)11; + } - for (int j = 0; j < i; ++j) - { - this.intArray[j] = input.readInt(); - } - } + public String toString() { + StringBuilder sb = new StringBuilder("["); + for(int i : this.data) { + sb.append(i + ","); + } + return sb.append("]").toString(); + } - /** - * Gets the type byte for the tag. - */ - public byte getId() - { - return (byte)11; - } + public NBTBase copy() { + int[] data = new int[this.data.length]; + System.arraycopy(this.data, 0, data, 0, this.data.length); + return new NBTTagIntArray(data); + } - public String toString() - { - String s = "["; + public boolean equals(Object other) { + return super.equals(other) && Arrays.equals(this.data, ((NBTTagIntArray)other).data); + } - for (int i : this.intArray) - { - s = s + i + ","; - } + public int hashCode() { + return super.hashCode() ^ Arrays.hashCode(this.data); + } - return s + "]"; - } - - /** - * 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 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.intArray); - } - - public int[] getIntArray() - { - return this.intArray; - } + public int[] getIntArray() { + return this.data; + } } diff --git a/common/src/main/java/common/nbt/NBTTagIntArrayList.java b/common/src/main/java/common/nbt/NBTTagIntArrayList.java new file mode 100644 index 0000000..81d34df --- /dev/null +++ b/common/src/main/java/common/nbt/NBTTagIntArrayList.java @@ -0,0 +1,27 @@ +package common.nbt; + +public class NBTTagIntArrayList extends NBTTagList { + public byte getId() { + return 15; + } + + public byte getType() { + return 11; + } + + public NBTTagList 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)); + } +} diff --git a/common/src/main/java/common/nbt/NBTTagList.java b/common/src/main/java/common/nbt/NBTTagList.java index 4052a77..fea099c 100755 --- a/common/src/main/java/common/nbt/NBTTagList.java +++ b/common/src/main/java/common/nbt/NBTTagList.java @@ -9,292 +9,86 @@ import java.util.List; import common.collect.Lists; import common.log.Log; -public class NBTTagList extends NBTBase -{ - private List tagList = Lists.newArrayList(); +abstract class NBTTagList extends NBTBase { + private List list = Lists.newArrayList(); - /** - * The type byte for the tags in the list - they must all be of the same type. - */ - private byte tagType = 0; + 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); + } + } - /** - * 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; - } + 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"); + int len = input.readInt(); + tracker.read(4 * len); + this.list = new ArrayList(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); + } + } - output.writeByte(this.tagType); - output.writeInt(this.tagList.size()); + public abstract byte getId(); + public abstract byte getType(); + public abstract NBTTagList createInstance(); + public abstract K getDefault(); - for (int i = 0; i < this.tagList.size(); ++i) - { - ((NBTBase)this.tagList.get(i)).write(output); - } - } + 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(); + } - void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException - { - sizeTracker.read(296L); + protected void add(K tag) { + this.list.add(tag); + } - 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(); + 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.list.set(index, tag); + } - if (this.tagType == 0 && i > 0) - { - throw new RuntimeException("Missing type on ListTag"); - } - else - { - sizeTracker.read(32L * (long)i); - this.tagList = new ArrayList(i); + public K remove(int index) { + return this.list.remove(index); + } - for (int j = 0; j < i; ++j) - { - NBTBase nbtbase = NBTBase.createNewByType(this.tagType); - nbtbase.read(input, depth + 1, sizeTracker); - this.tagList.add(nbtbase); - } - } - } - } + public boolean isEmpty() { + return this.list.isEmpty(); + } - /** - * Gets the type byte for the tag. - */ - public byte getId() - { - return (byte)9; - } + protected K get(int index) { + return index >= 0 && index < this.list.size() ? this.list.get(index) : this.getDefault(); + } - public String toString() - { - StringBuilder stringbuilder = new StringBuilder("["); + public int size() { + return this.list.size(); + } - for (int i = 0; i < this.tagList.size(); ++i) - { - if (i != 0) - { - stringbuilder.append(','); - } + public NBTBase copy() { + NBTTagList list = this.createInstance(); + for(K tag : this.list) { + list.list.add((K)tag.copy()); + } + return list; + } - stringbuilder.append(i).append(':').append(this.tagList.get(i)); - } + public boolean equals(Object other) { + return super.equals(other) && this.list.equals(((NBTTagList)other).list); + } - 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"); - return; - } - - this.tagList.add(nbt); - } - } - - /** - * 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; - } - - this.tagList.set(idx, nbt); - } - else - { - Log.IO.warn("Index außerhalb des Bereiches um Tag in Tag-Liste zu setzen"); - } - } - - /** - * Removes a tag at the given index. - */ - public NBTBase removeTag(int i) - { - return (NBTBase)this.tagList.remove(i); - } - - /** - * Return whether this compound has no tags. - */ - public boolean hasNoTags() - { - return this.tagList.isEmpty(); - } - - /** - * 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 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 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(); + } } diff --git a/common/src/main/java/common/nbt/NBTTagLong.java b/common/src/main/java/common/nbt/NBTTagLong.java index aa9313a..47061cb 100755 --- a/common/src/main/java/common/nbt/NBTTagLong.java +++ b/common/src/main/java/common/nbt/NBTTagLong.java @@ -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; - } } diff --git a/common/src/main/java/common/nbt/NBTTagShort.java b/common/src/main/java/common/nbt/NBTTagShort.java index 684aa95..0b3a9cc 100755 --- a/common/src/main/java/common/nbt/NBTTagShort.java +++ b/common/src/main/java/common/nbt/NBTTagShort.java @@ -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; - } } diff --git a/common/src/main/java/common/nbt/NBTTagString.java b/common/src/main/java/common/nbt/NBTTagString.java index 5968697..4e91ab2 100755 --- a/common/src/main/java/common/nbt/NBTTagString.java +++ b/common/src/main/java/common/nbt/NBTTagString.java @@ -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). */ - private String data; +class NBTTagString extends NBTBase { + private String data; - public NBTTagString() - { - this.data = ""; - } + public NBTTagString() { + this.data = ""; + } - public NBTTagString(String data) - { - this.data = 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"); - } - } + void write(DataOutput output) throws IOException { + output.writeUTF(this.data); + } - /** - * Write the actual data contents of the tag, implemented in NBT extension classes - */ - void write(DataOutput output) throws IOException - { - output.writeUTF(this.data); - } + void read(DataInput input, int depth, SizeTracker tracker) throws IOException { + tracker.read(36); + this.data = input.readUTF(); + tracker.read(2 * this.data.length()); + } - void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException - { - sizeTracker.read(288L); - this.data = input.readUTF(); - sizeTracker.read((long)(16 * this.data.length())); - } + public byte getId() { + return (byte)8; + } - /** - * Gets the type byte for the tag. - */ - public byte getId() - { - return (byte)8; - } + public String toString() { + return "\"" + this.data.replace("\"", "\\\"") + "\""; + } - public String toString() - { - return "\"" + this.data.replace("\"", "\\\"") + "\""; - } + public NBTBase copy() { + return new NBTTagString(this.data); + } - /** - * Creates a clone of the tag. - */ - public NBTBase copy() - { - return new NBTTagString(this.data); - } + public boolean equals(Object other) { + if(!super.equals(other)) + return false; + NBTTagString tag = (NBTTagString)other; + return this.data == null && tag.data == null || this.data != null && this.data.equals(tag.data); + } - /** - * Return whether this compound has no tags. - */ - public boolean hasNoTags() - { - return this.data.isEmpty(); - } + public int hashCode() { + return super.hashCode() ^ this.data.hashCode(); + } - public boolean equals(Object p_equals_1_) - { - if (!super.equals(p_equals_1_)) - { - return false; - } - else - { - NBTTagString nbttagstring = (NBTTagString)p_equals_1_; - return this.data == null && nbttagstring.data == null || this.data != null && this.data.equals(nbttagstring.data); - } - } - - public int hashCode() - { - return super.hashCode() ^ this.data.hashCode(); - } - - public String getString() - { - return this.data; - } + public String getString() { + return this.data; + } } diff --git a/common/src/main/java/common/nbt/NBTTagStringList.java b/common/src/main/java/common/nbt/NBTTagStringList.java new file mode 100644 index 0000000..b3bd787 --- /dev/null +++ b/common/src/main/java/common/nbt/NBTTagStringList.java @@ -0,0 +1,27 @@ +package common.nbt; + +public class NBTTagStringList extends NBTTagList { + public byte getId() { + return 9; + } + + public byte getType() { + return 8; + } + + public NBTTagList 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)); + } +} diff --git a/common/src/main/java/common/nbt/NBTTagTagList.java b/common/src/main/java/common/nbt/NBTTagTagList.java new file mode 100644 index 0000000..988aebe --- /dev/null +++ b/common/src/main/java/common/nbt/NBTTagTagList.java @@ -0,0 +1,27 @@ +package common.nbt; + +public class NBTTagTagList extends NBTTagList { + public byte getId() { + return 12; + } + + public byte getType() { + return 10; + } + + public NBTTagList 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); + } +} diff --git a/common/src/main/java/common/nbt/NBTUtil.java b/common/src/main/java/common/nbt/NBTUtil.java deleted file mode 100755 index 8d3eaf8..0000000 --- a/common/src/main/java/common/nbt/NBTUtil.java +++ /dev/null @@ -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); - } - } -} diff --git a/common/src/main/java/common/nbt/SizeTracker.java b/common/src/main/java/common/nbt/SizeTracker.java new file mode 100755 index 0000000..e583b14 --- /dev/null +++ b/common/src/main/java/common/nbt/SizeTracker.java @@ -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"); + } +} diff --git a/common/src/main/java/common/network/PacketBuffer.java b/common/src/main/java/common/network/PacketBuffer.java index e7630ac..1c7196f 100755 --- a/common/src/main/java/common/network/PacketBuffer.java +++ b/common/src/main/java/common/network/PacketBuffer.java @@ -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) { diff --git a/common/src/main/java/common/packet/SPacketTrades.java b/common/src/main/java/common/packet/SPacketTrades.java index 2b1f8fb..a867576 100755 --- a/common/src/main/java/common/packet/SPacketTrades.java +++ b/common/src/main/java/common/packet/SPacketTrades.java @@ -69,9 +69,9 @@ public class SPacketTrades implements Packet 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) diff --git a/common/src/main/java/common/potion/PotionEffect.java b/common/src/main/java/common/potion/PotionEffect.java index dd0357c..91d83bf 100755 --- a/common/src/main/java/common/potion/PotionEffect.java +++ b/common/src/main/java/common/potion/PotionEffect.java @@ -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")); } } diff --git a/common/src/main/java/common/tileentity/LockCode.java b/common/src/main/java/common/tileentity/LockCode.java index cc8da4e..63d34b7 100755 --- a/common/src/main/java/common/tileentity/LockCode.java +++ b/common/src/main/java/common/tileentity/LockCode.java @@ -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); diff --git a/common/src/main/java/common/tileentity/MachineResource.java b/common/src/main/java/common/tileentity/MachineResource.java index 07075bd..a21c1a6 100755 --- a/common/src/main/java/common/tileentity/MachineResource.java +++ b/common/src/main/java/common/tileentity/MachineResource.java @@ -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) { diff --git a/common/src/main/java/common/tileentity/TileEntity.java b/common/src/main/java/common/tileentity/TileEntity.java index e65d5d9..2f96938 100755 --- a/common/src/main/java/common/tileentity/TileEntity.java +++ b/common/src/main/java/common/tileentity/TileEntity.java @@ -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()); } } diff --git a/common/src/main/java/common/tileentity/TileEntityBanner.java b/common/src/main/java/common/tileentity/TileEntityBanner.java index 5691dd5..2e158fb 100755 --- a/common/src/main/java/common/tileentity/TileEntityBanner.java +++ b/common/src/main/java/common/tileentity/TileEntityBanner.java @@ -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 patternList; private List 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 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); } diff --git a/common/src/main/java/common/tileentity/TileEntityBeacon.java b/common/src/main/java/common/tileentity/TileEntityBeacon.java index 9cdb493..99f86fd 100755 --- a/common/src/main/java/common/tileentity/TileEntityBeacon.java +++ b/common/src/main/java/common/tileentity/TileEntityBeacon.java @@ -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()); } diff --git a/common/src/main/java/common/tileentity/TileEntityBrewingStand.java b/common/src/main/java/common/tileentity/TileEntityBrewingStand.java index b1c3152..f07e904 100755 --- a/common/src/main/java/common/tileentity/TileEntityBrewingStand.java +++ b/common/src/main/java/common/tileentity/TileEntityBrewingStand.java @@ -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()) { diff --git a/common/src/main/java/common/tileentity/TileEntityChest.java b/common/src/main/java/common/tileentity/TileEntityChest.java index d426c7c..f3f872a 100755 --- a/common/src/main/java/common/tileentity/TileEntityChest.java +++ b/common/src/main/java/common/tileentity/TileEntityChest.java @@ -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()) { diff --git a/common/src/main/java/common/tileentity/TileEntityComparator.java b/common/src/main/java/common/tileentity/TileEntityComparator.java index 55b488d..3f80903 100755 --- a/common/src/main/java/common/tileentity/TileEntityComparator.java +++ b/common/src/main/java/common/tileentity/TileEntityComparator.java @@ -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() diff --git a/common/src/main/java/common/tileentity/TileEntityDispenser.java b/common/src/main/java/common/tileentity/TileEntityDispenser.java index d7910b0..9096359 100755 --- a/common/src/main/java/common/tileentity/TileEntityDispenser.java +++ b/common/src/main/java/common/tileentity/TileEntityDispenser.java @@ -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()) { diff --git a/common/src/main/java/common/tileentity/TileEntityEnchantmentTable.java b/common/src/main/java/common/tileentity/TileEntityEnchantmentTable.java index b3ae645..8025481 100755 --- a/common/src/main/java/common/tileentity/TileEntityEnchantmentTable.java +++ b/common/src/main/java/common/tileentity/TileEntityEnchantmentTable.java @@ -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"); } diff --git a/common/src/main/java/common/tileentity/TileEntityFurnace.java b/common/src/main/java/common/tileentity/TileEntityFurnace.java index c103aa7..13058c6 100755 --- a/common/src/main/java/common/tileentity/TileEntityFurnace.java +++ b/common/src/main/java/common/tileentity/TileEntityFurnace.java @@ -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()) { diff --git a/common/src/main/java/common/tileentity/TileEntityHopper.java b/common/src/main/java/common/tileentity/TileEntityHopper.java index 4667f09..8b7d1fc 100755 --- a/common/src/main/java/common/tileentity/TileEntityHopper.java +++ b/common/src/main/java/common/tileentity/TileEntityHopper.java @@ -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()) { diff --git a/common/src/main/java/common/tileentity/TileEntityMachine.java b/common/src/main/java/common/tileentity/TileEntityMachine.java index 84fb12c..9ea3593 100755 --- a/common/src/main/java/common/tileentity/TileEntityMachine.java +++ b/common/src/main/java/common/tileentity/TileEntityMachine.java @@ -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()); } diff --git a/common/src/main/java/common/tileentity/TileEntityMobSpawner.java b/common/src/main/java/common/tileentity/TileEntityMobSpawner.java index 0168d35..49a3263 100755 --- a/common/src/main/java/common/tileentity/TileEntityMobSpawner.java +++ b/common/src/main/java/common/tileentity/TileEntityMobSpawner.java @@ -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"); } diff --git a/common/src/main/java/common/tileentity/TileEntityPiston.java b/common/src/main/java/common/tileentity/TileEntityPiston.java index d4cc931..7f26755 100755 --- a/common/src/main/java/common/tileentity/TileEntityPiston.java +++ b/common/src/main/java/common/tileentity/TileEntityPiston.java @@ -201,20 +201,20 @@ public class TileEntityPiston extends TileEntity implements ITickable public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); - this.pistonState = BlockRegistry.getBlockById(compound.getInteger("blockId")).getStateFromMeta(compound.getInteger("blockData")); - this.pistonFacing = Facing.getFront(compound.getInteger("facing")); + this.pistonState = BlockRegistry.getBlockById(compound.getInt("blockId")).getStateFromMeta(compound.getInt("blockData")); + this.pistonFacing = Facing.getFront(compound.getInt("facing")); this.lastProgress = this.progress = compound.getFloat("progress"); - this.extending = compound.getBoolean("extending"); + this.extending = compound.getBool("extending"); } public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); - compound.setInteger("blockId", BlockRegistry.getIdFromBlock(this.pistonState.getBlock())); - compound.setInteger("blockData", this.pistonState.getBlock().getMetaFromState(this.pistonState)); - compound.setInteger("facing", this.pistonFacing.getIndex()); + compound.setInt("blockId", BlockRegistry.getIdFromBlock(this.pistonState.getBlock())); + compound.setInt("blockData", this.pistonState.getBlock().getMetaFromState(this.pistonState)); + compound.setInt("facing", this.pistonFacing.getIndex()); compound.setFloat("progress", this.lastProgress); - compound.setBoolean("extending", this.extending); + compound.setBool("extending", this.extending); } public int getColor() { diff --git a/common/src/main/java/common/tileentity/TileEntitySign.java b/common/src/main/java/common/tileentity/TileEntitySign.java index b567287..4d74f43 100755 --- a/common/src/main/java/common/tileentity/TileEntitySign.java +++ b/common/src/main/java/common/tileentity/TileEntitySign.java @@ -38,7 +38,7 @@ public class TileEntitySign extends TileEntity { this.signText[i] = compound.getString("Text" + (i + 1)); } -// if(compound.hasKey("Command", 8)) +// if(compound.hasString("Command")) // this.command = compound.getString("Command"); // if(!compound.getBoolean("NewFormat")) { diff --git a/common/src/main/java/common/tileentity/TileEntitySkull.java b/common/src/main/java/common/tileentity/TileEntitySkull.java index cd55919..76cd968 100755 --- a/common/src/main/java/common/tileentity/TileEntitySkull.java +++ b/common/src/main/java/common/tileentity/TileEntitySkull.java @@ -21,7 +21,7 @@ public class TileEntitySkull extends TileEntity { super.readFromNBT(compound); this.skullRotation = compound.getByte("Rot"); -// if(compound.hasKey("Owner", 8)) +// if(compound.hasString("Owner")) // this.user = compound.getString("Owner"); } diff --git a/common/src/main/java/common/village/MerchantRecipe.java b/common/src/main/java/common/village/MerchantRecipe.java index 28e4dfe..03e4c85 100755 --- a/common/src/main/java/common/village/MerchantRecipe.java +++ b/common/src/main/java/common/village/MerchantRecipe.java @@ -4,75 +4,53 @@ import common.item.Item; import common.item.ItemStack; import common.nbt.NBTTagCompound; -public class MerchantRecipe -{ - private ItemStack itemToBuy; - private ItemStack secondItemToBuy; - private ItemStack itemToSell; +public class MerchantRecipe { + private final ItemStack buying; + private final ItemStack buySecond; + private final ItemStack selling; - public MerchantRecipe(NBTTagCompound tagCompound) - { - this.readFromTags(tagCompound); - } + public MerchantRecipe(NBTTagCompound tag) { + this.buying = ItemStack.loadItemStackFromNBT(tag.getTag("buy")); + this.selling = ItemStack.loadItemStackFromNBT(tag.getTag("sell")); + this.buySecond = tag.hasTag("buyB") ? ItemStack.loadItemStackFromNBT(tag.getTag("buyB")) : null; + } - public MerchantRecipe(ItemStack buy1, ItemStack buy2, ItemStack sell) - { - this.itemToBuy = buy1; - this.secondItemToBuy = buy2; - this.itemToSell = sell; - } + public MerchantRecipe(ItemStack buy1, ItemStack buy2, ItemStack sell) { + this.buying = buy1; + this.buySecond = buy2; + this.selling = sell; + } - public MerchantRecipe(ItemStack buy1, ItemStack sell) - { - this(buy1, (ItemStack)null, sell); - } + public MerchantRecipe(ItemStack buy, ItemStack sell) { + this(buy, null, sell); + } - public MerchantRecipe(ItemStack buy1, Item sellItem) - { - this(buy1, new ItemStack(sellItem)); - } - - public ItemStack getItemToBuy() - { - return this.itemToBuy; - } - - public ItemStack getSecondItemToBuy() - { - return this.secondItemToBuy; - } - - public boolean hasSecondItemToBuy() - { - return this.secondItemToBuy != null; - } - - public ItemStack getItemToSell() - { - return this.itemToSell; - } + public MerchantRecipe(ItemStack buy, Item sell) { + this(buy, new ItemStack(sell)); + } - public void readFromTags(NBTTagCompound tagCompound) - { - NBTTagCompound nbttagcompound = tagCompound.getCompoundTag("buy"); - this.itemToBuy = ItemStack.loadItemStackFromNBT(nbttagcompound); - NBTTagCompound nbttagcompound1 = tagCompound.getCompoundTag("sell"); - this.itemToSell = ItemStack.loadItemStackFromNBT(nbttagcompound1); - if (tagCompound.hasKey("buyB", 10)) - { - this.secondItemToBuy = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("buyB")); - } - } + public ItemStack getBuying() { + return this.buying; + } - public NBTTagCompound writeToTags() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setTag("buy", this.itemToBuy.writeToNBT(new NBTTagCompound())); - nbttagcompound.setTag("sell", this.itemToSell.writeToNBT(new NBTTagCompound())); - if (this.secondItemToBuy != null) - { - nbttagcompound.setTag("buyB", this.secondItemToBuy.writeToNBT(new NBTTagCompound())); - } - return nbttagcompound; - } + public ItemStack getSecondBuy() { + return this.buySecond; + } + + public boolean hasSecondBuy() { + return this.buySecond != null; + } + + public ItemStack getSelling() { + return this.selling; + } + + public NBTTagCompound toNbt() { + NBTTagCompound tag = new NBTTagCompound(); + tag.setTag("buy", this.buying.writeToNBT(new NBTTagCompound())); + tag.setTag("sell", this.selling.writeToNBT(new NBTTagCompound())); + if(this.buySecond != null) + tag.setTag("buyB", this.buySecond.writeToNBT(new NBTTagCompound())); + return tag; + } } diff --git a/common/src/main/java/common/village/MerchantRecipeList.java b/common/src/main/java/common/village/MerchantRecipeList.java index d28a1c7..b652df2 100755 --- a/common/src/main/java/common/village/MerchantRecipeList.java +++ b/common/src/main/java/common/village/MerchantRecipeList.java @@ -3,130 +3,69 @@ package common.village; import java.util.ArrayList; import common.item.ItemStack; +import common.nbt.NBTBase; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; -import common.nbt.NBTUtil; +import common.nbt.NBTTagTagList; -public class MerchantRecipeList extends ArrayList -{ - public MerchantRecipeList() - { - } +public class MerchantRecipeList extends ArrayList { + public MerchantRecipe canUse(ItemStack stack1, ItemStack stack2, int index) { + if(index > 0 && index < this.size()) { + MerchantRecipe recipe = this.get(index); + return !areItemsSimilar(stack1, recipe.getBuying()) + || (stack2 != null || recipe.hasSecondBuy()) + && (!recipe.hasSecondBuy() || !areItemsSimilar(stack2, recipe.getSecondBuy())) + || stack1.stackSize < recipe.getBuying().stackSize + || recipe.hasSecondBuy() && stack2.stackSize < recipe.getSecondBuy().stackSize ? null : recipe; + } + else { + for(int z = 0; z < this.size(); z++) { + MerchantRecipe recipe = this.get(z); + if(areItemsSimilar(stack1, recipe.getBuying()) && stack1.stackSize >= recipe.getBuying().stackSize + && (!recipe.hasSecondBuy() && stack2 == null + || recipe.hasSecondBuy() && areItemsSimilar(stack2, recipe.getSecondBuy()) + && stack2.stackSize >= recipe.getSecondBuy().stackSize)) { + return recipe; + } + } + return null; + } + } - public MerchantRecipeList(NBTTagCompound compound) - { - this.readRecipiesFromTags(compound); - } + private static boolean areItemsSimilar(ItemStack stack1, ItemStack stack2) { + return ItemStack.areItemsEqual(stack1, stack2) + && (!stack2.hasTagCompound() || stack1.hasTagCompound() && compareTags(stack2.getTagCompound(), stack1.getTagCompound())); + } + + private static boolean compareTags(NBTBase tag1, NBTBase tag2) { + if(tag1 == tag2 || tag1 == null) + return true; + else if(tag2 == null || !tag1.getClass().equals(tag2.getClass())) + return false; + else if(tag1 instanceof NBTTagCompound) { + NBTTagCompound comp1 = (NBTTagCompound)tag1; + NBTTagCompound comp2 = (NBTTagCompound)tag2; + for(String key : comp1.getKeySet()) { + NBTBase tag = comp1.get(key); + if(!compareTags(tag, comp2.get(key))) + return false; + } + return true; + } + return tag1.equals(tag2); + } - /** - * can par1,par2 be used to in crafting recipe par3 - */ - public MerchantRecipe canRecipeBeUsed(ItemStack p_77203_1_, ItemStack p_77203_2_, int p_77203_3_) - { - if (p_77203_3_ > 0 && p_77203_3_ < this.size()) - { - MerchantRecipe merchantrecipe1 = (MerchantRecipe)this.get(p_77203_3_); - return !this.func_181078_a(p_77203_1_, merchantrecipe1.getItemToBuy()) || (p_77203_2_ != null || merchantrecipe1.hasSecondItemToBuy()) && (!merchantrecipe1.hasSecondItemToBuy() || !this.func_181078_a(p_77203_2_, merchantrecipe1.getSecondItemToBuy())) || p_77203_1_.stackSize < merchantrecipe1.getItemToBuy().stackSize || merchantrecipe1.hasSecondItemToBuy() && p_77203_2_.stackSize < merchantrecipe1.getSecondItemToBuy().stackSize ? null : merchantrecipe1; - } - else - { - for (int i = 0; i < this.size(); ++i) - { - MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i); + public void fromNbt(NBTTagTagList list) { + this.clear(); + for(int z = 0; z < list.size(); z++) { + this.add(new MerchantRecipe(list.getTag(z))); + } + } - if (this.func_181078_a(p_77203_1_, merchantrecipe.getItemToBuy()) && p_77203_1_.stackSize >= merchantrecipe.getItemToBuy().stackSize && (!merchantrecipe.hasSecondItemToBuy() && p_77203_2_ == null || merchantrecipe.hasSecondItemToBuy() && this.func_181078_a(p_77203_2_, merchantrecipe.getSecondItemToBuy()) && p_77203_2_.stackSize >= merchantrecipe.getSecondItemToBuy().stackSize)) - { - return merchantrecipe; - } - } - - return null; - } - } - - private boolean func_181078_a(ItemStack p_181078_1_, ItemStack p_181078_2_) - { - return ItemStack.areItemsEqual(p_181078_1_, p_181078_2_) && (!p_181078_2_.hasTagCompound() || p_181078_1_.hasTagCompound() && NBTUtil.compareTags(p_181078_2_.getTagCompound(), p_181078_1_.getTagCompound(), false)); - } - -// public void writeToBuf(PacketBuffer buffer) -// { -// buffer.writeByte((byte)(this.size() & 255)); -// -// for (int i = 0; i < this.size(); ++i) -// { -// MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i); -// buffer.writeItemStackToBuffer(merchantrecipe.getItemToBuy()); -// buffer.writeItemStackToBuffer(merchantrecipe.getItemToSell()); -// ItemStack itemstack = merchantrecipe.getSecondItemToBuy(); -// buffer.writeBoolean(itemstack != null); -// -// if (itemstack != null) -// { -// buffer.writeItemStackToBuffer(itemstack); -// } -// -// buffer.writeBoolean(merchantrecipe.isRecipeDisabled()); -// buffer.writeInt(merchantrecipe.getToolUses()); -// buffer.writeInt(merchantrecipe.getMaxTradeUses()); -// } -// } -// -// public static MerchantRecipeList readFromBuf(PacketBuffer buffer) throws IOException -// { -// MerchantRecipeList merchantrecipelist = new MerchantRecipeList(); -// int i = buffer.readByte() & 255; -// -// for (int j = 0; j < i; ++j) -// { -// ItemStack itemstack = buffer.readItemStackFromBuffer(); -// ItemStack itemstack1 = buffer.readItemStackFromBuffer(); -// ItemStack itemstack2 = null; -// -// if (buffer.readBoolean()) -// { -// itemstack2 = buffer.readItemStackFromBuffer(); -// } -// -// boolean flag = buffer.readBoolean(); -// int k = buffer.readInt(); -// int l = buffer.readInt(); -// MerchantRecipe merchantrecipe = new MerchantRecipe(itemstack, itemstack2, itemstack1, k, l); -// -// if (flag) -// { -// merchantrecipe.compensateToolUses(); -// } -// -// merchantrecipelist.add(merchantrecipe); -// } -// -// return merchantrecipelist; -// } - - public void readRecipiesFromTags(NBTTagCompound compound) - { - NBTTagList nbttaglist = compound.getTagList("Recipes", 10); - - for (int i = 0; i < nbttaglist.tagCount(); ++i) - { - NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); - this.add(new MerchantRecipe(nbttagcompound)); - } - } - - public NBTTagCompound getRecipiesAsTags() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.size(); ++i) - { - MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i); - nbttaglist.appendTag(merchantrecipe.writeToTags()); - } - - nbttagcompound.setTag("Recipes", nbttaglist); - return nbttagcompound; - } + public NBTTagTagList toNbt() { + NBTTagTagList list = new NBTTagTagList(); + for(int z = 0; z < this.size(); z++) { + list.add(this.get(z).toNbt()); + } + return list; + } } diff --git a/common/src/main/java/common/village/Village.java b/common/src/main/java/common/village/Village.java index 3801d4e..8ad4f1a 100755 --- a/common/src/main/java/common/village/Village.java +++ b/common/src/main/java/common/village/Village.java @@ -8,7 +8,7 @@ import common.block.Material; import common.block.artificial.BlockDoor; import common.collect.Lists; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; +import common.nbt.NBTTagTagList; import common.util.BlockPos; import common.world.AWorldServer; @@ -212,18 +212,18 @@ public class Village public void readVillageDataFromNBT(NBTTagCompound compound) { // this.numVillagers = compound.getInteger("PopSize"); - this.radius = compound.getInteger("Radius"); + this.radius = compound.getInt("Radius"); // this.lastDoor = compound.getInteger("Stable"); // this.tickCounter = compound.getInteger("Tick"); // this.noBreedTicks = compound.getInteger("MTick"); - this.center = new BlockPos(compound.getInteger("CX"), compound.getInteger("CY"), compound.getInteger("CZ")); - this.doorRange = new BlockPos(compound.getInteger("ACX"), compound.getInteger("ACY"), compound.getInteger("ACZ")); - NBTTagList nbttaglist = compound.getTagList("Doors", 10); + this.center = new BlockPos(compound.getInt("CX"), compound.getInt("CY"), compound.getInt("CZ")); + this.doorRange = new BlockPos(compound.getInt("ACX"), compound.getInt("ACY"), compound.getInt("ACZ")); + NBTTagTagList nbttaglist = compound.getTagList("Doors"); - for (int i = 0; i < nbttaglist.tagCount(); ++i) + for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); - VillageDoorInfo villagedoorinfo = new VillageDoorInfo(new BlockPos(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Y"), nbttagcompound.getInteger("Z")), nbttagcompound.getInteger("IDX"), nbttagcompound.getInteger("IDZ"), nbttagcompound.getInteger("TS")); + NBTTagCompound nbttagcompound = nbttaglist.getTag(i); + VillageDoorInfo villagedoorinfo = new VillageDoorInfo(new BlockPos(nbttagcompound.getInt("X"), nbttagcompound.getInt("Y"), nbttagcompound.getInt("Z")), nbttagcompound.getInt("IDX"), nbttagcompound.getInt("IDZ"), nbttagcompound.getInt("TS")); this.doors.add(villagedoorinfo); } } @@ -231,30 +231,30 @@ public class Village public void writeVillageDataToNBT(NBTTagCompound compound) { // compound.setInteger("PopSize", this.numVillagers); - compound.setInteger("Radius", this.radius); + compound.setInt("Radius", this.radius); // compound.setInteger("Stable", this.lastDoor); // compound.setInteger("Tick", this.tickCounter); // compound.setInteger("MTick", this.noBreedTicks); - compound.setInteger("CX", this.center.getX()); - compound.setInteger("CY", this.center.getY()); - compound.setInteger("CZ", this.center.getZ()); - compound.setInteger("ACX", this.doorRange.getX()); - compound.setInteger("ACY", this.doorRange.getY()); - compound.setInteger("ACZ", this.doorRange.getZ()); - NBTTagList nbttaglist = new NBTTagList(); + compound.setInt("CX", this.center.getX()); + compound.setInt("CY", this.center.getY()); + compound.setInt("CZ", this.center.getZ()); + compound.setInt("ACX", this.doorRange.getX()); + compound.setInt("ACY", this.doorRange.getY()); + compound.setInt("ACZ", this.doorRange.getZ()); + NBTTagTagList nbttaglist = new NBTTagTagList(); for (VillageDoorInfo villagedoorinfo : this.doors) { NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("X", villagedoorinfo.getDoorBlockPos().getX()); - nbttagcompound.setInteger("Y", villagedoorinfo.getDoorBlockPos().getY()); - nbttagcompound.setInteger("Z", villagedoorinfo.getDoorBlockPos().getZ()); - nbttagcompound.setInteger("IDX", villagedoorinfo.getInsideOffsetX()); - nbttagcompound.setInteger("IDZ", villagedoorinfo.getInsideOffsetZ()); - nbttagcompound.setInteger("TS", villagedoorinfo.getInsidePosY()); - nbttaglist.appendTag(nbttagcompound); + nbttagcompound.setInt("X", villagedoorinfo.getDoorBlockPos().getX()); + nbttagcompound.setInt("Y", villagedoorinfo.getDoorBlockPos().getY()); + nbttagcompound.setInt("Z", villagedoorinfo.getDoorBlockPos().getZ()); + nbttagcompound.setInt("IDX", villagedoorinfo.getInsideOffsetX()); + nbttagcompound.setInt("IDZ", villagedoorinfo.getInsideOffsetZ()); + nbttagcompound.setInt("TS", villagedoorinfo.getInsidePosY()); + nbttaglist.add(nbttagcompound); } - compound.setTag("Doors", nbttaglist); + compound.setTagList("Doors", nbttaglist); } } diff --git a/server/src/main/java/server/Server.java b/server/src/main/java/server/Server.java index 3eea84d..2d4f6f5 100755 --- a/server/src/main/java/server/Server.java +++ b/server/src/main/java/server/Server.java @@ -45,7 +45,8 @@ import common.init.Config.ValueType; import common.log.Log; import common.nbt.NBTLoader; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; +import common.nbt.NBTTagDoubleList; +import common.nbt.NBTTagFloatList; import common.net.bootstrap.ServerBootstrap; import common.net.channel.Channel; import common.net.channel.ChannelException; @@ -206,15 +207,15 @@ public final class Server implements IThreadListener { if(file.exists()) { try { NBTTagCompound tag = NBTLoader.readGZip(file); - NBTTagCompound cfg = tag.getCompoundTag("Config"); + NBTTagCompound cfg = tag.getTag("Config"); for(String key : cfg.getKeySet()) { Config.set(key, cfg.getString(key), false); } - UniverseRegistry.loadNbt(tag.getCompoundTag("Universe")); + UniverseRegistry.loadNbt(tag.getTag("Universe")); long lastPlayed = tag.getLong("LastAccess"); - String version = tag.hasKey("Version", 8) ? tag.getString("Version") : null; + String version = tag.hasString("Version") ? tag.getString("Version") : null; version = version != null && version.isEmpty() ? "" : version; - long time = tag.hasKey("Time", 4) ? tag.getLong("Time") : World.START_TIME; + long time = tag.hasLong("Time") ? tag.getLong("Time") : World.START_TIME; Log.IO.info("Version: %s", version); Log.IO.info("Weltzeit: %d Ticks / %d Sekunden", time, time / 20L); Log.IO.info("Zuletzt geladen: %s", new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date(lastPlayed))); @@ -328,14 +329,14 @@ public final class Server implements IThreadListener { NBTTagCompound tag = this.loadPlayerData(user); if(tag == null) return null; - NBTTagList pos = tag.getTagList("Pos", 6); - NBTTagList rot = tag.getTagList("Rotation", 5); - double posX = pos.getDoubleAt(0); - double posY = pos.getDoubleAt(1); - double posZ = pos.getDoubleAt(2); - float rotYaw = rot.getFloatAt(0); - float rotPitch = rot.getFloatAt(1); - int dimension = tag.getInteger("Dimension"); + NBTTagDoubleList pos = tag.getDoubleList("Pos"); + NBTTagFloatList rot = tag.getFloatList("Rotation"); + double posX = pos.getDouble(0); + double posY = pos.getDouble(1); + double posZ = pos.getDouble(2); + float rotYaw = rot.getFloat(0); + float rotPitch = rot.getFloat(1); + int dimension = tag.getInt("Dimension"); return new Position(posX, posY, posZ, rotYaw, rotPitch, dimension); } @@ -871,7 +872,7 @@ public final class Server implements IThreadListener { this.usermap.put(loginUser, conn); tag = conn.readCharacter(); - WorldServer world = tag == null ? this.space : this.getWorld(tag.getInteger("Dimension")); + WorldServer world = tag == null ? this.space : this.getWorld(tag.getInt("Dimension")); world = world == null ? this.space : world; EntityNPC player = conn.createPlayer(world, tag == null ? EntityRegistry.getEntityString(EntityHuman.class) : tag.getString("id")); if(tag != null) @@ -959,7 +960,7 @@ public final class Server implements IThreadListener { if(entity != null) { NBTTagCompound etag = new NBTTagCompound(); entity.writeToNBT(etag); - etag.setInteger("Dimension", entity.worldObj.dimension.getDimensionId()); + etag.setInt("Dimension", entity.worldObj.dimension.getDimensionId()); etag.setString("id", EntityRegistry.getEntityString(entity)); conn.writeCharacter(etag); } @@ -1049,7 +1050,7 @@ public final class Server implements IThreadListener { old.unmount(); NBTTagCompound oldTag = new NBTTagCompound(); old.writeToNBT(oldTag); - oldTag.setInteger("Dimension", old.worldObj.dimension.getDimensionId()); + oldTag.setInt("Dimension", old.worldObj.dimension.getDimensionId()); oldTag.setString("id", EntityRegistry.getEntityString(old)); WorldServer oldWorld = (WorldServer)old.getServerWorld(); @@ -1059,7 +1060,7 @@ public final class Server implements IThreadListener { oldWorld.removePlayerEntityDangerously(old); // old.dead = false; - WorldServer world = tag == null ? this.space : this.getWorld(tag.getInteger("Dimension")); + WorldServer world = tag == null ? this.space : this.getWorld(tag.getInt("Dimension")); world = world == null ? this.space : world; EntityNPC nplayer = conn.createPlayer(world, tag == null ? EntityRegistry.getEntityString(clazz) : tag.getString("id")); // conn.sendPacket(new SPacketRespawn(world.dimension, EntityRegistry.getEntityID(nplayer))); diff --git a/server/src/main/java/server/command/commands/CommandBlock.java b/server/src/main/java/server/command/commands/CommandBlock.java index 4aa0de2..7910264 100644 --- a/server/src/main/java/server/command/commands/CommandBlock.java +++ b/server/src/main/java/server/command/commands/CommandBlock.java @@ -39,9 +39,9 @@ public class CommandBlock extends Command { NBTTagCompound te = new NBTTagCompound(); tile.writeToNBT(te); tag.setString("id", te.getString("id")); - tag.setInteger("x", position.getX()); - tag.setInteger("y", position.getY()); - tag.setInteger("z", position.getZ()); + tag.setInt("x", position.getX()); + tag.setInt("y", position.getY()); + tag.setInt("z", position.getZ()); te.merge(tag); TileEntity newTile = TileEntity.createAndLoadEntity(te); if(newTile != null) { diff --git a/server/src/main/java/server/command/commands/CommandSpawn.java b/server/src/main/java/server/command/commands/CommandSpawn.java index ab5f0a7..366499f 100644 --- a/server/src/main/java/server/command/commands/CommandSpawn.java +++ b/server/src/main/java/server/command/commands/CommandSpawn.java @@ -42,9 +42,9 @@ public class CommandSpawn extends Command { if(type.equalsIgnoreCase("Lightning")) { for(int z = 0; z < count; z++) { int color = 0xffffff; - if(tag != null && tag.hasKey("color", 3)) - color = tag.getInteger("color"); - else if(tag != null && tag.hasKey("color", 8)) { + if(tag != null && tag.hasInt("color")) + color = tag.getInt("color"); + else if(tag != null && tag.hasString("color")) { try { color = Integer.parseUnsignedInt(tag.getString("color"), 16); } @@ -52,8 +52,8 @@ public class CommandSpawn extends Command { } } world.strikeLightning(pos.xCoord, pos.yCoord, pos.zCoord, color, - tag != null && tag.hasKey("damage", 3) ? tag.getInteger("damage") : 0, tag != null && tag.hasKey("fire", 1) && tag.getBoolean("fire"), - exec.isPlayer() && tag != null && tag.hasKey("summoned", 1) && tag.getBoolean("summoned") ? ((Player)exec).getPresentEntity() : null); + tag != null && tag.hasInt("damage") ? tag.getInt("damage") : 0, tag != null && tag.hasBool("fire") && tag.getBool("fire"), + exec.isPlayer() && tag != null && tag.hasBool("summoned") && tag.getBool("summoned") ? ((Player)exec).getPresentEntity() : null); } exec.logConsole("%sBlitz bei %d, %d, %d in %s erschaffen", count == 1 ? "" : (count + "x "), (int)pos.xCoord, (int)pos.yCoord, (int)pos.zCoord, world.dimension.getFormattedName(false)); return null; diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 1e299fa..f63bdbd 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -47,7 +47,8 @@ import common.item.ItemControl; import common.item.ItemStack; import common.log.Log; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; +import common.nbt.NBTTagDoubleList; +import common.nbt.NBTTagTagList; import common.net.util.concurrent.Future; import common.net.util.concurrent.GenericFutureListener; import common.network.IPlayer; @@ -617,18 +618,18 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer public void readFromNBT(NBTTagCompound tag) { - this.admin = tag.getBoolean("admin"); - if(tag.hasKey("password", 8)) + this.admin = tag.getBool("admin"); + if(tag.hasString("password")) this.password = tag.getString("password"); - this.selected = tag.getInteger("selected"); - NBTTagList list = tag.getTagList("characters", 10); - for(int z = 0; z < list.tagCount(); z++) { - this.characters.add(list.getCompoundTagAt(z)); + this.selected = tag.getInt("selected"); + NBTTagTagList list = tag.getTagList("characters"); + for(int z = 0; z < list.size(); z++) { + this.characters.add(list.getTag(z)); } this.selected = Math.min(this.selected, this.characters.size() - 1); this.charEditor = this.selected < 0; // this.stats.clear(); -// if(tag.hasKey("Stats", 10)) { +// if(tag.hasTag("Stats")) { // NBTTagCompound stats = tag.getCompoundTag("Stats"); // for(String key : stats.getKeySet()) { // StatBase stat = StatRegistry.getStat(key); @@ -643,16 +644,16 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer public void writeToNBT(NBTTagCompound tag) { if(this.admin) - tag.setBoolean("admin", this.admin); + tag.setBool("admin", this.admin); if(this.password != null) tag.setString("password", this.password); if(!this.characters.isEmpty()) { - tag.setInteger("selected", this.selected); - NBTTagList list = new NBTTagList(); + tag.setInt("selected", this.selected); + NBTTagTagList list = new NBTTagTagList(); for(NBTTagCompound etag : this.characters) { - list.appendTag(etag); + list.add(etag); } - tag.setTag("characters", list); + tag.setTagList("characters", list); } // NBTTagCompound stats = new NBTTagCompound(); // for(Entry entry : this.stats.entrySet()) { @@ -1652,12 +1653,12 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer if(info != null && info.isEmpty()) info = null; Alignment align = Alignment.getByName(tag.getString("Align")); - NBTTagList position = tag.getTagList("Pos", 6); - Dimension dimension = UniverseRegistry.getDimension(tag.getInteger("Dimension")); + NBTTagDoubleList position = tag.getDoubleList("Pos"); + Dimension dimension = UniverseRegistry.getDimension(tag.getInt("Dimension")); String dim = dimension == null ? "???" : dimension.getFormattedName(false); - BlockPos pos = new BlockPos(position.getDoubleAt(0), position.getDoubleAt(1), position.getDoubleAt(2)); + BlockPos pos = new BlockPos(position.getDouble(0), position.getDouble(1), position.getDouble(2)); String type = EntityRegistry.getEntityName(tag.getString("id")); - int level = tag.getInteger("XpLevel"); + int level = tag.getInt("XpLevel"); return new PlayerCharacter(name, info, align, dim, pos, type, level); } @@ -2987,27 +2988,27 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer // changed = true; // } - if (itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag")) + if (itemstack.hasTagCompound() && itemstack.getTagCompound().hasTag("BlockEntityTag")) { -// if(!itemstack.getTagCompound().hasKey("BlockEntityTag", 10)) { +// if(!itemstack.getTagCompound().hasTag("BlockEntityTag")) { // changed = true; // itemstack.setTagCompound(null); // } // else { - NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag"); + NBTTagCompound nbttagcompound = itemstack.getTagCompound().getTag("BlockEntityTag"); - if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z")) + if (nbttagcompound.hasInt("x") && nbttagcompound.hasInt("y") && nbttagcompound.hasInt("z")) { - BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z")); + BlockPos blockpos = new BlockPos(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")); TileEntity tileentity = this.entity.worldObj.getTileEntity(blockpos); if (tileentity != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); tileentity.writeToNBT(nbttagcompound1); - nbttagcompound1.removeTag("x"); - nbttagcompound1.removeTag("y"); - nbttagcompound1.removeTag("z"); + nbttagcompound1.remove("x"); + nbttagcompound1.remove("y"); + nbttagcompound1.remove("z"); itemstack.setTagInfo("BlockEntityTag", nbttagcompound1); } } diff --git a/server/src/main/java/server/village/VillageCollection.java b/server/src/main/java/server/village/VillageCollection.java index 4e7b939..b5ef3f2 100755 --- a/server/src/main/java/server/village/VillageCollection.java +++ b/server/src/main/java/server/village/VillageCollection.java @@ -8,7 +8,7 @@ import common.block.Material; import common.block.artificial.BlockDoor; import common.collect.Lists; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; +import common.nbt.NBTTagTagList; import common.util.BlockPos; import common.util.Facing; import common.village.Village; @@ -25,12 +25,12 @@ public class VillageCollection public VillageCollection(NBTTagCompound nbt) { if(nbt != null) { - this.tickCounter = nbt.getInteger("Tick"); - NBTTagList nbttaglist = nbt.getTagList("Villages", 10); + this.tickCounter = nbt.getInt("Tick"); + NBTTagTagList nbttaglist = nbt.getTagList("Villages"); - 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); Village village = new Village(); village.readVillageDataFromNBT(nbttagcompound); this.villageList.add(village); @@ -251,17 +251,17 @@ public class VillageCollection public NBTTagCompound writeToNBT() { NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("Tick", this.tickCounter); - NBTTagList nbttaglist = new NBTTagList(); + nbt.setInt("Tick", this.tickCounter); + NBTTagTagList nbttaglist = new NBTTagTagList(); for (Village village : this.villageList) { NBTTagCompound nbttagcompound = new NBTTagCompound(); village.writeVillageDataToNBT(nbttagcompound); - nbttaglist.appendTag(nbttagcompound); + nbttaglist.add(nbttagcompound); } - nbt.setTag("Villages", nbttaglist); + nbt.setTagList("Villages", nbttaglist); this.dirty = false; return nbt; } diff --git a/server/src/main/java/server/world/Converter.java b/server/src/main/java/server/world/Converter.java index 56e36d5..76d7b9b 100644 --- a/server/src/main/java/server/world/Converter.java +++ b/server/src/main/java/server/world/Converter.java @@ -69,9 +69,9 @@ import common.init.UniverseRegistry; import common.log.Log; import common.nbt.NBTLoader; 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.nbt.NBTTagTagList; import common.rng.Random; import common.tileentity.TileEntity; import common.tileentity.TileEntityBanner; @@ -976,7 +976,7 @@ public abstract class Converter { } } else if("Comparator".equals(id)) { - nent.setInteger("OutputSignal", ent.getInt("OutputSignal")); + nent.setInt("OutputSignal", ent.getInt("OutputSignal")); } else if("Music".equals(id)) { nent.setByte("note", ent.getByte("note")); @@ -997,18 +997,18 @@ public abstract class Converter { return idx >= 0 ? name.substring(idx + 1) : name; // save compat } - private static NBTTagList getList(float[] values) { - NBTTagList nlist = new NBTTagList(); + private static NBTTagFloatList getList(float[] values) { + NBTTagFloatList nlist = new NBTTagFloatList(); for(int z = 0; z < values.length; z++) { - nlist.appendTag(new NBTTagFloat(values[z])); + nlist.add(values[z]); } return nlist; } - private static NBTTagList getList(double[] values) { - NBTTagList nlist = new NBTTagList(); + private static NBTTagDoubleList getList(double[] values) { + NBTTagDoubleList nlist = new NBTTagDoubleList(); for(int z = 0; z < values.length; z++) { - nlist.appendTag(new NBTTagDouble(values[z])); + nlist.add(values[z]); } return nlist; } @@ -1027,7 +1027,7 @@ public abstract class Converter { byte[] olddata = tag.getByteArray("Data"); byte[] oldsky = tag.getByteArray("SkyLight"); byte[] oldlight = tag.getByteArray("BlockLight"); - NBTTagList sections = new NBTTagList(); + NBTTagTagList sections = new NBTTagTagList(); for(int n = 0; n < 8; ++n) { boolean empty = true; for(int x = 0; x < 16 && empty; ++x) { @@ -1065,10 +1065,10 @@ public abstract class Converter { section.setByteArray("Data", data.getData()); section.setByteArray("SkyLight", sky.getData()); section.setByteArray("BlockLight", light.getData()); - sections.appendTag(section); + sections.add(section); } } - ntag.setTag("Sections", sections); + ntag.setTagList("Sections", sections); byte[] biomes = new byte[256]; Arrays.fill(biomes, (byte)(Biome.DEF_BIOME.id & 255)); ntag.setByteArray("Biomes", biomes); @@ -1077,11 +1077,11 @@ public abstract class Converter { ntag.setIntArray("HeightMap", tag.getIntArray("HeightMap")); } - ntag.setBoolean("TerrainPopulated", true); - ntag.setBoolean("LightPopulated", tag.getByte("LightPopulated") != 0); + ntag.setBool("TerrainPopulated", true); + ntag.setBool("LightPopulated", tag.getByte("LightPopulated") != 0); OldNbtTag[] ents = tag.getTagList("Entities"); - NBTTagList entities = new NBTTagList(); + NBTTagTagList entities = new NBTTagTagList(); for(OldNbtTag ent : ents) { NBTTagCompound nent = new NBTTagCompound(); String mapped = ENTITY_MAP.get(trimColon(ent.getString("id"))); @@ -1092,35 +1092,35 @@ public abstract class Converter { if(pos.length != 3 || motion.length != 3 || rotation.length != 2) continue; boolean ground = ent.getByte("OnGround") != 0; - nent.setTag("Pos", getList(pos)); - nent.setTag("Motion", getList(motion)); - nent.setTag("Rotation", getList(rotation)); - nent.setBoolean("OnGround", ground); - nent.setInteger("Dimension", 1); + nent.setDoubleList("Pos", getList(pos)); + nent.setDoubleList("Motion", getList(motion)); + nent.setFloatList("Rotation", getList(rotation)); + nent.setBool("OnGround", ground); + nent.setInt("Dimension", 1); nent.setString("id", mapped); - entities.appendTag(nent); + entities.add(nent); } } - ntag.setTag("Entities", entities); + ntag.setTagList("Entities", entities); ents = tag.getTagList("TileEntities"); - entities = new NBTTagList(); + entities = new NBTTagTagList(); for(OldNbtTag ent : ents) { NBTTagCompound nent = new NBTTagCompound(); String mapped = TILE_MAP.get(trimColon(ent.getString("id"))); if(mapped != null) { nent = convertTile(ent, mapped); nent.setString("id", mapped); - nent.setInteger("x", ent.getInt("x")); - nent.setInteger("y", ent.getInt("y")); - nent.setInteger("z", ent.getInt("z")); - entities.appendTag(nent); + nent.setInt("x", ent.getInt("x")); + nent.setInt("y", ent.getInt("y")); + nent.setInt("z", ent.getInt("z")); + entities.add(nent); } } - ntag.setTag("TileEntities", entities); + ntag.setTagList("TileEntities", entities); OldNbtTag[] sects = tag.getTagList("Sections"); - entities = new NBTTagList(); + entities = new NBTTagTagList(); for(OldNbtTag sect : sects) { NBTTagCompound nsect = new NBTTagCompound(); byte[] blocks = sect.getByteArray("Blocks"); @@ -1161,9 +1161,9 @@ public abstract class Converter { nsect.setByteArray("Data", data.getData()); if(adddata != null) nsect.setByteArray("Add", adddata.getData()); - entities.appendTag(nsect); + entities.add(nsect); } - ntag.setTag("Sections", entities); + ntag.setTagList("Sections", entities); return ntag; } diff --git a/server/src/main/java/server/world/Region.java b/server/src/main/java/server/world/Region.java index 3068116..095bc9c 100755 --- a/server/src/main/java/server/world/Region.java +++ b/server/src/main/java/server/world/Region.java @@ -26,8 +26,9 @@ import common.init.BlockRegistry; import common.init.EntityRegistry; import common.log.Log; import common.nbt.NBTLoader; +import common.nbt.SizeTracker; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; +import common.nbt.NBTTagTagList; import common.tileentity.TileEntity; import common.util.BlockPos; import common.util.NextTickListEntry; @@ -347,7 +348,7 @@ public class Region { byte[] data = getRegionFile(dir, x >> 3, z >> 3).read(x & 7, z & 7); if(data == null) return null; - return NBTLoader.read(new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(data))))); + return NBTLoader.read(new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(data)))), SizeTracker.INFINITE); } public static /* synchronized */ void writeChunk(File dir, int x, int z, NBTTagCompound tag) throws IOException { @@ -360,31 +361,31 @@ public class Region { } public static ChunkServer readNbt(WorldServer world, int x, int z, NBTTagCompound tag) { -// if(!tag.hasKey("Level", 10)) { +// if(!tag.hasTag("Level")) { // Log.error("Chunk-Datei bei " + x + "," + z + " hat keine Level-Daten, überspringe"); // return null; // } // tag = tag.getCompoundTag("Level"); - if(!tag.hasKey("Sections", 9)) { + if(!tag.hasTagList("Sections")) { Log.IO.warn("Chunk-Datei bei " + x + "," + z + " hat keine Block-Daten, überspringe"); return null; } ChunkServer chunk = new ChunkServer(world, x, z); chunk.setHeights(tag.getIntArray("HeightMap")); - chunk.setTerrainPopulated(tag.getBoolean("TerrainPopulated")); - chunk.setLightPopulated(tag.getBoolean("LightPopulated")); + chunk.setTerrainPopulated(tag.getBool("TerrainPopulated")); + chunk.setLightPopulated(tag.getBool("LightPopulated")); chunk.setInhabited(tag.getLong("InhabitedTime")); - NBTTagList sects = tag.getTagList("Sections", 10); - BlockArray[] sections = new BlockArray[sects.tagCount()]; + NBTTagTagList sects = tag.getTagList("Sections"); + BlockArray[] sections = new BlockArray[sects.size()]; boolean light = !world.dimension.hasNoLight(); - for(int n = 0; n < sects.tagCount(); ++n) { - NBTTagCompound sect = sects.getCompoundTagAt(n); - int y = sect.getInteger("Y"); + for(int n = 0; n < sects.size(); ++n) { + NBTTagCompound sect = sects.getTag(n); + int y = sect.getInt("Y"); BlockArray storage = new BlockArray(y << 4, light, null); byte[] blocks = sect.getByteArray("Blocks"); NibbleArray data = new NibbleArray(sect.getByteArray("Data")); - NibbleArray adddata = sect.hasKey("Add", 7) ? new NibbleArray(sect.getByteArray("Add")) : null; + NibbleArray adddata = sect.hasByteArray("Add") ? new NibbleArray(sect.getByteArray("Add")) : null; char[] seg = new char[blocks.length]; for(int c = 0; c < seg.length; ++c) { @@ -408,15 +409,15 @@ public class Region { chunk.setStorage(sections); - if(tag.hasKey("Biomes", 7)) { + if(tag.hasByteArray("Biomes")) { chunk.setBiomes(tag.getByteArray("Biomes")); } - NBTTagList entities = tag.getTagList("Entities", 10); + NBTTagTagList entities = tag.getTagList("Entities"); if(entities != null) { - for(int n = 0; n < entities.tagCount(); ++n) { - NBTTagCompound ent = entities.getCompoundTagAt(n); + for(int n = 0; n < entities.size(); ++n) { + NBTTagCompound ent = entities.getTag(n); Entity entity = EntityRegistry.createEntityFromNBT(ent, world); chunk.setHasEntities(true); @@ -424,8 +425,8 @@ public class Region { chunk.addEntity(entity); Entity rider = entity; - for(NBTTagCompound ride = ent; ride.hasKey("Riding", 10); ride = ride.getCompoundTag("Riding")) { - Entity pass = EntityRegistry.createEntityFromNBT(ride.getCompoundTag("Riding"), world); + for(NBTTagCompound ride = ent; ride.hasTag("Riding"); ride = ride.getTag("Riding")) { + Entity pass = EntityRegistry.createEntityFromNBT(ride.getTag("Riding"), world); if(pass != null) { chunk.addEntity(pass); @@ -438,11 +439,11 @@ public class Region { } } - NBTTagList tiles = tag.getTagList("TileEntities", 10); + NBTTagTagList tiles = tag.getTagList("TileEntities"); if(tiles != null) { - for(int n = 0; n < tiles.tagCount(); ++n) { - NBTTagCompound tile = tiles.getCompoundTagAt(n); + for(int n = 0; n < tiles.size(); ++n) { + NBTTagCompound tile = tiles.getTag(n); TileEntity tileentity = TileEntity.createAndLoadEntity(tile); if(tileentity != null) { @@ -451,29 +452,29 @@ public class Region { } } - if(tag.hasKey("TileTicks", 9)) { - NBTTagList ticks = tag.getTagList("TileTicks", 10); + if(tag.hasTagList("TileTicks")) { + NBTTagTagList ticks = tag.getTagList("TileTicks"); if(ticks != null) { int invalid = 0; - for(int n = 0; n < ticks.tagCount(); ++n) { - NBTTagCompound tick = ticks.getCompoundTagAt(n); + for(int n = 0; n < ticks.size(); ++n) { + NBTTagCompound tick = ticks.getTag(n); Block block; - if(tick.hasKey("i", 8)) { + if(tick.hasString("i")) { block = BlockRegistry.getByIdFallback(tick.getString("i")); } else { - block = BlockRegistry.getBlockById(tick.getInteger("i")); + block = BlockRegistry.getBlockById(tick.getInt("i")); } if(block != null) { // FIX - world.scheduleBlockUpdate(new BlockPos(tick.getInteger("x"), tick.getInteger("y"), tick.getInteger("z")), block, - tick.getInteger("t"), tick.getInteger("p")); + world.scheduleBlockUpdate(new BlockPos(tick.getInt("x"), tick.getInt("y"), tick.getInt("z")), block, + tick.getInt("t"), tick.getInt("p")); } else if(invalid++ < 10) { Log.IO.warn("Unbekannter Block-Tick in Chunk " + x + "," + z + ": " + - (tick.hasKey("i", 8) ? ("'" + tick.getString("i") + "'") : ("#" + tick.getInteger("i")))); + (tick.hasString("i") ? ("'" + tick.getString("i") + "'") : ("#" + tick.getInt("i")))); } } if(invalid > 10) { @@ -490,17 +491,17 @@ public class Region { // tag.setShort("V", (short)Config.PROTOCOL); tag.setLong("LastUpdate", world.getTime()); tag.setIntArray("HeightMap", chunk.getHeights()); - tag.setBoolean("TerrainPopulated", chunk.isTerrainPopulated()); - tag.setBoolean("LightPopulated", chunk.isLightPopulated()); + tag.setBool("TerrainPopulated", chunk.isTerrainPopulated()); + tag.setBool("LightPopulated", chunk.isLightPopulated()); tag.setLong("InhabitedTime", chunk.getInhabited()); Set sections = chunk.getStorage(); - NBTTagList sects = new NBTTagList(); + NBTTagTagList sects = new NBTTagTagList(); boolean light = !world.dimension.hasNoLight(); for(BlockArray storage : sections) { if(storage != null) { NBTTagCompound sect = new NBTTagCompound(); - sect.setInteger("Y", storage.getY() >> 4); + sect.setInt("Y", storage.getY() >> 4); byte[] blocks = new byte[storage.getData().length]; NibbleArray data = new NibbleArray(); NibbleArray adddata = null; @@ -539,14 +540,14 @@ public class Region { sect.setByteArray("SkyLight", new byte[storage.getBlocklight().getData().length]); } - sects.appendTag(sect); + sects.add(sect); } } - tag.setTag("Sections", sects); + tag.setTagList("Sections", sects); tag.setByteArray("Biomes", chunk.getBiomes()); chunk.setHasEntities(false); - NBTTagList entities = new NBTTagList(); + NBTTagTagList entities = new NBTTagTagList(); for(int n = 0; n < chunk.getEntities().length; ++n) { for(Entity entity : chunk.getEntities()[n]) { @@ -554,40 +555,40 @@ public class Region { if(entity.writeToNBTOptional(ent)) { chunk.setHasEntities(true); - entities.appendTag(ent); + entities.add(ent); } } } - tag.setTag("Entities", entities); - NBTTagList tiles = new NBTTagList(); + tag.setTagList("Entities", entities); + NBTTagTagList tiles = new NBTTagTagList(); for(TileEntity tileentity : chunk.getTiles().values()) { NBTTagCompound tile = new NBTTagCompound(); tileentity.writeToNBT(tile); - tiles.appendTag(tile); + tiles.add(tile); } - tag.setTag("TileEntities", tiles); + tag.setTagList("TileEntities", tiles); List tics = world.getPendingBlockUpdates(chunk); if(tics != null) { long time = world.getTime(); - NBTTagList ticks = new NBTTagList(); + NBTTagTagList ticks = new NBTTagTagList(); for(NextTickListEntry tic : tics) { NBTTagCompound tick = new NBTTagCompound(); String res = BlockRegistry.REGISTRY.getNameForObject(tic.getBlock()); tick.setString("i", res == null ? "" : res.toString()); - tick.setInteger("x", tic.position.getX()); - tick.setInteger("y", tic.position.getY()); - tick.setInteger("z", tic.position.getZ()); - tick.setInteger("t", (int)(tic.scheduledTime - time)); - tick.setInteger("p", tic.priority); - ticks.appendTag(tick); + tick.setInt("x", tic.position.getX()); + tick.setInt("y", tic.position.getY()); + tick.setInt("z", tic.position.getZ()); + tick.setInt("t", (int)(tic.scheduledTime - time)); + tick.setInt("p", tic.priority); + ticks.add(tick); } - tag.setTag("TileTicks", ticks); + tag.setTagList("TileTicks", ticks); } return tag; diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index 75633f8..2b34c26 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -42,8 +42,7 @@ import common.log.Log; import common.model.ParticleType; import common.nbt.NBTLoader; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagInt; -import common.nbt.NBTTagList; +import common.nbt.NBTTagTagList; import common.network.IPlayer; import common.network.Packet; import common.packet.SPacketEntityStatus; @@ -308,10 +307,10 @@ public final class WorldServer extends AWorldServer { Log.IO.error(e, "Konnte Weltdaten nicht laden"); } if(tag != null) { - this.exterminated = tag.getBoolean("Exterminated"); + this.exterminated = tag.getBool("Exterminated"); this.time = tag.getLong("Time"); - if(tag.hasKey("Generator", 10)) { - this.dimension.fromNbt(tag.getCompoundTag("Generator")); + if(tag.hasTag("Generator")) { + this.dimension.fromNbt(tag.getTag("Generator")); if(this.dimension.getType().weather && !this.exterminated) this.weather = this.dimension.getWeather(); this.seed = this.dimension.getSeed(); @@ -449,11 +448,11 @@ public final class WorldServer extends AWorldServer { catch(Exception e) { Log.IO.error(e, "Konnte Ladeliste nicht laden"); } - if(tag != null && tag.hasKey("Loaders", 9)) { - NBTTagList list = tag.getTagList("Loaders", 10); - for(int z = 0; z < list.tagCount(); z++) { - NBTTagCompound pos = list.getCompoundTagAt(z); - this.addLoader(new BlockPos(pos.getInteger("X"), pos.getInteger("Y"), pos.getInteger("Z"))); + if(tag != null && tag.hasTagList("Loaders")) { + NBTTagTagList list = tag.getTagList("Loaders"); + for(int z = 0; z < list.size(); z++) { + NBTTagCompound pos = list.getTag(z); + this.addLoader(new BlockPos(pos.getInt("X"), pos.getInt("Y"), pos.getInt("Z"))); } this.loadersModified = false; } @@ -466,7 +465,7 @@ public final class WorldServer extends AWorldServer { // catch(Exception e) { // Log.warn("Konnte Warpliste nicht laden", e); // } -// if(tag != null && tag.hasKey("Warps", 9)) { +// if(tag != null && tag.hasList("Warps")) { // NBTTagList list = tag.getTagList("Warps", 10); // for(int z = 0; z < list.tagCount(); z++) { // NBTTagCompound pos = list.getCompoundTagAt(z); @@ -938,7 +937,7 @@ public final class WorldServer extends AWorldServer { catch(Exception e) { return false; } - return tag != null && tag.hasKey("Loaders", 9) && !tag.getTagList("Loaders", 10).hasNoTags(); + return tag != null && tag.hasTagList("Loaders") && !tag.getTagList("Loaders").isEmpty(); } public static void loadWarps(Dimension dim, Map warps) { @@ -952,10 +951,10 @@ public final class WorldServer extends AWorldServer { Log.IO.error(e, "Konnte Warpliste nicht laden"); return; } - if(tag != null && tag.hasKey("Warps", 9)) { - NBTTagList list = tag.getTagList("Warps", 10); - for(int z = 0; z < list.tagCount(); z++) { - NBTTagCompound pos = list.getCompoundTagAt(z); + if(tag != null && tag.hasTagList("Warps")) { + NBTTagTagList list = tag.getTagList("Warps"); + for(int z = 0; z < list.size(); z++) { + NBTTagCompound pos = list.getTag(z); warps.put(pos.getString("Name"), new Position(pos.getDouble("X"), pos.getDouble("Y"), pos.getDouble("Z"), pos.getFloat("Yaw"), pos.getFloat("Pitch"), dim.getDimensionId())); } @@ -963,13 +962,13 @@ public final class WorldServer extends AWorldServer { } public static void saveWarps(Map warps) { - Map map = Maps.newHashMap(); + Map map = Maps.newHashMap(); for(Entry pos : warps.entrySet()) { Dimension dim = UniverseRegistry.getDimension(pos.getValue().dim); if(dim != null) { - NBTTagList list = map.get(pos.getValue().dim); + NBTTagTagList list = map.get(pos.getValue().dim); if(list == null) - map.put(pos.getValue().dim, list = new NBTTagList()); + map.put(pos.getValue().dim, list = new NBTTagTagList()); NBTTagCompound warp = new NBTTagCompound(); warp.setString("Name", pos.getKey()); warp.setDouble("X", pos.getValue().x); @@ -977,18 +976,18 @@ public final class WorldServer extends AWorldServer { warp.setDouble("Z", pos.getValue().z); warp.setFloat("Yaw", pos.getValue().yaw); warp.setFloat("Pitch", pos.getValue().pitch); - list.appendTag(warp); + list.add(warp); } } for(Dimension dim : UniverseRegistry.getDimensions()) { - NBTTagList list = map.get(dim.getDimensionId()); + NBTTagTagList list = map.get(dim.getDimensionId()); File file = new File(new File(new File("chunk"), dim.getDimensionName()), "warps.nbt"); if(list == null) { file.delete(); } else { NBTTagCompound tag = new NBTTagCompound(); - tag.setTag("Warps", list); + tag.setTagList("Warps", list); try { NBTLoader.writeGZip(tag, file); } @@ -1032,17 +1031,17 @@ public final class WorldServer extends AWorldServer { if(this.loadersModified) { this.loadersModified = false; NBTTagCompound loaders = new NBTTagCompound(); - NBTTagList list = new NBTTagList(); + NBTTagTagList list = new NBTTagTagList(); for(BlockPos pos : this.loaderList) { NBTTagCompound loader = new NBTTagCompound(); - loader.setInteger("X", pos.getX()); - loader.setInteger("Y", pos.getY()); - loader.setInteger("Z", pos.getZ()); - list.appendTag(loader); + loader.setInt("X", pos.getX()); + loader.setInt("Y", pos.getY()); + loader.setInt("Z", pos.getZ()); + list.add(loader); } - loaders.setTag("Loaders", list); + loaders.setTagList("Loaders", list); File file = new File(this.chunkDir, "loaders.nbt"); - if(list.hasNoTags()) { + if(list.isEmpty()) { file.delete(); } else { @@ -1063,7 +1062,7 @@ public final class WorldServer extends AWorldServer { // data.setLong("Seed", this.seed); data.setTag("Generator", this.dimension.toNbt(true)); data.setLong("Time", this.time); - data.setBoolean("Exterminated", this.exterminated); + data.setBool("Exterminated", this.exterminated); data.setString("Weather", this.weather.getName()); // ... File file = new File(this.chunkDir, "data.nbt"); @@ -2233,9 +2232,9 @@ public final class WorldServer extends AWorldServer { this.removeTileEntity(pos); NBTTagCompound tag = block.getNbtData(); tag.setString("id", tag.getString("id")); - tag.setTag("x", new NBTTagInt(pos.getX())); - tag.setTag("y", new NBTTagInt(pos.getY())); - tag.setTag("z", new NBTTagInt(pos.getZ())); + tag.setInt("x", pos.getX()); + tag.setInt("y", pos.getY()); + tag.setInt("z", pos.getZ()); TileEntity tileEntity = TileEntity.createAndLoadEntity(tag); if(tileEntity != null) { this.setTileEntity(pos, tileEntity); diff --git a/server/src/main/java/server/worldgen/structure/MapGenStructure.java b/server/src/main/java/server/worldgen/structure/MapGenStructure.java index dc911fe..1443565 100755 --- a/server/src/main/java/server/worldgen/structure/MapGenStructure.java +++ b/server/src/main/java/server/worldgen/structure/MapGenStructure.java @@ -207,16 +207,16 @@ public abstract class MapGenStructure extends MapGenBase for (String s : tag.getKeySet()) { - NBTBase nbtbase = tag.getTag(s); + NBTBase nbtbase = tag.get(s); if (nbtbase.getId() == 10) { NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbtbase; - if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ")) + if (nbttagcompound1.hasInt("ChunkX") && nbttagcompound1.hasInt("ChunkZ")) { - int i = nbttagcompound1.getInteger("ChunkX"); - int j = nbttagcompound1.getInteger("ChunkZ"); + int i = nbttagcompound1.getInt("ChunkX"); + int j = nbttagcompound1.getInt("ChunkZ"); StructureStart structurestart = MapGenStructureIO.getStructureStart(nbttagcompound1, worldIn); if (structurestart != null) diff --git a/server/src/main/java/server/worldgen/structure/MapGenVillage.java b/server/src/main/java/server/worldgen/structure/MapGenVillage.java index 47f89ec..e9ad387 100755 --- a/server/src/main/java/server/worldgen/structure/MapGenVillage.java +++ b/server/src/main/java/server/worldgen/structure/MapGenVillage.java @@ -143,13 +143,13 @@ public class MapGenVillage extends MapGenStructure public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); - tagCompound.setBoolean("Valid", this.hasMoreThanTwoComponents); + tagCompound.setBool("Valid", this.hasMoreThanTwoComponents); } public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - this.hasMoreThanTwoComponents = tagCompound.getBoolean("Valid"); + this.hasMoreThanTwoComponents = tagCompound.getBool("Valid"); } } } diff --git a/server/src/main/java/server/worldgen/structure/StructureBoundingBox.java b/server/src/main/java/server/worldgen/structure/StructureBoundingBox.java index 70ddf56..b0dda2b 100755 --- a/server/src/main/java/server/worldgen/structure/StructureBoundingBox.java +++ b/server/src/main/java/server/worldgen/structure/StructureBoundingBox.java @@ -1,6 +1,5 @@ package server.worldgen.structure; -import common.nbt.NBTTagIntArray; import common.util.BlockPos; import common.util.Facing; import common.util.Vec3i; @@ -209,8 +208,8 @@ public class StructureBoundingBox // return Objects.toStringHelper(this).add("x0", this.minX).add("y0", this.minY).add("z0", this.minZ).add("x1", this.maxX).add("y1", this.maxY).add("z1", this.maxZ).toString(); // } - public NBTTagIntArray toNBTTagIntArray() + public int[] toIntArray() { - return new NBTTagIntArray(new int[] {this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ}); + return new int[] {this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ}; } } diff --git a/server/src/main/java/server/worldgen/structure/StructureBridge.java b/server/src/main/java/server/worldgen/structure/StructureBridge.java index 309a567..61faef4 100755 --- a/server/src/main/java/server/worldgen/structure/StructureBridge.java +++ b/server/src/main/java/server/worldgen/structure/StructureBridge.java @@ -118,13 +118,13 @@ public class StructureBridge protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.field_111021_b = tagCompound.getBoolean("Chest"); + this.field_111021_b = tagCompound.getBool("Chest"); } protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Chest", this.field_111021_b); + tagCompound.setBool("Chest", this.field_111021_b); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -189,13 +189,13 @@ public class StructureBridge protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.field_111020_b = tagCompound.getBoolean("Chest"); + this.field_111020_b = tagCompound.getBool("Chest"); } protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Chest", this.field_111020_b); + tagCompound.setBool("Chest", this.field_111020_b); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -639,13 +639,13 @@ public class StructureBridge protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.fillSeed = tagCompound.getInteger("Seed"); + this.fillSeed = tagCompound.getInt("Seed"); } protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setInteger("Seed", this.fillSeed); + tagCompound.setInt("Seed", this.fillSeed); } public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) @@ -1328,13 +1328,13 @@ public class StructureBridge protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.hasSpawner = tagCompound.getBoolean("Mob"); + this.hasSpawner = tagCompound.getBool("Mob"); } protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Mob", this.hasSpawner); + tagCompound.setBool("Mob", this.hasSpawner); } public static StructureBridge.Throne func_175874_a(List p_175874_0_, Random p_175874_1_, int p_175874_2_, int p_175874_3_, int p_175874_4_, int p_175874_5_, Facing p_175874_6_) diff --git a/server/src/main/java/server/worldgen/structure/StructureComponent.java b/server/src/main/java/server/worldgen/structure/StructureComponent.java index 8698a75..f6199c9 100755 --- a/server/src/main/java/server/worldgen/structure/StructureComponent.java +++ b/server/src/main/java/server/worldgen/structure/StructureComponent.java @@ -48,9 +48,9 @@ public abstract class StructureComponent { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("id", MapGenStructureIO.getStructureComponentName(this)); - nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray()); - nbttagcompound.setInteger("O", this.coordBaseMode == null ? -1 : this.coordBaseMode.getHorizontalIndex()); - nbttagcompound.setInteger("GD", this.componentType); + nbttagcompound.setIntArray("BB", this.boundingBox.toIntArray()); + nbttagcompound.setInt("O", this.coordBaseMode == null ? -1 : this.coordBaseMode.getHorizontalIndex()); + nbttagcompound.setInt("GD", this.componentType); this.writeStructureToNBT(nbttagcompound); return nbttagcompound; } @@ -67,14 +67,14 @@ public abstract class StructureComponent */ public void readStructureBaseNBT(WorldServer worldIn, NBTTagCompound tagCompound) { - if (tagCompound.hasKey("BB")) + if (tagCompound.hasIntArray("BB")) { this.boundingBox = new StructureBoundingBox(tagCompound.getIntArray("BB")); } - int i = tagCompound.getInteger("O"); + int i = tagCompound.getInt("O"); this.coordBaseMode = i == -1 ? null : Facing.getHorizontal(i); - this.componentType = tagCompound.getInteger("GD"); + this.componentType = tagCompound.getInt("GD"); this.readStructureFromNBT(tagCompound); } diff --git a/server/src/main/java/server/worldgen/structure/StructureMineshaft.java b/server/src/main/java/server/worldgen/structure/StructureMineshaft.java index bc88140..5d77070 100755 --- a/server/src/main/java/server/worldgen/structure/StructureMineshaft.java +++ b/server/src/main/java/server/worldgen/structure/StructureMineshaft.java @@ -8,7 +8,7 @@ import common.init.Blocks; import common.init.Items; import common.item.RngLoot; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; +import common.nbt.NBTTagIntArrayList; import common.rng.Random; import common.rng.WeightedList; import common.tileentity.TileEntity; @@ -102,18 +102,18 @@ public class StructureMineshaft protected void writeStructureToNBT(NBTTagCompound tagCompound) { - tagCompound.setBoolean("hr", this.hasRails); - tagCompound.setBoolean("sc", this.hasSpiders); - tagCompound.setBoolean("hps", this.spawnerPlaced); - tagCompound.setInteger("Num", this.sectionCount); + tagCompound.setBool("hr", this.hasRails); + tagCompound.setBool("sc", this.hasSpiders); + tagCompound.setBool("hps", this.spawnerPlaced); + tagCompound.setInt("Num", this.sectionCount); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { - this.hasRails = tagCompound.getBoolean("hr"); - this.hasSpiders = tagCompound.getBoolean("sc"); - this.spawnerPlaced = tagCompound.getBoolean("hps"); - this.sectionCount = tagCompound.getInteger("Num"); + this.hasRails = tagCompound.getBool("hr"); + this.hasSpiders = tagCompound.getBool("sc"); + this.spawnerPlaced = tagCompound.getBool("hps"); + this.sectionCount = tagCompound.getInt("Num"); } public Corridor(int type, Random rand, StructureBoundingBox structurebb, Facing facing) @@ -427,14 +427,14 @@ public class StructureMineshaft protected void writeStructureToNBT(NBTTagCompound tagCompound) { - tagCompound.setBoolean("tf", this.isMultipleFloors); - tagCompound.setInteger("D", this.corridorDirection.getHorizontalIndex()); + tagCompound.setBool("tf", this.isMultipleFloors); + tagCompound.setInt("D", this.corridorDirection.getHorizontalIndex()); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { - this.isMultipleFloors = tagCompound.getBoolean("tf"); - this.corridorDirection = Facing.getHorizontal(tagCompound.getInteger("D")); + this.isMultipleFloors = tagCompound.getBool("tf"); + this.corridorDirection = Facing.getHorizontal(tagCompound.getInt("D")); } public Cross(int type, Random rand, StructureBoundingBox structurebb, Facing facing) @@ -712,23 +712,23 @@ public class StructureMineshaft protected void writeStructureToNBT(NBTTagCompound tagCompound) { - NBTTagList nbttaglist = new NBTTagList(); + NBTTagIntArrayList nbttaglist = new NBTTagIntArrayList(); for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom) { - nbttaglist.appendTag(structureboundingbox.toNBTTagIntArray()); + nbttaglist.add(structureboundingbox.toIntArray()); } - tagCompound.setTag("Entrances", nbttaglist); + tagCompound.setIntArrayList("Entrances", nbttaglist); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { - NBTTagList nbttaglist = tagCompound.getTagList("Entrances", 11); + NBTTagIntArrayList nbttaglist = tagCompound.getIntArrayList("Entrances"); - for (int i = 0; i < nbttaglist.tagCount(); ++i) + for (int i = 0; i < nbttaglist.size(); ++i) { - this.roomsLinkedToTheRoom.add(new StructureBoundingBox(nbttaglist.getIntArrayAt(i))); + this.roomsLinkedToTheRoom.add(new StructureBoundingBox(nbttaglist.getIntArray(i))); } } } diff --git a/server/src/main/java/server/worldgen/structure/StructureScattered.java b/server/src/main/java/server/worldgen/structure/StructureScattered.java index 70fcb34..1d4b062 100755 --- a/server/src/main/java/server/worldgen/structure/StructureScattered.java +++ b/server/src/main/java/server/worldgen/structure/StructureScattered.java @@ -44,19 +44,19 @@ public class StructureScattered protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("hasPlacedChest0", this.hasPlacedChest[0]); - tagCompound.setBoolean("hasPlacedChest1", this.hasPlacedChest[1]); - tagCompound.setBoolean("hasPlacedChest2", this.hasPlacedChest[2]); - tagCompound.setBoolean("hasPlacedChest3", this.hasPlacedChest[3]); + tagCompound.setBool("hasPlacedChest0", this.hasPlacedChest[0]); + tagCompound.setBool("hasPlacedChest1", this.hasPlacedChest[1]); + tagCompound.setBool("hasPlacedChest2", this.hasPlacedChest[2]); + tagCompound.setBool("hasPlacedChest3", this.hasPlacedChest[3]); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.hasPlacedChest[0] = tagCompound.getBoolean("hasPlacedChest0"); - this.hasPlacedChest[1] = tagCompound.getBoolean("hasPlacedChest1"); - this.hasPlacedChest[2] = tagCompound.getBoolean("hasPlacedChest2"); - this.hasPlacedChest[3] = tagCompound.getBoolean("hasPlacedChest3"); + this.hasPlacedChest[0] = tagCompound.getBool("hasPlacedChest0"); + this.hasPlacedChest[1] = tagCompound.getBool("hasPlacedChest1"); + this.hasPlacedChest[2] = tagCompound.getBool("hasPlacedChest2"); + this.hasPlacedChest[3] = tagCompound.getBool("hasPlacedChest3"); } public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) @@ -295,18 +295,18 @@ public class StructureScattered protected void writeStructureToNBT(NBTTagCompound tagCompound) { - tagCompound.setInteger("Width", this.scatteredFeatureSizeX); - tagCompound.setInteger("Height", this.scatteredFeatureSizeY); - tagCompound.setInteger("Depth", this.scatteredFeatureSizeZ); - tagCompound.setInteger("HPos", this.field_74936_d); + tagCompound.setInt("Width", this.scatteredFeatureSizeX); + tagCompound.setInt("Height", this.scatteredFeatureSizeY); + tagCompound.setInt("Depth", this.scatteredFeatureSizeZ); + tagCompound.setInt("HPos", this.field_74936_d); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { - this.scatteredFeatureSizeX = tagCompound.getInteger("Width"); - this.scatteredFeatureSizeY = tagCompound.getInteger("Height"); - this.scatteredFeatureSizeZ = tagCompound.getInteger("Depth"); - this.field_74936_d = tagCompound.getInteger("HPos"); + this.scatteredFeatureSizeX = tagCompound.getInt("Width"); + this.scatteredFeatureSizeY = tagCompound.getInt("Height"); + this.scatteredFeatureSizeZ = tagCompound.getInt("Depth"); + this.field_74936_d = tagCompound.getInt("HPos"); } protected boolean func_74935_a(WorldServer worldIn, StructureBoundingBox p_74935_2_, int p_74935_3_) @@ -369,19 +369,19 @@ public class StructureScattered protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("placedMainChest", this.placedMainChest); - tagCompound.setBoolean("placedHiddenChest", this.placedHiddenChest); - tagCompound.setBoolean("placedTrap1", this.placedTrap1); - tagCompound.setBoolean("placedTrap2", this.placedTrap2); + tagCompound.setBool("placedMainChest", this.placedMainChest); + tagCompound.setBool("placedHiddenChest", this.placedHiddenChest); + tagCompound.setBool("placedTrap1", this.placedTrap1); + tagCompound.setBool("placedTrap2", this.placedTrap2); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.placedMainChest = tagCompound.getBoolean("placedMainChest"); - this.placedHiddenChest = tagCompound.getBoolean("placedHiddenChest"); - this.placedTrap1 = tagCompound.getBoolean("placedTrap1"); - this.placedTrap2 = tagCompound.getBoolean("placedTrap2"); + this.placedMainChest = tagCompound.getBool("placedMainChest"); + this.placedHiddenChest = tagCompound.getBool("placedHiddenChest"); + this.placedTrap1 = tagCompound.getBool("placedTrap1"); + this.placedTrap2 = tagCompound.getBool("placedTrap2"); } public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) @@ -616,13 +616,13 @@ public class StructureScattered protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Mage", this.hasMage); + tagCompound.setBool("Mage", this.hasMage); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.hasMage = tagCompound.getBoolean("Mage"); + this.hasMage = tagCompound.getBool("Mage"); } public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) diff --git a/server/src/main/java/server/worldgen/structure/StructureStart.java b/server/src/main/java/server/worldgen/structure/StructureStart.java index bc06008..9e46e3b 100755 --- a/server/src/main/java/server/worldgen/structure/StructureStart.java +++ b/server/src/main/java/server/worldgen/structure/StructureStart.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.LinkedList; import common.nbt.NBTTagCompound; -import common.nbt.NBTTagList; +import common.nbt.NBTTagTagList; import common.rng.Random; import common.util.ChunkPos; import server.world.WorldServer; @@ -71,17 +71,17 @@ public abstract class StructureStart { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("id", MapGenStructureIO.getStructureStartName(this)); - nbttagcompound.setInteger("ChunkX", chunkX); - nbttagcompound.setInteger("ChunkZ", chunkZ); - nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray()); - NBTTagList nbttaglist = new NBTTagList(); + nbttagcompound.setInt("ChunkX", chunkX); + nbttagcompound.setInt("ChunkZ", chunkZ); + nbttagcompound.setIntArray("BB", this.boundingBox.toIntArray()); + NBTTagTagList nbttaglist = new NBTTagTagList(); for (StructureComponent structurecomponent : this.components) { - nbttaglist.appendTag(structurecomponent.createStructureBaseNBT()); + nbttaglist.add(structurecomponent.createStructureBaseNBT()); } - nbttagcompound.setTag("Children", nbttaglist); + nbttagcompound.setTagList("Children", nbttaglist); this.writeToNBT(nbttagcompound); return nbttagcompound; } @@ -92,19 +92,19 @@ public abstract class StructureStart public void readStructureComponentsFromNBT(WorldServer worldIn, NBTTagCompound tagCompound) { - this.chunkPosX = tagCompound.getInteger("ChunkX"); - this.chunkPosZ = tagCompound.getInteger("ChunkZ"); + this.chunkPosX = tagCompound.getInt("ChunkX"); + this.chunkPosZ = tagCompound.getInt("ChunkZ"); - if (tagCompound.hasKey("BB")) + if (tagCompound.hasIntArray("BB")) { this.boundingBox = new StructureBoundingBox(tagCompound.getIntArray("BB")); } - NBTTagList nbttaglist = tagCompound.getTagList("Children", 10); + NBTTagTagList nbttaglist = tagCompound.getTagList("Children"); - for (int i = 0; i < nbttaglist.tagCount(); ++i) + for (int i = 0; i < nbttaglist.size(); ++i) { - this.components.add(MapGenStructureIO.getStructureComponent(nbttaglist.getCompoundTagAt(i), worldIn)); + this.components.add(MapGenStructureIO.getStructureComponent(nbttaglist.getTag(i), worldIn)); } this.readFromNBT(tagCompound); diff --git a/server/src/main/java/server/worldgen/structure/StructureStronghold.java b/server/src/main/java/server/worldgen/structure/StructureStronghold.java index 3679f4e..9650b55 100755 --- a/server/src/main/java/server/worldgen/structure/StructureStronghold.java +++ b/server/src/main/java/server/worldgen/structure/StructureStronghold.java @@ -255,13 +255,13 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Chest", this.hasMadeChest); + tagCompound.setBool("Chest", this.hasMadeChest); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.hasMadeChest = tagCompound.getBoolean("Chest"); + this.hasMadeChest = tagCompound.getBool("Chest"); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -327,13 +327,13 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setInteger("Steps", this.field_74993_a); + tagCompound.setInt("Steps", this.field_74993_a); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.field_74993_a = tagCompound.getInteger("Steps"); + this.field_74993_a = tagCompound.getInt("Steps"); } public static StructureBoundingBox func_175869_a(List p_175869_0_, Random p_175869_1_, int p_175869_2_, int p_175869_3_, int p_175869_4_, Facing p_175869_5_) @@ -428,19 +428,19 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("leftLow", this.field_74996_b); - tagCompound.setBoolean("leftHigh", this.field_74997_c); - tagCompound.setBoolean("rightLow", this.field_74995_d); - tagCompound.setBoolean("rightHigh", this.field_74999_h); + tagCompound.setBool("leftLow", this.field_74996_b); + tagCompound.setBool("leftHigh", this.field_74997_c); + tagCompound.setBool("rightLow", this.field_74995_d); + tagCompound.setBool("rightHigh", this.field_74999_h); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.field_74996_b = tagCompound.getBoolean("leftLow"); - this.field_74997_c = tagCompound.getBoolean("leftHigh"); - this.field_74995_d = tagCompound.getBoolean("rightLow"); - this.field_74999_h = tagCompound.getBoolean("rightHigh"); + this.field_74996_b = tagCompound.getBool("leftLow"); + this.field_74997_c = tagCompound.getBool("leftHigh"); + this.field_74995_d = tagCompound.getBool("rightLow"); + this.field_74999_h = tagCompound.getBool("rightHigh"); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -611,13 +611,13 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Tall", this.isLargeRoom); + tagCompound.setBool("Tall", this.isLargeRoom); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.isLargeRoom = tagCompound.getBoolean("Tall"); + this.isLargeRoom = tagCompound.getBool("Tall"); } public static StructureStronghold.Library func_175864_a(List p_175864_0_, Random p_175864_1_, int p_175864_2_, int p_175864_3_, int p_175864_4_, Facing p_175864_5_, int p_175864_6_) @@ -795,13 +795,13 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Mob", this.hasSpawner); + tagCompound.setBool("Mob", this.hasSpawner); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.hasSpawner = tagCompound.getBoolean("Mob"); + this.hasSpawner = tagCompound.getBool("Mob"); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -1033,13 +1033,13 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setInteger("Type", this.roomType); + tagCompound.setInt("Type", this.roomType); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.roomType = tagCompound.getInteger("Type"); + this.roomType = tagCompound.getInt("Type"); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -1202,13 +1202,13 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Source", this.field_75024_a); + tagCompound.setBool("Source", this.field_75024_a); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.field_75024_a = tagCompound.getBoolean("Source"); + this.field_75024_a = tagCompound.getBool("Source"); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -1396,15 +1396,15 @@ public class StructureStronghold protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Left", this.expandsX); - tagCompound.setBoolean("Right", this.expandsZ); + tagCompound.setBool("Left", this.expandsX); + tagCompound.setBool("Right", this.expandsZ); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.expandsX = tagCompound.getBoolean("Left"); - this.expandsZ = tagCompound.getBoolean("Right"); + this.expandsX = tagCompound.getBool("Left"); + this.expandsZ = tagCompound.getBool("Right"); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) diff --git a/server/src/main/java/server/worldgen/structure/StructureVillage.java b/server/src/main/java/server/worldgen/structure/StructureVillage.java index 7a81ed1..1c23066 100755 --- a/server/src/main/java/server/worldgen/structure/StructureVillage.java +++ b/server/src/main/java/server/worldgen/structure/StructureVillage.java @@ -406,19 +406,19 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setInteger("CA", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeA)); - tagCompound.setInteger("CB", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeB)); - tagCompound.setInteger("CC", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeC)); - tagCompound.setInteger("CD", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeD)); + tagCompound.setInt("CA", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeA)); + tagCompound.setInt("CB", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeB)); + tagCompound.setInt("CC", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeC)); + tagCompound.setInt("CD", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeD)); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.cropTypeA = BlockRegistry.getBlockById(tagCompound.getInteger("CA")); - this.cropTypeB = BlockRegistry.getBlockById(tagCompound.getInteger("CB")); - this.cropTypeC = BlockRegistry.getBlockById(tagCompound.getInteger("CC")); - this.cropTypeD = BlockRegistry.getBlockById(tagCompound.getInteger("CD")); + this.cropTypeA = BlockRegistry.getBlockById(tagCompound.getInt("CA")); + this.cropTypeB = BlockRegistry.getBlockById(tagCompound.getInt("CB")); + this.cropTypeC = BlockRegistry.getBlockById(tagCompound.getInt("CC")); + this.cropTypeD = BlockRegistry.getBlockById(tagCompound.getInt("CD")); } private Block func_151559_a(Random rand) @@ -515,15 +515,15 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setInteger("CA", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeA)); - tagCompound.setInteger("CB", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeB)); + tagCompound.setInt("CA", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeA)); + tagCompound.setInt("CB", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeB)); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.cropTypeA = BlockRegistry.getBlockById(tagCompound.getInteger("CA")); - this.cropTypeB = BlockRegistry.getBlockById(tagCompound.getInteger("CB")); + this.cropTypeA = BlockRegistry.getBlockById(tagCompound.getInt("CA")); + this.cropTypeB = BlockRegistry.getBlockById(tagCompound.getInt("CB")); } private Block func_151560_a(Random rand) @@ -858,13 +858,13 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Chest", this.hasMadeChest); + tagCompound.setBool("Chest", this.hasMadeChest); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.hasMadeChest = tagCompound.getBoolean("Chest"); + this.hasMadeChest = tagCompound.getBool("Chest"); } public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) @@ -1126,13 +1126,13 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("Terrace", this.isRoofAccessible); + tagCompound.setBool("Terrace", this.isRoofAccessible); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.isRoofAccessible = tagCompound.getBoolean("Terrace"); + this.isRoofAccessible = tagCompound.getBool("Terrace"); } public static StructureVillage.House4Garden func_175858_a(StructureVillage.Start start, List p_175858_1_, Random rand, int p_175858_3_, int p_175858_4_, int p_175858_5_, Facing facing, int p_175858_7_) @@ -1255,13 +1255,13 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setInteger("Length", this.length); + tagCompound.setInt("Length", this.length); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.length = tagCompound.getInteger("Length"); + this.length = tagCompound.getInt("Length"); } public void buildComponent(StructureComponent componentIn, List listIn, Random rand) @@ -1509,16 +1509,16 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { - tagCompound.setInteger("HPos", this.field_143015_k); - tagCompound.setInteger("VCount", this.villagersSpawned); - tagCompound.setBoolean("Desert", this.isDesertVillage); + tagCompound.setInt("HPos", this.field_143015_k); + tagCompound.setInt("VCount", this.villagersSpawned); + tagCompound.setBool("Desert", this.isDesertVillage); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { - this.field_143015_k = tagCompound.getInteger("HPos"); - this.villagersSpawned = tagCompound.getInteger("VCount"); - this.isDesertVillage = tagCompound.getBoolean("Desert"); + this.field_143015_k = tagCompound.getInt("HPos"); + this.villagersSpawned = tagCompound.getInt("VCount"); + this.isDesertVillage = tagCompound.getBool("Desert"); } protected StructureComponent getNextComponentNN(StructureVillage.Start start, List p_74891_2_, Random rand, int p_74891_4_, int p_74891_5_) @@ -1792,15 +1792,15 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setInteger("T", this.tablePosition); - tagCompound.setBoolean("C", this.isTallHouse); + tagCompound.setInt("T", this.tablePosition); + tagCompound.setBool("C", this.isTallHouse); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.tablePosition = tagCompound.getInteger("T"); - this.isTallHouse = tagCompound.getBoolean("C"); + this.tablePosition = tagCompound.getInt("T"); + this.isTallHouse = tagCompound.getBool("C"); } public static StructureVillage.WoodHut func_175853_a(StructureVillage.Start start, List p_175853_1_, Random rand, int p_175853_3_, int p_175853_4_, int p_175853_5_, Facing facing, int p_175853_7_) @@ -1904,13 +1904,13 @@ public class StructureVillage protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); - tagCompound.setBoolean("VSpawn", this.villagerSpawned); + tagCompound.setBool("VSpawn", this.villagerSpawned); } protected void readStructureFromNBT(NBTTagCompound tagCompound) { super.readStructureFromNBT(tagCompound); - this.villagerSpawned = tagCompound.getBoolean("VSpawn"); + this.villagerSpawned = tagCompound.getBool("VSpawn"); } public static StructureVillage.Cage func_175853_a(StructureVillage.Start start, List p_175853_1_, Random rand, int p_175853_3_, int p_175853_4_, int p_175853_5_, Facing facing, int p_175853_7_)