Search in sources :

Example 41 with ItemArmor

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

the class RenderBlockMannequinItems method renderLegsStack.

public void renderLegsStack(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, 2, renderPlayer.modelArmor);
            if (i == 0) {
                bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 2, null));
            } else {
                bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 2, "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.modelArmor) {
                setRotations(targetBiped.bipedLeftLeg, armourBiped.bipedLeftLeg);
                setRotations(targetBiped.bipedRightLeg, armourBiped.bipedRightLeg);
                armourBiped.bipedBody.showModel = true;
                armourBiped.bipedLeftLeg.showModel = true;
                armourBiped.bipedRightLeg.showModel = true;
                armourBiped.bipedBody.render(scale);
                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)

Example 42 with ItemArmor

use of net.minecraft.item.ItemArmor in project ImmersiveEngineering by BluSunrize.

the class ModelPowerpack method render.

@Override
public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) {
    if (entity instanceof EntityLivingBase) {
        ItemStack chest = ((EntityLivingBase) entity).getItemStackFromSlot(EntityEquipmentSlot.CHEST);
        ItemStack powerpack = null;
        float storage = 0;
        if (!chest.isEmpty() && chest.getItem() instanceof ItemPowerpack)
            powerpack = chest;
        else if (!chest.isEmpty() && chest.getItem() instanceof ItemArmor && ItemNBTHelper.hasKey(chest, "IE:Powerpack"))
            powerpack = ItemNBTHelper.getItemStack(chest, "IE:Powerpack");
        else if (IEBipedLayerRenderer.POWERPACK_PLAYERS.containsKey(entity.getUniqueID()))
            powerpack = IEBipedLayerRenderer.POWERPACK_PLAYERS.get(entity.getUniqueID()).getLeft();
        if (powerpack != null) {
            float max = EnergyHelper.getMaxEnergyStored(powerpack);
            storage = max <= 0 ? 0 : EnergyHelper.getEnergyStored(powerpack) / max;
            this.modelParts[7].rotateAngleZ = 0.5235987f - (1.047197f * storage);
        }
    }
    GlStateManager.enableBlend();
    super.render(entity, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale);
    GlStateManager.disableBlend();
    ClientUtils.bindTexture("immersiveengineering:textures/blocks/wire.png");
    GlStateManager.pushMatrix();
    if (entity instanceof EntityLivingBase)
        for (EnumHand hand : EnumHand.values()) {
            ItemStack stack = ((EntityLivingBase) entity).getHeldItem(hand);
            if (!stack.isEmpty() && EnergyHelper.isFluxItem(stack)) {
                boolean right = (hand == EnumHand.MAIN_HAND) == (((EntityLivingBase) entity).getPrimaryHand() == EnumHandSide.RIGHT);
                float angleX = (right ? bipedRightArm : bipedLeftArm).rotateAngleX;
                float angleZ = (right ? bipedRightArm : bipedLeftArm).rotateAngleZ;
                String cacheKey = keyFormat.format(angleX) + "_" + keyFormat.format(angleZ);
                Vec3d[] vex = new Vec3d[0];
                try {
                    vex = (right ? catenaryCacheRight : catenaryCacheLeft).get(cacheKey, () -> {
                        double armLength = .75f;
                        double x = .3125 + (right ? 1 : -1) * armLength * Math.sin(angleZ);
                        double y = armLength * Math.cos(angleX);
                        double z = armLength * Math.sin(angleX);
                        return ApiUtils.getConnectionCatenary(new Vec3d(.484375, -.75, .25), new Vec3d(x, -y, z), 1.5);
                    });
                } catch (Exception e) {
                }
                float vStep = 1f / vex.length;
                int i = 0;
                Tessellator tes = ClientUtils.tes();
                BufferBuilder worldrenderer = tes.getBuffer();
                // float[] colour = {.7f,.42f,.25f,1};
                float[] colour = { .93f, .63f, .27f, 1 };
                worldrenderer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_TEX_COLOR);
                for (Vec3d v : vex) {
                    worldrenderer.pos((right ? -v.x : v.x) - .015625, -v.y, v.z).tex(vStep * i, 0).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
                    worldrenderer.pos((right ? -v.x : v.x) + .015625, -v.y, v.z).tex(vStep * i++, 1).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
                }
                tes.draw();
                worldrenderer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_TEX_COLOR);
                i = 0;
                for (Vec3d v : vex) {
                    worldrenderer.pos((right ? -v.x : v.x), -v.y - .015625, v.z).tex(vStep * i, 0).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
                    worldrenderer.pos((right ? -v.x : v.x), -v.y + .015625, v.z).tex(vStep * i++, 1).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
                }
                tes.draw();
            }
        }
    GlStateManager.popMatrix();
}
Also used : ItemPowerpack(blusunrize.immersiveengineering.common.items.ItemPowerpack) Tessellator(net.minecraft.client.renderer.Tessellator) ItemArmor(net.minecraft.item.ItemArmor) EnumHand(net.minecraft.util.EnumHand) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d)

