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


Java AttackEntityEvent.getEntityPlayer方法代码示例

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


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

示例1: onWitherBoneAttackEvent

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onWitherBoneAttackEvent(AttackEntityEvent event) {
	
	EntityPlayer player = event.getEntityPlayer();
	ItemStack stack = player.getHeldItemMainhand();
	
	boolean flag = false;
	
	if (stack.getItem() instanceof IHaftTool) {
		if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
			flag = true;
		}
	}

	if (flag) {
		if (player.dimension != DimensionType.NETHER.getId()) {
			stack.damageItem(7, player);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:21,代码来源:SpecialToolAbilityHandler.java

示例2: onAttackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
  if (event.getTarget() instanceof EntityLivingBase == false) {
    return;
  }
  EntityLivingBase target = (EntityLivingBase) event.getTarget();
  EntityPlayer attacker = event.getEntityPlayer();
  ItemStack main = attacker.getHeldItemMainhand();
  ItemStack off = attacker.getHeldItemOffhand();
  int mainLevel = -1, offLevel = -1;
  if (main != null && EnchantmentHelper.getEnchantments(main).containsKey(this)) {
    mainLevel = EnchantmentHelper.getEnchantments(main).get(this);
  }
  if (off != null && EnchantmentHelper.getEnchantments(off).containsKey(this)) {
    offLevel = EnchantmentHelper.getEnchantments(off).get(this);
  }
  int level = Math.max(mainLevel, offLevel);
  if (level > 0) {
    // we -1  since potion level 1 is Poison II
    //so that means enchantment I giving poison I means this
    UtilEntity.addOrMergePotionEffect(target, new PotionEffect(MobEffects.POISON, durationTicksPerLevel * level, level - 1));
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:24,代码来源:EnchantVenom.java

示例3: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
	public void onAttack(AttackEntityEvent event) {
		EntityPlayer player = event.getEntityPlayer();
		if (player != null && player.getHealth() <= 0f) {
//			if(ModConfig.allowUnarmedMelee && player.getHeldItemMainhand().isEmpty()) {
//				return;
//			}
			event.setCanceled(true);
		}
	}
 
开发者ID:blay09,项目名称:HardcoreRevival,代码行数:11,代码来源:RestrictionHandler.java

示例4: onAttackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
    if (event.getTarget() instanceof EntityLivingBase) {
        EntityLivingBase target = (EntityLivingBase) event.getTarget();
        EntityPlayer player = event.getEntityPlayer();
        if (this.isActive(player)) {
            PossessivePlayer possessivePlayer = PossessHandler.get(player);
            EntityZombie possessing = (EntityZombie) possessivePlayer.getPossessing();
            if (possessing.getZombieType() == ZombieType.HUSK) {
                target.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 140));
            }
        }
    }
}
 
开发者ID:Fararise,项目名称:Possessed,代码行数:15,代码来源:ZombieHandler.java

示例5: onAttackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
    if (event.getTarget() instanceof EntityLivingBase) {
        EntityLivingBase target = (EntityLivingBase) event.getTarget();
        EntityPlayer player = event.getEntityPlayer();
        if (this.isActive(player)) {
            PossessivePlayer possessivePlayer = PossessHandler.get(player);
            EntitySkeleton possessing = (EntitySkeleton) possessivePlayer.getPossessing();
            if (possessing.getSkeletonType() == SkeletonType.WITHER) {
                target.addPotionEffect(new PotionEffect(MobEffects.WITHER, 100, 1));
            }
        }
    }
}
 
开发者ID:Fararise,项目名称:Possessed,代码行数:15,代码来源:SkeletonHandler.java

示例6: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("BooleanVariableAlwaysNegated")
@SubscribeEvent(priority = EventPriority.HIGH)
public void onAttack(AttackEntityEvent event)
{
    //Process for chiseling a sheep
    final Entity sheep = event.getTarget();
    if (sheep == null) return;

    final EntityPlayer entityPlayer = event.getEntityPlayer();
    ItemStack activeStack = entityPlayer.inventory.getCurrentItem();
    boolean attackedWithChisel = false;
    if (activeStack != null && ChiselLibrary.isChisel(activeStack.getItem()))
    {
        attackedWithChisel = true;
    } else
    {
        activeStack = entityPlayer.inventory.offHandInventory[0];
        if (activeStack != null && ChiselLibrary.isChisel(activeStack.getItem()))
        {
            attackedWithChisel = true;
        }
    }
    if (!attackedWithChisel)
    {
        return;
    }

    if (!sheep.hasCapability(Capability.CHISELED_SHEEP, null)) {
        return;
    }

    event.setCanceled(true);

    Chiseling.chiselSheep(sheep, entityPlayer, activeStack);
}
 
开发者ID:AtomicBlom,项目名称:ShearMadness,代码行数:36,代码来源:CommonForgeEventProxy.java

示例7: onPlayerAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
/**
 * Event listener for Action.ATTACK
 */
@SubscribeEvent
public void onPlayerAttack(AttackEntityEvent event)
{
    EntityPlayer player = event.getEntityPlayer();
    List<Action> events = CommonProxy.manager.getActions(player);

    if (!player.worldObj.isRemote && events != null && !Blockbuster.proxy.config.record_attack_on_swipe)
    {
        events.add(new AttackAction());
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:15,代码来源:ActionHandler.java

示例8: onAttackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
  if (event.getTarget() instanceof EntityLivingBase == false) {
    return;
  }
  //    EntityLivingBase target = (EntityLivingBase) event.getTarget();
  EntityPlayer attacker = event.getEntityPlayer();
  int level = getCurrentLevelTool(attacker);
  if (level > 0 && attacker.getHealth() < attacker.getMaxHealth()) {
    UtilParticle.spawnParticle(attacker.getEntityWorld(), EnumParticleTypes.HEART, attacker.getPosition().up(2));
    attacker.heal(level);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:14,代码来源:EnchantLifeLeech.java


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