本文整理汇总了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);
}
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}