本文整理匯總了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();
}