當前位置: 首頁>>代碼示例>>Java>>正文


Java AttackEntityEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.AttackEntityEvent的典型用法代碼示例。如果您正苦於以下問題:Java AttackEntityEvent類的具體用法?Java AttackEntityEvent怎麽用?Java AttackEntityEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AttackEntityEvent類屬於net.minecraftforge.event.entity.player包,在下文中一共展示了AttackEntityEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: playerTick

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@SubscribeEvent
public void playerTick(AttackEntityEvent attackEvent)
{
    Entity target = attackEvent.getTarget();
    EntityLivingBase attacker = attackEvent.getEntityLiving();
    if(attacker == null || target == null)
        return;
    World world = attacker.getEntityWorld();
    BlockPos pos = EntityUtil.getEntityFloor(target,2);

    if(!world.isRemote)
    {
        IBlockState state = world.getBlockState(pos);
        if(isChopBlock(state) && isSuitableWeapon(attacker.getHeldItemMainhand()))
        {
            attacker.addPotionEffect(new PotionEffect(MobEffects.STRENGTH,200));
            attacker.addPotionEffect(new PotionEffect(MobEffects.HUNGER,200));
            splatter(world,pos,1);
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:22,代碼來源:ButcherHandler.java

示例3: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@SubscribeEvent
public void onAttack(AttackEntityEvent event) {
	if (!event.getEntityLiving().getHeldItemMainhand().isEmpty()) {
		if (disabledItems.contains(event.getEntityLiving().getHeldItemMainhand().getItem())) {
			event.setCanceled(true);
			if (event.getTarget().canBeAttackedWithItem()) {
				if (!event.getTarget().hitByEntity(event.getEntity())) {
					event.getEntityPlayer().setLastAttackedEntity(event.getTarget());
					event.getEntityPlayer().world.playSound((EntityPlayer) null, event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, event.getEntityPlayer().getSoundCategory(), 1.0F, 1.0F);
					event.getTarget().attackEntityFrom(DamageSource.causePlayerDamage(event.getEntityPlayer()), event.getEntityPlayer().getCooledAttackStrength(1F));
					event.getEntityPlayer().addExhaustion(0.1F);
				}
			}
		}
	}
}
 
開發者ID:tom5454,項目名稱:Toms-Mod,代碼行數:17,代碼來源:EventHandler.java

示例4: onAttackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent ev)
{
    if (!ev.getTarget().isImmuneToFire() && !ev.getTarget().world.isRemote)
    {
        ItemStack stack = ev.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND);
        if (stack.getCount() > 0 && stack.getItem() instanceof ItemBlock)
        {
            ItemBlock b = (ItemBlock) stack.getItem();
            Block bl = b.getBlock();
            if (bl == Blocks.TORCH)
            {
                ev.getTarget().setFire(2);
                if (rnd.nextFloat() > 0.25)
                {
                    stack.grow(-1);
                    if (stack.getCount() <= 0)
                    {
                        ev.getEntityPlayer().inventory.setInventorySlotContents(ev.getEntityPlayer().inventory.currentItem, ItemStack.EMPTY);
                    }
                }
            }
        }
    }
}
 
開發者ID:gigaherz,項目名稱:Survivalist,代碼行數:26,代碼來源:TorchFireEventHandling.java

示例5: 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

示例6: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@SubscribeEvent
public void onAttack(AttackEntityEvent event){
	if(event.entityPlayer != null && event.entityPlayer.getHeldItem() != null)
		if(event.entityPlayer.getHeldItem().hasTagCompound())
			if(event.entityPlayer.getHeldItem().getTagCompound().hasKey("Fidelis"))
			{
				String fidelisID = event.entityPlayer.getHeldItem().getTagCompound().getString("Fidelis");
				if(event.entityPlayer.getGameProfile().getId().toString().equals(fidelisID))
					return;
				else if(fidelisID.equals(""))
				{
					event.entityPlayer.getHeldItem().getTagCompound().setString("Fidelis", event.entityPlayer.getGameProfile().getId().toString());
					event.entityPlayer.getHeldItem().getTagCompound().setString("FidelisDisplay", event.entityPlayer.getDisplayName());
				}
				else
					event.setCanceled(true);
			}
}
 
開發者ID:UnderMybrella,項目名稱:Fidelis,代碼行數:19,代碼來源:Fidelis.java

示例7: playerAttackEvent

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
/**
 * Makes stick truly a rudimentary weapon TODO add damage to stick info
 * 
 * @param event
 */
@SubscribeEvent(priority = EventPriority.NORMAL)
public void playerAttackEvent(AttackEntityEvent event)
{
	EntityPlayer player = event.entityPlayer;
	ItemStack itemstack = player.getCurrentEquippedItem();

	if (player != null)
	{
		if (!player.capabilities.disableDamage && itemstack != null)
		{
			if (OreDictionary.itemMatches(new ItemStack(Items.stick), itemstack, true))
			{
				event.target.attackEntityFrom(DamageSource.causePlayerDamage(player), 2.0F);
			}
		}
	}

	return;
}
 
開發者ID:VapourDrive,項目名稱:HarderStart,代碼行數:25,代碼來源:HS_PlayerAttackEntity.java

示例8: onEntityAttacked

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityAttacked(AttackEntityEvent event){
	if (event.entityPlayer.worldObj.isRemote)
		return;

	if (event.target instanceof EntityPlayer)
		if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.HARM_PLAYERS, event.target.posX, event.target.posY, event.target.posZ))
			event.setCanceled(true);

	if (event.target instanceof EntityCreature)
		if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.HARM_CREATURES, event.target.posX, event.target.posY, event.target.posZ))
			event.setCanceled(true);

	if (event.target instanceof EntityMob)
		if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.HARM_MONSTERS, event.target.posX, event.target.posY, event.target.posZ))
			event.setCanceled(true);		
}
 
