Esempio n. 1
0
 protected NBTTagCompound serialize() {
   NBTTagCompound tag = new NBTTagCompound();
   tag.setString("name", name);
   tag.setString("deserializer", getDeserializerID());
   tag.setString("defaultState", defaultState.name());
   return tag;
 }
Esempio n. 2
0
  @Override
  public void processCommand(ICommandSender sender, String[] par2ArrayOfStr) {
    EntityPlayer player = getCommandSenderAsPlayer(sender);
    EntityPlayerMP other = func_82359_c(sender, par2ArrayOfStr[0]);

    if (par2ArrayOfStr.length != 1) {
      player.addChatMessage(getCommandUsage(sender));
      return;
    }

    NBTTagCompound playerdata =
        NecessitiesMain.instance.necessities_data.getCompoundTag(other.username);
    NecessitiesMain.instance.necessities_data.setCompoundTag(other.username, playerdata);
    NBTTagCompound tpa = playerdata.getCompoundTag("[Tpa]");
    playerdata.setCompoundTag("[Tpa]", tpa);

    if (tpa.hasKey("DenyAll")) {
      player.addChatMessage("Player " + other.username + " has blocked all teleport requests.");
      return;
    }
    tpa.setString("Command", "TPA");
    tpa.setString("Who", player.username);
    player.addChatMessage("Sending teleport request to player " + other.username);
    other.addChatMessage(
        player.username
            + " has requested to teleport to you.  Use /tpaccept to accept or /tpreject to refuse.");
  }
 @Override
 public void onContainerClosed(EntityPlayer par1EntityPlayer) {
   super.onContainerClosed(par1EntityPlayer);
   if (par1EntityPlayer.worldObj.isRemote) {
     NBTTagCompound tag = new NBTTagCompound();
     tag.setString("EntityId", mobID);
     tag.setShort("MinSpawnDelay", (short) minSpawnDelay);
     tag.setShort("MaxSpawnDelay", (short) maxSpawnDelay);
     tag.setShort("SpawnCount", (short) spawnCount);
     tag.setShort("MaxNearbyEntities", (short) maxNearbyEntities);
     tag.setShort("RequiredPlayerRange", (short) activatingRangeFromPlayer);
     tag.setShort("SpawnRange", (short) spawnRange);
     sendDataToServer(tag);
     return;
   }
   ItemStack builderItem = player.inventory.getCurrentItem();
   if (builderItem == null
       || builderItem.getItem() == null
       || builderItem.getItem() != AWStructuresItemLoader.spawnerPlacer) {
     return;
   }
   if (!builderItem.hasTagCompound() || !builderItem.getTagCompound().hasKey("spawnData")) {
     builderItem.setTagInfo("spawnData", new NBTTagCompound());
   }
   NBTTagCompound tag = new NBTTagCompound();
   tag.setString("EntityId", mobID);
   tag.setShort("MinSpawnDelay", (short) minSpawnDelay);
   tag.setShort("MaxSpawnDelay", (short) maxSpawnDelay);
   tag.setShort("SpawnCount", (short) spawnCount);
   tag.setShort("MaxNearbyEntities", (short) maxNearbyEntities);
   tag.setShort("RequiredPlayerRange", (short) activatingRangeFromPlayer);
   tag.setShort("SpawnRange", (short) spawnRange);
   builderItem.getTagCompound().setTag("spawnData", tag);
 }
  static {
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setString("author", "Guess Who? :3");
    nbt.setString("title", "NotOnlyMoreOres");

    NBTTagList pages = new NBTTagList();
    pages.appendTag(
        new NBTTagString(
            "1",
            "Hey there handsome! ;) How are you doing today? "
                + "I see that you chose to play with this \u00a7nawesome\u00a7r mod that you found, \u00a7oSkorpio's NotOnlyMoreOres Mod\u00a7r! Just wanted to tell you some wise stuff about it! "
                + "Flip to the next page please! :)"));
    pages.appendTag(
        new NBTTagString(
            "2",
            "First of all, if you're just a normal player, I want you to have fun. Understood? Alright. "
                + "Are you a youtuber who's going to review this mod? Alright listen up man. You \u00a7lNEED TO READ THE THREAD FULLY \u00a70alright? ;) Thanks! :3 Flip again! :)"));
    pages.appendTag(
        new NBTTagString(
            "3",
            "And if you have any suggestions, PLEASE visit the thread for the mod and give the author a little help! :) "
                + "Now go, have fun! :D I'll talk to you later! <3"
                + "                               P.S. you seem to like flipping, so why don't you do it one more time? :3"));
    pages.appendTag(
        new NBTTagString(
            "4",
            "\u00a7bT\u00a71R\u00a72O\u00a73L\u00a74O\u00a75L\u00a76O\u00a77L\u00a78O\u00a7aL \u00a70nothing here! GOTCHA! x) \u00a7kSkorpio"));

    nbt.setTag("pages", pages);
    reading = new ItemStack(Item.writtenBook);
    reading.setTagCompound(nbt);
  }
