当前位置: 首页>>代码示例>>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;未经允许,请勿转载。