當前位置: 首頁>>代碼示例>>Java>>正文


Java LivingDeathEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingDeathEvent的典型用法代碼示例。如果您正苦於以下問題:Java LivingDeathEvent類的具體用法?Java LivingDeathEvent怎麽用?Java LivingDeathEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LivingDeathEvent類屬於net.minecraftforge.event.entity.living包,在下文中一共展示了LivingDeathEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onLivingDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event)
{
	/*
	 * Update player experience when they kill a monster. Experience gained is determined from how much health/damage the monsters has.
	 */

	if (event.getSource().getTrueSource() instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
		EntityLivingBase enemy = event.getEntityLiving();
		PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (!player.getEntityWorld().isRemote && playerInfo != null)
		{
			addExperience(player, playerInfo, enemy);
		}
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:20,代碼來源:EventLivingDeath.java

示例2: PlayerDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@HarshenEvent
public void PlayerDeath(LivingDeathEvent event)
{
	EntityPlayer player = (EntityPlayer) event.getEntity();
	event.setCanceled(true);
	if (player instanceof EntityPlayerMP)
	{
           EntityPlayerMP entityplayermp = (EntityPlayerMP)player;
           entityplayermp.addStat(StatList.getObjectUseStats(Items.TOTEM_OF_UNDYING));
           CriteriaTriggers.USED_TOTEM.trigger(entityplayermp, HarshenUtils.getFirstOccuringItem(player, Items.TOTEM_OF_UNDYING));
       }
	
	HarshenUtils.setStackInSlot(player, Items.TOTEM_OF_UNDYING, ItemStack.EMPTY);
	player.setHealth(1.0F);
	player.clearActivePotions();
	player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
	player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1));
	player.world.setEntityState(player, (byte)35);
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:20,代碼來源:HandlerTotemOfUndying.java

示例3: onEntityDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
	// if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
	if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
	{
		// iterate through the itemstacks in the villager's inventory
		InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
		for (int i = 0; i < inventory.getSizeInventory(); i++)
		{
			// remove the stack from the inventory and spawn it in the world
			ItemStack stack = inventory.getStackInSlot(i);
			if (stack != ItemStack.EMPTY)
			{
				event.getEntityLiving().entityDropItem(stack, 0.0F);
			}
		}
	}
}
 
開發者ID:crazysnailboy,項目名稱:VillagerInventory,代碼行數:20,代碼來源:VillagerInventoryMod.java

示例4: printChat

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
public void printChat(int ID, LivingDeathEvent event, String item) {

        Entity killer = event.getSource().getEntity();
        EntityLivingBase target = event.getEntityLiving();

        // Thanks again 'SourceCoded' <3
        // Add to statclock weapon
        if (killer != null && killer instanceof EntityPlayer) {

            EntityPlayer player = (EntityPlayer) killer;
            String name = killer.getName();
            item = translate(item + ".name");
            player.sendMessage(new TextComponentString( name + "'s " + item + " " + translate("statclock.translate.chat") + " §6[" + translate("strange." + ID) + "]"));
        }

    }
 
開發者ID:lucidagrande,項目名稱:statclock,代碼行數:17,代碼來源:EventStatclock.java

示例5: checkPlayerDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void checkPlayerDeath(LivingDeathEvent event) {
	
	if (event.getEntityLiving() != null && event.getEntityLiving() instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer)event.getEntityLiving();
		NBTTagCompound tag = player.getEntityData();
		if (tag.hasKey("hasSacrificed") && !tag.getBoolean("hasSacrificed"))
		{
			EntityItem ei = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(UCItems.heart));
			tag.setBoolean("hasSacrificed", true);
			if (!player.worldObj.isRemote)
				player.worldObj.spawnEntityInWorld(ei);
			return;
		}
	}
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:17,代碼來源:UCEventHandlerServer.java

