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