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


Java Entity.addTag方法代码示例

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


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

示例1: spawnTest

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
private void spawnTest(ICommandSender sender) throws CommandException {
	if (!(sender instanceof EntityPlayer)) {
		return;
	}

	EntityPlayer player = getCommandSenderAsPlayer(sender);
	World world = player.world;
	NemesisEntry nemesis = NemesisRegistryProvider.get(world).getById(TEST_ID);

	if (nemesis == null) {
		System.out.println("NemesisEntry is null, run /nemesis_system create_test");
		return;
	}

	Entity entity = SpawnApi.getEntityFromString(world, nemesis.getMob());

	if (entity == null) {
		return;
	}

	EntityDecorator.decorate((EntityCreature) entity, nemesis);
	entity.addTag(NemesisSystem.TAG_SPAWNING);
	SpawnApi.spawnEntityCreature(world, (EntityCreature) entity, player.getPosition(), 0);
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:25,代码来源:NemesisSystemCommand.java

示例2: work

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public static void work(MessageSyncNemesis message) {
	NemesisEntry nemesis = message.nemesis;

	if (nemesis == null) {
		return;
	}

	Entity entity = Minecraft.getMinecraft().world.getEntityByID(nemesis.getSpawned());

	if (entity == null) {
		return;
	}

	entity.addTag(NemesisSystem.TAG_NEMESIS);
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:16,代码来源:MessageSyncNemesis.java

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