本文整理汇总了Java中net.minecraft.item.ItemStack.setTagInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.setTagInfo方法的具体用法?Java ItemStack.setTagInfo怎么用?Java ItemStack.setTagInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.setTagInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadBook
import net.minecraft.item.ItemStack; //导入方法依赖的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;
}
示例2: skull
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
protected static ItemStack skull(String name, String owner, String texture)
{
ItemStack stack = new ItemStack(Items.SKULL, 1, 3);
NBTTagCompound display = new NBTTagCompound();
display.setString("LocName", name);
stack.setTagInfo("display", display);
NBTTagCompound skullOwner = new NBTTagCompound();
skullOwner.setString("Id", owner);
NBTTagCompound properties = new NBTTagCompound();
NBTTagList textures = new NBTTagList();
NBTTagCompound tex = new NBTTagCompound();
tex.setString("Value", texture);
textures.appendTag(tex);
properties.setTag("textures", textures);
skullOwner.setTag("Properties", properties);
stack.setTagInfo("SkullOwner", skullOwner);
return stack;
}
示例3: harvestBlock
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
if (te instanceof TileEntityBanner)
{
TileEntityBanner tileentitybanner = (TileEntityBanner)te;
ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)te).getBaseColor());
NBTTagCompound nbttagcompound = new NBTTagCompound();
TileEntityBanner.func_181020_a(nbttagcompound, tileentitybanner.getBaseColor(), tileentitybanner.func_181021_d());
itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
spawnAsEntity(worldIn, pos, itemstack);
}
else
{
super.harvestBlock(worldIn, player, pos, state, (TileEntity)null);
}
}
示例4: storeTEInStack
import net.minecraft.item.ItemStack; //导入方法依赖的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;
}
}
示例5: func_181036_a
import net.minecraft.item.ItemStack; //导入方法依赖的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;
}
}
示例6: storeTEInStack
import net.minecraft.item.ItemStack; //导入方法依赖的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;
}
}
示例7: getWailaStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
ItemStack stack = new ItemStack(ModBlocks.DANKNULL_DOCK);
TileEntity tile = accessor.getTileEntity();
if (tile != null && tile instanceof TileDankNullDock) {
TileDankNullDock te = (TileDankNullDock) tile;
NBTTagCompound nbttagcompound = new NBTTagCompound();
te.writeToNBT(nbttagcompound);
stack.setTagInfo("BlockEntityTag", nbttagcompound);
}
return stack;
}
示例8: getCraftingResult
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack getCraftingResult(InventoryCrafting inv)
{
ItemStack itemstack = ItemStack.field_190927_a;
ItemStack itemstack1 = ItemStack.field_190927_a;
for (int i = 0; i < inv.getSizeInventory(); ++i)
{
ItemStack itemstack2 = inv.getStackInSlot(i);
if (!itemstack2.func_190926_b())
{
if (itemstack2.getItem() == Items.BANNER)
{
itemstack = itemstack2;
}
else if (itemstack2.getItem() == Items.SHIELD)
{
itemstack1 = itemstack2.copy();
}
}
}
if (itemstack1.func_190926_b())
{
return itemstack1;
}
else
{
NBTTagCompound nbttagcompound = itemstack.getSubCompound("BlockEntityTag");
NBTTagCompound nbttagcompound1 = nbttagcompound == null ? new NBTTagCompound() : nbttagcompound.copy();
nbttagcompound1.setInteger("Base", itemstack.getMetadata() & 15);
itemstack1.setTagInfo("BlockEntityTag", nbttagcompound1);
return itemstack1;
}
}
示例9: createCmdBlock
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void createCmdBlock(String cmd)
{
// generate cmd-block
ItemStack stack = new ItemStack(Blocks.COMMAND_BLOCK);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
nbtTagCompound.setTag("Command", new NBTTagString(cmd));
stack.writeToNBT(nbtTagCompound);
stack.setTagInfo("BlockEntityTag", nbtTagCompound);
// give cmd-block
if(InventoryUtils.placeStackInHotbar(stack))
ChatUtils.message("Command Block created.");
else
ChatUtils.error("Please clear a slot in your hotbar.");
}
示例10: getSubTag
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static NBTTagCompound getSubTag(ItemStack stack, String key, boolean create) {
if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey(key, 10))
return stack.stackTagCompound.getCompoundTag(key);
else if (create) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
stack.setTagInfo(key, nbttagcompound);
return nbttagcompound;
} else
return null;
}
示例11: setEnchantments
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Set the enchantments for the specified stack.
*/
public static void setEnchantments(Map<Integer, Integer> enchMap, ItemStack stack)
{
NBTTagList nbttaglist = new NBTTagList();
Iterator iterator = enchMap.keySet().iterator();
while (iterator.hasNext())
{
int i = ((Integer)iterator.next()).intValue();
Enchantment enchantment = Enchantment.getEnchantmentById(i);
if (enchantment != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setShort("id", (short)i);
nbttagcompound.setShort("lvl", (short)((Integer)enchMap.get(Integer.valueOf(i))).intValue());
nbttaglist.appendTag(nbttagcompound);
if (stack.getItem() == Items.enchanted_book)
{
Items.enchanted_book.addEnchantment(stack, new EnchantmentData(enchantment, ((Integer)enchMap.get(Integer.valueOf(i))).intValue()));
}
}
}
if (nbttaglist.tagCount() > 0)
{
if (stack.getItem() != Items.enchanted_book)
{
stack.setTagInfo("ench", nbttaglist);
}
}
else if (stack.hasTagCompound())
{
stack.getTagCompound().removeTag("ench");
}
}
示例12: onEnable
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onEnable()
{
// check gamemode
if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
{
ChatUtils.error("Creative mode only.");
setEnabled(false);
return;
}
// generate potion
ItemStack stack = InventoryUtils.createSplashPotion();
NBTTagCompound effect = new NBTTagCompound();
effect.setInteger("Amplifier", 125);
effect.setInteger("Duration", 2000);
effect.setInteger("Id", 6);
NBTTagList effects = new NBTTagList();
effects.appendTag(effect);
stack.setTagInfo("CustomPotionEffects", effects);
stack.setStackDisplayName("�rSplash Potion of �4�lDEATH");
// give potion
if(InventoryUtils.placeStackInHotbar(stack))
ChatUtils.message("Potion created.");
else
ChatUtils.error("Please clear a slot in your hotbar.");
setEnabled(false);
}
示例13: processCreativeInventoryAction
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Update the server with an ItemStack in a slot.
*/
public void processCreativeInventoryAction(C10PacketCreativeInventoryAction packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
if (this.playerEntity.theItemInWorldManager.isCreative())
{
boolean flag = packetIn.getSlotId() < 0;
ItemStack itemstack = packetIn.getStack();
if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
{
NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");
if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
{
BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos);
if (tileentity != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
tileentity.writeToNBT(nbttagcompound1);
nbttagcompound1.removeTag("x");
nbttagcompound1.removeTag("y");
nbttagcompound1.removeTag("z");
itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
}
}
}
boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() < 36 + InventoryPlayer.getHotbarSize();
boolean flag2 = itemstack == null || itemstack.getItem() != null;
boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0;
if (flag1 && flag2 && flag3)
{
if (itemstack == null)
{
this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null);
}
else
{
this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
}
this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
}
else if (flag && flag2 && flag3 && this.itemDropThreshold < 200)
{
this.itemDropThreshold += 20;
EntityItem entityitem = this.playerEntity.dropPlayerItemWithRandomChoice(itemstack, true);
if (entityitem != null)
{
entityitem.setAgeToCreativeDespawnTime();
}
}
}
}
示例14: writePage
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static void writePage(ItemStack book, StringBuilder page) {
NBTTagList pages = getPagesNbt(book);
pages.appendTag(createPage(page.toString()));
book.setTagInfo("pages", pages);
}
示例15: registerVillagerTrades
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void registerVillagerTrades()
{
careerKrog.addTrade(1, new VillagerTradeItemForItem(new ItemStack(ModItems.shiny_stone), new EntityVillager.PriceInfo(1, 1),
new ItemStack(Items.LEATHER), new EntityVillager.PriceInfo(2, 2)));
careerKrog.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.PAINTING), new EntityVillager.PriceInfo(1, 1),
new ItemStack(Blocks.CACTUS), new EntityVillager.PriceInfo(8, 16)));
careerKrog.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.FISHING_ROD), new EntityVillager.PriceInfo(1, 1),
new ItemStack(Items.FISH), new EntityVillager.PriceInfo(5, 8)));
careerKrog.addTrade(2, new VillagerTradeItemForItem(new ItemStack(Items.DYE), new EntityVillager.PriceInfo(5, 10),
new ItemStack(Blocks.VINE), new EntityVillager.PriceInfo(2, 4)));
if (Loader.isModLoaded("tconstruct"))
{
Item arrowhead = Item.REGISTRY.getObject(new ResourceLocation("tconstruct", "arrow_head"));
if (arrowhead != null)
{
NBTTagCompound material = new NBTTagCompound();
material.setString("Material", "obsidian");
ItemStack stack = new ItemStack(arrowhead);
stack.setTagCompound(material);
careerKrog.addTrade(2, new VillagerTradeItemForItem(new ItemStack(Items.COAL, 1, 1), new EntityVillager.PriceInfo(10, 20),
stack, new EntityVillager.PriceInfo(1, 1)));
}
}
if (Loader.isModLoaded("actuallyadditions"))
{
Item crystal = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions", "item_crystal"));
if (crystal != null)
{
ItemStack starterKit = createChickenSpawnerKit();
careerKrog.addTrade(3, new VillagerTradeItemForItem(new ItemStack(crystal, 1, 4), new EntityVillager.PriceInfo(1, 3),
starterKit, new EntityVillager.PriceInfo(1, 1)));
}
}
careerTorg.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.BEEF), new EntityVillager.PriceInfo(1, 3),
new ItemStack(Blocks.SAPLING, 1, 3), new EntityVillager.PriceInfo(1, 3)));
careerTorg.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.LEATHER), new EntityVillager.PriceInfo(2, 4),
new ItemStack(Items.MELON_SEEDS), new EntityVillager.PriceInfo(4, 6)));
Block net = Block.REGISTRY.getObject(new ResourceLocation("actuallyadditions", "block_fishing_net"));
if (net != Blocks.AIR)
{
careerTorg.addTrade(2, new VillagerTradeItemForItem(new ItemStack(net), new EntityVillager.PriceInfo(1, 1),
new ItemStack(Items.DYE, 1, 3), new EntityVillager.PriceInfo(24, 36)));
}
if (Loader.isModLoaded("rustic"))
{
NBTTagCompound parrotTag = new NBTTagCompound();
parrotTag.setString("id", "minecraft:parrot");
ItemStack parrotEgg = new ItemStack(Items.SPAWN_EGG, 1);
parrotEgg.setTagInfo("EntityTag", parrotTag);
careerTorg.addTrade(3, new VillagerTradeItemForItem(new ItemStack(rustic.common.items.ModItems.HONEYCOMB), new EntityVillager.PriceInfo(30, 40),
parrotEgg, new EntityVillager.PriceInfo(1, 1)));
}
}