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


Java NBTUtil.readGameProfileFromNBT方法代碼示例

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


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

示例1: readFromNBT

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:25,代碼來源:TileEntitySkull.java

示例2: readOwner

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
private static GameProfile readOwner(NBTTagCompound tag) {
	if (tag.hasKey("owner", Constants.NBT.TAG_STRING)) {
		String ownerName = tag.getString("owner");
		return TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, ownerName));
	} else if (tag.hasKey("OwnerUUID", Constants.NBT.TAG_STRING)) {
		final String uuidStr = tag.getString("OwnerUUID");
		try {
			UUID uuid = UUID.fromString(uuidStr);
			return new GameProfile(uuid, null);
		} catch (IllegalArgumentException e) {
			Log.warn(e, "Failed to parse UUID: %s", uuidStr);
		}
	} else if (tag.hasKey("Owner", Constants.NBT.TAG_COMPOUND)) { return NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("Owner")); }

	return null;
}
 
開發者ID:OpenMods,項目名稱:OpenBlocks,代碼行數:17,代碼來源:EntityMiniMe.java

示例3: readFromNBT

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);

	if (nbt.hasKey("owner", Constants.NBT.TAG_STRING)) {
		String ownerName = nbt.getString("owner");

		this.owner = TileEntitySkull.updateGameprofile(new GameProfile(null, ownerName));
	} else if (nbt.hasKey("OwnerUUID", Constants.NBT.TAG_STRING)) {
		final String uuidStr = nbt.getString("OwnerUUID");
		try {
			UUID uuid = UUID.fromString(uuidStr);
			this.owner = new GameProfile(uuid, null);
		} catch (IllegalArgumentException e) {
			Log.warn(e, "Failed to parse UUID: %s", uuidStr);
		}
	} else if (nbt.hasKey("Owner", Constants.NBT.TAG_COMPOUND)) {
		this.owner = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("Owner"));
	}

}
 
開發者ID:OpenMods,項目名稱:OpenBlocks,代碼行數:22,代碼來源:TileEntityGoldenEgg.java

示例4: readEntityFromNBT

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
	this.data = compound.getCompoundTag("Entity");
	this.ticksLeft = compound.getShort("TicksLeft");
	this.player = compound.getBoolean("Player");
	if (player) {
		this.profile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Profile"));
	}
	this.useHand = compound.getBoolean("UseArm");
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:11,代碼來源:EntityStatue.java

示例5: fromNBT

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
@Override
public void fromNBT(NBTTagCompound tag)
{
    super.fromNBT(tag);

    if (tag.hasKey("PlayerProfile", 10))
    {
        this.profile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("PlayerProfile"));
    }
    else if (tag.hasKey("Username"))
    {
        this.profile = new GameProfile(null, tag.getString("Username"));
        this.profile = TileEntitySkull.updateGameprofile(this.profile);
    }
}
 
開發者ID:mchorse,項目名稱:metamorph,代碼行數:16,代碼來源:PlayerMorph.java

示例6: getProfile

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
public static GameProfile getProfile(NBTTagCompound nbtTag) {
    if (hasProfile(nbtTag)) {
        return NBTUtil.readGameProfileFromNBT(nbtTag.getCompoundTag("Owner"));
    } else {
        return null;
    }
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:8,代碼來源:GameProfileHelper.java

示例7: getItemStackDisplayName

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
@Override
public String getItemStackDisplayName(ItemStack itemStack) {
    if (itemStack.getItemDamage() == EnumCorpse.STEVE.ordinal()) {
        NBTTagCompound nbt = itemStack.getTagCompound();
        if (nbt != null && nbt.hasKey("Owner", 10)) {
            GameProfile playerProfile = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("Owner"));
            if (playerProfile != null) {
                return EnumCorpse.getPlayerUnLocalizedName() + " - " + playerProfile.getName();
            }
        }
    }
    return EnumCorpse.getById((byte) itemStack.getItemDamage()).getUnLocalizedName();
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:14,代碼來源:ItemBlockCorpse.java

示例8: readFromNBT

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound tag)
{
    super.readFromNBT(tag);
    hasBase = tag.getBoolean("hasBase");
    head = tag.getInteger("head");
    hasStand = tag.getBoolean("hasStand");
    isOnFloor = tag.getBoolean("isOnFloor");
    orientation = tag.getInteger("orientation");
    sideOn = tag.getInteger("sideOn");

    if(head == 4)
    {
        if(tag.hasKey("headName") && !tag.getString("headName").isEmpty())
        {
            this.gameProfile = EntityHelper.getGameProfile(tag.getString("headName"));
        }
        else if (tag.hasKey("headNameProfile", 10))
        {
            this.gameProfile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("headNameProfile"));
        }
    }

    hatName = tag.getString("hatName");
    colourR = tag.getInteger("colourR");
    colourG = tag.getInteger("colourG");
    colourB = tag.getInteger("colourB");
    alpha = tag.getInteger("alpha");

    if(alpha == 0)
    {
        alpha = 255;
    }

    info = new HatInfoClient(hatName, colourR, colourG, colourB, alpha);
}
 
