当前位置: 首页>>代码示例>>Java>>正文


Java LivingHurtEvent.getSource方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java LivingHurtEvent.getSource方法的具体用法?Java LivingHurtEvent.getSource怎么用?Java LivingHurtEvent.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.living.LivingHurtEvent的用法示例。


在下文中一共展示了LivingHurtEvent.getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onHurtEvent

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onHurtEvent(LivingHurtEvent event)
{
    EntityLivingBase entity = event.getEntityLiving();
    DamageSource damageSource = event.getSource();
    float damage = event.getAmount();
    if(entity != null)
    {
        IAttributeInstance damageRate = null;
        if(isPhysicalDamage(damageSource))
            damageRate = entity.getEntityAttribute(PHYSICAL_DAMAGE_RATE);
        if(damageSource.isFireDamage())
            damageRate = entity.getEntityAttribute(FIRE_DAMAGE_RATE);

        if(damageRate != null)
            damage *= damageRate.getAttributeValue();
    }
    event.setAmount(damage);
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:20,代码来源:Attributes.java

示例2: attackEntity

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
	try
	{
		if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
				&& (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof BaseHarshenSword ||
					((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
			   &&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
			event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
	}
	catch (ClassCastException clazz){}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HandlerSoulHarsherSword.java

示例3: attackEntity

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
	try
	{
		if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
				&& (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof RaptorScythe ||
					((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
			   &&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
			event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
	}
	catch (ClassCastException clazz){}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HandlerRaptorScythe.java

示例4: onHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的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

示例5: postInit

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void postInit(LivingHurtEvent e) {

	DamageSource source = e.getSource();

	Iterable<ItemStack> armorStacks = e.getEntityLiving().getArmorInventoryList();

	// boolean hasHeavyArmor = false;
	float reduction = 0;

	for (ItemStack armorStack : armorStacks) {
		if (isHeavyArmor(armorStack)) {
			if (source.isProjectile() || source.isExplosion()) {
				reduction += 0.2;
			}
		}
	}

	if (reduction > 0) {
		float newDamage = (1 - reduction) * e.getAmount();
		System.out.println("Heavy armor reduction: [" + reduction + "] IN[" + e.getAmount() + "] OUT[" + newDamage + "]");
		e.setAmount(newDamage);
	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:25,代码来源:ItemReinforcedDiamondArmor.java

示例6: fallOutOfTeletory

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void fallOutOfTeletory(LivingHurtEvent ev) {
	if (ev.getEntity().getEntityWorld().isRemote || !(ev.getEntity() instanceof EntityPlayerMP)) {
		return;
	}

	if (ev.getSource() != DamageSource.OUT_OF_WORLD) {
		return;
	}

	EntityPlayerMP thePlayer = (EntityPlayerMP) ev.getEntity();

	if (thePlayer.dimension != Teletory.DIMID) {
		return;
	}
	ev.setCanceled(true);
	changeEntityDimension(thePlayer, TeleportorType.FALL);
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:19,代码来源:Teletory.java

示例7: hurtEvents

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void hurtEvents(LivingHurtEvent e) {
    if (!e.getEntity().getEntityWorld().isRemote) {
        DamageSource source = e.getSource();
        Entity entity = e.getEntity();

        if (entity == null || entity.isDead) {
            return;
        }

        if (source == DamageSource.drown && entity.isWet() && entity instanceof EntityPlayer && ConfigurationFile.hardcoreAir) {
            ((EntityPlayer) entity).setHealth(0.0f);
        } else if (source == DamageSource.starve && entity instanceof EntityPlayer && ConfigurationFile.hardcoreHunger) {
            ((EntityPlayer) entity).setHealth(0.0f);
        } else if (source.getEntity() instanceof EntityPlayer && ConfigurationFile.mobsRevengeMode) {
            if (!(entity instanceof EntityPlayer) && entity instanceof EntityLiving) {
                ((EntityLiving) entity).addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 100, 1));
            }
        }
    }
}
 
开发者ID:baileyholl,项目名称:Event-Tweaks,代码行数:22,代码来源:MobEventHandler.java

示例8: onLivingHurtEvent

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurtEvent(LivingHurtEvent event) {
	if (event.getEntity() != null && event.getEntity() instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer)event.getEntity();
		
		for (ItemStack armor : player.getArmorInventoryList()) {
		    if (armor != null && armor.getItem() instanceof LongFallBoots)
		    {
		    	if (event.getSource() == DamageSource.FLY_INTO_WALL) {
		    		System.out.println("Flew into wall");
					// this cancels the fall event so you take no damage
					event.setCanceled(true);
		    	}
		    }
		}
	}
}
 
开发者ID:yyon,项目名称:grapplemod,代码行数:19,代码来源:LongFallBoots.java

示例9: onEntityDamage

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityDamage(LivingHurtEvent event) {
	DamageSource source = event.getSource();

	Entity attacker = source.getTrueSource();
	if ((attacker instanceof EntityLivingBase) && ((EntityLivingBase) attacker).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) {
		event.setAmount(event.getAmount() * 0.95F);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:ItemSilverArmor.java

示例10: onEntityHit

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityHit(LivingHurtEvent event)
{
	if(event.getSource() instanceof EntityDamageSource && ((EntityDamageSource) event.getSource()).getTrueSource() instanceof EntityLivingBase && 
			((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof GlassContainer && 
			((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand().getItemDamage() == 0)
	{
		ItemStack stack = ((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand();
		stack.setItemDamage(2);
		((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).setHeldItem(EnumHand.MAIN_HAND, stack);
	}		
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:13,代码来源:HandlerGlassContainer.java

示例11: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
	if(new Random().nextDouble() < GeneralConfig.bloodChance && event.getSource() instanceof EntityDamageSource && HarshenUtils.toArray(AllowedEntities).contains(event.getEntity().getClass()))
		if(event.getEntity().world.isAirBlock(event.getEntity().getPosition()) && GeneralConfig.bloodDrops)
			event.getEntity().getEntityWorld().setBlockState(event.getEntity().getPosition(), HarshenBlocks.BLOOD_BLOCK.getDefaultState(), 3);
		else if(event.getSource().getTrueSource() instanceof EntityPlayer && GeneralConfig.bloodOffHand &&
				((EntityPlayer)event.getSource().getTrueSource()).getHeldItemOffhand().getItem() == HarshenItems.BLOOD_COLLECTOR)
			((BloodCollector)((EntityPlayer)event.getSource().getTrueSource()).getHeldItemOffhand().getItem()).fill(((EntityPlayer)event.getSource().getTrueSource()), EnumHand.OFF_HAND, 1);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:11,代码来源:HandlerBloodOnHurt.java

示例12: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@HarshenEvent
public void onLivingHurt(LivingHurtEvent event)
{
	if(event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityZombie &&
			!(((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityPigZombie))
		event.setAmount(1);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:8,代码来源:ZombiPendant.java

示例13: PlayerPunchedEvent

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
public PlayerPunchedEvent(LivingHurtEvent event, EntityPlayer attacker)
{
    super(event.getEntityLiving());
    this.source = event.getSource();
    this.amount = event.getAmount();
    this.attacker = attacker;
    this.event = event;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:9,代码来源:PlayerPunchedEvent.java

示例14: onHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
    DamageSource source = ev.getSource();
    Entity root = source.getTrueSource();
    if (root instanceof EntityLivingBase) {
        EntityLivingBase cause = (EntityLivingBase) root;
        EntityLivingBase hurt = ev.getEntityLiving();
        if (EmpoweredEnchantment.appliedTo(hurt)) {
            EmpoweredEnchantment.doArmor(hurt, cause);
        }
    }
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:13,代码来源:EmpoweredArmorListener.java

示例15: onHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的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


注:本文中的net.minecraftforge.event.entity.living.LivingHurtEvent.getSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。