当前位置: 首页>>代码示例>>Java>>正文


Java ItemStack.setTagCompound方法代码示例

本文整理汇总了Java中net.minecraft.item.ItemStack.setTagCompound方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.setTagCompound方法的具体用法?Java ItemStack.setTagCompound怎么用?Java ItemStack.setTagCompound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.item.ItemStack的用法示例。


在下文中一共展示了ItemStack.setTagCompound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: breakBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    if (world.getTileEntity(pos) instanceof BlackHoleUnitTile) {
        BlackHoleUnitTile tile = (BlackHoleUnitTile) world.getTileEntity(pos);
        ItemStack stack = new ItemStack(Item.getItemFromBlock(this), 1);
        if (tile.getAmount() > 0) {
            if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setInteger(BlackHoleUnitTile.NBT_AMOUNT, tile.getAmount());
            stack.getTagCompound().setString(BlackHoleUnitTile.NBT_ITEMSTACK, tile.getItemStack().getItem().getRegistryName().toString());
            stack.getTagCompound().setInteger(BlackHoleUnitTile.NBT_META, tile.getItemStack().getMetadata());
            if (tile.getItemStack().hasTagCompound())
                stack.getTagCompound().setTag(BlackHoleUnitTile.NBT_ITEM_NBT, tile.getItemStack().getTagCompound());
        }
        float f = 0.7F;
        float d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
        float d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
        float d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
        EntityItem entityitem = new EntityItem(world, pos.getX() + d0, pos.getY() + d1, pos.getZ() + d2, stack);
        entityitem.setDefaultPickupDelay();
        if (stack.hasTagCompound()) {
            entityitem.getItem().setTagCompound(stack.getTagCompound().copy());
        }
        world.spawnEntity(entityitem);
    }
    world.removeTileEntity(pos);
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:27,代码来源:BlackHoleUnitBlock.java

示例2: removeBannerData

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Removes all the banner related data from a provided instance of ItemStack.
 */
