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


Java ItemStack.hasTagCompound方法代码示例

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


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

示例1: getNameOfFaction

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private String getNameOfFaction(ItemStack stack)
{
	// We're storing the faction ID in the item after it has been signed by a leader
	if (stack.hasTagCompound())
	{
		String id = stack.getTagCompound().getString("factionID");
		
		if (id == null || id.isEmpty())
		{
			// ...eh?
			return null;
		}
		else
		{
			// What're you called...
			return TerritoryHandler.getNameOfFaction(UUID.fromString(id));
		}
	}
	else
	{
		// Has no faction ID tag, so cannot be signed
		return null;
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:25,代码来源:ClaimTerritoryOrder.java

示例2: getRemainingItems

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null)
        {
            if (itemstack.getItem().hasContainerItem())
            {
                aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
            }
            else if (itemstack.hasTagCompound() && TileEntityBanner.getPatterns(itemstack) > 0)
            {
                aitemstack[i] = itemstack.copy();
                aitemstack[i].stackSize = 1;
            }
        }
    }

    return aitemstack;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:RecipesBanners.java

示例3: isChunkLoaded

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public Optional<Boolean> isChunkLoaded(ItemStack stack) {
	if (!stack.hasTagCompound()) return UNATTUNED;
	
	NBTTagCompound tag = stack.getTagCompound();
	if (tag.hasKey("world")) {
		int worldId = tag.getInteger("world");
		if (!DimensionManager.isDimensionRegistered(worldId)) return UNATTUNED;
		
		//We're reasonably certain at this point the unloader is attuned to a valid world.
		
		WorldServer world = DimensionManager.getWorld(worldId);
		if (world==null) return UNLOADED;
		
		//boolean playerLoad = world.getPlayerChunkMap().contains(tag.getInteger("x"), tag.getInteger("z"));
		//System.out.println("chunk["+tag.getInteger("x")+","+tag.getInteger("z")+"] isPlayerLoaded:"+playerLoad);
		
		Chunk chunk = world.getChunkProvider().getLoadedChunk(tag.getInteger("x"), tag.getInteger("z"));
		return (chunk!=null) ? LOADED : UNLOADED;
		//Chunk chunk = world.getChunkFromChunkCoords(tag.getInteger("x"),tag.getInteger("z"));
		//return (chunk.isLoaded()) ? LOADED : UNLOADED;
	}
	
	return UNATTUNED;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:25,代码来源:ItemChunkUnloader.java

示例4: setFactionID

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void setFactionID(ItemStack stack, UUID id)
{
	if (stack == null) { return; }
	if (id == null) { return; }
	
	if (!stack.hasTagCompound())
	{
		stack.setTagCompound(new NBTTagCompound());	// Init
	}
	
	stack.getTagCompound().setString("factionID", id.toString());	// Done
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:13,代码来源:ClaimTerritoryOrder.java

示例5: 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");
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:40,代码来源:EnchantmentHelper.java

示例6: livingUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SubscribeEvent
public void livingUpdate(LivingUpdateEvent event) {
	EntityLivingBase living = event.getEntityLiving();
	if(living.hasCapability(RIG.RIG_ITEM, null)) {
		ItemStack rig = living.getCapability(RIG.RIG_ITEM, null).getStackInSlot(0);
		if(rig.hasTagCompound() && living.isInWater()) {
			int extraair = 100 + RIGUpgrade.upgradesMap.get("Air").getAttributeValue(rig) * 100;
			if (living.getRNG().nextInt(300+extraair)>=300) {
				living.setAir(living.getAir()+1);
			}
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:14,代码来源:RIGEvents.java

示例7: verifySellingItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void verifySellingItem(ItemStack stack) {
	// TODO Auto-generated method stub
	if(!stack.isEmpty() && stack.hasTagCompound())
		stack.getTagCompound().setBoolean("Bought", true);
	/*if (this.trader != null && !stack.isEmpty() &&stack.getItem() instanceof ItemWeapon)
		this.trader.addStat(TF2Achievements.MANN_CO_MADE);*/

}
 
开发者ID:rafradek,项目名称:Mods,代码行数:10,代码来源:EntitySaxtonHale.java

示例8: isCurrentlyZoomed

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
boolean isCurrentlyZoomed(ItemStack stack)
{
	if (stack == null) { return false; }	// Not a  valid item
	if (!stack.hasTagCompound()) { return false; } // No tag
	
	return stack.stackTagCompound.getBoolean("isZoomed");
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:8,代码来源:EnderBow.java

示例9: getLastUsed

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static long getLastUsed(ItemStack stack) {

        if(!stack.hasTagCompound())
            return 0;

        NBTTagCompound tag = stack.getTagCompound();
        if(!tag.hasKey("LastUsed"))
            return 0;
        return tag.getLong("LastUsed");
    }
 
开发者ID:ImbaKnugel,项目名称:Whoosh,代码行数:11,代码来源:ItemTransporter.java

示例10: getItemStackDisplayName

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public String getItemStackDisplayName(ItemStack stack)
  {
if(!stack.hasTagCompound())
	return super.getItemStackDisplayName(stack);
if(!stack.getTagCompound().getCompoundTag("Statue").getBoolean("Player"))
	return I18n.translateToLocal("entity." + EntityList.getTranslationName
			(new ResourceLocation(stack.getTagCompound().getCompoundTag("Statue").getCompoundTag("Entity").getString("id")))+".name")+" "+
			I18n.translateToLocal(this.getUnlocalizedName() + ".name");
else
	return I18n.translateToLocal(this.getUnlocalizedName() + ".player.name");
  }
 
开发者ID:rafradek,项目名称:Mods,代码行数:12,代码来源:ItemStatue.java

示例11: spawnItemStack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static void spawnItemStack(World worldIn, double x, double y, double z, ItemStack stack)
{
    float f = RANDOM.nextFloat() * 0.8F + 0.1F;
    float f1 = RANDOM.nextFloat() * 0.8F + 0.1F;
    float f2 = RANDOM.nextFloat() * 0.8F + 0.1F;

    while (stack.stackSize > 0)
    {
        int i = RANDOM.nextInt(21) + 10;

        if (i > stack.stackSize)
        {
            i = stack.stackSize;
        }

        stack.stackSize -= i;
        EntityItem entityitem = new EntityItem(worldIn, x + (double)f, y + (double)f1, z + (double)f2, new ItemStack(stack.getItem(), i, stack.getMetadata()));

        if (stack.hasTagCompound())
        {
            entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
        }

        float f3 = 0.05F;
        entityitem.motionX = RANDOM.nextGaussian() * (double)f3;
        entityitem.motionY = RANDOM.nextGaussian() * (double)f3 + 0.20000000298023224D;
        entityitem.motionZ = RANDOM.nextGaussian() * (double)f3;
        worldIn.spawnEntityInWorld(entityitem);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:31,代码来源:InventoryHelper.java

示例12: itemInteractionForEntity

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack item, EntityPlayer player, EntityLivingBase entity) {
    if (entity.worldObj.isRemote) {
        return false;
    }
    if (entity instanceof IMob) {
        if (item.hasTagCompound())
            return false;
        item.setTagCompound(new NBTTagCompound());
        NBTTagCompound mainTag = new NBTTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        entity.writeToNBT(entityTag);
        mainTag.setFloat("health",entity.getHealth());
        mainTag.setTag("data", entityTag);
        mainTag.setString("id", EntityList.getEntityString(entity));
        if (entity instanceof EntitySlime) {
            mainTag.setInteger("slimesize", ((EntitySlime) entity).getSlimeSize());
        }
        if(entity instanceof EntityZombie){
            mainTag.setBoolean("isBabyZombie",entity.isChild());
        }
        item.getTagCompound().setTag("entity",mainTag);
        player.setCurrentItemOrArmor(0, item);
        entity.setDead();
        return true;
    }
    return super.itemInteractionForEntity(item, player, entity);
}
 
开发者ID:SihenZhang,项目名称:CursedLasso,代码行数:29,代码来源:ItemCursedLasso.java

示例13: getRarity

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public EnumRarity getRarity(ItemStack stack)
   {
	if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("hasEmeraldMuzzle")) { return EnumRarity.rare; }
       
       return EnumRarity.common;	// Default
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:8,代码来源:ERA.java

示例14: setCurrentZoom

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
void setCurrentZoom(ItemStack stack, boolean zoom)
{
	if (stack == null) { return; }	// Not a  valid item
	if (!stack.hasTagCompound()) { return; } // No tag
	
	stack.stackTagCompound.setBoolean("isZoomed", zoom);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:8,代码来源:EnderBow.java

示例15: getDurabilityForDisplay

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
	if (stack.hasTagCompound()) 
	{ 
		return stack.getTagCompound().getFloat("displayDurability"); 
	}
	// else, no info yet about any territories

	return 1.0f;	// Displaying 1.0 as "full damage", meaning an empty bar.
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:12,代码来源:ClaimTerritoryOrder.java


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