Esempio n. 5
0
 @Override
 public void writeEntityToNBT(NBTTagCompound nbt) {
   super.writeEntityToNBT(nbt);
   nbt.setString("Name", getName());
   nbt.setString("Model", dataWatcher.getWatchableObjectString(4));
   if (npcLocation == null) npcLocation = SpawnLocation.Land;
   nbt.setInteger("trainerLocation", npcLocation.index);
 }
Esempio n. 6
0
 public static void setPlayerForTracker(ItemStack stack, EntityPlayer player) {
   NBTTagCompound stackTag =
       stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
   UUID id = player.getGameProfile().getId();
   TEC.idToUsername.put(id, player.getCommandSenderName());
   stackTag.setString("playerUUID", id.toString());
   stackTag.setString("playerName", player.getCommandSenderName());
   stack.setTagCompound(stackTag);
 }
  /** Writes a tile entity to NBT. */
  public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
    super.writeToNBT(par1NBTTagCompound);
    if (this.owner != null && this.owner != "") {
      par1NBTTagCompound.setString("owner", this.owner);
    }

    if (this.ownerUUID != null && this.ownerUUID != "") {
      par1NBTTagCompound.setString("ownerUUID", this.ownerUUID);
    }
  }
Esempio n. 8
0
  @Override
  public ItemStack getStack() {
    ItemStack stack = new ItemStack(BuildCraftBuilders.templateItem, 1);
    NBTTagCompound nbt = NBTUtils.getItemData(stack);
    id.write(nbt);
    nbt.setString("author", author);
    nbt.setString("name", id.name);

    return stack;
  }
Esempio n. 9
0
 public NBTTagCompound createDefault() {
   NBTTagCompound nbt = new NBTTagCompound("tag");
   nbt.setInteger("material", 0);
   nbt.setString("name", "Blank Artifact");
   nbt.setString("icon", "Artifact");
   int col = Color.HSBtoRGB((float) (rand.nextInt(360) / 360F), .8f, 1);
   nbt.setLong("overlay_color", col);
   nbt.setIntArray("allComponents", new int[] {0, 0, 0, 0, 0});
   return nbt;
 }
Esempio n. 10
0
  /** (abstract) Protected helper method to write subclass entity data to NBT. */
  public void writeEntityToNBT(NBTTagCompound tagCompound) {
    super.writeEntityToNBT(tagCompound);
    tagCompound.setShort("Anger", (short) this.angerLevel);

    if (this.angerTargetUUID != null) {
      tagCompound.setString("HurtBy", this.angerTargetUUID.toString());
    } else {
      tagCompound.setString("HurtBy", "");
    }
  }
Esempio n. 11
0
 public static void registerTransparentBlock(Block block, float transparency, int meta) {
   if (block != null) {
     NBTTagCompound tag = new NBTTagCompound();
     ResourceLocation b1 = block.delegate.name();
     tag.setString("blockName", b1.getResourcePath());
     tag.setString("modid", b1.getResourceDomain());
     tag.setFloat("t", transparency);
     tag.setInteger("m", meta);
     TomsModRecipeHelper.sendMessage(tag, "glass", 2);
   }
 }