Example 43 with ItemArmor

use of net.minecraft.item.ItemArmor in project ImmersiveEngineering by BluSunrize.

the class RecipeEarmuffs method matches.

@Override
public boolean matches(InventoryCrafting inv, World world) {
    ItemStack earmuffs = ItemStack.EMPTY;
    ItemStack armor = ItemStack.EMPTY;
    List<ItemStack> list = Lists.newArrayList();
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stackInSlot = inv.getStackInSlot(i);
        if (!stackInSlot.isEmpty())
            if (earmuffs.isEmpty() && IEContent.itemEarmuffs.equals(stackInSlot.getItem()))
                earmuffs = stackInSlot;
            else if (armor.isEmpty() && stackInSlot.getItem() instanceof ItemArmor && ((ItemArmor) stackInSlot.getItem()).armorType == EntityEquipmentSlot.HEAD && !IEContent.itemEarmuffs.equals(stackInSlot.getItem()))
                armor = stackInSlot;
            else if (Utils.isDye(stackInSlot))
                list.add(stackInSlot);
            else
                return false;
    }
    if (!earmuffs.isEmpty() && (!armor.isEmpty() || !list.isEmpty()))
        return true;
    else
        return !armor.isEmpty() && ItemNBTHelper.hasKey(armor, Lib.NBT_Earmuffs) && earmuffs.isEmpty() && list.isEmpty();
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack)

Example 44 with ItemArmor

use of net.minecraft.item.ItemArmor in project PneumaticCraft by MineMaarten.

the class ContainerChargingStationItemInventory method transferStackInSlot.

/**
 * @param itemStack
 *            ItemStack to merge into inventory
 * @param start
 *            minimum slot to attempt fill
 * @param end
 *            maximum slot to attempt fill
 * @param backwards
 *            go backwards
 * @return true if stacks merged successfully public boolean
 *         mergeItemStack(itemStack, start, end, backwards)
 */
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack var3 = null;
    Slot var4 = (Slot) inventorySlots.get(par2);
    if (var4 != null && var4.getHasStack()) {
        ItemStack var5 = var4.getStack();
        var3 = var5.copy();
        if (par2 < 9 || par2 >= 44) {
            if (!mergeItemStack(var5, 9, 44, false))
                return null;
            var4.onSlotChange(var5, var3);
        } else {
            if (var3.getItem() instanceof ItemArmor && !((Slot) inventorySlots.get(45 + ((ItemArmor) var3.getItem()).armorType)).getHasStack()) {
                int j = 45 + ((ItemArmor) var3.getItem()).armorType;
                if (!mergeItemStack(var5, j, j + 1, false)) {
                    return null;
                }
            } else if (var3.getItem() == Itemss.machineUpgrade) {
                if (!mergeItemStack(var5, 0, 9, false))
                    return null;
            }
        }
        if (var5.stackSize == 0) {
            var4.putStack((ItemStack) null);
        } else {
            var4.onSlotChanged();
        }
        if (var5.stackSize == var3.stackSize)
            return null;
        var4.onPickupFromSlot(par1EntityPlayer, var5);
    }
    return var3;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 45 with ItemArmor

use of net.minecraft.item.ItemArmor in project BetterStorage by copygirl.

the class RenderFrienderman method shouldRenderPass.

@Override
protected int shouldRenderPass(EntityEnderman entity, int slot, float partialTicks) {
    if (slot == 0) {
        setRenderPassModel(mainModel);
        return super.shouldRenderPass(entity, slot, partialTicks);
    } else if (slot != 1)
        return -1;
    ItemStack stack = entity.getEquipmentInSlot(EquipmentSlot.CHEST);
    if (stack == null)
        return -1;
    Item item = stack.getItem();
    if (!(item instanceof ItemArmor))
        return -1;
    ItemArmor itemarmor = (ItemArmor) item;
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    textureManager.bindTexture(RenderBiped.getArmorResource(entity, stack, slot, null));
    ModelBiped modelBiped = ForgeHooksClient.getArmorModel(entity, stack, slot, null);
    setRenderPassModel(modelBiped);
    if (modelBiped != null) {
        modelBiped.onGround = mainModel.onGround;
        modelBiped.isRiding = mainModel.isRiding;
        modelBiped.isChild = mainModel.isChild;
    }
    int color = itemarmor.getColor(stack);
    if (color != -1) {
        RenderUtils.setColorFromInt(color);
        if (stack.isItemEnchanted())
            return 31;
        return 16;
    }
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    return (stack.isItemEnchanted() ? 15 : 1);
}
Also used : Item(net.minecraft.item.Item) TextureManager(net.minecraft.client.renderer.texture.TextureManager) ModelBiped(net.minecraft.client.model.ModelBiped) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack)

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