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


Java LivingAttackEvent.getEntity方法代码示例

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


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

示例1: onPlayerAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
/**
 * When player is morphed, he can deal an damage or effect onto the enemy. 
 * 
 * For example, if player is morphed into the wither skeleton, he also 
 * grants a target wither potion effect. Pretty realistic, however I don't 
 * really know what that does. 
 */
@SubscribeEvent
public void onPlayerAttack(LivingAttackEvent event)
{
    Entity source = event.getSource().getEntity();
    Entity target = event.getEntity();

    if (source instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) source;
        IMorphing capability = Morphing.get(player);

        if (capability == null || !capability.isMorphed())
        {
            return;
        }

        capability.getCurrentMorph().attack(target, player);
    }
}
 
开发者ID:mchorse,项目名称:metamorph,代码行数:27,代码来源:MorphHandler.java

示例2: onLivingAttackEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttackEvent(LivingAttackEvent event)
{
    if (event.getEntity() == null || event.getSource().getEntity() != Minecraft.getMinecraft().player)
        return;
    synchronized (this.damages)
    {
        for (MobWithReward mob : this.params.getMob())
        {
            // Have we caught one of these mobs?
            for (EntityTypes et : mob.getType())
            {
                String mobName = et.value();
                if (event.getEntity().getName().equals(mobName))
                {
                    if (this.damages.containsKey(mob))
                        this.damages.put(mob, this.damages.get(mob) + event.getAmount());
                    else
                        this.damages.put(mob, event.getAmount());
                }
            }
        }
    }
}
 
开发者ID:Microsoft,项目名称:malmo,代码行数:25,代码来源:RewardForDamagingEntityImplementation.java

示例3: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent evt) {
	if (evt.getEntity() instanceof EntityPlayer && evt.getSource() instanceof EntityDamageSource) {
		EntityDamageSource source = (EntityDamageSource) evt.getSource();
		if (source.getEntity() instanceof EntityPlayer) {
			EntityPlayer attacker = (EntityPlayer) source.getEntity();
			EntityPlayer damagee = (EntityPlayer) evt.getEntity();

			ItemStack attackerBoots = attacker.inventory.armorItemInSlot(0);
			ItemStack damageeBoots = damagee.inventory.armorItemInSlot(0);
			if (attackerBoots != null && damageeBoots != null && attackerBoots == damageeBoots) {
				Item id = damageeBoots.getItem();
				if (id == WarsItems.redBoots || id == WarsItems.greenBoots || id == WarsItems.blueBoots || id == WarsItems.yellowBoots) {
					evt.setCanceled(true);
				}
			}
		}
	}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Wars-Mod,代码行数:20,代码来源:CommonEvents.java

示例4: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event){
    if(DifficultyManager.enabled) {
        Entity causeMob = event.getSource().getTrueSource();
        if (causeMob instanceof EntityLiving
                && event.getEntity() instanceof EntityPlayer
                && MobNBTHandler.isModifiedMob((EntityLiving) causeMob)) {
            Map<String, Integer> changes = MobNBTHandler.getChangeMap((EntityLiving) causeMob);
            String regionName = MobNBTHandler.getEntityRegion((EntityLiving) causeMob);
            Region mobRegion = DifficultyManager.getRegionByName(regionName);
            String mobId = EntityList.getEntityString(causeMob);
            for (String change : changes.keySet()) {
                try {
                    DifficultyModifier modifier = mobRegion.getModifierForMobById(mobId, change);
                    if (modifier != null) {
                        modifier.handleDamageEvent(event);
                    }
                } catch (Exception e) {
                    LOG.warn("Error applying modifier at onLivingAttack.  Mob was " + causeMob.getName() + ", Modifier was " + change + ".  Please report to Progressive Difficulty Developer!");
                    LOG.warn("\tCaught Exception had message " + e.getMessage());
                }
            }
        } else if (event.getSource().getImmediateSource() instanceof PotionCloudModifier.PlayerEffectingOnlyEntityAreaEffectCloud
                && !(event.getEntity() instanceof EntityPlayer)) {
            event.setCanceled(true);
        }
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:29,代码来源:EventHandler.java

示例5: handleDamageEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void handleDamageEvent(LivingAttackEvent event) {
    super.handleDamageEvent(event);
    if(!(event.getEntity() instanceof EntityLivingBase))
        return;
    EntityLivingBase hitEntity = (EntityLivingBase)event.getEntity();
    EntityLiving cause = (EntityLiving)event.getSource().getTrueSource();
    int level = MobNBTHandler.getModifierLevel(cause,identifier);
    hitEntity.addPotionEffect(new PotionEffect(effect, duration,level,false,false));
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:11,代码来源:OnHitEffectModifier.java

示例6: playerAttacked

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
/** Alters behaviour when the player takes damage. */
@SubscribeEvent
public void playerAttacked(LivingAttackEvent event) {
    
    if (!(event.getEntity() instanceof EntityPlayer)) {
        
        return;
    }
    
    EntityPlayer player = (EntityPlayer) event.getEntity();
    DamageSource source = event.getSource();
    
    // Copy vanilla shield functionality to allow for custom shields
    if (!source.isUnblockable() && player.isActiveItemStackBlocking() &&
            player.getActiveItemStack().getItem() instanceof ItemShield) {
        
        Vec3d sourceVec = source.getDamageLocation();

        if (sourceVec != null) {
            
            Vec3d playerVec = player.getLook(1.0F);
            Vec3d attackVec = sourceVec.subtractReverse(new
                    Vec3d(player.posX, player.posY,
                    player.posZ)).normalize();
            attackVec = new Vec3d(attackVec.xCoord,
                    0.0D, attackVec.zCoord);

            if (attackVec.dotProduct(playerVec) < 0.0D &&
                    event.getAmount() >= 3) {
                
                player.getActiveItemStack().damageItem(1 +
                        MathHelper.floor(event.getAmount()), player);
            }
        }
    }
}
 
开发者ID:JayAvery,项目名称:geomastery,代码行数:37,代码来源:PlayerEvents.java

示例7: onLivingHurt

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void onLivingHurt(LivingAttackEvent event) {
  // if it's cancelled it got handled by the battlesign (or something else. but it's a prerequisite.)
  if(!event.isCanceled()) {
    return;
  }
  if(event.getSource().isUnblockable() || !event.getSource().isProjectile() || event.getSource().getTrueSource() == null) {
    return;
  }
  // hit entity is a player?
  if(!(event.getEntity() instanceof EntityPlayer)) {
    return;
  }
  EntityPlayer player = (EntityPlayer) event.getEntity();
  // needs to be blocking with a battlesign
  if(!player.isActiveItemStackBlocking() || player.getActiveItemStack().getItem() != TinkerMeleeWeapons.battleSign) {
    return;
  }
  // broken battlesign.
  if(ToolHelper.isBroken(player.getActiveItemStack())) {
    return;
  }

  // at this point we duplicated all the logic if the battlesign should reflect a projectile.. bleh.
  int xp = Math.max(1, Math.round(event.getAmount()));
  addXp(player.getActiveItemStack(), xp, player);
}
 
开发者ID:SlimeKnights,项目名称:TinkersToolLeveling,代码行数:28,代码来源:ModToolLeveling.java

示例8: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (!(event.getEntity() instanceof EntityPlayerMP)) return;
	
	if (!getPlayerSettings((EntityPlayerMP) event.getEntity()).mobdamage) {
		if (event.getSource().getImmediateSource() instanceof EntityCreature || event.getSource().getTrueSource() instanceof EntityCreature)
			event.setCanceled(true);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:10,代码来源:CommandMobdamage.java

示例9: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (!(event.getEntity() instanceof EntityPlayerMP)) return;
	
	if (getPlayerSettings((EntityPlayerMP) event.getEntity()).killattacker) {
		if (event.getSource().getImmediateSource() instanceof EntityCreature || event.getSource().getTrueSource() instanceof EntityCreature) {
			if (event.getSource().getImmediateSource() instanceof EntityCreature) 
				event.getSource().getImmediateSource().attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) event.getEntity()), Float.MAX_VALUE);
			if (event.getSource().getTrueSource() instanceof EntityCreature)
				event.getSource().getTrueSource().attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) event.getEntity()), Float.MAX_VALUE);
		}
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:14,代码来源:CommandKillattacker.java