Esempio n. 12
0
 public static void setPagesToNBT(ItemStack stack, List<Text> pages) {
   final NBTTagList list = SpongeTexts.asLegacy(pages);
   final NBTTagCompound compound = getOrCreateCompound(stack);
   compound.setTag(ITEM_BOOK_PAGES, list);
   if (!compound.hasKey(ITEM_BOOK_TITLE)) {
     compound.setString(ITEM_BOOK_TITLE, INVALID_TITLE);
   }
   if (!compound.hasKey(ITEM_BOOK_AUTHOR)) {
     compound.setString(ITEM_BOOK_AUTHOR, INVALID_TITLE);
   }
   compound.setBoolean(ITEM_BOOK_RESOLVED, true);
 }
Esempio n. 13
0
  public static void findCompoundAndWrite() {
    NBTTagCompound cmp = new NBTTagCompound();

    cmp.setBoolean("useGradients", useGradients);
    cmp.setBoolean("contrastHudText", contrastHudText);
    cmp.setBoolean("useVanillaFont", useVanillaFont);
    cmp.setBoolean("drawHud", drawHud);
    cmp.setInteger("hudRelativeTo", hudRelativeTo);
    cmp.setInteger("hudPosX", hudPosX);
    cmp.setInteger("hudPosY", hudPosY);
    cmp.setString("hudCategory", hudCategory);
    cmp.setString("hudPlayer", hudPlayer);

    injectNBTToFile(cmp);
  }
Esempio n. 14
0
  public static void register() {

    if (Loader.isModLoaded("VersionChecker")) {
      final NBTTagCompound nbt = new NBTTagCompound();
      nbt.setString("curseProjectName", CURSE_PROJECT_NAME);
      nbt.setString("curseFilenameParser", MOD_NAME_TEMPLATE);
      FMLInterModComms.sendRuntimeMessage(Module.MOD_ID, "VersionChecker", "addVersionCheck", nbt);
    }

    if (ModOptions.getOnlineVersionChecking()) {
      final VersionCheck test = new VersionCheck();
      MinecraftForge.EVENT_BUS.register(test);
      new Thread(test).start();
    }
  }
  @Override
  public void writeToNBT(NBTTagCompound nbtTagCompound) {
    super.writeToNBT(nbtTagCompound);

    nbtTagCompound.setByte(Names.NBT.DIRECTION, (byte) orientation.ordinal());
    nbtTagCompound.setByte(Names.NBT.STATE, state);

    if (this.hasCustomName()) {
      nbtTagCompound.setString(Names.NBT.CUSTOM_NAME, customName);
    }

    if (this.hasOwner()) {
      nbtTagCompound.setString(Names.NBT.OWNER, owner);
    }
  }
Esempio n. 16
0
  private NBTTagCompound complementNBT(
      NBTTagCompound parent, NBTTagCompound inner, MachineDefinition definition) {

    inner.setString("id", definition.teIdent);
    inner.setInteger("x", this.xCoord);
    inner.setInteger("y", this.yCoord);
    inner.setInteger("z", this.zCoord);

    inner.setInteger("Access", parent.getInteger("Access"));
    if (parent.hasKey("Owner")) inner.setString("Owner", parent.getString("Owner"));
    if (parent.hasKey("Orientation"))
      inner.setInteger("Orientation", parent.getInteger("Orientation"));

    return inner;
  }
  public static void getBookFromFileUnformatted(EntityPlayer player, File file, String title) {
    NBTTagCompound tag = new NBTTagCompound();
    NBTTagList pages = new NBTTagList();

    HashMap<String, String> map = new HashMap<String, String>();
    if (file.isFile()) {
      if (file.getName().contains(".txt")) {
        List<String> lines = new ArrayList<String>();
        try {
          FileInputStream stream = new FileInputStream(file);
          InputStreamReader streamReader = new InputStreamReader(stream);
          BufferedReader reader = new BufferedReader(streamReader);
          String line = reader.readLine();
          while (line != null) {
            lines.add(line);
            line = reader.readLine();
          }
          reader.close();
          streamReader.close();
          stream.close();

        } catch (Exception e) {
          OutputHandler.felog.warning("Error reading book: " + file.getName());
        }
        while (lines.size() != 0) {
          String temp = "";
          for (int i = 0; i < 10 && lines.size() > 0; i++) {
            temp += lines.get(0) + "\n";
            lines.remove(0);
          }
          map.put("", temp);
        }
      }
    }

    SortedSet<String> keys = new TreeSet<String>(map.keySet());
    for (String name : keys) {
      pages.appendTag(new NBTTagString("", name + map.get(name)));
    }

    tag.setString("author", "ForgeEssentials");
    tag.setString("title", title);
    tag.setTag("pages", pages);

    ItemStack is = new ItemStack(Item.writtenBook);
    is.setTagCompound(tag);
    player.inventory.addItemStackToInventory(is);
  }
