Search in sources :

Example 1 with ItemArmor

use of net.minecraft.item.ItemArmor in project SpongeCommon by SpongePowered.

the class ArmorTypePropertyStore method getFor.

@Override
protected Optional<ArmorTypeProperty> getFor(ItemStack itemStack) {
    if (itemStack.getItem() instanceof ItemArmor) {
        final ItemArmor armor = (ItemArmor) itemStack.getItem();
        final ItemArmor.ArmorMaterial armorMaterial = armor.getArmorMaterial();
        return Optional.of(new ArmorTypeProperty((ArmorType) (Object) armorMaterial));
    }
    return Optional.empty();
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) ArmorTypeProperty(org.spongepowered.api.data.property.item.ArmorTypeProperty) ArmorType(org.spongepowered.api.data.type.ArmorType)

Example 2 with ItemArmor

use of net.minecraft.item.ItemArmor in project SilentGems by SilentChaos512.

the class EquipmentTooltips method renderForArmor.

private void renderForArmor(RenderTooltipEvent.PostText event, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    FontRenderer fontRenderer = event.getFontRenderer();
    ItemArmor itemArmor = (ItemArmor) stack.getItem();
    ItemStack currentEquip = StackHelper.empty();
    for (ItemStack itemstack : mc.player.getEquipmentAndArmor()) {
        Item item = itemstack.getItem();
        if (item instanceof ItemArmor && ((ItemArmor) item).armorType == itemArmor.armorType) {
            currentEquip = itemstack;
        }
    }
    double scale = 0.75;
    int x = (int) (event.getX() / scale);
    int y = (int) ((event.getY() - 16) / scale);
    int durability = getDurability(stack, 0);
    int equippedDurability = getDurability(currentEquip, durability);
    float protection = getProtection(stack, 0);
    float equippedProtection = getProtection(currentEquip, protection);
    float toughness = getToughness(stack, 0);
    float equippedToughness = getToughness(currentEquip, toughness);
    GlStateManager.pushMatrix();
    GlStateManager.color(1f, 1f, 1f, 1f);
    GlStateManager.scale(scale, scale, scale);
    mc.renderEngine.bindTexture(TEXTURE);
    // Durability
    x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
    // Protection
    x = renderStat(mc, fontRenderer, 6, x, y, protection, equippedProtection, StackHelper.isValid(currentEquip));
    // Toughness
    if (toughness > 0 || equippedToughness > 0)
        x = renderStat(mc, fontRenderer, 7, x, y, toughness, equippedToughness, StackHelper.isValid(currentEquip));
    lastWidth = (int) (x * scale - event.getX());
    GlStateManager.popMatrix();
}
Also used : Item(net.minecraft.item.Item) ItemArmor(net.minecraft.item.ItemArmor) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Example 3 with ItemArmor

use of net.minecraft.item.ItemArmor in project SpongeForge by SpongePowered.

the class StaticMixinForgeHelper method getProperties.

private static ISpecialArmor.ArmorProperties getProperties(EntityLivingBase base, ItemStack armorStack, DamageSource damageSource, double damage, int index) {
    if (armorStack.isEmpty()) {
        return null;
    }
    ISpecialArmor.ArmorProperties prop = null;
    if (armorStack.getItem() instanceof ISpecialArmor) {
        ISpecialArmor armor = (ISpecialArmor) armorStack.getItem();
        prop = armor.getProperties(base, armorStack, damageSource, damage / 25D, index).copy();
    } else if (armorStack.getItem() instanceof ItemArmor && !damageSource.isUnblockable()) {
        ItemArmor armor = (ItemArmor) armorStack.getItem();
        prop = new ISpecialArmor.ArmorProperties(0, armor.damageReduceAmount / 25D, Integer.MAX_VALUE);
    }
    if (prop != null) {
        prop.Slot = index;
        return prop;
    }
    return null;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) ISpecialArmor(net.minecraftforge.common.ISpecialArmor)

Example 4 with ItemArmor

use of net.minecraft.item.ItemArmor in project Cavern2 by kegare.

the class RandomiteHelper method refreshItems.

