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


Java LivingSetAttackTargetEvent.getEntityLiving方法代码示例

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


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

示例1: onTargetSelect

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
		}
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:18,代码来源:ModEvents.java

示例2: untargetable

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
		}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:17,代码来源:TF2EventsCommon.java

示例3: warnPlayerIfNecessary

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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());
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:13,代码来源:EventHandlerPneumaticCraft.java

示例4: onLivingSetTarget

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:Fararise,项目名称:Possessed,代码行数:28,代码来源:ServerEventHandler.java

示例5: onLivingSetAttackTarget

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
/**
 * 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);
            }
        }
    }
}
 
开发者ID:mchorse,项目名称:metamorph,代码行数:37,代码来源:MorphHandler.java

示例6: onEntityTargetingEvent

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:InfinityRaider,项目名称:NinjaGear,代码行数:16,代码来源:EntityTargetingHandler.java

示例7: onLivingSetAttackTarget

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:16,代码来源:ItemHeadForestBat.java

示例8: onLivingSetAttackTarget

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:8,代码来源:PotionWitchcraft.java

示例9: onLivingSetAttackTarget

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:15,代码来源:PotionElapse.java

示例10: onEntityTargetingEvent

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:InfinityRaider,项目名称:InfinityLib,代码行数:13,代码来源:PlayerStateHandler.java

示例11: onEvent1

import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入方法依赖的package包/类
@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);
		}
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:10,代码来源:CommandNoattack.java


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