Esempio n. 18
0
  public void writeToNBT(NBTTagCompound p_98280_1_) {
    p_98280_1_.setString("EntityId", this.getEntityNameToSpawn());
    p_98280_1_.setShort("Delay", (short) this.spawnDelay);
    p_98280_1_.setShort("MinSpawnDelay", (short) this.minSpawnDelay);
    p_98280_1_.setShort("MaxSpawnDelay", (short) this.maxSpawnDelay);
    p_98280_1_.setShort("SpawnCount", (short) this.spawnCount);
    p_98280_1_.setShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
    p_98280_1_.setShort("RequiredPlayerRange", (short) this.activatingRangeFromPlayer);
    p_98280_1_.setShort("SpawnRange", (short) this.spawnRange);

    if (this.getRandomMinecart() != null) {
      p_98280_1_.setTag("SpawnData", this.getRandomMinecart().field_98222_b.copy());
    }

    if (this.getRandomMinecart() != null
        || this.minecartToSpawn != null && this.minecartToSpawn.size() > 0) {
      NBTTagList var2 = new NBTTagList();

      if (this.minecartToSpawn != null && this.minecartToSpawn.size() > 0) {
        Iterator var3 = this.minecartToSpawn.iterator();

        while (var3.hasNext()) {
          MobSpawnerBaseLogic.WeightedRandomMinecart var4 =
              (MobSpawnerBaseLogic.WeightedRandomMinecart) var3.next();
          var2.appendTag(var4.func_98220_a());
        }
      } else {
        var2.appendTag(this.getRandomMinecart().func_98220_a());
      }

      p_98280_1_.setTag("SpawnPotentials", var2);
    }
  }
 public ItemStack getItemStackWithData(World world, int x, int y, int z) {
   ItemStack stack = new ItemStack(world.getBlock(x, y, z), 1, 0);
   TileEntity tentity = world.getTileEntity(x, y, z);
   if (tentity instanceof TileVendorBlock) {
     TileVendorBlock te = (TileVendorBlock) tentity;
     NBTTagList itemList = new NBTTagList();
     NBTTagCompound tagCompound = new NBTTagCompound();
     for (int i = 0; i < te.getSizeInventory(); i++) {
       ItemStack invStack = te.getStackInSlot(i);
       if (invStack != null) {
         NBTTagCompound tag = new NBTTagCompound();
         tag.setByte("Slot", (byte) i);
         invStack.writeToNBT(tag);
         itemList.appendTag(tag);
       }
     }
     tagCompound.setTag("Inventory", itemList);
     tagCompound.setInteger("CoinSum", te.coinSum);
     tagCompound.setInteger("UserCoinSum", te.userCoinSum);
     tagCompound.setInteger("ItemPrice", te.itemPrice);
     tagCompound.setString("BlockOwner", te.blockOwner);
     tagCompound.setBoolean("Infinite", te.infiniteMode);
     stack.setTagCompound(tagCompound);
     return stack;
   } else return stack;
 }
Esempio n. 20
0
 public NBTTagCompound func_98220_a() {
   NBTTagCompound var1 = new NBTTagCompound();
   var1.setTag("Properties", this.field_98222_b);
   var1.setString("Type", this.minecartName);
   var1.setInteger("Weight", this.itemWeight);
   return var1;
 }
