本文整理汇总了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;
}
}
}
}
示例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);
}
示例3: getContainerItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack getContainerItem(ItemStack itemstack) {
itemstack.attemptDamageItem(1, itemRand);
return itemstack;
}
示例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);
}
}