當前位置: 首頁>>代碼示例>>Java>>正文


Java NBTTagString類代碼示例

本文整理匯總了Java中net.minecraft.nbt.NBTTagString的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagString類的具體用法?Java NBTTagString怎麽用?Java NBTTagString使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NBTTagString類屬於net.minecraft.nbt包,在下文中一共展示了NBTTagString類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadBook

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
private static ItemStack loadBook(String name) throws IOException {
  ItemStack book = new ItemStack(Items.WRITTEN_BOOK);
  String line;
  int lineNumber = 1;
  StringBuilder page = newPage();
  try (BufferedReader reader = openBookReader(name)) {
    while ((line = reader.readLine()) != null) {
      if (lineNumber == 1) {
        book.setTagInfo("title", new NBTTagString(line));
      } else if (lineNumber == 2) {
        book.setTagInfo("author", new NBTTagString(line));
      } else if (PAGE_DELIMITER.equals(line)) {
        writePage(book, page);
        page = newPage();
      } else {
        page.append(line).append("\n");
      }
      lineNumber++;
    }
  }
  writePage(book, page);
  return book;
}
 
開發者ID:ToroCraft,項目名稱:Minecoprocessors,代碼行數:24,代碼來源:BookCreator.java

示例2: writeToNBT

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
/**
 * Store the data to the specified NBT tag.
 *
 * @param nbt the tag to save the data to.
 */
public void writeToNBT(final NBTTagCompound nbt) {
  final NBTTagList pagesNbt = new NBTTagList();
  int removed = 0;
  for (int index = 0; index < pages.size(); index++) {
    final List<String> program = pages.get(index);
    if (program.size() > 1 || program.get(0).length() > 0) {
      pagesNbt.appendTag(new NBTTagString(String.join("\n", program)));
    } else if (index < selectedPage) {
      removed++;
    }
  }
  nbt.setTag(TAG_PAGES, pagesNbt);

  nbt.setInteger(TAG_SELECTED, selectedPage - removed);
}
 
開發者ID:ToroCraft,項目名稱:Minecoprocessors,代碼行數:21,代碼來源:ItemBookCode.java

示例3: playerJoin

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
@SubscribeEvent
public void playerJoin(PlayerEvent.PlayerLoggedInEvent event) {
    ItemStack guideBookStack = new ItemStack(Items.WRITTEN_BOOK, 1);
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setString("title", new TextComponentTranslation("book.title.guide").getFormattedText());
    nbt.setString("author", new TextComponentTranslation("book.author.guide").getFormattedText());
    nbt.setInteger("generation", 2);
    NBTTagList nbtList = new NBTTagList();
    for (int index = 0; index <= 15; index++)
        nbtList.appendTag(new NBTTagString(String.format("{\"text\": \"%s\"}", new TextComponentTranslation(String.format("book.pages.guide.%d", index)).getFormattedText())));
    nbt.setTag("pages", nbtList);
    guideBookStack.setTagCompound(nbt);
    if (!event.player.getEntityData().getBoolean("genera.joined_before")) {
        event.player.getEntityData().setBoolean("genera.joined_before", true);
        event.player.getEntityData().setInteger("genera.sacrifices_made", 0);
        event.player.addItemStackToInventory(guideBookStack);
    }
}
 
開發者ID:BenjaminSutter,項目名稱:genera,代碼行數:19,代碼來源:EventHandler.java

