Search in sources :

Example 36 with ItemArmor

use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.

the class ArmorHelper method imbueArmor.

public static void imbueArmor(ItemStack armorStack, String id, boolean ignoreLevelRequirement) {
    IArmorImbuement imbuement = ImbuementRegistry.instance.getImbuementByID(id);
    if (armorStack != null && imbuement != null && armorStack.getItem() instanceof ItemArmor) {
        if (!ignoreLevelRequirement && getArmorLevel(armorStack) < getImbueCost(imbuement.getTier()))
            return;
        for (int i : imbuement.getValidSlots()) {
            if (i == ((ItemArmor) armorStack.getItem()).armorType) {
                if (!armorStack.hasTagCompound())
                    armorStack.setTagCompound(new NBTTagCompound());
                NBTTagCompound armorProps = (NBTTagCompound) armorStack.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
                if (armorProps == null)
                    armorProps = new NBTTagCompound();
                String infusionList = armorProps.getString(AMArmor.NBT_KEY_EFFECTS);
                if (infusionList == null || infusionList == "")
                    infusionList = id;
                else
                    infusionList += "|" + id;
                armorProps.setString(AMArmor.NBT_KEY_EFFECTS, infusionList);
                armorStack.stackTagCompound.setTag(AMArmor.NBT_KEY_AMPROPS, armorProps);
                deductXPFromArmor(EntityUtilities.getXPFromLevel(getImbueCost(imbuement.getTier())), armorStack);
                break;
            }
        }
    }
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IArmorImbuement(am2.api.items.armor.IArmorImbuement)

Example 37 with ItemArmor

use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.

the class ArmorHelper method addXPToArmor.

public static void addXPToArmor(float amt, ItemStack armor) {
    if (armor != null && armor.getItem() instanceof ItemArmor) {
        if (!armor.hasTagCompound())
            armor.setTagCompound(new NBTTagCompound());
        NBTTagCompound armorProps = (NBTTagCompound) armor.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
        if (armorProps == null)
            armorProps = new NBTTagCompound();
        armorProps.setDouble(AMArmor.NBT_KEY_TOTALXP, armorProps.getDouble(AMArmor.NBT_KEY_TOTALXP) + amt);
        armorProps.setInteger(AMArmor.NBT_KEY_ARMORLEVEL, EntityUtilities.getLevelFromXP((float) armorProps.getDouble(AMArmor.NBT_KEY_TOTALXP)));
        armor.stackTagCompound.setTag(AMArmor.NBT_KEY_AMPROPS, armorProps);
    }
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 38 with ItemArmor

use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.

the class ContainerArmorInfuser method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
    Slot slot = (Slot) this.inventorySlots.get(index);
    ItemStack stack = slot.getStack();
    if (stack == null)
        return null;
    if (stack.getItem() instanceof ItemArmor) {
        ItemArmor armor = (ItemArmor) stack.getItem();
        if (index == 0) {
            Slot playerSlot = (Slot) inventorySlots.get(armor.armorType + 1);
            if (!playerSlot.getHasStack()) {
                ItemStack clone = stack.copy();
                playerSlot.putStack(clone);
                slot.putStack(null);
                playerSlot.onSlotChanged();
                slot.onSlotChanged();
                return clone;
            }
        } else {
            Slot armorSlot = (Slot) this.inventorySlots.get(0);
            if (!armorSlot.getHasStack()) {
                ItemStack clone = stack.copy();
                armorSlot.putStack(clone);
                slot.putStack(null);
                armorSlot.onSlotChanged();
                slot.onSlotChanged();
                return clone;
            }
        }
    }
    return null;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 39 with ItemArmor

use of net.minecraft.item.ItemArmor in project Armourers-Workshop by RiskyKen.

the class RenderBlockMannequinItems method renderHeadStack.

public void renderHeadStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
    Item targetItem = stack.getItem();
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, targetBiped, extraColours, distance, true);
        return;
    }
    if (targetItem instanceof ItemBlock) {
        float blockScale = 0.5F;
        GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleZ), 0, 0, 1);
        GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleY), 0, 1, 0);
        GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleX), 1, 0, 0);
        GL11.glTranslatef(0, -4 * scale, 0);
        GL11.glScalef(-blockScale, -blockScale, blockScale);
        GL11.glRotatef(90F, 0F, 1F, 0F);
        rm.itemRenderer.renderItem(fakePlayer, stack, stack.getItemDamage());
    } else {
        if (targetItem instanceof ItemArmor) {
            int passes = targetItem.getRenderPasses(stack.getItemDamage());
            for (int i = 0; i < passes; i++) {
                ModelBiped armourBiped = ForgeHooksClient.getArmorModel(fakePlayer, stack, 0, renderPlayer.modelArmorChestplate);
                if (i == 0) {
                    bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 0, null));
                } else {
                    bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 0, "overlay"));
                }
                Color c = new Color(targetItem.getColorFromItemStack(stack, i));
                GL11.glColor3f((float) c.getRed() / 255, (float) c.getGreen() / 255, (float) c.getBlue() / 255);
                armourBiped.isChild = false;
                if (armourBiped == renderPlayer.modelArmorChestplate) {
                    setRotations(targetBiped.bipedHead, armourBiped.bipedHead);
                    armourBiped.bipedHead.showModel = true;
                    armourBiped.bipedHead.render(scale);
                    resetRotations(targetBiped.bipedHead);
                } else {
                    try {
                        GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleZ), 0, 0, 1);
                        GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleY), 0, 1, 0);
                        GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleX), 1, 0, 0);
                        armourBiped.render(null, 0, 0, 0, 0, 0, scale);
                    } catch (Exception e) {
                    // ModLogger.log(e);
                    }
                }
            }
        }
    }
}
Also used : Item(net.minecraft.item.Item) ModelBiped(net.minecraft.client.model.ModelBiped) ItemArmor(net.minecraft.item.ItemArmor) Color(java.awt.Color) ItemBlock(net.minecraft.item.ItemBlock)