開發者ID:Mithion,項目名稱:GriefGuardian,代碼行數:18,代碼來源:ClaimGuardEventHandler.java

示例9: onAttackEntityEvent

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@ForgeSubscribe
public void onAttackEntityEvent(AttackEntityEvent event)
{
	if (!event.entityPlayer.worldObj.isRemote && event.target.getEntityName() != null)
	{		
		player = (EntityPlayer) event.entityPlayer;
		
		stack = player.getCurrentEquippedItem();
		 
		if (stack != null && stack.itemID == ItemInfo.ESSENCE_CONTAINER_ID + 256)
		{
			for (String s : ModItem.essenceNames)
			{
				if (!usedEssenceContainer && s.equals(event.target.getEntityName()))
				{
					usedEssenceContainer = true;
					entity = s;
				}
			}
		}		
		else if (stack != null && stack.itemID != ItemInfo.ESSENCE_CONTAINER_ID + 256)
		{
			usedEssenceContainer = false;
		}
	}
}
 
開發者ID:tterrag1098,項目名稱:SimpleTransmutations,代碼行數:27,代碼來源:EntityLivingHandler.java

示例10: emitRedstoneOnEvent

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@Override
public int emitRedstoneOnEvent(PlayerEvent event, TileEntity sensor, int range) {
    if (event instanceof AttackEntityEvent) {
        return 15;
    }
    return 0;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:8,代碼來源:PlayerAttackSensor.java

示例11: 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

示例12: onDamage

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
@SubscribeEvent
public void onDamage(AttackEntityEvent entityEvent) {
    if (entityEvent.target instanceof EntityPlayer) {

        // Making sure the player isn't fake (Delivery man etc)
        if (entityEvent.target.getUniqueID().toString().charAt(14) != '4') {
            return;
        }

        this.lastDamaged = (EntityPlayer) entityEvent.target;
        timer = 120;
    }
}
 
開發者ID:boomboompower,項目名稱:TextDisplayer,代碼行數:14,代碼來源:FightingParser.java

示例13: onPlayerAttackTarget

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入依賴的package包/類
public static boolean onPlayerAttackTarget(EntityPlayer player, Entity target)
{
    if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false;
    ItemStack stack = player.getHeldItemMainhand();
    if (stack != null && stack.getItem().onLeftClickEntity(stack, player, target)) return false;
    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:ForgeHooks.java

示例14: 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

示例15: 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


注:本文中的net.minecraftforge.event.entity.player.AttackEntityEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。