當前位置: 首頁>>代碼示例>>Java>>正文


Java DamageSource.getImmediateSource方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:Randores,項目名稱:Randores2,代碼行數:19,代碼來源:LivingHurtListener.java

示例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);
		}
	}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:19,代碼來源:ItemProjectileWeapon.java

示例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);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:10,代碼來源:ShellArmorBrew.java

示例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);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:8,代碼來源:OvercoatBrew.java

示例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);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:8,代碼來源:BulletProofBrew.java

示例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);
			}
		}
	}
}
 
開發者ID:the-realest-stu,項目名稱:Adventurers-Toolbox,代碼行數:15,代碼來源:WeaponHandler.java

示例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();
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:5,代碼來源:Attributes.java


注:本文中的net.minecraft.util.DamageSource.getImmediateSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。