Example 40 with ItemArmor

use of net.minecraft.item.ItemArmor in project Armourers-Workshop by RiskyKen.

the class RenderBlockMannequinItems method renderFeetStack.

public void renderFeetStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
    Item targetItem = stack.getItem();
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, targetBiped, extraColours, distance, true);
        return;
    }
    if (targetItem instanceof ItemArmor) {
        int passes = targetItem.getRenderPasses(stack.getItemDamage());
        for (int i = 0; i < passes; i++) {
            ModelBiped armourBiped = ForgeHooksClient.getArmorModel(fakePlayer, stack, 3, renderPlayer.modelArmorChestplate);
            if (i == 0) {
                bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 3, null));
            } else {
                bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 3, "overlay"));
            }
            Color c = new Color(targetItem.getColorFromItemStack(stack, i));
            GL11.glColor3f((float) c.getRed() / 255, (float) c.getGreen() / 255, (float) c.getBlue() / 255);
            armourBiped.isChild = false;
            if (armourBiped == renderPlayer.modelArmorChestplate) {
                setRotations(targetBiped.bipedLeftLeg, armourBiped.bipedLeftLeg);
                setRotations(targetBiped.bipedRightLeg, armourBiped.bipedRightLeg);
                armourBiped.bipedLeftLeg.showModel = true;
                armourBiped.bipedRightLeg.showModel = true;
                armourBiped.bipedLeftLeg.render(scale);
                armourBiped.bipedRightLeg.render(scale);
                resetRotations(armourBiped.bipedLeftLeg);
                resetRotations(armourBiped.bipedRightLeg);
            } else {
                try {
                    armourBiped.render(fakePlayer, 0, 0, 0, 0, 0, scale);
                } catch (Exception e) {
                // ModLogger.log(e);
                }
            }
        }
    }
}
Also used : Item(net.minecraft.item.Item) ModelBiped(net.minecraft.client.model.ModelBiped) ItemArmor(net.minecraft.item.ItemArmor) Color(java.awt.Color)

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