當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。