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


Java ItemStack.isItemStackDamageable方法代碼示例

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


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

示例1: performEffect

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
		EntityLivingBase entity = (EntityLivingBase) rtrace.entityHit;
		EnumHand hand = null;
		if (!entity.getHeldItemMainhand().isEmpty()) hand = EnumHand.MAIN_HAND;
		else if (!entity.getHeldItemOffhand().isEmpty()) hand = EnumHand.OFF_HAND;
		if (hand != null) {
			ItemStack stack = entity.getHeldItem(hand).copy();
			entity.setHeldItem(hand, ItemStack.EMPTY);
			if (!(entity instanceof EntityPlayer) && stack.isItemStackDamageable() && stack.getItemDamage() == 0) {
				stack.setItemDamage((int) (stack.getMaxDamage() * (0.5D + 0.5D * Math.random())));
			}
			EntityItem ei = new EntityItem(world, entity.posX, entity.posY, entity.posZ, stack);
			ei.setPickupDelay(200);
			ei.setNoDespawn();
			if (!world.isRemote) world.spawnEntity(ei);
		}
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:21,代碼來源:SpellDisarming.java

示例2: getContainerItem

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public static ItemStack getContainerItem(ItemStack stack)
{
    if (stack == null) return null;

    if (stack.getItem().hasContainerItem(stack))
    {
        stack = stack.getItem().getContainerItem(stack);
        if (stack != null && stack.isItemStackDamageable() && stack.getMetadata() > stack.getMaxDamage())
        {
            ForgeEventFactory.onPlayerDestroyItem(craftingPlayer.get(), stack, null);
            return null;
        }
        return stack;
    }
    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:ForgeHooks.java

示例3: apply

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    if (stack.isItemStackDamageable())
    {
        float f = 1.0F - this.damageRange.generateFloat(rand);
        stack.setItemDamage(MathHelper.floor(f * (float)stack.getMaxDamage()));
    }
    else
    {
        LOGGER.warn("Couldn\'t set damage of loot item {}", new Object[] {stack});
    }

    return stack;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:15,代碼來源:SetDamage.java

示例4: onEntityUpdate

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event)
{
	EntityLivingBase living = event.getEntityLiving();
	if(living instanceof IBurnInDay && living.world.isDaytime() && !living.world.isRemote && !living.isChild() && ((IBurnInDay)living).shouldBurn() && living.getBrightness() > 0.5F && 
			living.getRNG().nextFloat() * 30.0F < (living.getBrightness() - 0.4F) * 2.0F && living.world.canSeeSky(new BlockPos(living.posX, living.posY + (double)living.getEyeHeight(), living.posZ)))
	{
		boolean flag = true;
           ItemStack itemstack = living.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
           if (!itemstack.isEmpty())
           {
               if (itemstack.isItemStackDamageable())
               {
                   itemstack.setItemDamage(itemstack.getItemDamage() + living.getRNG().nextInt(2));

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

               flag = false;
           }

           if (flag)
           {
           	living.setFire(8);
           }
	}
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:32,代碼來源:HandlerBurnInDaylight.java

示例5: updateTick

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * The update tick for the ingame UI
 */
public void updateTick() {
	if (this.recordPlayingUpFor > 0) {
		--this.recordPlayingUpFor;
	}

	if (this.field_175195_w > 0) {
		--this.field_175195_w;

		if (this.field_175195_w <= 0) {
			this.field_175201_x = "";
			this.field_175200_y = "";
		}
	}

	++this.updateCounter;
	this.streamIndicator.func_152439_a();

	if (this.mc.thePlayer != null) {
		ItemStack itemstack = this.mc.thePlayer.inventory.getCurrentItem();

		if (itemstack == null) {
			this.remainingHighlightTicks = 0;
		} else if (this.highlightingItemStack != null && itemstack.getItem() == this.highlightingItemStack.getItem()
				&& ItemStack.areItemStackTagsEqual(itemstack, this.highlightingItemStack)
				&& (itemstack.isItemStackDamageable()
						|| itemstack.getMetadata() == this.highlightingItemStack.getMetadata())) {
			if (this.remainingHighlightTicks > 0) {
				--this.remainingHighlightTicks;
			}
		} else {
			this.remainingHighlightTicks = 40;
		}

		this.highlightingItemStack = itemstack;
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:40,代碼來源:GuiIngame.java

示例6: isHittingPosition

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
private boolean isHittingPosition(BlockPos pos)
{
    ItemStack itemstack = this.mc.player.getHeldItemMainhand();
    boolean flag = this.currentItemHittingBlock.func_190926_b() && itemstack.func_190926_b();

    if (!this.currentItemHittingBlock.func_190926_b() && !itemstack.func_190926_b())
    {
        flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.currentItemHittingBlock.getMetadata());
    }

    return pos.equals(this.currentBlock) && flag;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:13,代碼來源:PlayerControllerMP.java

示例7: 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)
    {
        float f = this.getBrightness(1.0F);
        BlockPos blockpos = 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.getEquipmentInSlot(4);

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

                    if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
                    {
                        this.renderBrokenItemStack(itemstack);
                        this.setCurrentItemOrArmor(4, (ItemStack)null);
                    }
                }

                flag = false;
            }

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

    if (this.worldObj.isRemote && this.getSkeletonType() == 1)
    {
        this.setSize(0.72F, 2.535F);
    }

    super.onLivingUpdate();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:47,代碼來源:EntitySkeleton.java

示例8: canApply

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.isItemStackDamageable() ? true : super.canApply(stack);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:EnchantmentDurability.java

示例9: 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())
    {
        float f = this.getBrightness(1.0F);
        BlockPos blockpos = 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.getEquipmentInSlot(4);

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

                    if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
                    {
                        this.renderBrokenItemStack(itemstack);
                        this.setCurrentItemOrArmor(4, (ItemStack)null);
                    }
                }

                flag = false;
            }

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

    if (this.isRiding() && this.getAttackTarget() != null && this.ridingEntity instanceof EntityChicken)
    {
        ((EntityLiving)this.ridingEntity).getNavigator().setPath(this.getNavigator().getPath(), 1.5D);
    }

    super.onLivingUpdate();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:47,代碼來源:EntityZombie.java

