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


Java EntityDamageSource类代码示例

本文整理汇总了Java中net.minecraft.util.EntityDamageSource的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageSource类的具体用法?Java EntityDamageSource怎么用?Java EntityDamageSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handleNonLivingEntityDamageEvent

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:18,代码来源:CraftEventFactory.java

示例2: attackEntity

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
	try
	{
		if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
				&& (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof BaseHarshenSword ||
					((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
			   &&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
			event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
	}
	catch (ClassCastException clazz){}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HandlerSoulHarsherSword.java

示例3: attackEntity

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
	try
	{
		if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
				&& (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof RaptorScythe ||
					((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
			   &&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
				&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
			event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
	}
	catch (ClassCastException clazz){}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HandlerRaptorScythe.java

示例4: attackEntityFrom

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if (source instanceof EntityDamageSource || source == DamageSource.magic)
        {
            this.summonSilverfish.func_179462_f();
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntitySilverfish.java

示例5: entityHurtEvent

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:26,代码来源:ServerEventHandler.java

示例6: activateSkill

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@Override
public int activateSkill(IWeaponSkillInfo info, EntityLivingBase attacker, ItemStack item, DamageSource source, EntityLivingBase opponent) {
	//If you don't know about Earthbound, we can't be friends. Sorry, I don't make the rules.
	DamageSource smaaaaaaash = new EntityDamageSource("weaponskill.smash", attacker);
	opponent.attackEntityFrom(smaaaaaaash, 4f);
	
	opponent.addPotionEffect( new PotionEffect(Potion.getPotionFromResourceLocation("minecraft:blindness"), 20*3, 2 ));
	//Thermionics.LOG.info("SMAAAAAAASH WeaponSkill activated against entity {} at {},{},{}", opponent, opponent.posX, opponent.posY, opponent.posZ);
	if (opponent instanceof EntityMob) {
		EntityMob monster = (EntityMob)opponent;
		monster.setAttackTarget(null);
		monster.setRevengeTarget(null);
	}
	if (!attacker.world.isRemote) {
		//Serverside, queue the effect
		SpawnParticleEmitterMessage fx = new SpawnParticleEmitterMessage(Thermionics.CONTEXT, EnumWeaponSkill.SMAAAAAAASH, opponent);
		fx.sendToAllWatching(opponent);
	}
	
	return 20*5;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:22,代码来源:ItemHammer.java

示例7: attackEntityFrom

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if ((source instanceof EntityDamageSource || source == DamageSource.magic) && this.summonSilverfish != null)
        {
            this.summonSilverfish.notifyHurt();
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:EntitySilverfish.java

示例8: onEntityDropLoot

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@SubscribeEvent
public void onEntityDropLoot(LivingDropsEvent event)
{
	if (event.getSource() instanceof EntityDamageSource)
	{
		EntityLivingBase entity = event.getEntityLiving();
		EntityDamageSource source = (EntityDamageSource) event.getSource();

		if (source.getEntity() instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) source.getEntity();
			ItemStack currentItem = player.inventory.getCurrentItem();

			if (currentItem != null && currentItem.getItem() instanceof ItemSkyrootSword && !(entity instanceof EntityPlayer) && !(entity instanceof EntityWither))
			{
				for (EntityItem items : event.getDrops())
				{
					EntityItem item = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, items.getEntityItem());
					entity.worldObj.spawnEntityInWorld(item);
				}
			}
		}
	}
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:25,代码来源:AetherEventHandler.java

示例9: eventDeath

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
public void eventDeath(EntityPlayer player, DamageSource damageSource){
    if(node != null){
        if(damageSource instanceof EntityDamageSource){
            EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
            String damage = "";
            try{
                damage = entityDamageSource.func_151519_b(player).getUnformattedTextForChat();
            }catch (Exception e){
                e.printStackTrace();
            }
            node.sendToReachable("computer.signal", "player_death", player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, getDistanceFrom(player.posX, player.posY, player.posZ), player.getDisplayName(), damageSource.damageType, damage);
        }else{

            node.sendToReachable("computer.signal", "player_death", player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, getDistanceFrom(player.posX, player.posY, player.posZ), player.getDisplayName(), damageSource.damageType, null);
        }
    }
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:18,代码来源:TileEntityCreativeChatBox.java

示例10: onImpact

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@Override
protected void onImpact(RayTraceResult result) {
	if (world.isRemote)
		return;
	boolean kill = true;
	if (result.typeOfHit == Type.ENTITY) {
		Entity ent = result.entityHit;
		if (ent instanceof EntityPlayerMP) {
			kill = false;
		} else
			ent.attackEntityFrom(
					(new EntityDamageSource("arrow", getThrower())).setProjectile(),
					damage);
	}
	if (result.typeOfHit == Type.BLOCK) {
		if (!world.getBlockState(result.getBlockPos()).isFullBlock()) {
			kill = false;
		}
	}
	if (kill)
		setDead();
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:23,代码来源:EntityBullet.java

示例11: onLivingAttack

import net.minecraft.util.EntityDamageSource; //导入依赖的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

示例12: attackEntityFrom

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else
    {
        if (this.allySummonCooldown <= 0 && (par1DamageSource instanceof EntityDamageSource || par1DamageSource == DamageSource.magic))
        {
            this.allySummonCooldown = 20;
        }

        return super.attackEntityFrom(par1DamageSource, par2);
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:20,代码来源:EntitySilverfish.java

示例13: onEntityDeath

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
	if(event.source instanceof EntityDamageSource) {
		EntityDamageSource entitySource = (EntityDamageSource) event.source;
		
		if(entitySource.getEntity() instanceof EntityPlayer) {
			EntityPlayer killer = (EntityPlayer) entitySource.getEntity();
			
			if(killer.inventory.getCurrentItem() != null) {	
				if(EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.vorpal.effectId)) {
					int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.vorpal.effectId, killer.inventory.getCurrentItem());
					
					if(level == 1) {
						if(killer.worldObj.rand.nextInt(6) == 1) {
							this.dropHeads(event);
						}
					} else if(level == 2) {
						if(killer.worldObj.rand.nextInt(3) == 1) {
 						this.dropHeads(event);
						}
					}
				}
			}
		}
	}
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:27,代码来源:BPEventHandler.java

示例14: onLivingHurt

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
    DamageSource source = event.source;
    if (source.damageType == "player" && SprinklesForVanilla.isOnServer && event.ammount > 0)
    {
        EntityPlayer player = (EntityPlayer)((EntityDamageSource)source).getEntity();
        if (player != null)
        {
            ItemStack heldItem = player.getCurrentEquippedItem();
            if (heldItem != null)
            {
                Multimap attribMap = heldItem.getAttributeModifiers();
                //If held item doesn't change the base damage
                if (!attribMap.containsKey(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()))
                {
                    event.ammount *= Settings.playerPunchDamageMultiplier[1];
                }
            }
            else
            {
                event.ammount *= Settings.playerPunchDamageMultiplier[1];
            }
        }
    }
}
 
开发者ID:VikeStep,项目名称:sprinkles_for_vanilla,代码行数:27,代码来源:EntityHandlers.java

示例15: onDeathEvent

import net.minecraft.util.EntityDamageSource; //导入依赖的package包/类
@Override
public void onDeathEvent(LivingDeathEvent event) {
    if (event.entity instanceof EntityPlayerMP) {
        DamageSource source = event.source;
        String killer = null;
        if (source instanceof EntityDamageSource) {
            Entity ent = source.getEntity();
            if (ent != null) {
                killer = ent.getCommandSenderName();
            }
        }
        if (rangeRead < 0 || entityInRange(event.entity, rangeRead)) {
            computerQueueEvent(EVENT_DEATH, event.entity.getCommandSenderName(), source.getDamageType(), killer);
        }
    }
}
 
开发者ID:theoriginalbit,项目名称:MoarPeripherals,代码行数:17,代码来源:TileChatBox.java


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