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


Java ItemStack.attemptDamageItem方法代码示例

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


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

示例1: 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

示例2: autoShield

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SubscribeEvent
public void autoShield(LivingAttackEvent event) {
	
	if (!(event.getEntityLiving() instanceof EntityPlayer)) return;
	if (!(event.getSource().getSourceOfDamage() instanceof EntityArrow)) return;
	
	ItemStack shield = ((EntityPlayer)event.getEntityLiving()).getHeldItemOffhand();
	ItemStack emblem = BaublesApi.getBaublesHandler((EntityPlayer)event.getEntityLiving()).getStackInSlot(6);
	if (shield == null || emblem == null) return;
	if (emblem.getItem() != this || !(shield.getItem() instanceof ItemShield)) return;
	
	shield.attemptDamageItem(1, event.getEntityLiving().worldObj.rand);
	event.setCanceled(true);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:15,代码来源:EmblemDefense.java

示例3: getContainerItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack getContainerItem(ItemStack itemstack) {
	itemstack.attemptDamageItem(1, itemRand);
	return itemstack;
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:5,代码来源:TechnicalCrusher.java

示例4: handleArmorProtection

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static float handleArmorProtection(EntityPlayer player, DamageSource source, float amount, ItemStack armor, BodyPart damaged, EntityEquipmentSlot slotDamaged)
{
	if (source.isUnblockable())
	{
		return amount;
	}
	
	Item armorItem = armor.getItem();
	if (armorItem instanceof ISpecialArmor)
	{
		ISpecialArmor specialArmor = (ISpecialArmor) armorItem;
		float value = ArmorProperties.applyArmor(player, NonNullList.withSize(1, armor), source, amount);
		specialArmor.damageArmor(player, armor, source, (int) amount / 2, slotDamaged.getSlotIndex());
		return value;
	}
	else
	{
		Multimap<String, AttributeModifier> modifiers = armor.getAttributeModifiers(slotDamaged);
		float toughnessMod = 1;
		for (AttributeModifier mod : modifiers.get(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName()))
		{
			if (mod.getOperation() == 0)
			{
				toughnessMod += mod.getAmount();
			}
			else
			{
				toughnessMod *= mod.getAmount();
			}
		}

		if (player instanceof EntityPlayerMP)
		{
			if (armor.attemptDamageItem((int) (amount / 2), player.world.rand, (EntityPlayerMP) player))
			{
				armor.setCount(0);
			}
		}
		
		return amount * (1 / toughnessMod);
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:43,代码来源:PlayerManager.java


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