開發者ID:iChun,項目名稱:Hats,代碼行數:37,代碼來源:TileEntityHatStand.java

示例9: doRenderLayer

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
{
    ItemStack itemstack = entitylivingbaseIn.getCurrentArmor(3);

    if (itemstack != null && itemstack.getItem() != null)
    {
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
        GlStateManager.pushMatrix();

        if (entitylivingbaseIn.isSneaking())
        {
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }

        boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombie && ((EntityZombie)entitylivingbaseIn).isVillager();

        if (!flag && entitylivingbaseIn.isChild())
        {
            float f = 2.0F;
            float f1 = 1.4F;
            GlStateManager.scale(f1 / f, f1 / f, f1 / f);
            GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
        }

        this.field_177209_a.postRender(0.0625F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

        if (item instanceof ItemBlock)
        {
            float f2 = 0.625F;
            GlStateManager.translate(0.0F, -0.25F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.scale(f2, -f2, -f2);

            if (flag)
            {
                GlStateManager.translate(0.0F, 0.1875F, 0.0F);
            }

            minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD);
        }
        else if (item == Items.skull)
        {
            float f3 = 1.1875F;
            GlStateManager.scale(f3, -f3, -f3);

            if (flag)
            {
                GlStateManager.translate(0.0F, 0.0625F, 0.0F);
            }

            GameProfile gameprofile = null;

            if (itemstack.hasTagCompound())
            {
                NBTTagCompound nbttagcompound = itemstack.getTagCompound();

                if (nbttagcompound.hasKey("SkullOwner", 10))
                {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }
                else if (nbttagcompound.hasKey("SkullOwner", 8))
                {
                    String s = nbttagcompound.getString("SkullOwner");

                    if (!StringUtils.isNullOrEmpty(s))
                    {
                        gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
                        nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                    }
                }
            }

            TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1);
        }

        GlStateManager.popMatrix();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:81,代碼來源:LayerCustomHead.java

示例10: doRenderLayer

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

    if (!itemstack.func_190926_b())
    {
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
        GlStateManager.pushMatrix();

        if (entitylivingbaseIn.isSneaking())
        {
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }

        boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombieVillager;

        if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager))
        {
            float f = 2.0F;
            float f1 = 1.4F;
            GlStateManager.translate(0.0F, 0.5F * scale, 0.0F);
            GlStateManager.scale(0.7F, 0.7F, 0.7F);
            GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
        }

        this.modelRenderer.postRender(0.0625F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

        if (item == Items.SKULL)
        {
            float f2 = 1.1875F;
            GlStateManager.scale(1.1875F, -1.1875F, -1.1875F);

            if (flag)
            {
                GlStateManager.translate(0.0F, 0.0625F, 0.0F);
            }

            GameProfile gameprofile = null;

            if (itemstack.hasTagCompound())
            {
                NBTTagCompound nbttagcompound = itemstack.getTagCompound();

                if (nbttagcompound.hasKey("SkullOwner", 10))
                {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }
                else if (nbttagcompound.hasKey("SkullOwner", 8))
                {
                    String s = nbttagcompound.getString("SkullOwner");

                    if (!StringUtils.isBlank(s))
                    {
                        gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
                        nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                    }
                }
            }

            TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, limbSwing);
        }
        else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD)
        {
            float f3 = 0.625F;
            GlStateManager.translate(0.0F, -0.25F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.scale(0.625F, -0.625F, -0.625F);

            if (flag)
            {
                GlStateManager.translate(0.0F, 0.1875F, 0.0F);
            }

            minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD);
        }

        GlStateManager.popMatrix();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:82,代碼來源:LayerCustomHead.java

