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