本文整理汇总了Java中net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments方法的典型用法代码示例。如果您正苦于以下问题:Java EnchantmentHelper.applyThornEnchantments方法的具体用法?Java EnchantmentHelper.applyThornEnchantments怎么用?Java EnchantmentHelper.applyThornEnchantments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.enchantment.EnchantmentHelper
的用法示例。
在下文中一共展示了EnchantmentHelper.applyThornEnchantments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyEnchantments
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
protected void applyEnchantments(EntityLivingBase entityLivingBaseIn, Entity entityIn)
{
if (entityIn instanceof EntityLivingBase)
{
EnchantmentHelper.applyThornEnchantments((EntityLivingBase)entityIn, entityLivingBaseIn);
}
EnchantmentHelper.applyArthropodEnchantments(entityLivingBaseIn, entityIn);
}
示例2: onImpact
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
@Override
protected void onImpact(RayTraceResult result) {
if (result.typeOfHit == RayTraceResult.Type.ENTITY) {
EntityLivingBase thrower = getThrower();
// prevent damaging thrower
if (result.entityHit == thrower)
return;
Entity entity = result.entityHit;
DamageSource ds = createDamageSource(null == thrower ? this : thrower);
if (isBurning() && !(entity instanceof EntityEnderman))
entity.setFire(5);
if (entity.attackEntityFrom(ds, getDamage())) {
if (entity instanceof EntityLivingBase) {
EntityLivingBase base = (EntityLivingBase) entity;
if (knockbackStrength > 0) {
float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
if (f1 > 0f) {
base.addVelocity(motionX * knockbackStrength * 0.6000000238418579D / f1,
0.1D, motionZ * knockbackStrength * 0.6000000238418579D / f1);
}
}
if (null != thrower) {
EnchantmentHelper.applyThornEnchantments(base, thrower);
EnchantmentHelper.applyArthropodEnchantments(thrower, base);
if (base != thrower && base instanceof EntityPlayer && thrower instanceof EntityPlayerMP)
{
((EntityPlayerMP)thrower).connection.sendPacket(new SPacketChangeGameState(6, 0.0F));
}
}
}
}
}
if (!worldObj.isRemote)
setDead();
}