本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent类的典型用法代码示例。如果您正苦于以下问题:Java LivingSetAttackTargetEvent类的具体用法?Java LivingSetAttackTargetEvent怎么用?Java LivingSetAttackTargetEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LivingSetAttackTargetEvent类属于net.minecraftforge.event.entity.living包,在下文中一共展示了LivingSetAttackTargetEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: checkSetTarget
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入依赖的package包/类
@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);
}
}
示例3: 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);
}
}
示例4: stopBodyGuardsFromAttackingNemeses
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入依赖的package包/类
@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);
}
}
}
示例5: onLivingSetAttackTarget
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入依赖的package包/类
@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);
}
}
}
示例6: onMobTargetSet
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; //导入依赖的package包/类
/**
* 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);
}
}
}
示例7: 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());
}
}
示例8: 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);
}
}
}
}
示例9: 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);
}
}
}
}
示例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)) {
return;
}
if(target.isPotionActive(PotionRegistry.getInstance().potionNinjaHidden)) {
if(attacker instanceof IEntityTrueSight && ((IEntityTrueSight) attacker).canSeeTarget((EntityPlayer) target)) {
return;
}
((EntityLiving) attacker).setAttackTarget(null);
}
}
示例11: 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);
}
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: 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);
}
}
示例15: 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);
}
}
}