public static void removeBannerData(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
    {
        NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

        if (nbttaglist.tagCount() > 0)
        {
            nbttaglist.removeTag(nbttaglist.tagCount() - 1);

            if (nbttaglist.hasNoTags())
            {
                stack.getTagCompound().removeTag("BlockEntityTag");

                if (stack.getTagCompound().hasNoTags())
                {
                    stack.setTagCompound((NBTTagCompound)null);
                }
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:28,代码来源:TileEntityBanner.java

示例3: getCraftingResult

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack getCraftingResult(InventoryCrafting matrix)
   {
	ItemStack stack = this.getRecipeOutput().copy();
	ItemStack previousAA = this.getAAFromMatrix(matrix);
	
	if (previousAA != null && previousAA.hasTagCompound())	// Copying existing properties
	{
		stack.setTagCompound((NBTTagCompound) previousAA.getTagCompound().copy());
	}
	else	// ...or just applying new ones
	{
		stack.setTagCompound(new NBTTagCompound());
	}
	
	// Apply the new upgrade now
	stack.getTagCompound().setBoolean("hasRidingUpgrade", true);
	
       return stack;
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:21,代码来源:Recipe_AA_Riding.java

示例4: initSockLists

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static void initSockLists() {
	if (socksOrdered == null) {
		socksOrdered = new ArrayList<>(256);

		for (int i = 0; i < 256; i++) {
			ItemStack sock = new ItemStack(PonySocks.sock, 1, 0);
			sock.setTagCompound(new NBTTagCompound());
			sock.getTagCompound().setInteger("color1", RecipeDyeableBase.fromFloats(EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(i & 15))));
			sock.getTagCompound().setInteger("color2", RecipeDyeableBase.fromFloats(EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(i >> 4))));
			socksOrdered.add(sock);
		}

		socksShuffled = Lists.newArrayList(socksOrdered);
		Collections.shuffle(socksShuffled);
	}
}
 
开发者ID:asiekierka,项目名称:PonySocks2,代码行数:17,代码来源:PonySocks.java

示例5: getSubItems

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
	if(!Config.DISABLED_TOOLS.contains("mace")) {
		ItemStack stack1 = new ItemStack(this);
		NBTTagCompound tag = new NBTTagCompound();
		tag.setString(HEAD_TAG, Materials.randomHead().getName());
		tag.setString(HAFT_TAG, Materials.randomHaft().getName());
		tag.setString(HANDLE_TAG, Materials.randomHandle().getName());
		tag.setString(ADORNMENT_TAG, Materials.randomAdornment().getName());
		stack1.setTagCompound(tag);
		if (isInCreativeTab(tab)) {
			subItems.add(stack1);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:17,代码来源:ItemATMace.java

示例6: getRecipeOutput

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack getRecipeOutput() {
	ItemStack stack = new ItemStack(PonySocks.sock, 1, 0);
	stack.setTagCompound(new NBTTagCompound());
	stack.getTagCompound().setInteger("type", 1);
	return stack;
}
 
开发者ID:asiekierka,项目名称:PonySocks2,代码行数:8,代码来源:RecipeSockRainbow.java

示例7: setChambered

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void setChambered(ItemStack stack, World world, Entity entity, boolean toggle)
{
	if (stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); }	// Init

	stack.stackTagCompound.setBoolean("isChambered", toggle);	// Done, we're good to go again

	// SFX
	world.playSoundAtEntity(entity, "random.click", 0.8F, 0.5F);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:10,代码来源:Crossbow_Auto.java

示例8: initDefaultNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void initDefaultNBT(ItemStack is)
{
	NBTTagCompound foodTag = new NBTTagCompound();
	foodTag.setFloat("weight", this.getEntry(is).getMaxWeight());
	foodTag.setFloat("rot", 0.1F);
	is.setTagCompound(is.hasTagCompound() ? is.getTagCompound() : new NBTTagCompound());
	is.getTagCompound().setTag("exp.foodData", foodTag);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:9,代码来源:ItemFood.java

示例9: finishCrafting

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean finishCrafting(MachineComponent component, RecipeCraftingContext context, ResultChance chance) {
    if(component.getComponentType() != MachineComponent.ComponentType.ITEM ||
            !(component instanceof MachineComponent.ItemBus) ||
            component.getIOType() != getActionType()) return false;

    if(fuelBurntime > 0 && oreDictName == null && required.isEmpty()) {
        throw new IllegalStateException("Can't output fuel burntime...");
    }
    IItemHandlerModifiable handler = context.getItemHandler(component);
    switch (getActionType()) {
        case OUTPUT:
            ItemStack stack;
            if(oreDictName != null) {
                stack = Iterables.getFirst(OreDictionary.getOres(oreDictName), ItemStack.EMPTY);
                stack = ItemUtils.copyStackWithSize(stack, this.oreDictItemAmount);
            } else {
                stack = ItemUtils.copyStackWithSize(required, this.countIOBuffer);
            }

            if(stack.isEmpty()) {
                return true;
            }
            if(tag != null) {
                stack.setTagCompound(tag);
            }
            //If we don't produce the item, we only need to see if there would be space for it at all.
            int inserted = ItemUtils.tryPlaceItemInInventory(stack.copy(), handler, true);
            if(chance.canProduce(this.chance)) {
                return inserted > 0;
            }
            if(inserted > 0) {
                int actual = ItemUtils.tryPlaceItemInInventory(stack.copy(), handler, false);
                this.countIOBuffer -= actual;
                return this.countIOBuffer <= 0;
            }
            return false;
    }
    return false;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:41,代码来源:ComponentRequirement.java

示例10: getTankStackFromTile

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ItemStack getTankStackFromTile(TileGlassFluidTank tank, boolean keepFluid) {
	
	ItemStack stack = new ItemStack(GrandFluidTank.glassfluidtank);
	stack.setTagCompound(new NBTTagCompound());
	FluidStack fluid = tank.tank.getFluid();
	if (fluid != null && keepFluid) {
		NBTTagCompound tagFluid = new NBTTagCompound();
		fluid.writeToNBT(tagFluid);
		stack.getTagCompound().setTag("Fluid", tagFluid);
		
	}

	return stack;
}
 
开发者ID:grand-mine-inc,项目名称:Steam-and-Steel,代码行数:15,代码来源:Utils.java

示例11: getSubItems

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items)
{
	if (this.isInCreativeTab(tab))
	{
		items.add(new ItemStack(this));

		ItemStack stack = new ItemStack(this);
		NBTTagCompound tags = new NBTTagCompound();
		tags.setInteger("charge", getMaxCharge(stack));
		stack.setTagCompound(tags);
		items.add(stack);
	}
}
 
开发者ID:Lemonszz,项目名称:Anima-Mundi,代码行数:14,代码来源:ItemAnimaCharged.java

示例12: setSelectedStackIndex

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void setSelectedStackIndex(InventoryDankNull inventory, int index, boolean sync) {
	if (inventory != null && !inventory.getDankNull().isEmpty()) {
		ItemStack dankNull = inventory.getDankNull();
		if (!dankNull.hasTagCompound()) {
			dankNull.setTagCompound(new NBTTagCompound());
		}
		//NBTTagCompound capData = getInventory(dankNull).serializeNBT();
		dankNull.getTagCompound().setInteger("selectedIndex", index);
		//getInventory(dankNull).deserializeNBT(capData);
		if (FMLCommonHandler.instance().getSide().isClient()) {
			ModNetworking.INSTANCE.sendToServer(new PacketSetSelectedItem(index));
		}
	}
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:15,代码来源:DankNullUtils.java

示例13: testBurnTimeWithNbt

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Test
public void testBurnTimeWithNbt()
{
    Fuel fuel = gson.fromJson("{ \"item\": {\"item\" : \"minecraft:bow\", \"nbt\":\"{AInt:1}\" }, \"burnTime\":1337 }", Fuel.class);
    fuel.init(InitPhase.PRE_INIT, new TestContentHelper("{}", TestContent.class));

    ItemStack stack = new ItemStack(Items.BOW);
    stack.setTagCompound(new NBTTagCompound());
    stack.getTagCompound().setInteger("AInt", 1);

    assertFalse(fuel.appliesToStack(new ItemStack(Items.BOW)));
    assertTrue(fuel.appliesToStack(stack));
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:14,代码来源:FuelTests.java

示例14: loadCraftingRecipes

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void loadCraftingRecipes(ItemStack result) {
	if (result.getItem() != Item.getItemFromBlock(ModBlocks.banner))
		return;

	NBTTagCompound nbt = ItemBanner.getSubTag(result, "BlockEntityTag", false);
	if (nbt != null && nbt.hasKey("Patterns", 9)) {
		NBTTagList patterns = nbt.getTagList("Patterns", 10);
		for (int i = 0; i < patterns.tagCount(); i++) {
			NBTTagCompound patternNBT = patterns.getCompoundTagAt(i);
			EnumBannerPattern pattern = EnumBannerPattern.getPatternByID(patternNBT.getString("Pattern"));
			if (pattern == null)
				continue;

			ItemStack copy = new ItemStack(ModBlocks.banner, 1, result.getItemDamage());
			copy.setTagCompound(null);
			EnumColour colour = patternNBT.hasKey("Color") ? EnumColour.fromDamage(patternNBT.getInteger("Color")) : null;
			if (!pattern.hasValidCrafting())
				continue;
			if (pattern.hasCraftingStack()) {
				if (colour != null)
					arecipes.add(new CachedPatternRecipe(pattern, new String[] { "   ", "xy ", " z " }, Arrays.asList('x', pattern.getCraftingStack(), 'y', colour.getOreName(), 'z', copy)));
				else
					arecipes.add(new CachedPatternRecipe(pattern, new String[] { "   ", "xy ", "   " }, Arrays.asList('x', pattern.getCraftingStack(), 'y', copy)));
			} else {
				String[] layers = pattern.getCraftingLayers();
				String[] layersCopy = new String[] { layers[0], layers[1], layers[2] };
				for (int j = 0; j < 3; j++) {
					String newLayer = layersCopy[j].replaceFirst(" ", "x");
					if (!newLayer.equals(layersCopy[j])) {
						layersCopy[j] = newLayer;
						break;
					}
				}
				arecipes.add(new CachedPatternRecipe(pattern, layersCopy, Arrays.asList('#', colour == null ? "dye" : colour.getOreName(), 'x', copy)));
			}
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:40,代码来源:BannerPatternHandler.java

示例15: getIngredients

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void getIngredients(IIngredients ingredients) {
	ItemStack pattern = new ItemStack(ModItems.pattern);
	NBTTagCompound tag = new NBTTagCompound();
	ItemStack output = recipe.outputItem();
	tag.setTag("defieritem", output.serializeNBT());
	pattern.setTagCompound(tag);
	ingredients.setInput(ItemStack.class, pattern);
	ingredients.setOutput(ItemStack.class, output);
}
 
开发者ID:tiffit,项目名称:Defier,代码行数:11,代码来源:DefierRecipeWrapper.java


注:本文中的net.minecraft.item.ItemStack.setTagCompound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。