當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemStack.getMaxDamage方法代碼示例

本文整理匯總了Java中net.minecraft.item.ItemStack.getMaxDamage方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemStack.getMaxDamage方法的具體用法?Java ItemStack.getMaxDamage怎麽用?Java ItemStack.getMaxDamage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.item.ItemStack的用法示例。


在下文中一共展示了ItemStack.getMaxDamage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onWornTick

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
	if (player.ticksExisted % 40 == 0 && player instanceof EntityPlayer) {
		EntityPlayer p = (EntityPlayer) player;
		boolean flag = p.getActivePotionEffect(MobEffects.POISON) != null || p.getActivePotionEffect(MobEffects.NAUSEA) != null || p.getActivePotionEffect(MobEffects.WITHER) != null || p.getActivePotionEffect(MobEffects.BLINDNESS) != null || p.getActivePotionEffect(MobEffects.WEAKNESS) != null;
		p.removePotionEffect(MobEffects.NAUSEA);
		p.removePotionEffect(MobEffects.WITHER);
		p.removePotionEffect(MobEffects.BLINDNESS);
		p.removePotionEffect(MobEffects.POISON);
		p.removePotionEffect(MobEffects.WEAKNESS);
		if (flag) {
			itemstack.setItemDamage(itemstack.getItemDamage() + 1);
			if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) {
				itemstack.setCount(0);
			}
		}
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:19,代碼來源:ItemRemedyTalisman.java

示例2: onUpdate

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int animTick, boolean holdingItem) 	// Overhauled default
{
	if (world.isRemote) { return; }	// Not doing this on client side
	
	if (this.getCooldown(stack) > 0) { this.setCooldown(stack, this.getCooldown(stack) - 1); }	// Cooling down
	if (this.getCooldown(stack) == 1) { this.doCooldownSFX(world, entity); }					// One tick before cooldown is done with, so SFX now
	
	if (this.getBurstFire(stack) > 0)
	{
		this.setBurstFire(stack, this.getBurstFire(stack) - 1); // One done
		
		if (stack.getItemDamage() < stack.getMaxDamage() && holdingItem)	// Can only do it if we're loaded and holding the weapon
		{
			this.doBurstFire(stack, world, entity);
			
			if (this.consumeAmmo(stack, entity, 1)) 	// We're done here
			{ 
				this.dropMagazine(world, stack, entity);
				return;
			}
			// else, still has ammo left. Continue.
		}
		// else, either not loaded or not held
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:27,代碼來源:ThornSpitter.java

示例3: detectAndSendChanges

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public void detectAndSendChanges() {
    super.detectAndSendChanges();

    for(IContainerListener listener : this.listeners) {
    	ItemStack weapon = this.mercenary.loadout.getStackInSlot(0);
    	int loaded = weapon.getItem() instanceof ItemWeapon ? weapon.getMaxDamage() - weapon.getItemDamage() : 0;
     if(this.primaryAmmo != this.mercenary.getAmmo(0)) {
     	this.primaryAmmo = this.mercenary.getAmmo(0);
     	//System.out.println("ammo in:");
     	listener.sendWindowProperty(this, 0, this.primaryAmmo);
     }
     weapon = this.mercenary.loadout.getStackInSlot(0);
    	loaded = weapon.getItem() instanceof ItemWeapon ? weapon.getMaxDamage() - weapon.getItemDamage() : 0;
     if(this.secondaryAmmo != this.mercenary.getAmmo(1) + loaded) {
     	this.secondaryAmmo = this.mercenary.getAmmo(1) + loaded;
     	listener.sendWindowProperty(this, 1, this.secondaryAmmo);
     }
    }
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:20,代碼來源:ContainerMercenary.java

示例4: checkMatch

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
protected boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
{
    int[] amounts = getAmounts(mirror);

    for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
    {
        for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
        {
            int subX = x - startX;
            int subY = y - startY;
            int damage = 0;
            Ingredient target = Ingredient.EMPTY;

            if (subX >= 0 && subY >= 0 && subX < width && subY < height)
            {
                damage = amounts[subX + width * subY];

                if (mirror)
                {
                    target = input.get(width - subX - 1 + subY * width);
                } else
                {
                    target = input.get(subX + subY * width);
                }
            }

            ItemStack slot = inv.getStackInRowAndColumn(x, y);

            if (!target.apply(slot) || damage > slot.getMaxDamage() - slot.getItemDamage() + 1)
            {
                return false;
            }
        }
    }

    return true;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:39,代碼來源:DamageableShapedOreRecipe.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 "EnderRifle_empty"; }
	if (this.getCooldown(stack) > 0) { return "EnderRifle_hot"; }	// Cooling down

	return "EnderRifle";	// Regular
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:9,代碼來源:EnderRifle.java

示例6: 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.world.isDaytime() && !this.world.isRemote)
    {
        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.world.canSeeSky(blockpos))
        {
            boolean flag = true;
            ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

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

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

                flag = false;
            }

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

    super.onLivingUpdate();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:42,代碼來源:AbstractSkeleton.java

示例7: getModelTexPath

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "LapisCoil2_empty"; }		// Empty
	if (this.getCooldown(stack) > 0) { return "LapisCoil2_hot"; }	// Hot

	return "LapisCoil2";	// Regular
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:9,代碼來源:LapisCoil.java

示例8: getModelTexPath

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "RPG_Imp_empty"; }	// Empty

	return "RPG_Imp";	// Regular
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:8,代碼來源:RPG_Imp.java

