private void func_143027_a(World world) {
    if (this.itemData == null) {
      this.itemData = world.loadItemData(MapGenStructureData.class, this.getStructureName());

      if (this.itemData == null) {
        this.itemData = new MapGenStructureData(this.getStructureName());
        world.setItemData(this.getStructureName(), this.itemData);
      } else {
        NBTTagCompound var2 = this.itemData.getTag();

        for (String var4 : var2.getKeySet()) {
          NBTBase var5 = var2.getTag(var4);

          if (var5.getType() == 10) {
            NBTTagCompound var6 = (NBTTagCompound) var5;

            if (var6.hasKey("ChunkX") && var6.hasKey("ChunkZ")) {
              int x = var6.getInteger("ChunkX");
              int z = var6.getInteger("ChunkZ");
              StructureStart var9 = MapGenStructureIO.func_143035_a(var6);

              if (var9 != null) {
                this.structureMap.put(ChunkPos.toLong(x, z), var9);
              }
            }
          }
        }
      }
    }
  }
Beispiel #2
0
 public static void combineNBT(NBTTagCompound tag1, NBTTagCompound tag2) {
   if (tag2 == null || tag2.hasNoTags()) return;
   for (Object o : tag2.func_150296_c()) {
     String s = (String) o;
     NBTBase key = tag2.getTag(s);
     tag1.setTag(s, key.copy());
   }
 }
Beispiel #3
0
  void func_74735_a(DataInput p_74735_1_) throws IOException {
    this.field_74784_a.clear();

    NBTBase var2;
    while ((var2 = NBTBase.func_74739_b(p_74735_1_)).func_74732_a() != 0) {
      this.field_74784_a.put(var2.func_74740_e(), var2);
    }
  }
  public Entity func_98265_a(Entity p_98265_1_) {
    if (this.getRandomMinecart() != null) {
      NBTTagCompound var2 = new NBTTagCompound();
      p_98265_1_.writeToNBTOptional(var2);
      Iterator var3 = this.getRandomMinecart().field_98222_b.func_150296_c().iterator();

      while (var3.hasNext()) {
        String var4 = (String) var3.next();
        NBTBase var5 = this.getRandomMinecart().field_98222_b.getTag(var4);
        var2.setTag(var4, var5.copy());
      }

      p_98265_1_.readFromNBT(var2);

      if (p_98265_1_.worldObj != null) {
        p_98265_1_.worldObj.spawnEntityInWorld(p_98265_1_);
      }

      NBTTagCompound var11;

      for (Entity var10 = p_98265_1_; var2.func_150297_b("Riding", 10); var2 = var11) {
        var11 = var2.getCompoundTag("Riding");
        Entity var12 = EntityList.createEntityByName(var11.getString("id"), p_98265_1_.worldObj);

        if (var12 != null) {
          NBTTagCompound var6 = new NBTTagCompound();
          var12.writeToNBTOptional(var6);
          Iterator var7 = var11.func_150296_c().iterator();

          while (var7.hasNext()) {
            String var8 = (String) var7.next();
            NBTBase var9 = var11.getTag(var8);
            var6.setTag(var8, var9.copy());
          }

          var12.readFromNBT(var6);
          var12.setLocationAndAngles(
              var10.posX, var10.posY, var10.posZ, var10.rotationYaw, var10.rotationPitch);

          if (p_98265_1_.worldObj != null) {
            p_98265_1_.worldObj.spawnEntityInWorld(var12);
          }

          var10.mountEntity(var12);
        }

        var10 = var12;
      }
    } else if (p_98265_1_ instanceof EntityLivingBase && p_98265_1_.worldObj != null) {
      ((EntityLiving) p_98265_1_).onSpawnWithEgg((IEntityLivingData) null);
      this.getSpawnerWorld().spawnEntityInWorld(p_98265_1_);
    }

    return p_98265_1_;
  }
  /** 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;
  }
  private static void writeNBT(NBTTagCompound tag, File file) {
    try {
      // create file/folders if they don;t exist..
      if (!file.getParentFile().exists()) file.getParentFile().mkdirs();

      // make temp file
      File temp = new File(file.getPath() + "_tmp");
      if (temp.exists()) temp.delete();

      // write temp file
      DataOutputStream stream =
          new DataOutputStream(new GZIPOutputStream(new FileOutputStream(temp)));
      try {
        NBTBase.writeNamedTag(tag, stream);
      } finally {
        stream.close();
      }

      // change from temp to real
      if (file.exists()) {
        file.delete();
      }

      if (file.exists()) {
        throw new IOException("Failed to delete " + file);
      } else {
        temp.renameTo(file);
      }
    } catch (Exception e) {
      OutputHandler.SOP("Writing NBT to " + file + " failed");
    }
  }
  @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));
  }
Beispiel #8
0
 public ItemStack getOutput(ItemStack in, Random R) {
   ItemStack is = getOutput(R);
   if (is != null && this.keepNBT) {
     if (is.hasTagCompound()) {
       NBTTagCompound nbt = is.getTagCompound();
       for (Object o : in.getTagCompound().func_150296_c()) {
         NBTBase n = (NBTBase) o;
         if (nbt.hasKey(n.toString())) nbt.removeTag(n.toString());
         nbt.func_150296_c().add(o);
       }
     } else {
       is.setTagCompound(in.stackTagCompound);
       if (TFC_ItemHeat.HasTemp(is)) TFC_ItemHeat.SetTemp(is, TFC_ItemHeat.GetTemp(is) * 0.9f);
     }
   }
   return is;
 }
 private static void saveWorldCompound() {
   try {
     DataOutputStream dout = new DataOutputStream(new FileOutputStream(worldSaveFile));
     NBTBase.writeNamedTag(worldCompound, dout);
     dout.close();
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Beispiel #10
0
  void func_74734_a(DataOutput p_74734_1_) throws IOException {
    Iterator var2 = this.field_74784_a.values().iterator();

    while (var2.hasNext()) {
      NBTBase var3 = (NBTBase) var2.next();
      NBTBase.func_74731_a(var3, p_74734_1_);
    }

    p_74734_1_.writeByte(0);
  }
 // ICLIENTSTATE
 @Override
 public void writeData(DataOutputStream data) throws IOException {
   NBTTagCompound nbt = new NBTTagCompound();
   for (int i = 0; i < fluids.length; ++i) {
     NBTTagCompound nbttagcompound = new NBTTagCompound();
     if (fluids[i] != null) nbttagcompound.setString("FluidName", fluids[i].getName());
     nbt.setTag("fluidStack[" + i + "]", nbttagcompound);
   }
   NBTBase.writeNamedTag(nbt, data);
 }
 @Override
 public void readData(DataInputStream data) throws IOException {
   NBTBase nbt = NBTBase.readNamedTag(data);
   if (nbt instanceof NBTTagCompound) {
     for (int i = 0; i < fluids.length; ++i) {
       NBTTagCompound nbttagcompound =
           ((NBTTagCompound) nbt).getCompoundTag("fluidStack[" + i + "]");
       if (nbttagcompound != null)
         fluids[i] = FluidRegistry.getFluid(nbttagcompound.getString("FluidName"));
     }
   }
 }
Beispiel #13
0
  public static ArrayList<String> parseNBTAsLines(NBTTagCompound nbt) {
    ArrayList<String> li = new ArrayList();
    Iterator<NBTBase> it = nbt.func_150296_c().iterator();
    for (Object o : nbt.func_150296_c()) {
      String key = (String) o;
      NBTBase b = nbt.getTag(key); /*
			if (b instanceof NBTTagByteArray) {
				li.add(b.getName()+": "+Arrays.toString(((NBTTagByteArray)b).byteArray));
			}
			else if (b instanceof NBTTagIntArray) {
				li.add(b.getName()+": "+Arrays.toString(((NBTTagIntArray)b).intArray));
			}
			else if (b instanceof NBTTagCompound) {
				li.add(EnumChatFormatting.GOLD+b.getName()+": "+b.toString());
			}
			else {
				li.add(b.getName()+": "+b.toString());
			}*/
      li.add(key + ": " + b.toString());
    }
    return li;
  }