示例6: onDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onDeath(LivingDeathEvent event) {

	World world = event.getEntity().getEntityWorld();

	if (world.isRemote) {
		return;
	}

	Entity slayer = event.getSource().getTrueSource();

	if (event.getEntity() instanceof EntityPlayer && slayer instanceof EntityCreature) {
		handlePlayerDeath((EntityPlayer) event.getEntity(), (EntityCreature) slayer);
		return;
	}

	if (!(event.getEntity() instanceof EntityCreature)) {
		return;
	}

	if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
		handleNemesisDeath((EntityCreature) event.getEntity(), slayer);
	}
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:25,代碼來源:DeathHandler.java

示例7: onLivingDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
    if (event.getSource().getSourceOfDamage() != null && event.getSource().getSourceOfDamage() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getSourceOfDamage();
        if (this.isActive(player) && event.getEntityLiving() instanceof EntityVillager) {
            EntityVillager villager = (EntityVillager) event.getEntityLiving();
            EntityZombie zombieVillager = new EntityZombie(player.worldObj);
            zombieVillager.copyLocationAndAnglesFrom(villager);
            player.worldObj.removeEntity(villager);
            zombieVillager.onInitialSpawn(player.worldObj.getDifficultyForLocation(new BlockPos(zombieVillager)), null);
            zombieVillager.setVillagerType(villager.getProfessionForge());
            zombieVillager.setChild(villager.isChild());
            zombieVillager.setNoAI(villager.isAIDisabled());
            if (villager.hasCustomName()) {
                zombieVillager.setCustomNameTag(villager.getCustomNameTag());
                zombieVillager.setAlwaysRenderNameTag(villager.getAlwaysRenderNameTag());
            }
            player.worldObj.spawnEntityInWorld(zombieVillager);
            player.worldObj.playEvent(null, 1026, zombieVillager.getPosition(), 0);
        }
    }
}
 
開發者ID:Fararise,項目名稱:Possessed,代碼行數:23,代碼來源:ZombieHandler.java

