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


Java LivingHurtEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingHurtEvent的典型用法代碼示例。如果您正苦於以下問題:Java LivingHurtEvent類的具體用法?Java LivingHurtEvent怎麽用?Java LivingHurtEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LivingHurtEvent類屬於net.minecraftforge.event.entity.living包,在下文中一共展示了LivingHurtEvent類的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: recalc

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
  public void recalc(LivingHurtEvent event) {
if (!(event.entity instanceof EntityPlayer)) {
	return;
}
EntityPlayer player = (EntityPlayer) event.entity;
if (!AbilityData.get(player).isSkillLearned(SkillAirControl.INSTANCE)) {
	return;
}
if (event.source.getDamageType().equals("inWall") || event.source.getDamageType().equals("drown")) {
	event.ammount *= 0.1;
} else if (event.source.getDamageType().equals("fall")) {
	event.ammount *= 0.25;
} else if (event.source.isProjectile() || event.source.getDamageType().equals("anvil")) {
	event.ammount *= 0.75;
}
  }
 
開發者ID:Kanbe-Kotori,項目名稱:ExtraAcC,代碼行數:18,代碼來源:DamageRecalc.java

示例6: entityHurtEvent

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:26,代碼來源:ServerEventHandler.java

示例7: onHitEntity

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
public void onHitEntity(LivingHurtEvent event) {
	
	if (event.getAmount() <= 0 || event.getEntityLiving() instanceof EntityPlayer) return;
	
	if (!(event.getSource().getSourceOfDamage() instanceof EntityPlayer)) return;
	
	ItemStack transformer = BaublesApi.getBaublesHandler((EntityPlayer)event.getSource().getSourceOfDamage()).getStackInSlot(6);
	if (transformer == null || (transformer != null && transformer.getItem() != this)) return;
	
	Random rand = new Random();
	if (rand.nextInt(100) != 0) return;
	
	EntityLivingBase elb = event.getEntityLiving();
	List<String> entities = new ArrayList<String>(EntityList.ENTITY_EGGS.keySet());
	String randomString = entities.get(rand.nextInt(entities.size()));
	Entity entity = EntityList.createEntityByName(randomString, elb.worldObj);
	if (!entity.isNonBoss()) return;
	entity.setPositionAndRotation(elb.posX, elb.posY, elb.posZ, elb.rotationYaw, elb.rotationPitch);
	
	elb.worldObj.spawnEntityInWorld(entity);
	elb.setDead();
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:24,代碼來源:EmblemTransformation.java

示例8: obsidianArmor

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
/** Handle wearing obsidian armor */
private boolean obsidianArmor(LivingHurtEvent e) {
	EntityLivingBase hurt = e.getEntityLiving();

	// do things based on the armor status
	int armorCount = getWearingSetCount(hurt, ItemArmorObsidian.class);
	if(armorCount > 0) {
		
		// blast resistance II
		if(e.getSource().isExplosion()) {
			e.setAmount(e.getAmount() * (1 - armorCount / 4F));
		}
		
		return true;
	}
	return false;
}
 
開發者ID:sblectric,項目名稱:AdvancedCombat,代碼行數:18,代碼來源:ArmorHandler.java

示例9: livingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
public static void livingHurt(LivingHurtEvent event) {
	if (!event.getEntity().world.isRemote)
		if(event.getSource().getTrueSource() instanceof EntityArmyMember) {
			if (event.getEntityLiving() instanceof EntityPlayerMP) {
				if (event.getSource().isProjectile()) {
					if (event.getSource().getTrueSource() instanceof EntitySkeletonWarrior && ((EntitySkeletonWarrior) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
						CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 0);
					else if (event.getSource().getTrueSource() instanceof EntityConvertedSkeleton && ((EntityConvertedSkeleton) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
						CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 1);
				}
				if(ConfigValues.FF && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), event.getEntityLiving().getUniqueID()))
					event.setCanceled(true);
			} else if(ConfigValues.FF && event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
				event.setCanceled(true);
		} else if (ConfigValues.FF && event.getSource().getTrueSource() instanceof EntityPlayer) {
			if(event.getEntityLiving() instanceof EntityPlayer && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), event.getEntityLiving().getUniqueID()))
				event.setCanceled(true);
			else if(event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
				event.setCanceled(true);
		}
}
 
開發者ID:The-Fireplace-Minecraft-Mods,項目名稱:Overlord,代碼行數:23,代碼來源:CommonEvents.java

示例10: onEntityDamaged

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityDamaged(LivingHurtEvent event)
{
    if (event.source.damageType.equals(DamageSource.onFire.damageType))
    {
        if (OxygenUtil.noAtmosphericCombustion(event.entityLiving.worldObj.provider))
        {
	        if (OxygenUtil.isAABBInBreathableAirBlock(event.entityLiving.worldObj, event.entityLiving.boundingBox))
	        	return;

            if (event.entityLiving.worldObj instanceof WorldServer)
            {
                ((WorldServer) event.entityLiving.worldObj).func_147487_a("smoke", event.entityLiving.posX, event.entityLiving.posY + event.entityLiving.boundingBox.maxY - event.entityLiving.boundingBox.minY, event.entityLiving.posZ, 50, 0.0, 0.05, 0.0, 0.001);
            }

            event.entityLiving.extinguish();
        }
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:20,代碼來源:EventHandlerGC.java

示例11: reflecteffect

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
public void reflecteffect(LivingHurtEvent lde,EntityPlayerMP sender)
  {
    if ((Main.allowPFeather) && ((lde.entityLiving instanceof EntityPlayer)))
    {
      EntityPlayer ep = (EntityPlayer)lde.entityLiving;
  	if (((EntityLivingBase) ep).isPotionActive(ItemRegistry1.customPotion2))
      {
        if (!ep.worldObj.isRemote)
        {
        	 lde.setCanceled(true);
        	 
          ep.worldObj.playSoundAtEntity(ep, "fireworks.launch", 5.0F, 1.0F);
          ep.worldObj.playSoundAtEntity(ep, "assets.speedboost", 0.4F, 0.3F);
          ((EntityLivingBase) ep).removePotionEffect(ItemRegistry1.customPotion2.id);
        }
       
       
      }
    }
  }
 
開發者ID:GhostMonk3408,項目名稱:MidgarCrusade,代碼行數:22,代碼來源:ForgeEventHooksHandler.java

示例12: 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

示例13: onPlayerFall

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unused")
public void onPlayerFall(LivingHurtEvent event) {
    if(!(event.getEntity() instanceof EntityPlayer)) {
        return;
    }
    if(!event.getSource().damageType.equals(DamageSource.FALL.getDamageType())) {
        return;
    }
    EntityPlayer player = (EntityPlayer) event.getEntity();
    ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
    if(boots != null && boots.getItem() == ItemRegistry.getInstance().itemFallBoots) {
        event.setAmount((1.0F-ConfigurationHandler.getInstance().bootFallDamageReduction)*event.getAmount());
    }

}
 
開發者ID:InfinityRaider,項目名稱:3DManeuverGear,代碼行數:17,代碼來源:EntityLivingHandler.java

示例14: 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

示例15: onEntityAttacked

import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityAttacked(LivingHurtEvent event)
{
	Entity sourceEntity = event.getSource().getTrueSource();
	if (sourceEntity instanceof EntityLivingBase)
	{
		EntityLivingBase target = event.getEntityLiving();
		if (target == null)
			return;
		EntityLivingBase attacker = (EntityLivingBase) sourceEntity;
		ItemStack weapon = attacker.getHeldItemMainhand();
		ItemStack offhand = attacker.getHeldItemOffhand();
		if (offhand != null && offhand.getItem() instanceof IUpgradable)
			((IUpgradable) weapon.getItem()).onAttackEntity(event, attacker, target, weapon, offhand);
		if (weapon != null && weapon.getItem() instanceof IUpgradable)
			((IUpgradable) weapon.getItem()).onAttackEntity(event, attacker, target, weapon, offhand);
	}
}
 
開發者ID:murapix,項目名稱:Inhuman-Resources,代碼行數:19,代碼來源:EventHandler.java


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