@SuppressWarnings("rawtypes") public void readFromNBT(NBTTagCompound var1) { Iterator<NBTTagCompound> i = var1.getTags().iterator(); while (i.hasNext()) { NBTTagCompound tag = i.next(); ComputerBox c = new ComputerBox(this, Integer.parseInt(tag.getName())); c.load(tag); storageBoxes[Integer.parseInt(tag.getName())] = c; } }
/** Checks if the region of a crafting inventory is match for the recipe. */ private boolean checkMatch(IInventory par1InventoryCrafting, int par2, int par3, boolean par4) { for (int var5 = 0; var5 < 3; ++var5) { for (int var6 = 0; var6 < 3; ++var6) { int var7 = var5 - par2; int var8 = var6 - par3; ItemStack var9 = null; if (var7 >= 0 && var8 >= 0 && var7 < this.recipeWidth && var8 < this.recipeHeight) { if (par4) { var9 = this.recipeItems[this.recipeWidth - var7 - 1 + var8 * this.recipeWidth]; } else { var9 = this.recipeItems[var7 + var8 * this.recipeWidth]; } } ItemStack var10 = ThaumcraftApiHelper.getStackInRowAndColumn(par1InventoryCrafting, var5, var6); if (var10 != null || var9 != null) { if (var10 == null && var9 != null || var10 != null && var9 == null) { return false; } if (var9.itemID != var10.itemID) { return false; } if (var9.getItemDamage() != -1 && var9.getItemDamage() != var10.getItemDamage()) { return false; } if (var9.hasTagCompound()) { NBTTagCompound tc = var9.getTagCompound(); for (Object tag : tc.getTags().toArray()) { NBTBase base = (NBTBase) tag; Class nc = NBTBase.newTag(base.getId(), base.getName()).getClass(); if (!(var10.hasTagCompound() && nc.cast(var10.getTagCompound().getTag(base.getName())) .equals(nc.cast(base)))) { return false; } } } } } } return true; }
@Override public ShapedOreRecipe getRecipeFromNBT(NBTTagCompound nbtRecipe) { ArrayList<Object> input = new ArrayList<Object>(); // Becomes entire recipe input ItemStack output = ItemStack.loadItemStackFromNBT(nbtRecipe.getCompoundTag(NBT_output)); NBTTagList inputs = nbtRecipe.getTagList(NBT_input); for (int i = 0; i < inputs.tagCount(); i++) input.add(((NBTTagString) inputs.tagAt(i)).data); NBTTagCompound map = nbtRecipe.getCompoundTag(NBT_map); for (NBTBase entry : (Collection<NBTBase>) map.getTags()) { input.add(entry.getName().charAt(0)); if (entry instanceof NBTTagString) input.add(((NBTTagString) entry).data); else input.add(ItemStack.loadItemStackFromNBT((NBTTagCompound) entry)); } return new ShapedOreRecipe(output, input.toArray()) .setMirrored(nbtRecipe.getBoolean(NBT_mirror)); }
@SuppressWarnings("rawtypes") public void readFromNBT(NBTTagCompound var1) { pokeDollars = var1.getInteger("pixelDollars"); Iterator iterator = var1.getTags().iterator(); do { if (!iterator.hasNext()) break; NBTBase nbtbase = (NBTBase) iterator.next(); if (nbtbase instanceof NBTTagCompound) { NBTTagCompound pokemonData = (NBTTagCompound) nbtbase; pokemonData.setName(pokemonData.getString("Name")); partyPokemon[pokemonData.getInteger("PixelmonOrder")] = pokemonData; if (mode == PokeballManagerMode.Player) player.playerNetServerHandler.sendPacketToPlayer( new PixelmonDataPacket(pokemonData, EnumPackets.AddToStorage).getPacket()); } } while (true); if (pokedex != null) pokedex.readFromNBT(var1); }
@Override public boolean onBlockActivated( EntityPlayer player, int side, float hitX, float hitY, float hitZ) { ItemStack held = player.getCurrentEquippedItem(); if (held != null && held.itemID == Item.redstoneRepeater.itemID) { if (held.stackTagCompound != null) { if (held.stackTagCompound.hasKey("miscperipheralsLinkX") && held.stackTagCompound.hasKey("miscperipheralsLinkY") && held.stackTagCompound.hasKey("miscperipheralsLinkZ") && held.stackTagCompound.hasKey("miscperipheralsLinkDim")) { ChunkCoordinates link = new ChunkCoordinates( held.stackTagCompound.getInteger("miscperipheralsLinkX"), held.stackTagCompound.getInteger("miscperipheralsLinkY"), held.stackTagCompound.getInteger("miscperipheralsLinkZ")); int linkDim = held.stackTagCompound.getInteger("miscperipheralsLinkDim"); World srcWorld = MinecraftServer.getServer().worldServerForDimension(linkDim); if (srcWorld == null) { player.sendChatToPlayer("Link failed: World is missing"); } else { TileEntity te = srcWorld.getBlockTileEntity(link.posX, link.posY, link.posZ); if (!(te instanceof TileTeleporter)) { player.sendChatToPlayer("Link failed: Teleporter no longer exists"); } else { TileTeleporter src = (TileTeleporter) te; if (link.posX == xCoord && link.posY == yCoord && link.posZ == zCoord) { player.sendChatToPlayer("Link canceled"); } else { boolean unlinked = false; for (int i = 0; i < src.links.size(); i++) { LinkData rlink = src.links.get(i); System.out.println( "comparing: " + rlink.link.posX + " " + xCoord + " " + rlink.link.posY + " " + yCoord + " " + rlink.link.posZ + " " + zCoord); if (rlink.link.posX == xCoord && rlink.link.posY == yCoord && rlink.link.posZ == zCoord && rlink.linkDim == worldObj.provider.dimensionId) { player.sendChatToPlayer( "Unlinked teleporter at " + rlink.linkDim + ":(" + rlink.link.posX + "," + rlink.link.posY + "," + rlink.link.posZ + ") (link " + (i + 1) + ") from this teleporter"); src.links.remove(i); unlinked = true; break; } } if (!unlinked) { src.addLink( worldObj.provider.dimensionId, new ChunkCoordinates(xCoord, yCoord, zCoord)); player.sendChatToPlayer( "Linked teleporter at " + linkDim + ":(" + link.posX + "," + link.posY + "," + link.posZ + ") (link " + src.links.size() + ") to this teleporter"); } } } } held.stackTagCompound.removeTag("miscperipheralsLinkX"); held.stackTagCompound.removeTag("miscperipheralsLinkY"); held.stackTagCompound.removeTag("miscperipheralsLinkZ"); held.stackTagCompound.removeTag("miscperipheralsLinkDim"); if (held.stackTagCompound.hasKey("display")) { NBTTagCompound display = held.stackTagCompound.getCompoundTag("display"); display.removeTag("Lore"); if (display.getTags().isEmpty()) { held.stackTagCompound.removeTag("display"); } else { held.stackTagCompound.setTag("display", display); } } return true; } } if (held.stackTagCompound == null) held.stackTagCompound = new NBTTagCompound(); held.stackTagCompound.setInteger("miscperipheralsLinkX", xCoord); held.stackTagCompound.setInteger("miscperipheralsLinkY", yCoord); held.stackTagCompound.setInteger("miscperipheralsLinkZ", zCoord); held.stackTagCompound.setInteger("miscperipheralsLinkDim", worldObj.provider.dimensionId); NBTTagCompound display = new NBTTagCompound(); NBTTagList lore = new NBTTagList(); lore.appendTag(new NBTTagString("", "Turtle Teleporter Link")); lore.appendTag( new NBTTagString( "", worldObj.provider.dimensionId + ":(" + xCoord + "," + yCoord + "," + zCoord + ")")); display.setTag("Lore", lore); held.stackTagCompound.setTag("display", display); player.sendChatToPlayer("Link started"); return true; } return false; }