示例8: japaneseDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void japaneseDeath(LivingDeathEvent event)
{
    EntityLivingBase living = event.getEntityLiving();
    World world = living.world;
    if(!event.isCanceled() && !world.isRemote && living.hasCapability(JAPANESE_MOB_CAP,null))
    {
        JapaneseMob japaneseMob = living.getCapability(JAPANESE_MOB_CAP,null);
        int i = japaneseMob.spirits;

        while (i > 0)
        {
            int j = EntitySpirit.getSpiritSplit(i);
            i -= j;
            world.spawnEntity(new EntitySpirit(world, living.posX, living.posY, living.posZ, j));
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:19,代碼來源:JapaneseMobHandler.java

示例9: onHunt

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onHunt(LivingDeathEvent event) {

	EntityPlayer player = null;

	EntityLivingBase e = (EntityLivingBase) event.getEntity();
	DamageSource source = event.getSource();

	if (source.getTrueSource() instanceof EntityPlayer) {
		player = (EntityPlayer) source.getTrueSource();
	}

	if (player == null) {
		return;
	}

	IDailiesCapability dailies = getCapability(player);
	if (dailies == null) {
		return;
	}

	dailies.hunt(player, e);
}
 
開發者ID:ToroCraft,項目名稱:Dailies,代碼行數:24,代碼來源:Events.java

示例10: reviveEffect

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void reviveEffect(LivingDeathEvent lde)
  {
    if ((Main.allowPFeather) && ((lde.entityLiving instanceof EntityPlayer)))
    {
      EntityPlayer ep = (EntityPlayer)lde.entityLiving;
  	if (((EntityLivingBase) ep).isPotionActive(ItemRegistry1.customPotion))
      {
        if (!ep.worldObj.isRemote)
        {
        	ep.setHealth(17);
          ep.worldObj.playSoundAtEntity(ep, "fireworks.launch", 5.0F, 1.0F);
          ep.worldObj.playSoundAtEntity(ep, "assets.speedboost", 0.4F, 0.3F);
          ((EntityLivingBase) ep).removePotionEffect(ItemRegistry1.customPotion.id);
        }
        System.out.println("Potion types capacity: " + Potion.potionTypes.length);
        lde.setCanceled(true);
      }
    }
    }
 
開發者ID:GhostMonk3408,項目名稱:MidgarCrusade,代碼行數:21,代碼來源:ForgeEventHooksHandler.java

示例11: onKill

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onKill(LivingDeathEvent event) {
	EntityPlayer player = null;
	EntityLivingBase victim = (EntityLivingBase) event.getEntity();
	DamageSource source = event.getSource();

	if (source.getTrueSource() instanceof EntityPlayer) {
		player = (EntityPlayer) source.getTrueSource();
	}

	if (player == null) {
		return;
	}

	Province province = PlayerCivilizationCapabilityImpl.get(player).getInCivilization();

	if (province == null || province.civilization == null) {
		return;
	}

	handleKillMobsQuest(player, province, victim);
}
 
開發者ID:ToroCraft,項目名稱:ToroQuest,代碼行數:23,代碼來源:QuestKillMobs.java

示例12: checkkills

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void checkkills(LivingDeathEvent event) {
	EntityPlayer player = null;
	EntityLivingBase victum = (EntityLivingBase) event.getEntity();
	DamageSource source = event.getSource();

	if (!victum.getTags().contains("encampment_quest")) {
		return;
	}

	if (source.getTrueSource() instanceof EntityPlayer) {
		player = (EntityPlayer) source.getTrueSource();
	} else {
		return;
	}

	Set<QuestData> quests = PlayerCivilizationCapabilityImpl.get(player).getCurrentQuests();
	for (QuestData data : quests) {
		if (ID == data.getQuestType() && victum.getTags().contains(data.getQuestId().toString())) {
			incrementKills(data);
			return;
		}
	}
}
 
開發者ID:ToroCraft,項目名稱:ToroQuest,代碼行數:25,代碼來源:QuestEnemyEncampment.java

示例13: checkKillsInCivilization

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void checkKillsInCivilization(LivingDeathEvent event) {
	EntityPlayer player = null;
	EntityLivingBase victim = (EntityLivingBase) event.getEntity();
	DamageSource source = event.getSource();

	if (source.getTrueSource() instanceof EntityPlayer) {
		player = (EntityPlayer) source.getTrueSource();
	}

	if (player == null) {
		return;
	}

	Province province = PlayerCivilizationCapabilityImpl.get(player).getInCivilization();

	if (province == null || province.civilization == null) {
		return;
	}

	PlayerCivilizationCapabilityImpl.get(player).adjustReputation(province.civilization, getRepuationAdjustmentFor(victim, province));

}
 
開發者ID:ToroCraft,項目名稱:ToroQuest,代碼行數:24,代碼來源:CivilizationHandlers.java

示例14: onEntityKill

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
    BlockPos pos = e.getEntity().getPosition();
    World w = e.getEntity().getEntityWorld();
    if (!w.isRemote && e.getSource().getTrueSource() != null) {
        if (e.getSource().getTrueSource() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
            if (random.nextFloat() <= chance && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
                int id = e.getEntity().getEntityId();
                Entity ent = EntityList.createEntityByID(id, w);
                if (ent != null) {
                    ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
                    w.spawnEntity(ent);
                    e.getSource().getTrueSource().playSound(SoundEvents.AMBIENT_CAVE, 1.0F, 1.0F);
                }
            }
        }
    }
}
 
開發者ID:TeamFRM,項目名稱:TAIGA,代碼行數:19,代碼來源:TraitReviving.java

示例15: onTargetKilled

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onTargetKilled(LivingDeathEvent event) {
    if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLiving) {
        World w = event.getSource().getTrueSource().world;
        ItemStack tool = ((EntityPlayer) event.getSource().getTrueSource()).getHeldItemMainhand();
        if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
            NBTTagCompound tag = TagUtil.getExtraTag(tool);
            Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
            float health = ((EntityLiving) event.getEntity()).getMaxHealth();
            data.killcount += 1;
            data.health = health;
            float bonus = Math.round(random.nextFloat() * health * 100) / divisor;
            data.bonus += bonus;
            data.bonus = (float) Math.round(data.bonus * 100f) / 100f;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
        }
    }
}
 
開發者ID:TeamFRM,項目名稱:TAIGA,代碼行數:20,代碼來源:TraitSoulEater.java


注:本文中的net.minecraftforge.event.entity.living.LivingDeathEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。