本文整理汇总了Java中net.minecraft.util.DamageSource.getImmediateSource方法的典型用法代码示例。如果您正苦于以下问题:Java DamageSource.getImmediateSource方法的具体用法?Java DamageSource.getImmediateSource怎么用?Java DamageSource.getImmediateSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.DamageSource
的用法示例。
在下文中一共展示了DamageSource.getImmediateSource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHurt
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
DamageSource source = ev.getSource();
Entity root = source.getImmediateSource();
if (root instanceof EntityLivingBase) {
EntityLivingBase cause = (EntityLivingBase) root;
EntityLivingBase hurt = ev.getEntityLiving();
EnumHand active = cause.getActiveHand();
ItemStack stack = cause.getHeldItem(active);
RandoresItemHelper.doEmpowered(stack, hurt, cause);
if(stack.getItem() instanceof RandoresSledgehammer) {
Vec3d vector = hurt.getPositionVector().subtract(cause.getPositionVector()).normalize().scale(2);
hurt.addVelocity(vector.x, 0.5, vector.z);
}
}
}
示例2: onDealDamage
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@Override
public void onDealDamage(ItemStack stack, EntityLivingBase attacker, Entity target, DamageSource source, float amount) {
super.onDealDamage(stack, attacker, target, source, amount);
if (target instanceof EntityLivingBase && !(target instanceof EntityBuilding)
&& getData(stack).getName().equals("sandmanball")) {
EntityBall ball = (EntityBall) source.getImmediateSource();
double reduce=Math.max(0.5, (25-((EntityLivingBase) target).getEntityAttribute(SharedMonsterAttributes.ARMOR).getAttributeValue())/25D);
if (!ball.canBePickedUp && ball.throwPos.squareDistanceTo(target.getPositionVector()) > 1100) {
TF2Util.stun((EntityLivingBase) target,
(int) (160 * reduce), true);
target.playSound(TF2Sounds.WEAPON_STUN_MAX, 4f, 1f);
} else if (!ball.canBePickedUp && ball.throwPos.squareDistanceTo(target.getPositionVector()) > 12) {
TF2Util.stun((EntityLivingBase) target,
(int) (ball.throwPos.distanceTo(target.getPositionVector()) * 8 * reduce), false);
target.playSound(TF2Sounds.WEAPON_STUN, 1.6f, 1f);
}
}
}
示例3: onHurt
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
Entity attacker = source.getImmediateSource();
int redo = 5 - amplifier;
if (attacker != null && (redo < 0 || attacker.world.rand.nextInt(redo) == 0)) {
float damage = event.getAmount();
attacker.attackEntityFrom(DamageSource.causeThornsDamage(affected), damage);
}
}
示例4: onHurt
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
Entity attacker = source.getImmediateSource();
if (attacker != null) {
event.setCanceled(true);
}
}
示例5: onHurt
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
Entity attacker = source.getImmediateSource();
if (attacker != null && source.isProjectile()) {
event.setCanceled(true);
}
}
示例6: onHurt
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
DamageSource source = event.getSource();
if (source != null && source.getImmediateSource() != null) {
Entity entity = source.getImmediateSource();
if (entity != null && entity instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase) entity;
if (attacker.getHeldItemMainhand().getItem() == ModItems.mace) {
float amount = Math.max(event.getAmount() - (20F / ((event.getEntityLiving().getTotalArmorValue() + 1F)) - 1F), (event.getAmount() / 3F));
event.setAmount(amount);
}
}
}
}
示例7: isPhysicalDamage
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
private static boolean isPhysicalDamage(DamageSource damageSource)
{
return damageSource.getImmediateSource() != null && !damageSource.isProjectile() && !damageSource.isExplosion() && !damageSource.isFireDamage() && !damageSource.isMagicDamage() && !damageSource.isDamageAbsolute();
}