當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。