@Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); Utils.writeStacksToNBT(nbttagcompound, "Items", items); if (box.isInitialized()) { NBTTagCompound boxStore = new NBTTagCompound(); box.writeToNBT(boxStore); nbttagcompound.setTag("box", boxStore); } if (path != null) { NBTTagList list = new NBTTagList(); for (BlockIndex i : path) { NBTTagCompound c = new NBTTagCompound(); i.writeTo(c); list.appendTag(c); } nbttagcompound.setTag("path", list); } nbttagcompound.setBoolean("done", done); }
public void readFromNBT(NBTTagCompound nbttagcompound) { NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); contents = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); int j = nbttagcompound1.getByte("Slot") & 0xff; if (j >= 0 && j < contents.length) { contents[j] = new ItemStack(nbttagcompound1); } } }
public void writeToNBT(NBTTagCompound nbttagcompound) { NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < contents.length; i++) { if (contents[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); contents[i].writeToNBT(nbttagcompound1); nbttaglist.setTag(nbttagcompound1); } } nbttagcompound.setTag("Items", nbttaglist); }
@Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList list = new NBTTagList(); for (int i = 0; i < contents.length; i++) { if (contents[i] == null) continue; NBTTagCompound item = new NBTTagCompound(); item.setByte("Slot", (byte) i); contents[i].writeToNBT(item); list.appendTag(item); } compound.setTag("Items", list); if (lock != null) compound.setCompoundTag("lock", lock.writeToNBT(new NBTTagCompound(""))); }
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList items = compound.getTagList("Items"); contents = new ItemStack[getSizeInventory()]; for (int i = 0; i < items.tagCount(); i++) { NBTTagCompound item = (NBTTagCompound) items.tagAt(i); int slot = item.getByte("Slot") & 255; if (slot >= 0 && slot < contents.length) contents[slot] = ItemStack.loadItemStackFromNBT(item); } if (compound.hasKey("lock")) lock = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("lock")); }
@Override public void readFromNBT(NBTTagCompound ntc) { super.readFromNBT(ntc); this.grindingTicks = ntc.getInteger("grindingTicks"); NBTTagList list = ntc.getTagList("Items"); this.inv = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound ntc2 = (NBTTagCompound) list.tagAt(i); byte b = ntc2.getByte("Slot"); if ((b >= 0) && (b < this.inv.length)) { this.inv[b] = ItemStack.loadItemStackFromNBT(ntc2); } } }
public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); SecurtyStation_ID = nbttagcompound.getInteger("Secstation_ID"); stationname = nbttagcompound.getString("stationname"); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); inventory = 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 < inventory.length) { inventory[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } }
private static void func_77518_a(IEnchantmentModifier p_77518_0_, ItemStack p_77518_1_) { if (p_77518_1_ != null) { NBTTagList var2 = p_77518_1_.func_77986_q(); if (var2 != null) { for (int var3 = 0; var3 < var2.func_74745_c(); ++var3) { short var4 = ((NBTTagCompound) var2.func_74743_b(var3)).func_74765_d("id"); short var5 = ((NBTTagCompound) var2.func_74743_b(var3)).func_74765_d("lvl"); if (Enchantment.field_77331_b[var4] != null) { p_77518_0_.func_77493_a(Enchantment.field_77331_b[var4], var5); } } } } }
/** Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.poubelleContents = 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.poubelleContents.length) { this.poubelleContents[var5] = ItemStack.loadItemStackFromNBT(var4); } } }
/** Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.poubelleContents.length; ++var3) { if (this.poubelleContents[var3] != null) { NBTTagCompound var4 = new NBTTagCompound(); var4.setByte("Slot", (byte) var3); this.poubelleContents[var3].writeToNBT(var4); var2.appendTag(var4); } } par1NBTTagCompound.setTag("Items", var2); }
@Override public void writeToNBT(NBTTagCompound ntc) { super.writeToNBT(ntc); ntc.setInteger("grindingTicks", this.grindingTicks); NBTTagList list = new NBTTagList(); for (int i = 0; i < inv.length; ++i) { if (this.inv[i] != null) { NBTTagCompound ntc2 = new NBTTagCompound(); ntc2.setByte("Slot", (byte) i); this.inv[i].writeToNBT(ntc2); list.appendTag(ntc2); } } ntc.setTag("Items", list); }
public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); usechannel = nbttagcompound.getInteger("usechannel"); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); ItemStacks = 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 < ItemStacks.length) { ItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } }
/** Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setShort("BurnTime", (short) this.freezerBurnTime); par1NBTTagCompound.setShort("CookTime", (short) this.freezerCookTime); NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.freezerItemStacks.length; ++var3) { if (this.freezerItemStacks[var3] != null) { NBTTagCompound var4 = new NBTTagCompound(); var4.setByte("Slot", (byte) var3); this.freezerItemStacks[var3].writeToNBT(var4); var2.appendTag(var4); } } par1NBTTagCompound.setTag("Items", var2); }
public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); nbttagcompound.setInteger("Secstation_ID", SecurtyStation_ID); nbttagcompound.setString("stationname", stationname); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < inventory.length; i++) { if (inventory[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); inventory[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbttagcompound.setTag("Items", nbttaglist); }
public void func_70307_a(NBTTagCompound p_70307_1_) { super.func_70307_a(p_70307_1_); NBTTagList var2 = p_70307_1_.func_74761_m("Items"); this.field_70359_a = new ItemStack[this.func_70302_i_()]; for (int var3 = 0; var3 < var2.func_74745_c(); ++var3) { NBTTagCompound var4 = (NBTTagCompound) var2.func_74743_b(var3); byte var5 = var4.func_74771_c("Slot"); if (var5 >= 0 && var5 < this.field_70359_a.length) { this.field_70359_a[var5] = ItemStack.func_77949_a(var4); } } this.field_70357_b = p_70307_1_.func_74765_d("BrewTime"); if (p_70307_1_.func_74764_b("CustomName")) { this.field_94132_e = p_70307_1_.func_74779_i("CustomName"); } }
public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); nbttagcompound.setInteger("usechannel", usechannel); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < ItemStacks.length; i++) { if (ItemStacks[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); ItemStacks[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbttagcompound.setTag("Items", nbttaglist); }
/** Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.freezerItemStacks = 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.freezerItemStacks.length) { this.freezerItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4); } } this.freezerBurnTime = par1NBTTagCompound.getShort("BurnTime"); this.freezerCookTime = par1NBTTagCompound.getShort("CookTime"); this.freezercurrentItemBurnTime = getItemBurnTime(this.freezerItemStacks[1]); }
public void func_70443_b(NBTTagList p_70443_1_) { this.field_70462_a = new ItemStack[36]; this.field_70460_b = new ItemStack[4]; for (int var2 = 0; var2 < p_70443_1_.func_74745_c(); ++var2) { NBTTagCompound var3 = (NBTTagCompound) p_70443_1_.func_74743_b(var2); int var4 = var3.func_74771_c("Slot") & 255; ItemStack var5 = ItemStack.func_77949_a(var3); if (var5 != null) { if (var4 >= 0 && var4 < this.field_70462_a.length) { this.field_70462_a[var4] = var5; } if (var4 >= 100 && var4 < this.field_70460_b.length + 100) { this.field_70460_b[var4 - 100] = var5; } } } }
public void func_70310_b(NBTTagCompound p_70310_1_) { super.func_70310_b(p_70310_1_); p_70310_1_.func_74777_a("BrewTime", (short) this.field_70357_b); NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.field_70359_a.length; ++var3) { if (this.field_70359_a[var3] != null) { NBTTagCompound var4 = new NBTTagCompound(); var4.func_74774_a("Slot", (byte) var3); this.field_70359_a[var3].func_77955_b(var4); var2.func_74742_a(var4); } } p_70310_1_.func_74782_a("Items", var2); if (this.func_94042_c()) { p_70310_1_.func_74778_a("CustomName", this.field_94132_e); } }
public static int func_77506_a(int p_77506_0_, ItemStack p_77506_1_) { if (p_77506_1_ == null) { return 0; } else { NBTTagList var2 = p_77506_1_.func_77986_q(); if (var2 == null) { return 0; } else { for (int var3 = 0; var3 < var2.func_74745_c(); ++var3) { short var4 = ((NBTTagCompound) var2.func_74743_b(var3)).func_74765_d("id"); short var5 = ((NBTTagCompound) var2.func_74743_b(var3)).func_74765_d("lvl"); if (var4 == p_77506_0_) { return var5; } } return 0; } } }
@Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); Utils.readStacksFromNBT(nbttagcompound, "Items", items); if (nbttagcompound.hasKey("box")) { box.initialize(nbttagcompound.getCompoundTag("box")); } if (nbttagcompound.hasKey("path")) { path = new LinkedList<BlockIndex>(); NBTTagList list = nbttagcompound.getTagList("path"); for (int i = 0; i < list.tagCount(); ++i) { path.add(new BlockIndex((NBTTagCompound) list.tagAt(i))); } } done = nbttagcompound.getBoolean("done"); }
public void beforeReadEntityFromNBT(NBTTagCompound tags) { if (player.worldObj.isRemote) return; NBTTagCompound customData = new NBTTagCompound(); try { // Load the data File file = new File(FlansModHandler.getSaveDirectory(player.worldObj), "Flan.dat"); customData = CompressedStreamTools.readCompressed(new FileInputStream(file)); // Fill the unlocks list NBTTagList unlocks = customData.getTagList("Unlocks"); for (int i = 0; i < unlocks.tagCount(); ++i) { NBTTagString string = (NBTTagString) unlocks.tagAt(i); FlansMod.blueprintsUnlocked = new ArrayList<PlaneType>(); FlansMod.blueprintsUnlocked.add(PlaneType.getPlane(string.toString())); } NBTTagList vehicleUnlocks = customData.getTagList("VehicleUnlocks"); for (int i = 0; i < vehicleUnlocks.tagCount(); ++i) { NBTTagString string = (NBTTagString) vehicleUnlocks.tagAt(i); FlansMod.vehicleBlueprintsUnlocked = new ArrayList<VehicleType>(); FlansMod.vehicleBlueprintsUnlocked.add(VehicleType.getVehicle(string.toString())); } FlansMod.doneTutorial = customData.getBoolean("DoneTutorial"); } catch (IOException ioexception) { System.out.println("Failed to read data for Flan's mod. Using defaults."); } }
public NBTTagList func_70442_a(NBTTagList p_70442_1_) { int var2; NBTTagCompound var3; for (var2 = 0; var2 < this.field_70462_a.length; ++var2) { if (this.field_70462_a[var2] != null) { var3 = new NBTTagCompound(); var3.func_74774_a("Slot", (byte) var2); this.field_70462_a[var2].func_77955_b(var3); p_70442_1_.func_74742_a(var3); } } for (var2 = 0; var2 < this.field_70460_b.length; ++var2) { if (this.field_70460_b[var2] != null) { var3 = new NBTTagCompound(); var3.func_74774_a("Slot", (byte) (var2 + 100)); this.field_70460_b[var2].func_77955_b(var3); p_70442_1_.func_74742_a(var3); } } return p_70442_1_; }
public void afterWriteEntityToNBT(NBTTagCompound tags) { if (player.worldObj.isRemote) return; NBTTagCompound customData = new NBTTagCompound(); NBTTagList unlocks = new NBTTagList(); for (PlaneType type : FlansMod.blueprintsUnlocked) { unlocks.appendTag(new NBTTagString("Plane", type.shortName)); } customData.setTag("Unlocks", unlocks); NBTTagList vehicleUnlocks = new NBTTagList(); for (VehicleType type : FlansMod.vehicleBlueprintsUnlocked) { vehicleUnlocks.appendTag(new NBTTagString("Vehicle", type.shortName)); } customData.setTag("VehicleUnlocks", vehicleUnlocks); customData.setBoolean("DoneTutorial", FlansMod.doneTutorial); // Store the data try { File file = new File(FlansModHandler.getSaveDirectory(player.worldObj), "Flan.dat"); CompressedStreamTools.writeCompressed(customData, new FileOutputStream(file)); } catch (IOException ioexception) { ioexception.printStackTrace(); throw new RuntimeException("Failed to create data for Flan's mod."); } }