示例11: renderByItem

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
public void renderByItem(ItemStack itemStackIn)
{
    Item item = itemStackIn.getItem();

    if (item == Items.BANNER)
    {
        this.banner.setItemValues(itemStackIn, false);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (item == Items.SHIELD)
    {
        if (itemStackIn.getSubCompound("BlockEntityTag") != null)
        {
            this.banner.setItemValues(itemStackIn, true);
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_DESIGNS.getResourceLocation(this.banner.getPatternResourceLocation(), this.banner.getPatternList(), this.banner.getColorList()));
        }
        else
        {
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
        }

        GlStateManager.pushMatrix();
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        this.modelShield.render();
        GlStateManager.popMatrix();
    }
    else if (item == Items.SKULL)
    {
        GameProfile gameprofile = null;

        if (itemStackIn.hasTagCompound())
        {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            if (nbttagcompound.hasKey("SkullOwner", 10))
            {
                gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
            }
            else if (nbttagcompound.hasKey("SkullOwner", 8) && !StringUtils.isBlank(nbttagcompound.getString("SkullOwner")))
            {
                GameProfile gameprofile1 = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
                gameprofile = TileEntitySkull.updateGameprofile(gameprofile1);
                nbttagcompound.removeTag("SkullOwner");
                nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
            }
        }

        if (TileEntitySkullRenderer.instance != null)
        {
            GlStateManager.pushMatrix();
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 180.0F, itemStackIn.getMetadata(), gameprofile, -1, 0.0F);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    else if (item == Item.getItemFromBlock(Blocks.ENDER_CHEST))
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (item == Item.getItemFromBlock(Blocks.TRAPPED_CHEST))
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestTrap, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (Block.getBlockFromItem(item) instanceof BlockShulkerBox)
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(field_191274_b[BlockShulkerBox.func_190955_b(item).getMetadata()], 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestBasic, 0.0D, 0.0D, 0.0D, 0.0F);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:74,代碼來源:TileEntityItemStackRenderer.java

示例12: doRenderLayer

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

    if (itemstack != null && itemstack.getItem() != null)
    {
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
        GlStateManager.pushMatrix();

        if (entitylivingbaseIn.isSneaking())
        {
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }

        boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombie && ((EntityZombie)entitylivingbaseIn).isVillager();

        if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager))
        {
            float f = 2.0F;
            float f1 = 1.4F;
            GlStateManager.translate(0.0F, 0.5F * scale, 0.0F);
            GlStateManager.scale(0.7F, 0.7F, 0.7F);
            GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
        }

        this.modelRenderer.postRender(0.0625F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

        if (item == Items.SKULL)
        {
            float f2 = 1.1875F;
            GlStateManager.scale(1.1875F, -1.1875F, -1.1875F);

            if (flag)
            {
                GlStateManager.translate(0.0F, 0.0625F, 0.0F);
            }

            GameProfile gameprofile = null;

            if (itemstack.hasTagCompound())
            {
                NBTTagCompound nbttagcompound = itemstack.getTagCompound();

                if (nbttagcompound.hasKey("SkullOwner", 10))
                {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }
                else if (nbttagcompound.hasKey("SkullOwner", 8))
                {
                    String s = nbttagcompound.getString("SkullOwner");

                    if (!StringUtils.isNullOrEmpty(s))
                    {
                        gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
                        nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                    }
                }
            }

            TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, limbSwing);
        }
        else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD)
        {
            float f3 = 0.625F;
            GlStateManager.translate(0.0F, -0.25F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.scale(0.625F, -0.625F, -0.625F);

            if (flag)
            {
                GlStateManager.translate(0.0F, 0.1875F, 0.0F);
            }

            minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD);
        }

        GlStateManager.popMatrix();
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:82,代碼來源:LayerCustomHead.java

示例13: renderByItem

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
public void renderByItem(ItemStack itemStackIn)
{
    if (itemStackIn.getItem() == Items.BANNER)
    {
        this.banner.setItemValues(itemStackIn);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (itemStackIn.getItem() == Items.SHIELD)
    {
        if (itemStackIn.getSubCompound("BlockEntityTag", false) != null)
        {
            this.banner.setItemValues(itemStackIn);
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_DESIGNS.getResourceLocation(this.banner.getPatternResourceLocation(), this.banner.getPatternList(), this.banner.getColorList()));
        }
        else
        {
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
        }

        GlStateManager.pushMatrix();
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        this.modelShield.render();
        GlStateManager.popMatrix();
    }
    else if (itemStackIn.getItem() == Items.SKULL)
    {
        GameProfile gameprofile = null;

        if (itemStackIn.hasTagCompound())
        {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            if (nbttagcompound.hasKey("SkullOwner", 10))
            {
                gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
            }
            else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
            {
                GameProfile lvt_2_2_ = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
                gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                nbttagcompound.removeTag("SkullOwner");
                nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
            }
        }

        if (TileEntitySkullRenderer.instance != null)
        {
            GlStateManager.pushMatrix();
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1, 0.0F);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    else
    {
        Block block = Block.getBlockFromItem(itemStackIn.getItem());

        if (block == Blocks.ENDER_CHEST)
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
        }
        else if (block == Blocks.TRAPPED_CHEST)
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestTrap, 0.0D, 0.0D, 0.0D, 0.0F);
        }
        else if (block != Blocks.CHEST) net.minecraftforge.client.ForgeHooksClient.renderTileItem(itemStackIn.getItem(), itemStackIn.getMetadata());
        else
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestBasic, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:74,代碼來源:TileEntityItemStackRenderer.java

