当前位置: 首页>>代码示例>>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;未经允许,请勿转载。