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


Java LivingDeathEvent.setCanceled方法代碼示例

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


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

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

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

示例3: livingDeathEvent

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void livingDeathEvent(LivingDeathEvent event)
{
    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return;
    if (event.getSource() != DamageSource.OUT_OF_WORLD || !(event.getEntity() instanceof EntityPlayer)) return;
    if (event.getEntityLiving().lastDamage >= (Float.MAX_VALUE / 2)) return; // try to ignore /kill command
    for (int dim : voidRefundDimensions)
    {
        if (dim != event.getEntity().dimension) continue;
        event.setCanceled(true);

        //noinspection ConstantConditions
        InventoryPlayer tempCopy = new InventoryPlayer(null);
        tempCopy.copyInventory(((EntityPlayer) event.getEntity()).inventory);
        map.put(event.getEntity().getPersistentID(), tempCopy);
    }
}
 
開發者ID:DoubleDoorDevelopment,項目名稱:D3Core,代碼行數:18,代碼來源:VoidRefunds.java

示例4: onDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@Override
public void onDeath(ItemStack itemStack, LivingDeathEvent event, boolean isWornArmor) {
	System.out.println("ABORTING DEATH");
	if(isWornArmor && !event.isCanceled()) {
		EntityPlayer player = (EntityPlayer)event.entity;
		NBTTagCompound data = itemStack.getTagCompound();
		//System.out.println("Cooldown: " + data.getInteger("resCooldown"));
		if(data.getInteger("resCooldown_armor") <= 0) {
			event.setCanceled(true);
			player.setHealth(20);
			data.setInteger("resCooldown_armor", 6000);
			itemStack.damageItem(5, player);
			return;
		}
	}
}
 
開發者ID:Draco18s,項目名稱:Artifacts,代碼行數:17,代碼來源:ComponentResurrect.java

示例5: phoenixEffect

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void phoenixEffect(LivingDeathEvent lde)
  {
    if ((Main.allowPFeather) && ((lde.entityLiving instanceof EntityPlayer)))
    {
      EntityPlayer ep = (EntityPlayer)lde.entityLiving;
      if (ep. inventory.hasItem(Main.PhoenixFeather))
      {
        if (!ep.worldObj.isRemote)
        {
          ep.inventory.consumeInventoryItem(Main.PhoenixFeather);
          ep.setHealth(1);
          ep.hurtResistantTime = 65;
          ep.addPotionEffect(new PotionEffect(Potion.regeneration.id, 28, 6));
          ep.addPotionEffect(new PotionEffect(Potion.resistance.id, 65, 4));
          ep.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 65, 1));
          ep.removePotionEffect(Potion.poison.id);
          ep.removePotionEffect(Potion.wither.id);
          ep.setFire(3);
          ep.worldObj.playSoundAtEntity(ep, "fireworks.launch", 5.0F, 1.0F);
          ep.worldObj.playSoundAtEntity(ep, "assets.speedboost", 0.4F, 0.3F);
        }
        System.out.println("Potion types capacity: " + Potion.potionTypes.length);
        lde.setCanceled(true);
      }
    }
  }
 
開發者ID:GhostMonk3408,項目名稱:MidgarCrusade,代碼行數:28,代碼來源:ForgeEventHooksHandler.java

示例6: killEntity

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void killEntity(LivingDeathEvent event) {
    if (!(event.getSource().getTrueSource() instanceof EntityPlayer))
        return;
    if (event.getEntityLiving() instanceof EntityPlayer || event.getEntityLiving() instanceof EntityPlayerMP)
        return;
    World w = event.getSource().getTrueSource().getEntityWorld();
    EntityPlayer p = (EntityPlayer) event.getSource().getTrueSource();
    EntityLivingBase target = event.getEntityLiving();
    NBTTagCompound tag = TagUtil.getExtraTag(p.getHeldItemMainhand());
    Data data = Data.read(tag);
    if (!data.mobClass.isEmpty())
        return;
    if (!w.isRemote && random.nextInt((int) target.getMaxHealth()) <= chance && target instanceof EntityLiving) {
        event.setCanceled(true);
        target.setDropItemsWhenDead(false);
        if (data.mobClass.isEmpty()) {
            data.mobClass = target.getClass().getName();
            data.mobName = target.getName();
            data.write(tag);
            TagUtil.setExtraTag(p.getHeldItemMainhand(), tag);
            p.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
            target.setDropItemsWhenDead(false);
            target.setDead();
        }
    }
}
 
開發者ID:TeamFRM,項目名稱:TAIGA,代碼行數:28,代碼來源:TraitCatcher.java

示例7: entityAttacked

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@ForgeSubscribe
public void entityAttacked(LivingDeathEvent event) {
    Entity player = event.entity;

    if (player instanceof EntityPlayer) {
        ((EntityPlayer) player).closeScreen();
    }

    if (event.isCancelable()) {
        event.setCanceled(false);
    }
}
 
開發者ID:kunik-ru,項目名稱:Apocalyptic,代碼行數:13,代碼來源:EventPlayerHook.java

示例8: onEntityDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityDeath(LivingDeathEvent event)
{
	EventCancellable deathEvent = new EventEntityDeath(event.entity);
	
	EventFactory.fireEvent(deathEvent);
	
	if (deathEvent.isCancelled())
	{
		event.setCanceled(true);
	}
}
 
開發者ID:Niadel,項目名稱:N-API,代碼行數:13,代碼來源:EventHandlerForge.java

示例9: onLivingDeathEvent

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
/**
 * Set to highest priority to prevent loss of "extra lives" from HQM mod
 */
