当前位置: 首页>>代码示例>>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;未经允许,请勿转载。