示例10: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP && event.getSource() == DamageSource.DROWN) {
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		if (!getPlayerSettings((EntityPlayerMP) player).waterdamage) event.setCanceled(true);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandWaterdamage.java

示例11: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP && (event.getSource() == DamageSource.IN_FIRE || event.getSource() == DamageSource.ON_FIRE || event.getSource() == DamageSource.LAVA)) {
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		if (!getPlayerSettings(player).firedamage) event.setCanceled(true);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandFiredamage.java

示例12: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (!(event.getEntity() instanceof EntityPlayerMP)) return;
	
	if (!getPlayerSettings((EntityPlayerMP) event.getEntity()).damage)
		event.setCanceled(true);
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandDamage.java

示例13: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP && 
		((EntityPlayerMP) event.getEntity()).connection instanceof NetHandlerPlayServer &&
		((NetHandlerPlayServer) ((EntityPlayerMP) event.getEntity()).connection).getOverrideNoclip() 
		&& event.getSource() == DamageSource.IN_WALL) event.setCanceled(true);
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandNoclip.java

示例14: jimmysSwordPvP

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void jimmysSwordPvP(LivingAttackEvent event) {
	if (event.getSource().getEntity() instanceof EntityPlayerMP && event.getEntity() instanceof EntityPlayerMP
			&& isUsingProcSword((EntityPlayerMP) event.getSource().getEntity()) && !Settings.Abilities.canJimmyPvP) {
		event.setCanceled(true);
	}
}
 
开发者ID:Nincraft,项目名称:NincraftLib,代码行数:8,代码来源:ProcHandler.java

示例15: onAttackEntity

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(LivingAttackEvent event)
{
    // When a "passified" entity is attacked by another entity, remove the "passified" tag,
    // and restore the target AI tasks by re-adding all the AI tasks from a fresh clone
    if ((event.getEntity() instanceof EntityLiving) && event.getEntity().getEntityWorld().isRemote == false &&
        event.getSource() instanceof EntityDamageSource && event.getEntity().getTags().contains(ItemSyringe.TAG_PASSIFIED))
    {
        ItemSyringe.removePassifiedState((EntityLiving) event.getEntity());
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:12,代码来源:EntityEventHandler.java


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