示例14: addInformation

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
    } else {
        NBTTagCompound nbt = stack.getTagCompound();

        String deathText = "";
        if (nbt.hasKey("DeathText") && nbt.getString("DeathText").length() != 0) {
            deathText = nbt.getString("DeathText");
        }

        if (nbt.hasKey("isLocalized") && nbt.getBoolean("isLocalized")) {
            if (nbt.hasKey("name")) {
                String name = ModGravestoneExtended.proxy.getLocalizedEntityName(nbt.getString("name"));
                String killerName = ModGravestoneExtended.proxy.getLocalizedEntityName(nbt.getString("KillerName"));
                if (killerName.length() == 0) {
                    list.add(new TextComponentTranslation(deathText, new Object[]{name}).getFormattedText());
                } else {
                    list.add(new TextComponentTranslation(deathText, new Object[]{name, killerName.toLowerCase()}).getFormattedText());
                }
            }
        } else {
            list.add(deathText);
        }

        if (nbt != null && nbt.hasKey("Owner", 10)) {
            GameProfile playerProfile = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("Owner"));
            if (playerProfile != null) {
                list.add(playerProfile.getName());
            }
        }

        EnumGraveMaterial material = EnumMemorials.getById(stack.getItemDamage()).getMaterial();
        if (material != EnumGraveMaterial.OTHER) {
            StringBuilder materialStr = new StringBuilder();
            materialStr.append(ModGravestoneExtended.proxy.getLocalizedString("material.title"))
                    .append(" ")
                    .append(ModGraveStone.proxy.getLocalizedMaterial(material));
            if (nbt.getBoolean("Mossy")) {
                materialStr.append(", ")
                        .append(ModGravestoneExtended.proxy.getLocalizedString("material.mossy"));
            }
            list.add(materialStr.toString());
        }
    }
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:48,代碼來源:ItemBlockGSMemorial.java

示例15: doRenderLayer

import net.minecraft.nbt.NBTUtil; //導入方法依賴的package包/類
/**
 * Render the layer
 *
 * This method is responsible for rendering either skull with player's name
 * or an item (i.e. block or something) on custom model's head. Hardcoded
 * to vanilla player model.
 */
@Override
public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

    if (itemstack != null && itemstack.getItem() != null)
    {
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
        GlStateManager.pushMatrix();

        if (entity.isSneaking())
        {
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }

        if (entity.isChild() && !(entity instanceof EntityVillager))
        {
            GlStateManager.translate(0.0F, 0.5F * scale, 0.0F);
            GlStateManager.scale(0.7F, 0.7F, 0.7F);
            GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
        }

        this.model.setLivingAnimations(entity, limbSwing, limbSwingAmount, partialTicks);
        this.model.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
        this.model.bipedHead.postRender(0.0625F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

        /* Player skull rendering */
        if (item == Items.SKULL)
        {
            GlStateManager.scale(1.1875F, -1.1875F, -1.1875F);

            GameProfile gameprofile = null;

            if (itemstack.hasTagCompound())
            {
                NBTTagCompound nbttagcompound = itemstack.getTagCompound();

                if (nbttagcompound.hasKey("SkullOwner", 10))
                {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }
                else if (nbttagcompound.hasKey("SkullOwner", 8))
                {
                    String s = nbttagcompound.getString("SkullOwner");

                    if (!StringUtils.isNullOrEmpty(s))
                    {
                        gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID) null, s));
                        nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                    }
                }
            }

            TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, limbSwing);
        }
        else if (!(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD)
        {
            /* Custom block rendering */
            GlStateManager.translate(0.0F, -0.25F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.scale(0.625F, -0.625F, -0.625F);

            minecraft.getItemRenderer().renderItem(entity, itemstack, ItemCameraTransforms.TransformType.HEAD);
        }

        GlStateManager.popMatrix();
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:78,代碼來源:LayerCustomHead.java


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