Beispiel #14
0
 private void checkValidInput() {
   boolean valid = true;
   kError = null;
   vError = null;
   if (canEditText && !validName()) {
     valid = false;
     kError = "Duplicate Tag Name";
   }
   try {
     validValue(value.getText(), nbt.getId());
     valid &= true;
   } catch (NumberFormatException e) {
     vError = e.getMessage();
     valid = false;
   }
   save.enabled = valid;
 }
  private static void loadSavedConfig(World world) {
    try {
      worldSaveDir = DimensionManager.getCurrentSaveRootDirectory();
      worldSaveFile = new File(worldSaveDir, "NEI.dat");
      if (!worldSaveFile.getParentFile().exists()) worldSaveFile.getParentFile().mkdirs();
      if (!worldSaveFile.exists()) worldSaveFile.createNewFile();

      if (worldSaveFile.length() == 0) worldCompound = new NBTTagCompound();
      else {
        DataInputStream din = new DataInputStream(new FileInputStream(worldSaveFile));
        worldCompound = (NBTTagCompound) NBTBase.readNamedTag(din);
        din.close();
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Beispiel #16
0
 private static String getValue(NBTBase base) {
   switch (base.getId()) {
     case 7:
       String s = "";
       for (byte b : ((NBTTagByteArray) base).getByteArray() /* byteArray */) {
         s += b + " ";
       }
       return s;
     case 9:
       return "TagList";
     case 10:
       return "TagCompound";
     case 11:
       String i = "";
       for (int a : ((NBTTagIntArray) base).getIntArray() /* intArray */) {
         i += a + " ";
       }
       return i;
     default:
       return NBTStringHelper.toString(base);
   }
 }
  @Override
  public void handle(DataInputStream iStream, EntityPlayer player) {
    try {
      int eID = iStream.readInt();
      NBTTagCompound nbt = (NBTTagCompound) NBTBase.readNamedTag(iStream);
      Map<String, Boolean> tgt = Maps.newHashMap();
      NBTTagList var1 = nbt.getTagList("targetsTag");

      for (int var2 = 0; var2 < var1.tagCount(); ++var2) {
        NBTTagCompound var3 = (NBTTagCompound) var1.tagAt(var2);
        tgt.put(var3.getString("tgName"), var3.getBoolean("isEnabled"));
      }

      GuiScreen gui = Minecraft.getMinecraft().currentScreen;
      if (gui != null && gui instanceof GuiTCUBase) {
        ((GuiTCUBase) gui).turret =
            (EntityTurret_Base) Minecraft.getMinecraft().theWorld.getEntityByID(eID);
        ((GuiTCUBase) gui).turret.targets = tgt;
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Beispiel #18
0
 private boolean match(NBTBase old, NBTBase cur) {
   if (old == cur) return true;
   if (old == null || cur == null) return false;
   return cur.equals(old);
 }
Beispiel #19
0
 public void func_74782_a(String p_74782_1_, NBTBase p_74782_2_) {
   this.field_74784_a.put(p_74782_1_, p_74782_2_.func_74738_o(p_74782_1_));
 }
 public static Data<?> create(final NBTBase nbt) throws Exception {
   throw new DataException("Could not create Data from " + nbt.getClass().getSimpleName(), null);
 }