本文整理了Java中net.minecraft.entity.Entity.canBeAttackedWithItem()
方法的一些代码示例,展示了Entity.canBeAttackedWithItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.canBeAttackedWithItem()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:canBeAttackedWithItem
暂无
代码示例来源:origin: TeamWizardry/Wizardry
@SubscribeEvent
public static void onAttackEntity(AttackEntityEvent event) {
if (event.getTarget().canBeAttackedWithItem() && !event.getTarget().hitByEntity(event.getEntity()) && event.getTarget() instanceof EntityLivingBase && event.getTarget().hurtResistantTime <= 0) {
EntityLivingBase attacker = event.getEntityLiving();
EntityLivingBase target = (EntityLivingBase) event.getTarget();
if (attacker.getHeldItemMainhand() == ItemStack.EMPTY)
return;
if (attacker.getHeldItemMainhand().getItem() != ModItems.UNICORN_DAGGER)
return;
float damage = 1 + EnchantmentHelper.getEnchantmentLevel(Enchantments.KNOCKBACK, attacker.getHeldItemMainhand());
float attackCD = attacker instanceof EntityPlayer ? ((EntityPlayer) attacker).getCooledAttackStrength(0.5F) : 1;
damage *= (0.2f + attackCD * attackCD * 0.8f);
target.attackEntityFrom(DamageSource.causeIndirectMagicDamage(attacker, null), damage);
target.hurtResistantTime = 0;
}
}
}
代码示例来源:origin: Glitchfiend/ToughAsNails
if (target.canBeAttackedWithItem() && !player.isCreative())
代码示例来源:origin: Mine-and-blade-admin/Battlegear2
return;
if (target.canBeAttackedWithItem() && !target.hitByEntity(player)){
float f = (float)player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
float f1;
内容来源于网络,如有侵权,请联系作者删除!