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


Java LivingAttackEvent.getEntityLiving方法代码示例

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


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

示例1: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event)
{
	/*
	 * Player attacks a monster OR another player
	 */
	if (event.getSource().getTrueSource() instanceof EntityPlayer && !event.getSource().getTrueSource().getEntityWorld().isRemote)
	{
		EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
		EntityLivingBase enemy = event.getEntityLiving();
		ItemStack stack = player.inventory.getCurrentItem();
		PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (playerInfo != null && stack != null && stack.getItem() instanceof ItemSword && !(stack.getItem() instanceof ItemLEAdvancedMelee))
		{
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			
			if (playerInfo.getPlayerLevel() >= nbt.getInteger("Level"))
			{
				useWeaponAttributes(event.getAmount(), player, enemy, stack, nbt);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:25,代码来源:EventLivingHurtAttack.java

示例2: onLivingAttackCallback

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.BOTTOM)
public void onLivingAttackCallback(LivingAttackEvent event) {
	if (Always.isServer()) {
		EntityLivingBase living = event.getEntityLiving(), attacker = event.getSource().getTrueSource() instanceof EntityLivingBase ?
				(EntityLivingBase) event.getSource().getTrueSource() : null;
		if (isEquipmented(living) && !(living instanceof EntityPlayer && ((EntityPlayer) living).isCreative())) {
			living.getCombatTracker().lastDamageTime = living.ticksExisted;
			if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
				AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(-1), (EntityPlayerMP) living);
		}
		if (attacker != null && isEquipmented(attacker)) {
			attacker.setLastAttackedEntity(living);
			if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
				AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(living.getEntityId()), (EntityPlayerMP) attacker);
		}
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:18,代码来源:ItemBeltGuard.java

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

示例4: autoShield

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void autoShield(LivingAttackEvent event) {
	
	if (!(event.getEntityLiving() instanceof EntityPlayer)) return;
	if (!(event.getSource().getSourceOfDamage() instanceof EntityArrow)) return;
	
	ItemStack shield = ((EntityPlayer)event.getEntityLiving()).getHeldItemOffhand();
	ItemStack emblem = BaublesApi.getBaublesHandler((EntityPlayer)event.getEntityLiving()).getStackInSlot(6);
	if (shield == null || emblem == null) return;
	if (emblem.getItem() != this || !(shield.getItem() instanceof ItemShield)) return;
	
	shield.attemptDamageItem(1, event.getEntityLiving().worldObj.rand);
	event.setCanceled(true);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:15,代码来源:EmblemDefense.java

示例5: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent e)
{
    EntityLivingBase attacked = e.getEntityLiving();
    EntityLivingBase attacker = attacked.getAttackingEntity();
    if(attacker == null) return;
    damageShield(attacked, attacker, e.getAmount());
    doAxeStuff(attacked, attacker);
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:10,代码来源:ItemWickerShield.java

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

示例7: onAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttack(LivingAttackEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        PossessivePlayer possessivePlayer = PossessHandler.get(player);
        if (possessivePlayer != null) {
            if (event.getSource().isFireDamage()) {
                event.setCanceled(true);
            } else {
                possessivePlayer.getPossessing().attackEntityFrom(event.getSource(), event.getAmount());
                event.setCanceled(true);
                if (!player.capabilities.isCreativeMode && !event.getSource().canHarmInCreative() && possessivePlayer.getPossessing().hurtTime <= 0) {
                    this.playPossessedHurtAnimation(player);
                }
            }
        }
    } else {
        EntityPlayer possessor = PossessHandler.getPossesor(event.getEntityLiving());
        if (possessor != null) {
            if (possessor.capabilities.isCreativeMode && !event.getSource().canHarmInCreative()) {
                event.setCanceled(true);
            } else if (possessor.hurtTime <= 0) {
                this.playPossessedHurtAnimation(possessor);
            }
        }
    }
}
 
开发者ID:Fararise,项目名称:Possessed,代码行数:28,代码来源:ServerEventHandler.java

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

示例9: onPlayerDamaged

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerDamaged(LivingAttackEvent event){
	event.getEntityLiving().getEntityWorld();
	EntityLivingBase attacked = event.getEntityLiving();
	DamageSource source = event.getSource();
	int pureCount = getArmorCount(attacked, "pure");
	if(getArmorCount(attacked, "red") == 4 || pureCount == 4){
		if(source == DamageSource.HOT_FLOOR){
			event.setCanceled(true);
		}
	}
	if(getArmorCount(attacked, "dark") == 4 || pureCount == 4){
		if(source.getSourceOfDamage() !=null){
			Entity toAttack = source.getSourceOfDamage();
			toAttack.attackEntityFrom(DamageSource.causeThornsDamage(attacked), EnchantmentThorns.getDamage(5, EntityUtil.rand));
			if(toAttack instanceof EntityLivingBase){
				EntityLivingBase living = (EntityLivingBase)toAttack;
				if(EntityUtil.rand.nextInt(10) == 0){
					living.addPotionEffect(new PotionEffect(MobEffects.WITHER, MathHelper.getInt(EntityUtil.rand, 20*3, 20*6), 0));
				}
			}
		}
	}
	
	/*if(source == DamageSource.FALL){
		BlockPos pos = new BlockPos(attacked).down();
		IBlockState state = world.getBlockState(pos);
		if (state.getBlock() instanceof BlockLiquid && attacked.posY > pos.getY() + 0.9 && !(world.getBlockState(pos.up()).getBlock().getMaterial(world.getBlockState(pos.up())) == Material.WATER))
		{
			if(UpgradeItemRecipe.isWaterWalking(attacked.getItemStackFromSlot(EntityEquipmentSlot.FEET))){
				world.playSound(null, pos, SoundEvents.ENTITY_PLAYER_SPLASH, SoundCategory.PLAYERS, 1.0F, 1.0F);
				event.setCanceled(true);
			}
		}
	}*/
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:37,代码来源:ArmorEventHandler.java

示例10: onAttacked

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttacked(LivingAttackEvent event) {
	if(event.getSource() != null) {
		Entity attacker = event.getSource().getEntity();
		if(attacker != null && attacker instanceof EntityMinionWarrior && attacker.getRidingEntity() == event.getEntityLiving())
			event.setCanceled(true);
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:9,代码来源:EventHandler.java

示例11: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
	if (event.getEntityLiving() instanceof EntityPlayer)
	{
		PlayerAether playerAether = PlayerAether.get((EntityPlayer) event.getEntityLiving());

		if (playerAether != null)
		{
			event.setCanceled(playerAether.onPlayerAttacked(event.getSource()));
		}
	}
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:14,代码来源:PlayerAetherEvents.java

示例12: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void onLivingAttack(LivingAttackEvent event) {
	if (Always.isServer() && isEquipmented(event.getEntityLiving()) && isCDOver(event.getEntityLiving())) {
		AlchemyEventSystem.markEventCanceled(event);
		EntityLivingBase source = event.getSource().getTrueSource() instanceof EntityLivingBase ? (EntityLivingBase) event.getSource().getTrueSource() : null;
		if (source != null)
			source.attackEntityFrom(AlchemyDamageSourceLoader.dead_magic, event.getAmount());
		EntityLivingBase living = event.getEntityLiving();
		living.getCombatTracker().lastDamageTime = living.ticksExisted;
		if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
			AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(-1), (EntityPlayerMP) living);
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:14,代码来源:ItemBeltGuard.java

示例13: onDamageRender

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onDamageRender(LivingAttackEvent e) {
    if (e.getEntityLiving() instanceof EntityPlayer) {
        if (e.getSource() == DamageSource.MAGIC) {
            e.setCanceled(false);
            return;
        }
    }
}
 
开发者ID:Hoijima,项目名称:Fallout_Equestria,代码行数:10,代码来源:CommonEventHandler.java

示例14: onEvent2

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent2(LivingAttackEvent event) {
	if (event.getEntityLiving() instanceof EntityPlayerMP && event.getSource().getImmediateSource() instanceof EntityLiving) {
		if (getPlayerSettings((EntityPlayerMP) event.getEntityLiving()).disableAttacks.contains(event.getSource().getImmediateSource().getClass())) {
			((EntityLiving) event.getSource().getImmediateSource()).setAttackTarget(null);
			((EntityLiving) event.getSource().getImmediateSource()).setRevengeTarget(null);
			event.setCanceled(true);
		}
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:11,代码来源:CommandNoattack.java

示例15: livingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingAttack(LivingAttackEvent event) {
    if (!(event.getEntityLiving() instanceof EntityPlayer)) return;
    EntityPlayer player = (EntityPlayer) event.getEntityLiving();

    if (!player.capabilities.isCreativeMode) return;

    PacketCreateTipEntity packet = new PacketCreateTipEntity(player);
    ImmortalObjectTip.instance.network.sendToDimension(packet, packet.dim);
}
 
开发者ID:danny50610,项目名称:ImmortalObjectTip,代码行数:11,代码来源:LivingAttackEventHandler.java


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