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


Java Entity.removeTag方法代碼示例

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


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

示例1: handleRespawnOfNemesis

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
private void handleRespawnOfNemesis(EntityJoinWorldEvent event) {
	Entity entity = event.getEntity();
	NemesisEntry nemesis = NemesisUtil.loadNemesisFromEntity(event.getEntity());
	if (nemesis == null) {
		/*
		 * missing nemesis data
		 */
		entity.setDead();
		event.setCanceled(true);
	} else if (entity.getTags().contains(NemesisSystem.TAG_SPAWNING)) {
		/*
		 * new nemesis spawn in progress
		 */
		entity.removeTag(NemesisSystem.TAG_SPAWNING);
		nemesis.setSpawned(entity.getEntityId());
		nemesis.setUnloaded(null);
		NemesisRegistryProvider.get(entity.world).update(nemesis);
		sendNemesisDataToClient(nemesis);
	} else if (!nemesis.isSpawned()) {
		/*
		 * nemesis has been marked as despawned
		 */
		event.setCanceled(true);
	} else {
		/*
		 * nemesis is marked unloaded, mark as loaded now he is respawning
		 */
		if (!entity.getPersistentID().equals(nemesis.getEntityUuid())) {
			event.setCanceled(true);
			return;
		}

		nemesis.setSpawned(entity.getEntityId());
		nemesis.setUnloaded(null);
		nemesis.setLastSpawned(entity.world.getTotalWorldTime());
		NemesisRegistryProvider.get(event.getWorld()).update(nemesis);
		sendNemesisDataToClient(nemesis);
	}
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:40,代碼來源:SpawnHandler.java

示例2: applyPlayerTag

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
protected void applyPlayerTag(MinecraftServer server, ICommandSender sender, String[] p_184924_3_, int p_184924_4_) throws CommandException
{
    String s = getEntityName(server, sender, p_184924_3_[p_184924_4_]);
    Entity entity = getEntity(server, sender, p_184924_3_[p_184924_4_++]);
    String s1 = p_184924_3_[p_184924_4_++];
    Set<String> set = entity.getTags();

    if ("list".equals(s1))
    {
        if (!set.isEmpty())
        {
            TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.scoreboard.players.tag.list", new Object[] {s});
            textcomponenttranslation.getStyle().setColor(TextFormatting.DARK_GREEN);
            sender.addChatMessage(textcomponenttranslation);
            sender.addChatMessage(new TextComponentString(joinNiceString(set.toArray())));
        }

        sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, set.size());
    }
    else if (p_184924_3_.length < 5)
    {
        throw new WrongUsageException("commands.scoreboard.players.tag.usage", new Object[0]);
    }
    else
    {
        String s2 = p_184924_3_[p_184924_4_++];

        if (p_184924_3_.length > p_184924_4_)
        {
            try
            {
                NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(buildString(p_184924_3_, p_184924_4_));
                NBTTagCompound nbttagcompound1 = entityToNBT(entity);

                if (!NBTUtil.areNBTEquals(nbttagcompound, nbttagcompound1, true))
                {
                    throw new CommandException("commands.scoreboard.players.tag.tagMismatch", new Object[] {s});
                }
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.scoreboard.players.tag.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        if ("add".equals(s1))
        {
            if (!entity.addTag(s2))
            {
                throw new CommandException("commands.scoreboard.players.tag.tooMany", new Object[] {Integer.valueOf(1024)});
            }

            notifyCommandListener(sender, this, "commands.scoreboard.players.tag.success.add", new Object[] {s2});
        }
        else
        {
            if (!"remove".equals(s1))
            {
                throw new WrongUsageException("commands.scoreboard.players.tag.usage", new Object[0]);
            }

            if (!entity.removeTag(s2))
            {
                throw new CommandException("commands.scoreboard.players.tag.notFound", new Object[] {s2});
            }

            notifyCommandListener(sender, this, "commands.scoreboard.players.tag.success.remove", new Object[] {s2});
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:71,代碼來源:CommandScoreboard.java


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