Esempio n. 21
0
  /** (abstract) Protected helper method to write subclass entity data to NBT. */
  protected void writeEntityToNBT(NBTTagCompound tagCompound) {
    if (this.hasDisplayTile()) {
      tagCompound.setBoolean("CustomDisplayTile", true);
      IBlockState iblockstate = this.getDisplayTile();
      ResourceLocation resourcelocation =
          (ResourceLocation) Block.blockRegistry.getNameForObject(iblockstate.getBlock());
      tagCompound.setString(
          "DisplayTile", resourcelocation == null ? "" : resourcelocation.toString());
      tagCompound.setInteger("DisplayData", iblockstate.getBlock().getMetaFromState(iblockstate));
      tagCompound.setInteger("DisplayOffset", this.getDisplayTileOffset());
    }

    if (this.entityName != null && this.entityName.length() > 0) {
      tagCompound.setString("CustomName", this.entityName);
    }
  }
Esempio n. 22
0
  @Override
  public void write(NBTTagCompound nbtTags) {
    super.write(nbtTags);

    nbtTags.setInteger("type", 1);
    nbtTags.setString("oreDictName", oreDictName);
  }
Esempio n. 23
0
  public static FMLProxyPacket createPacketForTEntCommand(TileEntity tEnt, NBTTagCompound data) {
    /*ByteArrayOutputStream bos = new ByteArrayOutputStream(); //was ...(140);
    DataOutputStream dos = new DataOutputStream(bos);*/

    ByteBuf byteBuf = Unpooled.buffer();
    NBTTagCompound nbtSendData = new NBTTagCompound();

    try {
      nbtSendData.setString("command", "CoroAI_TEntCmd");
      nbtSendData.setInteger("dimID", tEnt.getWorldObj().provider.dimensionId);
      nbtSendData.setInteger("x", tEnt.xCoord);
      nbtSendData.setInteger("y", tEnt.yCoord);
      nbtSendData.setInteger("z", tEnt.zCoord);
      nbtSendData.setTag("data", data);
      // ByteBufUtils.writeUTF8String(byteBuf, "CoroAI_TEntCmd");
      /*byteBuf.writeInt(tEnt.getWorldObj().provider.dimensionId);
      byteBuf.writeInt(tEnt.xCoord);
      byteBuf.writeInt(tEnt.yCoord);
      byteBuf.writeInt(tEnt.zCoord);*/
      ByteBufUtils.writeTag(byteBuf, nbtSendData);
      // writeNBTTagCompound(data, dos);

    } catch (Exception ex) {
      ex.printStackTrace();
    }

    /*Packet250CustomPayload pkt = new Packet250CustomPayload();
    pkt.channel = "CoroAI_TEntCmd";
    pkt.data = bos.toByteArray();
    pkt.length = bos.size();*/

    return new FMLProxyPacket(byteBuf, CoroAI.eventChannelName);
  }
  @Override
  public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    super.writeToNBT(compound);

    if (this instanceof IStructurePart) {
      if (((IStructurePart) this).getStructure() != null) {
        compound.setInteger(
            CoreReferences.NBT.StructureData.DIMENSION, getWorld().provider.getDimension());
        compound.setTag(
            CoreReferences.NBT.STRUCTURE,
            ((IStructurePart) this).getStructure().getMasterLocation().toCompound());
      }
    }

    if (getState().requiresNBTStorage())
      compound.setTag(CoreReferences.NBT.STATE, this.getState().writeToNBTTagCompound());

    if (this instanceof IItemStorage)
      compound.setTag(CoreReferences.NBT.INVENTORY, this.writeInventoryToCompound());

    if (this instanceof IFluidContainingEntity)
      compound.setTag(CoreReferences.NBT.FLUIDS, this.writeFluidsToCompound());

    if (this.hasCustomName()) {
      compound.setString(CoreReferences.NBT.NAME, name);
    }

    return compound;
  }
 @Override
 public void addInformation(
     ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
   if (par1ItemStack.getTagCompound() == null) {
     par1ItemStack.setTagCompound(new NBTTagCompound());
   }
   NBTTagCompound tag = par1ItemStack.getTagCompound();
   if (tag.getString("Creator") == "") {
     tag.setString("Creator", par2EntityPlayer.username);
   }
   this.currentCharge = tag.getInteger("CurrentCharge");
   tag.setInteger("MaxStorage", this.maxStorage);
   this.maxStorage = tag.getInteger("MaxStorage");
   tag.setInteger("RechargeRate", this.rechargeRatePerTick);
   this.rechargeRatePerTick = tag.getInteger("RechargeRate");
   dimensionTravel = tag.getInteger("Dimension");
   x = tag.getInteger("posX");
   y = tag.getInteger("posY");
   z = tag.getInteger("posZ");
   if (x != null && y != null && z != null) {
     par3List.add("X: " + x.toString());
     par3List.add("Y: " + y.toString());
     par3List.add("Z: " + z.toString());
     par3List.add("Dimension: " + dimensionTravel);
     par3List.add(this.currentCharge + "/" + this.maxStorage + " MyJ");
     par3List.add("Creator: " + tag.getString("Creator"));
   }
 }
 @Override
 public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) {
   NBTTagCompound fmlData = new NBTTagCompound();
   NBTTagList list = new NBTTagList();
   for (ModContainer mc : Loader.instance().getActiveModList()) {
     NBTTagCompound mod = new NBTTagCompound();
     mod.setString("ModId", mc.getModId());
     mod.setString("ModVersion", mc.getVersion());
     list.appendTag(mod);
   }
   fmlData.setTag("ModList", list);
   NBTTagList itemList = new NBTTagList();
   GameData.writeItemData(itemList);
   fmlData.setTag("ModItemData", itemList);
   return fmlData;
 }
  /** Synchronizes the data tag to the partition list. */
  private void writePartitionList() {
    // Is the cell partitioned?
    if (!this.isPartitioned()) {
      // Remove the partition tag
      this.cellData.removeTag(HandlerItemEssentiaCell.NBT_PARTITION_KEY);
    } else {
      // Create the partition data
      NBTTagCompound partitionData = new NBTTagCompound();

      // Write the partition list
      int count = 0;
      for (Aspect pAspect : this.partitionAspects) {
        // Write the aspect tag
        partitionData.setString(
            HandlerItemEssentiaCell.NBT_PARTITION_NUMBER_KEY + count, pAspect.getTag());

        // Increment the count
        count++;
      }

      // Write the count
      partitionData.setInteger(HandlerItemEssentiaCell.NBT_PARTITION_COUNT_KEY, count);

      // Write the partition data
      this.cellData.setTag(HandlerItemEssentiaCell.NBT_PARTITION_KEY, partitionData);
    }

    // Inform the save provider
    if (this.saveProvider != null) {
      this.saveProvider.saveChanges(this);
    }
  }
 public NBTTagCompound func_92030_a() {
   NBTTagCompound var1 = new NBTTagCompound();
   var1.setCompoundTag("Properties", this.field_92032_b);
   var1.setString("Type", this.field_92033_c);
   var1.setInteger("Weight", this.itemWeight);
   return var1;
 }
