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


Java EntityDamageSource.getEntity方法代码示例

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


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

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

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

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

示例4: onDeath

import net.minecraft.util.EntityDamageSource; //导入方法依赖的package包/类
@ForgeSubscribe
public void onDeath(LivingDeathEvent ev) { 
	if (!(ev.source instanceof EntityDamageSource)){
		return;
	}
	EntityDamageSource eds = (EntityDamageSource)ev.source;

	Entity ent = eds.getEntity();
	if (!(ent instanceof EntityPlayer)) {
		return;
	}

	EntityPlayer epl = (EntityPlayer)ent;

	ItemStack wpn = epl.getHeldItem();
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 0)
	{
		return;
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 1){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 1, 0), 0.5F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 2){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 1, 0), 0.8F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 3){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 1, 0), 1.0F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 4){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 2, 0), 0.5F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 5){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 2, 0), 0.8F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 6){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 2, 0), 1.0F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 7){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 3, 0), 0.5F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 8){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 3, 0), 0.8F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 9){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 3, 0), 1.0F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 10){
		if(ev.entityLiving instanceof EntityDragon){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 4, 0), 0.8F);
		}
	}
}
 
开发者ID:Wehavecookies56,项目名称:Kingdom-Keys,代码行数:71,代码来源:KingdomHeartsDrops.java

示例5: onDeath

import net.minecraft.util.EntityDamageSource; //导入方法依赖的package包/类
@ForgeSubscribe
public void onDeath(LivingDeathEvent ev) { 
	if (!(ev.source instanceof EntityDamageSource)){
		return;
	}
	EntityDamageSource eds = (EntityDamageSource)ev.source;

	Entity ent = eds.getEntity();
	if (!(ent instanceof EntityPlayer)) {
		return;
	}

	EntityPlayer epl = (EntityPlayer)ent;

	ItemStack wpn = epl.getHeldItem();
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 0)
	{
		return;
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 1){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 1, 0), 0.5F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 2){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 1, 0), 0.8F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 3){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 1, 0), 1.0F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 4){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 2, 0), 0.5F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 5){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 2, 0), 0.8F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 6){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 2, 0), 1.0F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 7){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 3, 0), 0.5F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 8){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 3, 0), 0.8F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 9){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 3, 0), 1.0F);
		}
	}
	if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 10){
		if(ev.entityLiving instanceof EntityVillager){
			ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 4, 0), 0.8F);
		}
	}
}
 
开发者ID:Wehavecookies56,项目名称:Kingdom-Keys,代码行数:71,代码来源:PureHeartDrops.java


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