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


Java ItemStack.getItemDamage方法代码示例

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


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

示例1: matches

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean matches(ItemStack subject) {
	List<ItemStack> inputs = getOres();
	boolean useOreStackMeta = (meta == null);
	Item subjectItem = subject.getItem();
	int subjectMeta = subject.getItemDamage();

	for (ItemStack oreStack : inputs) {
		Item oreItem = oreStack.getItem();
		if (oreItem == null) continue; // ignore invalid

		int metaRequired = useOreStackMeta ? oreStack.getItemDamage() : meta;

		if (subjectItem == oreItem &&
				(subjectMeta == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) {
			return true;
		}
	}

	return false;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:22,代码来源:RecipeInputOreDict.java

示例2: onSlotHack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
protected void onSlotHack(int slot, boolean nuked) {
    if (!nuked && gui instanceof GuiSecurityStationHacking) {
        ((GuiSecurityStationHacking) gui).onSlotHack(slot);
    }
    ItemStack stack = station.getPrimaryInventory().getStackInSlot(slot);
    if (stack.getItemDamage() == ItemNetworkComponents.NETWORK_REGISTRY || stack.getItemDamage() == ItemNetworkComponents.DIAGNOSTIC_SUBROUTINE) {
        hackedSuccessfully = true;
        EntityPlayer player = FMLClientHandler.instance().getClient().player;
        NetworkHandler.sendToServer(new PacketSecurityStationAddHacker(station, player.getName()));
        FMLClientHandler.instance().getClient().player.closeScreen();
        player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Hacking successful! This Security Station now doesn't protect the area any longer!"), false);
        if (gui instanceof GuiSecurityStationHacking)
            ((GuiSecurityStationHacking) gui).removeUpdatesOnConnectionHandlers();
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:17,代码来源:NetworkConnectionPlayerHandler.java

示例3: getModelTexPath

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "CoinTosser_empty"; }	// Empty
	if (this.getCooldown(stack) > 0) { return "CoinTosser_hot"; }

	return "CoinTosser";
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:9,代码来源:CoinTosser.java

示例4: update

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void update() {
	if (!world.isRemote) {
		++tick;
		final ItemStack bee = getStackInSlot(0);
		if (!bee.isEmpty() && bee.getItemDamage() < 35) {
			lookForFlowers();
			if (tick % 60 == 0 && world.rand.nextBoolean()) {
				world.playSound(null, pos, WitchSoundEvents.BUZZ, SoundCategory.BLOCKS, 0.1F, 1F);
			}
			if (flowerCount > 0) {
				if (world.rand.nextInt(3) == 0 && tick % (GEN - flowerCount * 3) == 0) {
					for (int i = 1; i < 16; i++) {
						if (!getStackInSlot(i).isEmpty()) {
							bee.attemptDamageItem(1, world.rand, player);
							bonemealArea();

							itemStacks.set(i, randomItem());
							break;
						}
					}
				}
				flowerCount = 0;
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:28,代码来源:TileApiary.java

示例5: getModelTexPath

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "CrossbowBlaze_empty"; }		// empty

	return "CrossbowBlaze";	// Regular
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:8,代码来源:Crossbow_Blaze.java

示例6: PacketUpdateSearchStack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public PacketUpdateSearchStack(ItemStack stack) {
    if (stack != null) {
        itemId = Item.getIdFromItem(stack.getItem());
        itemDamage = stack.getItemDamage();
    } else {
        itemId = itemDamage = -1;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:PacketUpdateSearchStack.java

示例7: canSmelt

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Returns true if the furnace can smelt an item, i.e. has a source item,
 * destination stack isn't full, etc.
 */
private boolean canSmelt() {
	int[] ammoTypesCount = new int[ItemAmmo.AMMO_TYPES.length];
	for (int i = 0; i < 9; i++) {
		ItemStack base = this.furnaceItemStacks.get(i);
		// System.out.println("Base: "+i+" "+base+"
		// "+ItemAmmo.AMMO_RECIPES[base.getItemDamage()]);
		if (base != null && base.getMetadata() < TF2CraftingManager.AMMO_RECIPES.length 
				&& base.getItem() instanceof ItemAmmo && !(base.getItem() instanceof ItemFireAmmo)
				&& TF2CraftingManager.AMMO_RECIPES[base.getItemDamage()] != null) {
			/*
			 * &&
			 * base.getCount()>=ItemAmmo.AMMO_RECIPES[base.getItemDamage()].
			 * getRecipeOutput().getCount()){
			 */
			ammoTypesCount[base.getItemDamage()] += base.getCount();
			if (ammoTypesCount[base.getItemDamage()] >= MathHelper.ceil(
					TF2CraftingManager.AMMO_RECIPES[base.getItemDamage()].getRecipeOutput().getCount() * 1.2f)) {
				this.ammoSmeltType = base.getItemDamage();
				return true;
			}
		}
		/*
		 * ItemStack itemstack =
		 * FurnaceRecipes.instance().getSmeltingResult(this.
		 * furnaceItemStacks[0]); if (itemstack == null) return false; if
		 * (this.furnaceItemStacks[2] == null) return true; if
		 * (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false;
		 * int result = furnaceItemStacks[2].getCount() +
		 * itemstack.getCount(); return result <= getInventoryStackLimit() &&
		 * result <= this.furnaceItemStacks[2].getMaxStackSize();
		 */// Forge BugFix: Make it respect stack sizes properly.
	}
	return false;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:39,代码来源:TileEntityAmmoFurnace.java

示例8: isBeingHeld

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean isBeingHeld() {
    ItemStack held = owner.inventory.getCurrentItem();
    return owner.inventory.currentItem == slot && //same slot
            held != null && //not holding nothing
            held.getItem() == ModItems.itemRemote && //same item type
            held.getItemDamage() == freq;//same freq
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:8,代码来源:Remote.java

示例9: convertEdibles

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private ItemStack convertEdibles(ItemStack stack) {
	
	int[] oreIDs = OreDictionary.getOreIDs(stack);
	if (oreIDs.length == 0) return stack;

	String oreName = OreDictionary.getOreName(oreIDs[0]);
	ItemStack converted = OreDictionary.getOres(oreName).get(0);
	if (converted != null)
		return new ItemStack(converted.getItem(), stack.stackSize, converted.getItemDamage());
	
	return stack;
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:13,代码来源:ItemEdibleMetal.java

示例10: onLivingUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    if (this.worldObj.isDaytime() && !this.worldObj.isRemote && !this.isChild() && (this.getZombieType() == null || this.getZombieType().isSunSensitive()))
    {
        float f = this.getBrightness(1.0F);
        BlockPos blockpos = this.getRidingEntity() instanceof EntityBoat ? (new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ)).up() : new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ);

        if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canSeeSky(blockpos))
        {
            boolean flag = true;
            ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

            if (itemstack != null)
            {
                if (itemstack.isItemStackDamageable())
                {
                    itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));

                    if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
                    {
                        this.renderBrokenItemStack(itemstack);
                        this.setItemStackToSlot(EntityEquipmentSlot.HEAD, (ItemStack)null);
                    }
                }

                flag = false;
            }

            if (flag)
            {
                this.setFire(8);
            }
        }
    }

    super.onLivingUpdate();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:42,代码来源:EntityZombie.java

示例11: onItemRightClick

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) 
   {  
	if (world.isRemote) { return stack; }	// Not doing this on client side
	
	if (stack.getItemDamage() == 0) { return stack; }	// Already fully loaded
	
	boolean doSFX = false;
	
	int counter = 4;
	
	while (counter > 0)	// Doing it 4 times, to speed that process up a bit
	{
		if (player.inventory.hasItem(Items.reeds) && player.inventory.hasItem(Items.stick))
		{
			// ...why does this not work? Is it because I'm in creative? Yes, it is. :|
			int dmg = stack.getItemDamage() - 1;
			stack.setItemDamage(dmg);
			
			//System.out.println("Set ITEM DMG to " + dmg + ".");
			
			player.inventory.consumeInventoryItem(Items.reeds);	// We're just grabbing what we need from the inventory
			player.inventory.consumeInventoryItem(Items.stick);
			
			// SFX
			doSFX = true;
		}
		// else, doesn't have what it takes
		else
		{
			//player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[" + this.getItemStackDisplayName(stack) + "] Can't find sticks or sugar canes."));
		}
		
		counter -= 1;
	}
	
	if (doSFX) { world.playSoundAtEntity(player, "random.wood_click", 0.5F, 1.50F); }
	
	return stack;
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:41,代码来源:GatlingAmmo.java

示例12: doCookingDamage

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean doCookingDamage(ItemStack stack)
{
    int damage = stack.getItemDamage();
    stack.setItemDamage(damage + 1);

    return stack.getItemDamage() >= stack.getMaxDamage();
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:9,代码来源:ItemRotisserie.java

示例13: getBurnTime

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public int getBurnTime(ItemStack fuel) {
	
	if (fuel.getItem() == this && fuel.getItemDamage() == 3)
		return 16000;
	
	return 0;
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:9,代码来源:ItemGeneric.java

示例14: getModelTexPath

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "OWR_empty"; }	// empty
	if (this.getCooldown(stack) > 0) { return "OWR_hot"; }						// Cooling down

	return "OWR";	// Regular
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:9,代码来源:OWR.java

示例15: onWornTick

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
	if (itemstack.getItemDamage() == 0 && player.ticksExisted % 40 == 0) {
		player.addPotionEffect(new PotionEffect(MobEffects.LUCK, 120, 0, true, true));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:7,代码来源:ItemHorseshoe.java


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