public void importOldChunkTileEntities() { File file = wc.downloadSaveHandler.getSaveDirectory(); if (wc.worldProvider instanceof WorldProviderHell) { file = new File(file, "DIM-1"); file.mkdirs(); } java.io.DataInputStream datainputstream = RegionFileCache.getChunkInputStream(file, xPosition, zPosition); NBTTagCompound nbttagcompound; if (datainputstream != null) { try { nbttagcompound = CompressedStreamTools.func_1141_a(datainputstream); } catch (IOException e) { return; } } else return; if (!nbttagcompound.hasKey("Level")) return; NBTTagList nbttaglist1 = nbttagcompound.getCompoundTag("Level").getTagList("TileEntities"); if (nbttaglist1 != null) { for (int l = 0; l < nbttaglist1.tagCount(); l++) { NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l); TileEntity te = TileEntity.createAndLoadEntity(nbttagcompound2); if (te != null) { ChunkPosition cp = new ChunkPosition(te.xCoord & 0xf, te.yCoord, te.zCoord & 0xf); newChunkTileEntityMap.put(cp, te); } } } }
protected void func_96500_c(NBTTagList par1NBTTagList) { for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) { NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2); ScoreObjective var4 = this.field_96507_a.func_96518_b(var3.getString("Objective")); Score var5 = this.field_96507_a.func_96529_a(var3.getString("Name"), var4); var5.func_96647_c(var3.getInteger("Score")); } }
protected void func_96501_b(NBTTagList par1NBTTagList) { for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) { NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2); ScoreObjectiveCriteria var4 = (ScoreObjectiveCriteria) ScoreObjectiveCriteria.field_96643_a.get(var3.getString("CriteriaName")); ScoreObjective var5 = this.field_96507_a.func_96535_a(var3.getString("Name"), var4); var5.func_96681_a(var3.getString("DisplayName")); } }
public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); woodType = nbttagcompound.getByte("woodType"); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); storage = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < storage.length) { storage[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } }
public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); // timeleft = nbttagcompound.getInteger("timeleft"); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); metalItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < metalItemStacks.length) { metalItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } }
public void readFromNBT(NBTTagCompound tagCompound) { if (tagCompound != null) { NBTTagList tagList = tagCompound.getTagList("Inventory", 10); for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.getCompoundTagAt(i); int j = nbttagcompound.getByte("Slot") & 255; ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound); if (itemstack != null) { this.inventory[j] = itemstack; } } } }
/** Return the enchantments for the specified stack. */ public static Map getEnchantments(ItemStack par0ItemStack) { LinkedHashMap var1 = new LinkedHashMap(); NBTTagList var2 = par0ItemStack.getEnchantmentTagList(); if (var2 != null) { for (int var3 = 0; var3 < var2.tagCount(); ++var3) { short var4 = ((NBTTagCompound) var2.tagAt(var3)).getShort("id"); short var5 = ((NBTTagCompound) var2.tagAt(var3)).getShort("lvl"); var1.put(Integer.valueOf(var4), Integer.valueOf(var5)); } } return var1; }
public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); furnaceItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < furnaceItemStacks.length) { furnaceItemStacks[byte0] = new ItemStack(nbttagcompound1); } } furnaceBurnTime = nbttagcompound.getShort("BurnTime"); furnaceCookTime = nbttagcompound.getShort("CookTime"); currentItemBurnTime = getItemBurnTime(furnaceItemStacks[1]); }
/** Executes the enchantment modifier on the ItemStack passed. */ private static void applyEnchantmentModifier( IEnchantmentModifier par0IEnchantmentModifier, ItemStack par1ItemStack) { if (par1ItemStack != null) { NBTTagList var2 = par1ItemStack.getEnchantmentTagList(); if (var2 != null) { for (int var3 = 0; var3 < var2.tagCount(); ++var3) { short var4 = ((NBTTagCompound) var2.tagAt(var3)).getShort("id"); short var5 = ((NBTTagCompound) var2.tagAt(var3)).getShort("lvl"); if (Enchantment.enchantmentsList[var4] != null) { par0IEnchantmentModifier.calculateModifier(Enchantment.enchantmentsList[var4], var5); } } } } }
/** Set the enchantments for the specified stack. */ public static void setEnchantments(Map par0Map, ItemStack par1ItemStack) { NBTTagList var2 = new NBTTagList(); Iterator var3 = par0Map.keySet().iterator(); while (var3.hasNext()) { int var4 = ((Integer) var3.next()).intValue(); NBTTagCompound var5 = new NBTTagCompound(); var5.setShort("id", (short) var4); var5.setShort("lvl", (short) ((Integer) par0Map.get(Integer.valueOf(var4))).intValue()); var2.appendTag(var5); } if (var2.tagCount() > 0) { par1ItemStack.setTagInfo("ench", var2); } else if (par1ItemStack.hasTagCompound()) { par1ItemStack.getTagCompound().removeTag("ench"); } }
public void readFromNBT(NBTTagList nbttaglist) { mainInventory = new ItemStack[36]; armorInventory = new ItemStack[4]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i); int j = nbttagcompound.getByte("Slot") & 0xff; ItemStack itemstack = new ItemStack(nbttagcompound); if (itemstack.getItem() == null) { continue; } if (j >= 0 && j < mainInventory.length) { mainInventory[j] = itemstack; } if (j >= 100 && j < armorInventory.length + 100) { armorInventory[j - 100] = itemstack; } } }
/** Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.combinerItemStacks = new ItemStack[this.getSizeInventory()]; for (int var3 = 0; var3 < var2.tagCount(); ++var3) { NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3); byte var5 = var4.getByte("Slot"); if (var5 >= 0 && var5 < this.combinerItemStacks.length) { this.combinerItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4); } } this.combinerBurnTime = par1NBTTagCompound.getShort("BurnTime"); this.combinerCookTime = par1NBTTagCompound.getShort("CookTime"); this.currentItemBurnTime = getItemBurnTime(this.combinerItemStacks[1]); }
protected void func_96498_a(NBTTagList par1NBTTagList) { for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) { NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2); ScorePlayerTeam var4 = this.field_96507_a.func_96527_f(var3.getString("Name")); var4.func_96664_a(var3.getString("DisplayName")); var4.func_96666_b(var3.getString("Prefix")); var4.func_96662_c(var3.getString("Suffix")); if (var3.hasKey("AllowFriendlyFire")) { var4.func_96660_a(var3.getBoolean("AllowFriendlyFire")); } if (var3.hasKey("SeeFriendlyInvisibles")) { var4.func_98300_b(var3.getBoolean("SeeFriendlyInvisibles")); } this.func_96502_a(var4, var3.getTagList("Players")); } }
/** Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.brewingItemStacks = new ItemStack[this.getSizeInventory()]; for (int var3 = 0; var3 < var2.tagCount(); ++var3) { NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3); byte var5 = var4.getByte("Slot"); if (var5 >= 0 && var5 < this.brewingItemStacks.length) { this.brewingItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4); } } this.brewTime = par1NBTTagCompound.getShort("BrewTime"); if (par1NBTTagCompound.hasKey("CustomName")) { this.field_94132_e = par1NBTTagCompound.getString("CustomName"); } }
/** Reads from the given tag list and fills the slots in the inventory with the correct items. */ public void readFromNBT(NBTTagList par1NBTTagList) { this.mainInventory = new ItemStack[36]; this.armorInventory = new ItemStack[4]; for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) { NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2); int var4 = var3.getByte("Slot") & 255; ItemStack var5 = ItemStack.loadItemStackFromNBT(var3); if (var5 != null) { if (var4 >= 0 && var4 < this.mainInventory.length) { this.mainInventory[var4] = var5; } if (var4 >= 100 && var4 < this.armorInventory.length + 100) { this.armorInventory[var4 - 100] = var5; } } } }
/** (abstract) Protected helper method to read subclass entity data from NBT. */ protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { minecartType = par1NBTTagCompound.getInteger("Type"); if (minecartType == 2) { pushX = par1NBTTagCompound.getDouble("PushX"); pushZ = par1NBTTagCompound.getDouble("PushZ"); fuel = par1NBTTagCompound.getShort("Fuel"); } else if (minecartType == 1) { NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); cargoItems = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i); int j = nbttagcompound.getByte("Slot") & 0xff; if (j >= 0 && j < cargoItems.length) { cargoItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound); } } } }
/** (abstract) Protected helper method to read subclass entity data from NBT. */ protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { this.minecartType = par1NBTTagCompound.getInteger("Type"); if (this.minecartType == 2) { this.pushX = par1NBTTagCompound.getDouble("PushX"); this.pushZ = par1NBTTagCompound.getDouble("PushZ"); this.fuel = par1NBTTagCompound.getShort("Fuel"); } else if (this.minecartType == 1) { NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.cargoItems = new ItemStack[this.getSizeInventory()]; for (int var3 = 0; var3 < var2.tagCount(); ++var3) { NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3); int var5 = var4.getByte("Slot") & 255; if (var5 >= 0 && var5 < this.cargoItems.length) { this.cargoItems[var5] = ItemStack.loadItemStackFromNBT(var4); } } } }
/** Returns the level of enchantment on the ItemStack passed. */ public static int getEnchantmentLevel(int par0, ItemStack par1ItemStack) { if (par1ItemStack == null) { return 0; } else { NBTTagList var2 = par1ItemStack.getEnchantmentTagList(); if (var2 == null) { return 0; } else { for (int var3 = 0; var3 < var2.tagCount(); ++var3) { short var4 = ((NBTTagCompound) var2.tagAt(var3)).getShort("id"); short var5 = ((NBTTagCompound) var2.tagAt(var3)).getShort("lvl"); if (var4 == par0) { return var5; } } return 0; } } }
private void setupFromNBT(NBTTagCompound tagCompound) { terrainType = TerrainType.values()[tagCompound.getInteger("terrain")]; featureTypes = toEnumSet(getIntArraySafe(tagCompound, "features"), FeatureType.values()); structureTypes = toEnumSet(getIntArraySafe(tagCompound, "structures"), StructureType.values()); effectTypes = toEnumSet(getIntArraySafe(tagCompound, "effects"), EffectType.values()); biomes.clear(); for (int a : getIntArraySafe(tagCompound, "biomes")) { BiomeGenBase biome = BiomeGenBase.getBiome(a); if (biome != null) { biomes.add(biome); } else { // Protect against deleted biomes (i.e. a mod with biomes gets removed and this dimension // still uses it). // We will pick a replacement biome here. biomes.add(BiomeGenBase.plains); } } if (tagCompound.hasKey("controller")) { controllerType = ControllerType.values()[tagCompound.getInteger("controller")]; } else { // Support for old type. if (biomes.isEmpty()) { controllerType = ControllerType.CONTROLLER_DEFAULT; } else { controllerType = ControllerType.CONTROLLER_SINGLE; } } digitString = tagCompound.getString("digits"); forcedDimensionSeed = tagCompound.getLong("forcedSeed"); baseSeed = tagCompound.getLong("baseSeed"); worldVersion = tagCompound.getInteger("worldVersion"); baseBlockForTerrain = getBlockMeta(tagCompound, "baseBlock"); tendrilBlock = getBlockMeta(tagCompound, "tendrilBlock"); canyonBlock = getBlockMeta(tagCompound, "canyonBlock"); fluidForTerrain = (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("fluidBlock")); hugeLiquidSphereFluids = readFluidsFromNBT(tagCompound, "hugeLiquidSphereFluids"); hugeLiquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeLiquidSphereBlocks"); // Support for the old format with only one liquid block. Block oldLiquidSphereFluid = (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("liquidSphereFluid")); liquidSphereFluids = readFluidsFromNBT(tagCompound, "liquidSphereFluids"); if (liquidSphereFluids.length == 0) { liquidSphereFluids = new Block[] {oldLiquidSphereFluid}; } // Support for the old format with only one sphere block. BlockMeta oldLiquidSphereBlock = getBlockMeta(tagCompound, "liquidSphereBlock"); liquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "liquidSphereBlocks"); if (liquidSphereBlocks.length == 0) { liquidSphereBlocks = new BlockMeta[] {oldLiquidSphereBlock}; } pyramidBlocks = readBlockArrayFromNBT(tagCompound, "pyramidBlocks"); if (pyramidBlocks.length == 0) { pyramidBlocks = new BlockMeta[] {BlockMeta.STONE}; } // Support for the old format with only one sphere block. BlockMeta oldSphereBlock = getBlockMeta(tagCompound, "sphereBlock"); sphereBlocks = readBlockArrayFromNBT(tagCompound, "sphereBlocks"); if (sphereBlocks.length == 0) { sphereBlocks = new BlockMeta[] {oldSphereBlock}; } hugeSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeSphereBlocks"); extraOregen = readBlockArrayFromNBT(tagCompound, "extraOregen"); fluidsForLakes = readFluidsFromNBT(tagCompound, "lakeFluids"); peaceful = tagCompound.getBoolean("peaceful"); noanimals = tagCompound.getBoolean("noanimals"); shelter = tagCompound.getBoolean("shelter"); respawnHere = tagCompound.getBoolean("respawnHere"); if (tagCompound.hasKey("celestialAngle")) { celestialAngle = tagCompound.getFloat("celestialAngle"); } else { celestialAngle = null; } if (tagCompound.hasKey("timeSpeed")) { timeSpeed = tagCompound.getFloat("timeSpeed"); } else { timeSpeed = null; } probeCounter = tagCompound.getInteger("probes"); actualRfCost = tagCompound.getInteger("actualCost"); skyDescriptor = new SkyDescriptor.Builder().fromNBT(tagCompound).build(); calculateCelestialBodyDescriptors(); patreon1 = tagCompound.getLong("patreon1"); weatherDescriptor = new WeatherDescriptor.Builder().fromNBT(tagCompound).build(); extraMobs.clear(); NBTTagList list = tagCompound.getTagList("mobs", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound tc = list.getCompoundTagAt(i); String className = tc.getString("class"); int chance = tc.getInteger("chance"); int minGroup = tc.getInteger("minGroup"); int maxGroup = tc.getInteger("maxGroup"); int maxLoaded = tc.getInteger("maxLoaded"); Class<? extends EntityLiving> c = null; try { c = (Class<? extends EntityLiving>) Class.forName(className); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } MobDescriptor mob = new MobDescriptor(null, c, chance, minGroup, maxGroup, maxLoaded); extraMobs.add(mob); } String ds = tagCompound.getString("dimensionTypes"); dimensionTypes = StringUtils.split(ds, ","); if (dimensionTypes == null) { dimensionTypes = new String[0]; } }
/** reads in data from the NBTTagCompound into this MapDataBase */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { // DEBUG System.out.println( "MapData.readFromNBT() - " + cpw.mods.fml.common.FMLCommonHandler.instance().getEffectiveSide()); NBTBase dimension = par1NBTTagCompound.getTag("dimension"); if (dimension instanceof NBTTagByte) { this.dimension = ((NBTTagByte) dimension).data; } else { this.dimension = ((NBTTagInt) dimension).data; } this.xCenter = par1NBTTagCompound.getInteger("xCenter"); this.zCenter = par1NBTTagCompound.getInteger("zCenter"); this.scale = par1NBTTagCompound.getByte("scale"); if (this.scale < 0) { this.scale = 0; } if (this.scale > 4) { this.scale = 4; } short short1 = par1NBTTagCompound.getShort("width"); short short2 = par1NBTTagCompound.getShort("height"); if (short1 == 128 && short2 == 128) { this.colors = par1NBTTagCompound.getByteArray("colors"); } else { byte[] abyte = par1NBTTagCompound.getByteArray("colors"); this.colors = new byte[16384]; int i = (128 - short1) / 2; int j = (128 - short2) / 2; for (int k = 0; k < short2; ++k) { int l = k + j; if (l >= 0 || l < 128) { for (int i1 = 0; i1 < short1; ++i1) { int j1 = i1 + i; if (j1 >= 0 || j1 < 128) { this.colors[j1 + l * 128] = abyte[i1 + k * short1]; } } } } } // CartoCraft - Loads custom icons // OBS: This part is in SERVER, the info will need to be sent to clients NBTTagList iconTagList = par1NBTTagCompound.getTagList("customIcons"); if (iconTagList != null) { System.out.println("Found customIcons TagList! " + iconTagList.tagCount()); for (int i = 0; i < iconTagList.tagCount(); i++) { NBTTagCompound iconTagCompound = (NBTTagCompound) iconTagList.tagAt(i); byte iconNum = iconTagCompound.getByte("icon"); byte x = iconTagCompound.getByte("xPos"); byte z = iconTagCompound.getByte("zPos"); String iconKey = getCustomIconKey(x, z); System.out.println( " Adding icon [" + iconNum + "] at [" + x + "],[" + z + "] with key [" + iconKey + "]"); this.customIcons.put(iconKey, new MapCoord(this, iconNum, x, z, (byte) 0)); } } }
protected void func_96502_a(ScorePlayerTeam par1ScorePlayerTeam, NBTTagList par2NBTTagList) { for (int var3 = 0; var3 < par2NBTTagList.tagCount(); ++var3) { this.field_96507_a.func_96521_a( ((NBTTagString) par2NBTTagList.tagAt(var3)).data, par1ScorePlayerTeam); } }