Java 类net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent 实例源码

项目:EndermanEvolution    文件:ModEvents.java   
@SubscribeEvent
public void onTargetSelect(LivingSetAttackTargetEvent e) {
    if (e.getEntityLiving() instanceof EntityEnderman && e.getTarget() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) e.getTarget();
        ItemStack stack = player.inventory.armorInventory.get(3);
        boolean stopAttack = false;
        if (!stack.isEmpty() && stack.getItem() instanceof ItemSkullBase) {
            ItemSkullBase skull = (ItemSkullBase) stack.getItem();
            if (skull.isEndermanSkull()) {
                stopAttack = true;
            }
        }
        if (stopAttack) {
            ((EntityLiving) e.getEntityLiving()).setAttackTarget(null);
        }
    }
}
项目:uniquecrops    文件:UCEventHandlerServer.java   
@SubscribeEvent
public void checkSetTarget(LivingSetAttackTargetEvent event) {

    if (event.getTarget() == null)
        return;
    if (!(event.getTarget() instanceof EntityPlayer) || event.getTarget() instanceof FakePlayer)
        return;
    if (!(event.getEntity() instanceof EntityLiving))
        return;

    EntityPlayer player = (EntityPlayer)event.getTarget();
    EntityLiving ent = (EntityLiving)event.getEntity();
    boolean flag = player.inventory.armorInventory[2] != null && player.inventory.armorInventory[2].getItem() == UCItems.poncho && NBTUtils.getInt(player.inventory.armorInventory[2], ItemGeneric.TAG_UPGRADE, -1) == 10;
    if (flag && ent.isNonBoss() && !(ent instanceof EntityGuardian || ent instanceof EntityShulker))
    {
        ent.setAttackTarget(null);
        ent.setRevengeTarget(null);
    }
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent
public void untargetable(LivingSetAttackTargetEvent event) {
    if (event.getTarget() != null
            && ((event.getTarget().hasCapability(TF2weapons.WEAPONS_CAP, null) && event.getTarget().getCapability(TF2weapons.WEAPONS_CAP, null).invisTicks >= 20))) {
        event.getEntityLiving().setRevengeTarget(null);
        if (event.getEntityLiving() instanceof EntityLiving) {
            ((EntityLiving) event.getEntity()).setAttackTarget(null);
        }
    }
    if (event.getTarget() != null
            && (event.getTarget().hasCapability(TF2weapons.WEAPONS_CAP, null) && 
                    ItemDisguiseKit.isDisguised(event.getTarget(),event.getEntityLiving()) && event.getEntityLiving().getAttackingEntity() != event.getTarget()))
        if (event.getEntityLiving() instanceof EntityLiving) {
            ((EntityLiving) event.getEntity()).setAttackTarget(null);
        }
}
项目:NemesisSystem    文件:SetAttackTargetHandler.java   
@SubscribeEvent
public void stopBodyGuardsFromAttackingNemeses(LivingSetAttackTargetEvent event) {
    World world = event.getEntity().getEntityWorld();

    if (world.isRemote) {
        return;
    }

    Entity entity = event.getEntity();

    if (event.getTarget() == null || !(event.getEntity() instanceof EntityCreature)) {
        return;
    }

    if (hasTag(entity, NemesisSystem.TAG_BODY_GUARD) || hasTag(entity, ToroTraits.TAG_SUMMONED_MOB)) {
        if (event.getTarget().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
            ((EntityCreature) event.getEntityLiving()).setAttackTarget(null);
        }
    }
}
项目:MoArmor    文件:ForgeEventHandler.java   
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if (event.target instanceof EntityPlayer && event.entityLiving instanceof EntityLiving)
    {
        EntityLiving el = (EntityLiving) event.entityLiving;
        EntityPlayer e = (EntityPlayer) event.target;

        if (!PlayerHelper.getProperties(e).isPlayerTargetable() && el.getDistanceSqToEntity(e) > 4)
        {
            if (PlayerHelper.armorHasAbility(e, PlayerHelper.AbilityCamouflage)) el.setAttackTarget(null);
        }
        else
        {
            PlayerHelper.getProperties(e).setTimeUntilUnseen(100);
        }
    }
}
项目:pnc-repressurized    文件:EventHandlerPneumaticCraft.java   
/**
 * Used by PneumaticHelmet
 *
 * @param event
 */
