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


Java Entity.getUniqueID方法代碼示例

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


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

示例1: SPacketSpawnObject

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public SPacketSpawnObject(Entity entityIn, int typeIn, int dataIn)
{
    this.entityId = entityIn.getEntityId();
    this.uniqueId = entityIn.getUniqueID();
    this.x = entityIn.posX;
    this.y = entityIn.posY;
    this.z = entityIn.posZ;
    this.pitch = MathHelper.floor(entityIn.rotationPitch * 256.0F / 360.0F);
    this.yaw = MathHelper.floor(entityIn.rotationYaw * 256.0F / 360.0F);
    this.type = typeIn;
    this.data = dataIn;
    double d0 = 3.9D;
    this.speedX = (int)(MathHelper.clamp(entityIn.motionX, -3.9D, 3.9D) * 8000.0D);
    this.speedY = (int)(MathHelper.clamp(entityIn.motionY, -3.9D, 3.9D) * 8000.0D);
    this.speedZ = (int)(MathHelper.clamp(entityIn.motionZ, -3.9D, 3.9D) * 8000.0D);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:17,代碼來源:SPacketSpawnObject.java

示例2: applyItemEntityDataToEntity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Applies the data in the EntityTag tag of the given ItemStack to the given Entity.
 */
public static void applyItemEntityDataToEntity(World entityWorld, @Nullable EntityPlayer player, ItemStack stack, @Nullable Entity targetEntity)
{
    MinecraftServer minecraftserver = entityWorld.getMinecraftServer();

    if (minecraftserver != null && targetEntity != null)
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();

        if (nbttagcompound != null && nbttagcompound.hasKey("EntityTag", 10))
        {
            if (!entityWorld.isRemote && targetEntity.ignoreItemEntityData() && (player == null || !minecraftserver.getPlayerList().canSendCommands(player.getGameProfile())))
            {
                return;
            }

            NBTTagCompound nbttagcompound1 = targetEntity.writeToNBT(new NBTTagCompound());
            UUID uuid = targetEntity.getUniqueID();
            nbttagcompound1.merge(nbttagcompound.getCompoundTag("EntityTag"));
            targetEntity.setUniqueId(uuid);
            targetEntity.readFromNBT(nbttagcompound1);
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:27,代碼來源:ItemMonsterPlacer.java

示例3: SPacketSpawnObject

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public SPacketSpawnObject(Entity entityIn, int typeIn, int dataIn)
{
    this.entityId = entityIn.getEntityId();
    this.uniqueId = entityIn.getUniqueID();
    this.x = entityIn.posX;
    this.y = entityIn.posY;
    this.z = entityIn.posZ;
    this.pitch = MathHelper.floor_float(entityIn.rotationPitch * 256.0F / 360.0F);
    this.yaw = MathHelper.floor_float(entityIn.rotationYaw * 256.0F / 360.0F);
    this.type = typeIn;
    this.data = dataIn;
    double d0 = 3.9D;
    this.speedX = (int)(MathHelper.clamp_double(entityIn.motionX, -3.9D, 3.9D) * 8000.0D);
    this.speedY = (int)(MathHelper.clamp_double(entityIn.motionY, -3.9D, 3.9D) * 8000.0D);
    this.speedZ = (int)(MathHelper.clamp_double(entityIn.motionZ, -3.9D, 3.9D) * 8000.0D);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:SPacketSpawnObject.java

示例4: canAddEntity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
private boolean canAddEntity(Entity entityIn)
{
    if (entityIn.isDead)
    {
        LOGGER.warn("Tried to add entity {} but it was marked as removed already", new Object[] {EntityList.func_191301_a(entityIn)});
        return false;
    }
    else
    {
        UUID uuid = entityIn.getUniqueID();

        if (this.entitiesByUuid.containsKey(uuid))
        {
            Entity entity = (Entity)this.entitiesByUuid.get(uuid);

            if (this.unloadedEntityList.contains(entity))
            {
                this.unloadedEntityList.remove(entity);
            }
            else
            {
                if (!(entityIn instanceof EntityPlayer))
                {
                    LOGGER.warn("Keeping entity {} that already exists with UUID {}", new Object[] {EntityList.func_191301_a(entity), uuid.toString()});
                    return false;
                }

                LOGGER.warn("Force-added player with duplicate UUID {}", new Object[] {uuid.toString()});
            }

            this.removeEntityDangerously(entity);
        }

        return true;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:37,代碼來源:WorldServer.java

示例5: canAddEntity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
private boolean canAddEntity(Entity entityIn)
{
    if (entityIn.isDead)
    {
        LOGGER.warn("Tried to add entity {} but it was marked as removed already", new Object[] {EntityList.getEntityString(entityIn)});
        return false;
    }
    else
    {
        UUID uuid = entityIn.getUniqueID();

        if (this.entitiesByUuid.containsKey(uuid))
        {
            Entity entity = (Entity)this.entitiesByUuid.get(uuid);

            if (this.unloadedEntityList.contains(entity))
            {
                this.unloadedEntityList.remove(entity);
            }
            else
            {
                if (!(entityIn instanceof EntityPlayer))
                {
                    LOGGER.warn("Keeping entity {} that already exists with UUID {}", new Object[] {EntityList.getEntityString(entity), uuid.toString()});
                    return false;
                }

                LOGGER.warn("Force-added player with duplicate UUID {}", new Object[] {uuid.toString()});
            }

            this.removeEntityDangerously(entity);
        }

        return true;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:37,代碼來源:WorldServer.java

示例6: execute

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.entitydata.usage", new Object[0]);
    }
    else
    {
        Entity entity = getEntity(server, sender, args[0]);

        if (entity instanceof EntityPlayer)
        {
            throw new CommandException("commands.entitydata.noPlayers", new Object[] {entity.getDisplayName()});
        }
        else
        {
            NBTTagCompound nbttagcompound = entityToNBT(entity);
            NBTTagCompound nbttagcompound1 = nbttagcompound.copy();
            NBTTagCompound nbttagcompound2;

            try
            {
                nbttagcompound2 = JsonToNBT.getTagFromJson(getChatComponentFromNthArg(sender, args, 1).getUnformattedText());
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.entitydata.tagError", new Object[] {nbtexception.getMessage()});
            }

            UUID uuid = entity.getUniqueID();
            nbttagcompound.merge(nbttagcompound2);
            entity.setUniqueId(uuid);

            if (nbttagcompound.equals(nbttagcompound1))
            {
                throw new CommandException("commands.entitydata.failed", new Object[] {nbttagcompound.toString()});
            }
            else
            {
                entity.readFromNBT(nbttagcompound);
                notifyCommandListener(sender, this, "commands.entitydata.success", new Object[] {nbttagcompound.toString()});
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:49,代碼來源:CommandEntityData.java


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