當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。