Esempio n. 29
0
 @Override
 public NBTTagCompound writeToNBT(NBTTagCompound tag) {
   super.writeToNBT(tag);
   if (inventory.size() > 0) {
     NBTTagList list = new NBTTagList();
     for (int i = 0; i < inventory.size(); i++) {;
       if (inventory.get(i) != null) {
         list.appendTag(inventory.get(i).writeToNBT(new NBTTagCompound()));
       }
     }
     tag.setTag("inventory", list);
   }
   if (incenses.size() > 0) {
     NBTTagList list = new NBTTagList();
     for (int i = 0; i < incenses.size(); i++) {;
       if (incenses.get(i) != null) {
         list.appendTag(incenses.get(i).writeToNBT(new NBTTagCompound()));
       }
     }
     tag.setTag("incenses", list);
   }
   if (ritualName != null) {
     tag.setString("ritualName", ritualName);
   }
   tag.setInteger("progress", progress);
   return tag;
 }
 @Override
 public void writeEntityToNBT(NBTTagCompound tag) {
   tag.setCompoundTag("ammoSource", _ammoSource.writeToNBT(new NBTTagCompound()));
   tag.setDouble("distance", distance);
   tag.setBoolean("falling", _falling);
   if (_owner != null) tag.setString("owner", _owner);
 }