示例9: getModelTexPath

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "CrossbowAutoImp_empty"; }	// Empty

	return "CrossbowAutoImp";	// Regular
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:8,代碼來源:Crossbow_AutoImp.java

示例10: getModelTexPath

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

	return "FenFire";	// Regular
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:9,代碼來源:FenFire.java

示例11: getItemStack

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public ItemStack getItemStack(Random random)
{
    ItemStack itemstack = this.returnStack.copy();

    if (this.maxDamagePercent > 0.0F)
    {
        int i = (int)(this.maxDamagePercent * (float)this.returnStack.getMaxDamage());
        int j = itemstack.getMaxDamage() - random.nextInt(random.nextInt(i) + 1);

        if (j > i)
        {
            j = i;
        }

        if (j < 1)
        {
            j = 1;
        }

        itemstack.setItemDamage(j);
    }

    if (this.enchantable)
    {
        EnchantmentHelper.addRandomEnchantment(random, itemstack, 30);
    }

    return itemstack;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:30,代碼來源:WeightedRandomFishable.java

示例12: getModelTexPath

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{ 
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "AquaAcc_empty"; }	// empty
	
	return "AquaAcc";	// Regular
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:8,代碼來源:AquaAccelerator.java

示例13: getModelTexPath

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public String getModelTexPath(ItemStack stack)	// The model texture path
{
	if (stack.getItemDamage() >= stack.getMaxDamage()) { return "FlintDuster_empty"; }		// empty
	if (this.getCooldown(stack) > 0) { return "FlintDuster_hot"; }	// Firing

	return "FlintDuster";	// Regular
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:9,代碼來源:FlintDuster.java

示例14: getRemainingItems

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv)
{
    NonNullList<ItemStack> items = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);

    matches(inv, null);

    for (int i = 0; i < invSlots.length; i++)
    {
        int amount = damageAmounts[i];
        int invIndex = invSlots[i];
        if (amount > 0)
        {
            ItemStack stack = inv.getStackInSlot(invIndex).copy();
            stack.setItemDamage(stack.getItemDamage() + amount);
            if (stack.getItemDamage() > stack.getMaxDamage())
            {
                stack = ForgeHooks.getContainerItem(stack);
            }
            items.set(invIndex, stack);
        } else
        {
            items.set(invIndex, ForgeHooks.getContainerItem(inv.getStackInSlot(invIndex)));
        }
    }

    return items;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:30,代碼來源:DamageableShapelessOreRecipe.java

示例15: addInformation

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {

    int damage = stack.getMaxDamage() - stack.getItemDamage() ;

    tooltip.add("Uses Left: \u00A7c" + damage);
    if (GuiScreen.isShiftKeyDown()) {
        tooltip.add(tooltipInfo);
    }
    if (!GuiScreen.isShiftKeyDown())
        tooltip.add(TextFormatting.AQUA + I18n.format("press.for.info.name", "SHIFT"));
}
 
開發者ID:OCDiary,項目名稱:TheOink,代碼行數:14,代碼來源:OinkTools.java


注:本文中的net.minecraft.item.ItemStack.getMaxDamage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。