@SubscribeEvent(priority=EventPriority.HIGHEST)
public void onLivingDeathEvent(LivingDeathEvent event) {
	if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer) {
		event.setCanceled(ItemFairyBottle.onDeath((EntityPlayer) event.entity));
	}
	if (event.source.getEntity() instanceof EntityPlayer && event.entity instanceof IMob) {
		ItemZeldaSword.onKilledMob((EntityPlayer) event.source.getEntity(), (IMob) event.entity);
	}
}
 
開發者ID:coolAlias,項目名稱:ZeldaSwordSkills,代碼行數:13,代碼來源:ZSSCombatEvents.java

示例10: onEntityDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@HarshenEvent
public void onEntityDeath(LivingDeathEvent event)
{
	event.setCanceled(true);
	World world = event.getEntityLiving().world;
	if(!world.isRemote)
	{
		boolean flag = world.getGameRules().getBoolean("showDeathMessages");
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		player.connection.sendPacket(new SPacketCombatEvent(player.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag));
        if (flag)
        {
            Team team = player.getTeam();
            if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS)
                if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS)
                	player.mcServer.getPlayerList().sendMessageToAllTeamMembers(player, player.getCombatTracker().getDeathMessage());
                else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM)
                	player.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(player, player.getCombatTracker().getDeathMessage());
            else
            	player.mcServer.getPlayerList().sendMessage(player.getCombatTracker().getDeathMessage());
        }

        for (ScoreObjective scoreobjective : world.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT))
            player.getWorldScoreboard().getOrCreateScore(player.getName(), scoreobjective).incrementScore();

        EntityLivingBase entitylivingbase = player.getAttackingEntity();

        if (entitylivingbase != null)
        {
            EntityList.EntityEggInfo entitylist$entityegginfo = EntityList.ENTITY_EGGS.get(EntityList.getKey(entitylivingbase));
            if (entitylist$entityegginfo != null)
            	player.addStat(entitylist$entityegginfo.entityKilledByStat);
        }
        player.addStat(StatList.DEATHS);
        player.takeStat(StatList.TIME_SINCE_DEATH);
        player.extinguish();
        HarshenUtils.setFlag(player, 0, false);
        player.getCombatTracker().reset();
        INVENTORY_MAP.put(event.getEntity().getUniqueID(), ((EntityPlayer)event.getEntity()).inventory.writeToNBT(new NBTTagList()));
        HarshenUtils.damageOccuringItemNoPacket(player, HarshenItems.SOUL_BINDING_PENDANT, 1);
        if(HarshenUtils.getFirstOccuringItem(player, HarshenItems.SOUL_BINDING_PENDANT).getItemDamage() == 
        		HarshenUtils.getFirstOccuringItem(player, HarshenItems.SOUL_BINDING_PENDANT).getMaxDamage())
        			HarshenUtils.damageOccuringItemNoPacket(player, HarshenItems.SOUL_BINDING_PENDANT, 1);    	
	}	
	new HandlerHarshenInventory().onPlayerDeath(event);
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:47,代碼來源:SoulBindingPendant.java

示例11: onPlayerDeath

import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerDeath(LivingDeathEvent event) {
	if (event.getEntityLiving() instanceof EntityPlayerMP) {
		EntityPlayer player = (EntityPlayer) event.getEntityLiving();

		// If the player fell into the void, there's no rescuing
		if (event.getSource() == DamageSource.OUT_OF_WORLD) {
			player.getEntityData().setBoolean(IGNORE_REVIVAL_DEATH, true);
			NetworkHandler.instance.sendTo(new MessageDie(), (EntityPlayerMP) player);
			return;
		}

		// If IGNORE_REVIVAL_DEATH is set, this should be treated as a normal death
		if (event.getSource() == HardcoreRevival.notRescuedInTime || player.getEntityData().getBoolean(IGNORE_REVIVAL_DEATH)) {
			return;
		}

		// Fire event for compatibility addons
		MinecraftForge.EVENT_BUS.post(new PlayerKnockedOutEvent(player, event.getSource()));

		// Dead players glow
		if (ModConfig.glowOnDeath) {
			player.setGlowing(true);
		}

		// Cancel event - we're taking over from here
		event.setCanceled(true);

		// If enabled, show a death message
		if (player.world.getGameRules().getBoolean("showDeathMessages")) {
			MinecraftServer server = player.world.getMinecraftServer();
			if (server != null) {
				Team team = player.getTeam();
				if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS) {
					if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS) {
						server.getPlayerList().sendMessageToAllTeamMembers(player, player.getCombatTracker().getDeathMessage());
					} else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM) {
						server.getPlayerList().sendMessageToTeamOrAllPlayers(player, player.getCombatTracker().getDeathMessage());
					}
				} else {
					server.getPlayerList().sendMessage(player.getCombatTracker().getDeathMessage());
				}
			}
		}
	}
}
 
開發者ID:blay09,項目名稱:HardcoreRevival,代碼行數:47,代碼來源:DeathHandler.java

示例12: onEntityDeath

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

	if(!world.isRemote) {

		final EntityLivingBase entity = event.getEntityLiving();

		if(getStoredUUID() != null && entity.getUniqueID().equals(getStoredUUID())) {

			event.setCanceled(true);
			entity.isDead = false;
			entity.setHealth(entity.getMaxHealth());
			entity.moveToBlockPosAndAngles(pos.up(), entity.rotationYaw, entity.rotationPitch);

			if(getOwnerUUID() != null) {

				final EntityPlayer player = world.getPlayerEntityByUUID(getOwnerUUID());

				if(player != null) {

					player.sendMessage(new TextComponentTranslation("message.entity_respawned"));

				}

			}

		}

	}

}
 
開發者ID:ErrorCraftLP,項目名稱:Crying-Obsidian,代碼行數:32,代碼來源:TileEntityCryingObsidianAdvanced.java


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