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


Java LivingAttackEvent.getAmount方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingAttackEvent.getAmount方法的典型用法代碼示例。如果您正苦於以下問題:Java LivingAttackEvent.getAmount方法的具體用法?Java LivingAttackEvent.getAmount怎麽用?Java LivingAttackEvent.getAmount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.living.LivingAttackEvent的用法示例。


在下文中一共展示了LivingAttackEvent.getAmount方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: stopHurt

import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void stopHurt(LivingAttackEvent event) {
	if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityLivingBase &&
			(event.getSource().damageType.equals("mob") || event.getSource().damageType.equals("player"))) {
		EntityLivingBase damageSource = (EntityLivingBase) event.getSource().getTrueSource();
		if (!TF2Util.canInteract(damageSource)) {
			event.setCanceled(true);
		}
		if (damageSource.hasCapability(TF2weapons.WEAPONS_CAP, null) && WeaponsCapability.get(damageSource).isDisguised()) {
			disguise(damageSource, false);
		}
	}

	if (!event.isCanceled() && event.getAmount() > 0) {
		/*
		 * if(event.getEntity().getEntityData().getByte("IsCloaked")!=0){
		 * event.getEntity().getEntityData().setInteger("VisTicks",
		 * Math.min(10,event.getEntity().getEntityData().getInteger(
		 * "VisTicks"))); event.getEntity().setInvisible(false);
		 * //System.out.println("notInvisible"); }
		 */
		event.getEntityLiving().getEntityData().setInteger("lasthit", event.getEntityLiving().ticksExisted);
	}

}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:26,代碼來源:TF2EventsCommon.java

示例2: attackEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void attackEvent (LivingAttackEvent e) {
    if (e.getEntityLiving().getActiveItemStack() == null)
        return;
    final ItemStack stack = e.getEntityLiving().getActiveItemStack();
    if (stack.getItem() instanceof ItemCustomShield && e.getAmount() > 0.0f) {
        final int i = 1 + MathHelper.floor(e.getAmount());
        stack.damageItem(i, e.getEntityLiving());
        if (stack.stackSize <= 0) {
            final EnumHand enumhand = e.getEntityLiving().getActiveHand();
            if (e.getEntityLiving() instanceof EntityPlayer)
                ForgeEventFactory.onPlayerDestroyItem((EntityPlayer) e.getEntityLiving(), stack, enumhand);
            e.getEntityLiving().setItemStackToSlot(enumhand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, null);
            if (e.getEntityLiving().getEntityWorld().isRemote)
                e.getEntityLiving().playSound(SoundEvents.BLOCK_ANVIL_BREAK, 0.8F, 0.8F + e.getEntityLiving().getEntityWorld().rand.nextFloat() * 0.4F);
        }
    }
}
 
開發者ID:MinecraftModDevelopmentMods,項目名稱:MMDLib-old,代碼行數:19,代碼來源:ForgeEventHandler.java

示例3: handleDamageEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
@Override
public void handleDamageEvent(LivingAttackEvent event){
    EntityLiving attackingMob = (EntityLiving)event.getSource().getTrueSource();
    int level = MobNBTHandler.getModifierLevel(attackingMob,IDENTIFIER);
    float damage = event.getAmount();
    float healDamage = damage * 0.2f * level;
    attackingMob.heal(healDamage);
}
 
開發者ID:talandar,項目名稱:ProgressiveDifficulty,代碼行數:9,代碼來源:VampiricModifier.java

示例4: onShieldedAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
/** Damage the advanced shield correctly, as vanilla code only works for the vanilla shield */
@SubscribeEvent
public void onShieldedAttack(LivingAttackEvent e) {
	EntityLivingBase guy = e.getEntityLiving();
	if(!guy.world.isRemote && guy instanceof EntityPlayer) {
		if(e.getAmount() > 0.0F && !guy.getActiveItemStack().isEmpty() && guy.getActiveItemStack().getItem() instanceof ItemShieldAdvanced) {
			if(this.canBlockDamageSource((EntityPlayer)guy, e.getSource())) {
				this.damageShield((EntityPlayer)guy, e.getAmount());
			}
		}
	}
}
 
開發者ID:sblectric,項目名稱:AdvancedCombat,代碼行數:13,代碼來源:CustomShieldHandler.java

示例5: livingAttacked

import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void livingAttacked(LivingAttackEvent event) {
    if (!event.getEntityLiving().world.isRemote) {
        if (!event.isCanceled() && event.getAmount() > 0) {
            EntityLivingBase living = event.getEntityLiving();

            if (living.isPotionActive(ModPotions.cannonball) && (event.getSource().isExplosion() || event.getSource() == DamageSource.FALL)) {
                if (event.getSource() == DamageSource.FALL) //No you don't get to have superbuffs that make you immune to creepers and falldamage.
                    living.removePotionEffect(ModPotions.cannonball);
                event.setCanceled(true);
            }
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:15,代碼來源:AssortedHandler.java

示例6: playerAttacked

import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
/** Alters behaviour when the player takes damage. */
@SubscribeEvent
public void playerAttacked(LivingAttackEvent event) {
    
    if (!(event.getEntity() instanceof EntityPlayer)) {
        
        return;
    }
    
    EntityPlayer player = (EntityPlayer) event.getEntity();
    DamageSource source = event.getSource();
    
    // Copy vanilla shield functionality to allow for custom shields
    if (!source.isUnblockable() && player.isActiveItemStackBlocking() &&
            player.getActiveItemStack().getItem() instanceof ItemShield) {
        
        Vec3d sourceVec = source.getDamageLocation();

        if (sourceVec != null) {
            
            Vec3d playerVec = player.getLook(1.0F);
            Vec3d attackVec = sourceVec.subtractReverse(new
                    Vec3d(player.posX, player.posY,
                    player.posZ)).normalize();
            attackVec = new Vec3d(attackVec.xCoord,
                    0.0D, attackVec.zCoord);

            if (attackVec.dotProduct(playerVec) < 0.0D &&
                    event.getAmount() >= 3) {
                
                player.getActiveItemStack().damageItem(1 +
                        MathHelper.floor(event.getAmount()), player);
            }
        }
    }
}
 
開發者ID:JayAvery,項目名稱:geomastery,代碼行數:37,代碼來源:PlayerEvents.java


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