示例4: readDataNBT

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
@Override
protected void readDataNBT(NBTTagCompound tag) {
	cooldown = tag.getInteger("cooldown");
	if (tag.hasKey("ritual"))
		ritual = Ritual.REGISTRY.getValue(new ResourceLocation(tag.getString("ritual")));
	if (tag.hasKey("player"))
		entityPlayer = UUID.fromString(tag.getString("player"));
	if (tag.hasKey("data"))
		ritualData = tag.getCompoundTag("data");
	if (tag.hasKey("entityList")) {
		entityList = new ArrayList<Tuple<String, String>>();
		tag.getTagList("entityList", NBT.TAG_STRING).forEach(nbts -> {
			String[] names = ((NBTTagString) nbts).getString().split("!");
			if (names.length == 2)
				entityList.add(new Tuple<String, String>(names[0], names[1]));
		});
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:19,代碼來源:TileEntityGlyph.java

示例5: writeDataNBT

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
@Override
protected void writeDataNBT(NBTTagCompound tag) {
	tag.setInteger("cooldown", cooldown);
	if (ritual != null)
		tag.setString("ritual", ritual.getRegistryName().toString());
	if (entityPlayer != null)
		tag.setString("player", entityPlayer.toString());
	if (ritualData != null)
		tag.setTag("data", ritualData);
	NBTTagList list = new NBTTagList();
	for (int i = 0; i < entityList.size(); i++) {
		Tuple<String, String> t = entityList.get(i);
		list.appendTag(new NBTTagString(t.getFirst() + "!" + t.getSecond()));
	}
	tag.setTag("entityList", list);
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:17,代碼來源:TileEntityGlyph.java

示例6: getActionsSaveData

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
private NBTTagList getActionsSaveData()
{
	NBTTagList actionList = new NBTTagList();
	for (Map.Entry<Integer, Set<String>> entry : actionPoints.entrySet())
	{
		int time = entry.getKey();
		NBTTagList nameList = new NBTTagList();
		for (String name : entry.getValue())
		{
			nameList.appendTag(new NBTTagString(name));
		}

		NBTTagCompound timeCompound = new NBTTagCompound();
		timeCompound.setInteger("Time", time);
		timeCompound.setTag("Names", nameList);

		actionList.appendTag(timeCompound);
	}
	return actionList;
}
 
開發者ID:ObsidianSuite,項目名稱:ObsidianSuite,代碼行數:21,代碼來源:AnimationSequence.java

示例7: sendBook

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
private void sendBook(ItemStack stack) {
    NBTTagList pages = new NBTTagList(); // page tag list

    // copy pages into NBT
    for(int i = 0; i < MAX_PAGES && parser.hasNext(); i++) {
        pages.appendTag(new NBTTagString(parser.next().trim()));
        page++;
    }

    // set our client side book
    if(stack.hasTagCompound())
        stack.getTagCompound().setTag("pages", pages);
    else
        stack.setTagInfo("pages", pages);

    // publish the book
    stack.setTagInfo("author", new NBTTagString(getLocalPlayer().getName()));
    stack.setTagInfo("title", new NBTTagString(parent.name.get().replaceAll(NUMBER_TOKEN, "" + getBook()).trim()));

    PacketBuffer buff = new PacketBuffer(Unpooled.buffer());
    buff.writeItemStack(stack);
    MC.getConnection().sendPacket(new CPacketCustomPayload("MC|BSign", buff));
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:24,代碼來源:BookBot.java

示例8: func_181036_a

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
private ItemStack func_181036_a(Item p_181036_1_, int p_181036_2_, TileEntity p_181036_3_)
{
    ItemStack itemstack = new ItemStack(p_181036_1_, 1, p_181036_2_);
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    p_181036_3_.writeToNBT(nbttagcompound);

    if (p_181036_1_ == Items.skull && nbttagcompound.hasKey("Owner"))
    {
        NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
        NBTTagCompound nbttagcompound3 = new NBTTagCompound();
        nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
        itemstack.setTagCompound(nbttagcompound3);
        return itemstack;
    }
    else
    {
        itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        NBTTagList nbttaglist = new NBTTagList();
        nbttaglist.appendTag(new NBTTagString("(+NBT)"));
        nbttagcompound1.setTag("Lore", nbttaglist);
        itemstack.setTagInfo("display", nbttagcompound1);
        return itemstack;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:26,代碼來源:Minecraft.java

示例9: call

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
@Override
public void call(String[] args) throws CmdException
{
	if(args.length == 0)
		throw new CmdSyntaxError();
	if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
		throw new CmdError("Creative mode only.");
	ItemStack item = WMinecraft.getPlayer().inventory.getCurrentItem();
	if(item == null || Item.getIdFromItem(item.getItem()) != 387)
		throw new CmdError(
			"You are not holding a written book in your hand.");
	String author = args[0];
	for(int i = 1; i < args.length; i++)
		author += " " + args[i];
	item.setTagInfo("author", new NBTTagString(author));
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:17,代碼來源:AuthorCmd.java

示例10: func_181036_a

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
private ItemStack func_181036_a(Item p_181036_1_, int p_181036_2_, TileEntity p_181036_3_) {
	ItemStack itemstack = new ItemStack(p_181036_1_, 1, p_181036_2_);
	NBTTagCompound nbttagcompound = new NBTTagCompound();
	p_181036_3_.writeToNBT(nbttagcompound);

	if (p_181036_1_ == Items.skull && nbttagcompound.hasKey("Owner")) {
		NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
		NBTTagCompound nbttagcompound3 = new NBTTagCompound();
		nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
		itemstack.setTagCompound(nbttagcompound3);
		return itemstack;
	} else {
		itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
		NBTTagCompound nbttagcompound1 = new NBTTagCompound();
		NBTTagList nbttaglist = new NBTTagList();
		nbttaglist.appendTag(new NBTTagString("(+NBT)"));
		nbttagcompound1.setTag("Lore", nbttaglist);
		itemstack.setTagInfo("display", nbttagcompound1);
		return itemstack;
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:Minecraft.java

示例11: storeTEInStack

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
private ItemStack storeTEInStack(ItemStack stack, TileEntity te)
{
    NBTTagCompound nbttagcompound = te.writeToNBT(new NBTTagCompound());

    if (stack.getItem() == Items.SKULL && nbttagcompound.hasKey("Owner"))
    {
        NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
        NBTTagCompound nbttagcompound3 = new NBTTagCompound();
        nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
        stack.setTagCompound(nbttagcompound3);
        return stack;
    }
    else
    {
        stack.setTagInfo("BlockEntityTag", nbttagcompound);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        NBTTagList nbttaglist = new NBTTagList();
        nbttaglist.appendTag(new NBTTagString("(+NBT)"));
        nbttagcompound1.setTag("Lore", nbttaglist);
        stack.setTagInfo("display", nbttagcompound1);
        return stack;
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:24,代碼來源:Minecraft.java

示例12: GuiScreenBook

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
public GuiScreenBook(EntityPlayer player, ItemStack book, boolean isUnsigned)
{
    this.editingPlayer = player;
    this.bookObj = book;
    this.bookIsUnsigned = isUnsigned;

    if (book.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = book.getTagCompound();
        this.bookPages = nbttagcompound.getTagList("pages", 8).copy();
        this.bookTotalPages = this.bookPages.tagCount();

        if (this.bookTotalPages < 1)
        {
            this.bookTotalPages = 1;
        }
    }

    if (this.bookPages == null && isUnsigned)
    {
        this.bookPages = new NBTTagList();
        this.bookPages.appendTag(new NBTTagString(""));
        this.bookTotalPages = 1;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:26,代碼來源:GuiScreenBook.java

示例13: storeTEInStack

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
public ItemStack storeTEInStack(ItemStack stack, TileEntity te)
{
    NBTTagCompound nbttagcompound = te.writeToNBT(new NBTTagCompound());

    if (stack.getItem() == Items.SKULL && nbttagcompound.hasKey("Owner"))
    {
        NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
        NBTTagCompound nbttagcompound3 = new NBTTagCompound();
        nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
        stack.setTagCompound(nbttagcompound3);
        return stack;
    }
    else
    {
        stack.setTagInfo("BlockEntityTag", nbttagcompound);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        NBTTagList nbttaglist = new NBTTagList();
        nbttaglist.appendTag(new NBTTagString("(+NBT)"));
        nbttagcompound1.setTag("Lore", nbttaglist);
        stack.setTagInfo("display", nbttagcompound1);
        return stack;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:24,代碼來源:Minecraft.java

示例14: addLore

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
public static ItemStack addLore(final ItemStack a, final String... lore) {
    NBTTagCompound tag = a.getTagCompound();
    if (tag == null) {
        tag = new NBTTagCompound();
    }
    if (!tag.hasKey("display", 10)) {
        tag.setTag("display", (NBTBase)new NBTTagCompound());
    }
    final NBTTagList l = new NBTTagList();
    for (final String s : lore) {
        l.appendTag((NBTBase)new NBTTagString(s));
    }
    tag.getCompoundTag("display").setTag("Lore", (NBTBase)l);
    a.setTagCompound(tag);
    return a;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:17,代碼來源:XUHelper.java

示例15: storeTEInStack

import net.minecraft.nbt.NBTTagString; //導入依賴的package包/類
/**
 * Originally copied from {@link Minecraft#storeTEInStack(ItemStack, TileEntity)}
 * 
 */
private static ItemStack storeTEInStack(ItemStack stack, NBTTagCompound nbttagcompound) {
  if (stack.getItem() == Items.SKULL && nbttagcompound.hasKey("Owner")) {
    NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
    NBTTagCompound nbttagcompound3 = new NBTTagCompound();
    nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
    stack.setTagCompound(nbttagcompound3);
    return stack;
  } else {
    stack.setTagInfo("BlockEntityTag", nbttagcompound);
    if (stack.isStackable()) {
      NBTTagCompound nbttagcompound1 = new NBTTagCompound();
      NBTTagList nbttaglist = new NBTTagList();
      nbttaglist.appendTag(new NBTTagString("(+NBT)"));
      nbttagcompound1.setTag("Lore", nbttaglist);
      stack.setTagInfo("display", nbttagcompound1);
    }
    return stack;
  }
}
 
開發者ID:wizards-of-lua,項目名稱:wizards-of-lua,代碼行數:24,代碼來源:ItemUtil.java


注:本文中的net.minecraft.nbt.NBTTagString類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。