示例10: processRightClick

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
    if (this.gameType == GameType.SPECTATOR)
    {
        return EnumActionResult.PASS;
    }
    else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
    {
        return EnumActionResult.PASS;
    }
    else
    {
        if (net.minecraftforge.common.ForgeHooks.onItemRightClick(player, hand, stack)) return net.minecraft.util.EnumActionResult.PASS;
        int i = stack.stackSize;
        int j = stack.getMetadata();
        ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
        ItemStack itemstack = (ItemStack)actionresult.getResult();

        if (itemstack == stack && itemstack.stackSize == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
        {
            return actionresult.getType();
        }
        else
        {
            player.setHeldItem(hand, itemstack);

            if (this.isCreative())
            {
                itemstack.stackSize = i;

                if (itemstack.isItemStackDamageable())
                {
                    itemstack.setItemDamage(j);
                }
            }

            if (itemstack.stackSize == 0)
            {
                player.setHeldItem(hand, (ItemStack)null);
                net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand);
            }

            if (!player.isHandActive())
            {
                ((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
            }

            return actionresult.getType();
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:52,代碼來源:PlayerInteractionManager.java

示例11: dropEquipment

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Drop the equipment for this entity.
 */
protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier)
{
    for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
    {
        ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);
        double d0;

        switch (entityequipmentslot.getSlotType())
        {
            case HAND:
                d0 = (double)this.inventoryHandsDropChances[entityequipmentslot.getIndex()];
                break;
            case ARMOR:
                d0 = (double)this.inventoryArmorDropChances[entityequipmentslot.getIndex()];
                break;
            default:
                d0 = 0.0D;
        }

        boolean flag = d0 > 1.0D;

        if (itemstack != null && (wasRecentlyHit || flag) && (double)(this.rand.nextFloat() - (float)lootingModifier * 0.01F) < d0)
        {
            if (!flag && itemstack.isItemStackDamageable())
            {
                int i = Math.max(itemstack.getMaxDamage() - 25, 1);
                int j = itemstack.getMaxDamage() - this.rand.nextInt(this.rand.nextInt(i) + 1);

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

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

                itemstack.setItemDamage(j);
            }

            this.entityDropItem(itemstack, 0.0F);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:49,代碼來源:EntityLiving.java

示例12: getMetadata

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
protected int getMetadata(ItemStack stack)
{
    return stack.isItemStackDamageable() ? 0 : stack.getMetadata();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:5,代碼來源:ItemModelMesher.java

示例13: damageAndDrop

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public static EntityItem damageAndDrop(EntityCreature entity, ItemStack stack) {
	if (stack.isItemStackDamageable()) {
		stack.setItemDamage(stack.getMaxDamage() - entity.getRNG().nextInt(1 + entity.getRNG().nextInt(Math.max(stack.getMaxDamage() - 3, 1))));
	}
	return drop(entity, stack);
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:7,代碼來源:DeathHandler.java

示例14: tryUseItem

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Attempts to right-click use an item by the given EntityPlayer in the given World
 */
public boolean tryUseItem(EntityPlayer player, World worldIn, ItemStack stack)
{
    if (this.gameType == WorldSettings.GameType.SPECTATOR)
    {
        return false;
    }
    else
    {
        int i = stack.stackSize;
        int j = stack.getMetadata();
        ItemStack itemstack = stack.useItemRightClick(worldIn, player);

        if (itemstack != stack || itemstack != null && (itemstack.stackSize != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getMetadata() != j))
        {
            player.inventory.mainInventory[player.inventory.currentItem] = itemstack;

            if (this.isCreative())
            {
                itemstack.stackSize = i;

                if (itemstack.isItemStackDamageable())
                {
                    itemstack.setItemDamage(j);
                }
            }

            if (itemstack.stackSize == 0)
            {
                player.inventory.mainInventory[player.inventory.currentItem] = null;
            }

            if (!player.isUsingItem())
            {
                ((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
            }

            return true;
        }
        else
        {
            return false;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:48,代碼來源:ItemInWorldManager.java


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