@SubscribeEvent
public void onMobTargetSet(LivingSetAttackTargetEvent event) {
    if (event.getEntity() instanceof EntityCreature) {
        if (!event.getEntity().world.isRemote) {
            NetworkHandler.sendToAllAround(
                    new PacketSetMobTarget((EntityCreature) event.getEntity(), event.getTarget()),
                    new NetworkRegistry.TargetPoint(event.getEntity().world.provider.getDimension(),
                            event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, TileEntityConstants.PACKET_UPDATE_DISTANCE));
        } else {
            warnPlayerIfNecessary(event);
        }
    }
}
项目:pnc-repressurized    文件:EventHandlerPneumaticCraft.java   
@SideOnly(Side.CLIENT)
private void warnPlayerIfNecessary(LivingSetAttackTargetEvent event) {
    EntityPlayer player = FMLClientHandler.instance().getClient().player;
    if (event.getTarget() == player && (event.getEntityLiving() instanceof EntityGolem || event.getEntityLiving() instanceof EntityMob)) {
        ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
        if (helmetStack.getItem() == Itemss.PNEUMATIC_HELMET && ((IPressurizable) helmetStack.getItem()).getPressure(helmetStack) > 0 && ItemPneumaticArmor.getUpgrades(EnumUpgrade.ENTITY_TRACKER, helmetStack) > 0 && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + EntityTrackUpgradeHandler.UPGRADE_NAME).checked) {
            HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).warnIfNecessary(event.getEntity());
        }
    } else {
        HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).removeTargetingEntity(event.getEntityLiving());
    }
}
项目:Possessed    文件:ServerEventHandler.java   
@SubscribeEvent
public void onLivingSetTarget(LivingSetAttackTargetEvent event) {
    if (event.getTarget() instanceof EntityPlayer && event.getEntityLiving() instanceof EntityLiving) {
        EntityPlayer player = (EntityPlayer) event.getTarget();
        PossessivePlayer possessivePlayer = PossessHandler.get(player);
        if (possessivePlayer != null) {
            EntityLiving entity = (EntityLiving) event.getEntityLiving();
            boolean cancelled = true;
            for (EntityAITasks.EntityAITaskEntry task : entity.targetTasks.taskEntries) {
                if (task.action instanceof EntityAINearestAttackableTarget) {
                    try {
                        Class<? extends EntityLivingBase> target = (Class<? extends EntityLivingBase>) ReflectionHandler.TARGET_CLASS.get(task.action);
                        if (target.isAssignableFrom(possessivePlayer.getPossessing().getClass())) {
                            cancelled = false;
                            break;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            if (cancelled) {
                entity.setAttackTarget(null);
            }
        }
    }
}
项目:metamorph    文件:MorphHandler.java   
/**
 * Another morphing handler.
 * 
 * This handler is responsible for canceling setting attack target for 
 * hostile morphs.
 */
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if (Metamorph.proxy.config.disable_morph_disguise)
    {
        return;
    }

    Entity target = event.getTarget();
    EntityLivingBase source = event.getEntityLiving();

    if (target instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) target;
        IMorphing morphing = Morphing.get(player);

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

        if (morphing.getCurrentMorph().settings.hostile && source.getAttackingEntity() != target)
        {
            if (source instanceof EntityLiving)
            {
                ((EntityLiving) event.getEntity()).setAttackTarget(null);
            }
        }
    }
}
项目:NinjaGear    文件:EntityTargetingHandler.java   
@SubscribeEvent
@SuppressWarnings("unused")
public void onEntityTargetingEvent(LivingSetAttackTargetEvent event) {
    EntityLivingBase target = event.getTarget();
    EntityLivingBase attacker = event.getEntityLiving();
    if(target == null || attacker == null || !(target instanceof EntityPlayer)) {
        return;
    }
    if(target.isPotionActive(PotionRegistry.getInstance().potionNinjaHidden)) {
        if(attacker instanceof IEntityTrueSight && ((IEntityTrueSight) attacker).canSeeTarget((EntityPlayer) target)) {
            return;
        }
        ((EntityLiving) attacker).setAttackTarget(null);
    }
}
项目:Alchemy    文件:ItemHeadForestBat.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event) {
    EntityLivingBase living = event.getEntityLiving();
    if (lastAttackTarget.get(living) != null) {
        lastAttackTarget.set(living, null);
        PotionEffect effect = living.getActivePotionEffect(MobEffects.GLOWING);
        if (effect == null || effect.getDuration() == 0)
            living.setGlowing(false);
    }
    EntityLivingBase target = (EntityLivingBase) event.getTarget();
    if (target != null && getFormLiving(target) != null) {
        lastAttackTarget.set(living, target);
        living.setGlowing(true);
    }
}
项目:Alchemy    文件:PotionWitchcraft.java   
@SubscribeEvent(priority = EventPriority.TOP)
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event) {
    if (event.getEntityLiving().isPotionActive(this) && event.getEntityLiving() instanceof EntityLiving) {
        ((EntityLiving) event.getEntityLiving()).attackTarget = null;
        AlchemyEventSystem.markEventIgnore(event);
    }
}
项目:Alchemy    文件:PotionElapse.java   
@SubscribeEvent(priority = EventPriority.TOP)
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event) {
    if (event.getEntityLiving() instanceof EntityLiving && event.getEntityLiving().isNonBoss()
        && event.getTarget() != null && event.getTarget().isPotionActive(this)
        && event.getEntityLiving().getCombatTracker().getBestAttacker() != event.getTarget()) {
        EntityLiving living = (EntityLiving) event.getEntityLiving();
        Class<EntityLivingBase> type = (Class<EntityLivingBase>) 
                (event.getEntityLiving() instanceof EntityPlayer ? EntityPlayer.class : event.getEntityLiving().getClass());
        living.attackTarget = EntityAIFindEntityNearestHelper.<EntityLivingBase>findNearest(
                living.attackTarget, type, null, NOT_ACTIVE
                .and(l -> EntityAIFindEntityNearestHelper.isSuitableLivingTarget(living, l)));
        AlchemyEventSystem.markEventIgnore(event);
    }
}
项目:InfinityLib    文件:PlayerStateHandler.java   
@SubscribeEvent
@SuppressWarnings("unused")
public void onEntityTargetingEvent(LivingSetAttackTargetEvent event) {
    EntityLivingBase target = event.getTarget();
    EntityLivingBase attacker = event.getEntityLiving();
    if(target == null || attacker == null || !(target instanceof EntityPlayer) || !(attacker instanceof EntityLiving)) {
        return;
    }
    if(getState((EntityPlayer) target).isUndetectable()) {
        ((EntityLiving) attacker).setAttackTarget(null);
    }
}
项目:morecommands    文件:CommandNoattack.java   
@Override
public void onEvent1(LivingSetAttackTargetEvent event) {
    if (event.getTarget() instanceof EntityPlayerMP && event.getEntityLiving() instanceof EntityLiving) {
        if (getPlayerSettings((EntityPlayerMP) event.getTarget()).disableAttacks.contains(event.getTarget().getClass())) {
            ((EntityLiving) event.getEntityLiving()).setAttackTarget(null);
            event.getEntityLiving().setRevengeTarget(null);
        }
    }
}
项目:MineFantasy    文件:EventManagerMF.java   
@ForgeSubscribe
public void setTarget(LivingSetAttackTargetEvent event)
{
    if(event.entity != null && event.target != null)
    {
        if(event.entityLiving.canEntityBeSeen(event.target))
        if(!TacticalManager.isDetected(event.target, event.entityLiving))
        {
                if(event.isCancelable())
                    event.setCanceled(true);
                else
                {
                    if(event.entityLiving instanceof EntityLiving)
                    {
                        ((EntityLiving)event.entityLiving).setAttackTarget(null);
                    }
                }
        }

        if(event.entityLiving instanceof EntityCreeper && !(event.target instanceof EntityPlayer))
            if(event.isCancelable())
            event.setCanceled(true);
            else
            {
                if(event.entityLiving instanceof EntityLiving)
                {
                    ((EntityLiving)event.entityLiving).setAttackTarget(null);
                }
            }
    }
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if(event.getTarget() != null && event.getTarget() instanceof EntityPlayer && event.getTarget() != event.getEntityLiving().getAttackingEntity())
        if(PlayerUtils.isPlayerMountedOnCamera(event.getTarget()))
            ((EntityLiving)event.getEntityLiving()).setAttackTarget(null);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if(event.getTarget() != null && event.getTarget() instanceof EntityPlayer && event.getTarget() != event.getEntityLiving().getAttackingEntity())
        if(PlayerUtils.isPlayerMountedOnCamera(event.getTarget()))
            ((EntityLiving)event.getEntityLiving()).setAttackTarget(null);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if(event.target != null && event.target instanceof EntityPlayer && event.target != event.entityLiving.func_94060_bK())
        if(PlayerUtils.isPlayerMountedOnCamera(event.target))
            ((EntityLiving)event.entityLiving).setAttackTarget(null);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if(event.target != null && event.target instanceof EntityPlayer && event.target != event.entityLiving.getAttackingEntity())
        if(PlayerUtils.isPlayerMountedOnCamera(event.target))
            ((EntityLiving)event.entityLiving).setAttackTarget(null);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if(event.getTarget() != null && event.getTarget() instanceof EntityPlayer && event.getTarget() != event.getEntityLiving().getAttackingEntity())
        if(PlayerUtils.isPlayerMountedOnCamera(event.getTarget()))
            ((EntityLiving)event.getEntityLiving()).setAttackTarget(null);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
    if(event.target != null && event.target instanceof EntityPlayer && event.target != event.entityLiving.func_94060_bK())
        if(PlayerUtils.isPlayerMountedOnCamera(event.target))
            ((EntityLiving)event.entityLiving).setAttackTarget(null);
}
项目:FysiksFun    文件:EventListener.java   
@ForgeSubscribe
public void animalIsDamagedByEntity(LivingSetAttackTargetEvent event) {
  EntityLivingBase entity = event.entityLiving;
  if(!(entity instanceof EntityAnimal)) return;
  if(!FysiksFun.settings.doAnimalAI) return;
  EntityAICoward.registerEntityThreat(event.target);   
}
项目:ZeldaSwordSkills    文件:ZSSCombatEvents.java   
@SubscribeEvent
public void onSetAttackTarget(LivingSetAttackTargetEvent event) {
    if (event.target instanceof EntityPlayer && event.entity instanceof EntityLiving) {
        ItemStack mask = ((EntityPlayer) event.target).getCurrentArmor(ArmorIndex.WORN_HELM);
        if (mask != null && mask.getItem() == ZSSItems.maskSpooky && event.entityLiving.getAttackingEntity() != event.target) {
            ((EntityLiving) event.entity).setAttackTarget(null);
        }
    }
}
项目:PneumaticCraft    文件:EventHandlerPneumaticCraft.java   
/**
 * Used by PneumaticHelmet
 * @param event
 */
