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


Java LivingAttackEvent.getSource方法代码示例

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


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

示例1: onLivingHurt

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingAttackEvent event)
{
	if (event.getSource() == null)
		return;
	if (event.getSource().getTrueSource() == null)
		return;
	if (event.getSource().getTrueSource() instanceof EntityLivingBase)
	{
		PotionEffect effect = ((EntityLivingBase) event.getSource().getTrueSource()).getActivePotionEffect(PotionRegistry.REDSTONE_NEEDLE);
		if (effect == null)
			return;
		if (effect.getAmplifier() >= 4)
			event.setCanceled(true);
	}
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:17,代码来源:PotionRedstoneNeedle.java

示例2: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent evt) {
	if (evt.getEntity() instanceof EntityPlayer && evt.getSource() instanceof EntityDamageSource) {
		EntityDamageSource source = (EntityDamageSource) evt.getSource();
		if (source.getEntity() instanceof EntityPlayer) {
			EntityPlayer attacker = (EntityPlayer) source.getEntity();
			EntityPlayer damagee = (EntityPlayer) evt.getEntity();

			ItemStack attackerBoots = attacker.inventory.armorItemInSlot(0);
			ItemStack damageeBoots = damagee.inventory.armorItemInSlot(0);
			if (attackerBoots != null && damageeBoots != null && attackerBoots == damageeBoots) {
				Item id = damageeBoots.getItem();
				if (id == WarsItems.redBoots || id == WarsItems.greenBoots || id == WarsItems.blueBoots || id == WarsItems.yellowBoots) {
					evt.setCanceled(true);
				}
			}
		}
	}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Wars-Mod,代码行数:20,代码来源:CommonEvents.java

示例3: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
	if (event.getSource() != null && event.getSource().getTrueSource() != null)
	{
		if (event.getSource().getTrueSource() instanceof EntityLivingBase && ((EntityLivingBase)event.getSource().getTrueSource()).isPotionActive(ExPPotions.stunned))
		{
			event.setCanceled(true);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:12,代码来源:ExPHandlerServer.java

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

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

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

示例7: onLivingHurt

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingAttackEvent event)
{
	if (event.getSource() == null) return;
	if (event.getSource().getTrueSource() == null) return;
	if (event.getSource().getTrueSource() instanceof EntityLivingBase)
	{
		PotionEffect effect = ((EntityLivingBase) event.getSource().getTrueSource()).getActivePotionEffect(PotionRegistry.STUN);
		if (effect == null) return;
		event.setCanceled(true);
	}
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:13,代码来源:PotionStun.java

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

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

示例10: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP && event.getSource() == DamageSource.DROWN) {
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		if (!getPlayerSettings((EntityPlayerMP) player).waterdamage) event.setCanceled(true);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandWaterdamage.java

示例11: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP && (event.getSource() == DamageSource.IN_FIRE || event.getSource() == DamageSource.ON_FIRE || event.getSource() == DamageSource.LAVA)) {
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		if (!getPlayerSettings(player).firedamage) event.setCanceled(true);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandFiredamage.java

示例12: onEvent

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP && 
		((EntityPlayerMP) event.getEntity()).connection instanceof NetHandlerPlayServer &&
		((NetHandlerPlayServer) ((EntityPlayerMP) event.getEntity()).connection).getOverrideNoclip() 
		&& event.getSource() == DamageSource.IN_WALL) event.setCanceled(true);
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandNoclip.java

示例13: onAttackEntity

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(LivingAttackEvent event)
{
    // When a "passified" entity is attacked by another entity, remove the "passified" tag,
    // and restore the target AI tasks by re-adding all the AI tasks from a fresh clone
    if ((event.getEntity() instanceof EntityLiving) && event.getEntity().getEntityWorld().isRemote == false &&
        event.getSource() instanceof EntityDamageSource && event.getEntity().getTags().contains(ItemSyringe.TAG_PASSIFIED))
    {
        ItemSyringe.removePassifiedState((EntityLiving) event.getEntity());
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:12,代码来源:EntityEventHandler.java

示例14: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
    if(event.getSource() == DamageSource.IN_WALL) //check to see if entity is inside a portal.
    {
        if(isInPortal(event.getEntity()))
        {
            event.setCanceled(true);
        }
    }
}
 
开发者ID:iChun,项目名称:iChunUtil,代码行数:12,代码来源:EventHandlerWorldPortal.java

示例15: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event) {
	if (event.getSource() == DamageSource.OUT_OF_WORLD && isEquipmented(event.getEntityLiving()))
		AlchemyEventSystem.markEventCanceled(event);
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:6,代码来源:ItemRingSpace.java


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