public static void refreshItems() {
    DROP_ITEMS.clear();
    Set<String> oreNames = Sets.newTreeSet();
    String[] targetNames = { "treeSapling", "sugarcane", "vine", "slimeball", "enderpearl", "bone", "gunpowder", "string", "torch" };
    String[] targetPrefixes = { "gem", "ingot", "nugget", "dust", "crop" };
    for (String name : targetNames) {
        if (OreDictionary.doesOreNameExist(name)) {
            oreNames.add(name);
        }
    }
    for (String name : OreDictionary.getOreNames()) {
        for (String prefix : targetPrefixes) {
            if (name.startsWith(prefix) && Character.isUpperCase(name.charAt(prefix.length()))) {
                oreNames.add(name);
            }
        }
    }
    for (String name : oreNames) {
        for (ItemStack stack : OreDictionary.getOres(name, false)) {
            if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
                NonNullList<ItemStack> list = NonNullList.create();
                stack.getItem().getSubItems(CreativeTabs.SEARCH, list);
                for (ItemStack subStack : list) {
                    addItem(subStack, 50);
                }
            } else {
                addItem(stack, 50);
            }
        }
    }
    for (Item item : Item.REGISTRY) {
        if (item == null || item == Items.AIR || item instanceof ItemBlock) {
            continue;
        }
        if (item instanceof ItemFood) {
            NonNullList<ItemStack> list = NonNullList.create();
            item.getSubItems(CreativeTabs.SEARCH, list);
            for (ItemStack stack : list) {
                addItem(stack, 15);
            }
        } else if (item instanceof ItemTool || item instanceof ItemArmor || item instanceof ItemSword || item instanceof ItemBow) {
            addItem(new ItemStack(item), 5);
        }
    }
    addItem(ItemCave.EnumType.MINER_ORB.getItemStack(), 1);
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) ItemFood(net.minecraft.item.ItemFood) ItemTool(net.minecraft.item.ItemTool) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack) WeightedItemStack(cavern.util.WeightedItemStack) ItemBlock(net.minecraft.item.ItemBlock) ItemBow(net.minecraft.item.ItemBow)

Example 5 with ItemArmor

use of net.minecraft.item.ItemArmor in project BloodMagic by WayofTime.

the class RenderEntityMimic method doRender.

@Override
public void doRender(EntityMimic mimic, double x, double y, double z, float entityYaw, float partialTicks) {
    super.doRender(mimic, x, y, z, entityYaw, partialTicks);
    GlStateManager.pushMatrix();
    if (mimic.getMimicItemStack() != null) {
        GlStateManager.pushMatrix();
        if (this.renderOutlines) {
            GlStateManager.enableColorMaterial();
            GlStateManager.enableOutlineMode(this.getTeamColor(mimic));
        }
        GlStateManager.translate(x, y, z);
        ItemStack itemstack = mimic.getMimicItemStack();
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
        GlStateManager.pushMatrix();
        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);
            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(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, 0);
        } else if (!(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) {
            GlStateManager.translate(0, 0.5f, 0);
            GlStateManager.rotate(-(mimic.prevRotationYawHead + partialTicks * (mimic.rotationYawHead - mimic.prevRotationYawHead)) - 180, 0, 1, 0);
            minecraft.getItemRenderer().renderItem(mimic, itemstack, ItemCameraTransforms.TransformType.HEAD);
        }
        GlStateManager.popMatrix();
        if (this.renderOutlines) {
            GlStateManager.disableOutlineMode();
            GlStateManager.disableColorMaterial();
        }
        GlStateManager.popMatrix();
        super.doRender(mimic, x, y, z, entityYaw, partialTicks);
    }
    GlStateManager.popMatrix();
    if (!this.renderOutlines) {
        this.renderLeash(mimic, x, y, z, entityYaw, partialTicks);
    }
}
Also used : Item(net.minecraft.item.Item) GameProfile(com.mojang.authlib.GameProfile) ItemArmor(net.minecraft.item.ItemArmor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Aggregations

ItemArmor (net.minecraft.item.ItemArmor)45 ItemStack (net.minecraft.item.ItemStack)27 Item (net.minecraft.item.Item)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 ModelBiped (net.minecraft.client.model.ModelBiped)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 Color (java.awt.Color)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)4 IArmorImbuement (am2.api.items.armor.IArmorImbuement)3 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)3 Slot (net.minecraft.inventory.Slot)3 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 Minecraft (net.minecraft.client.Minecraft)2 TextureManager (net.minecraft.client.renderer.texture.TextureManager)2 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)2 ItemBlock (net.minecraft.item.ItemBlock)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2