@SubscribeEvent
public void onMobTargetSet(LivingSetAttackTargetEvent event){
    if(event.entity instanceof EntityCreature) {
        if(!event.entity.worldObj.isRemote) {
            NetworkHandler.sendToAllAround(new PacketSetMobTarget((EntityCreature)event.entity, event.target), new NetworkRegistry.TargetPoint(event.entity.worldObj.provider.dimensionId, event.entity.posX, event.entity.posY, event.entity.posZ, TileEntityConstants.PACKET_UPDATE_DISTANCE));
        } else {
            warnPlayerIfNecessary(event);
        }
    }
}
项目:PneumaticCraft    文件:EventHandlerPneumaticCraft.java   
@SideOnly(Side.CLIENT)
private void warnPlayerIfNecessary(LivingSetAttackTargetEvent event){
    EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
    if(event.target == player && (event.entityLiving instanceof EntityGolem || event.entityLiving instanceof EntityMob)) {
        ItemStack helmetStack = player.getCurrentArmor(3);
        if(helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet && ((IPressurizable)helmetStack.getItem()).getPressure(helmetStack) > 0 && ItemPneumaticArmor.getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER, helmetStack) > 0 && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + EntityTrackUpgradeHandler.UPGRADE_NAME).checked) {
            HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).warnIfNecessary(event.entityLiving);
        }
    } else {
        HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).removeTargetingEntity(event.entityLiving);
    }
}
项目:CustomWorldGen    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:TRHS_Club_Mod_2016    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:CauldronGit    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:Cauldron    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:Cauldron    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:Cauldron    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:RuneCraftery    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:RuneCraftery    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:BetterNutritionMod    文件:ForgeHooks.java   
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
{
    MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
项目:ShadowsOfPhysis    文件:IEventGear.java   
public void onUserTargeted(LivingSetAttackTargetEvent event, ItemStack stack);