Search in sources :

Example 6 with ItemArmor

use of net.minecraft.item.ItemArmor in project Galacticraft by micdoodle8.

the class ContainerCreativeInv method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotIndex) {
    ItemStack transferredStack = null;
    Slot slot = (Slot) inventorySlots.get(slotIndex);
    if (slot != null && slot.getHasStack()) {
        ItemStack stack = slot.getStack();
        transferredStack = stack.copy();
        if (stack.getItem() instanceof ItemArmor) {
            ItemArmor armor = (ItemArmor) stack.getItem();
            if (!getSlot(90 + armor.armorType).getHasStack()) {
                getSlot(90 + armor.armorType).putStack(transferredStack);
                slot.putStack(null);
                return transferredStack;
            }
        }
        if (slotIndex < 54) {
            if (!this.mergeItemStack(stack, 54, 90, true)) {
                return null;
            }
        } else if (!this.mergeItemStack(stack, 0, 54, false)) {
            return null;
        }
        if (stack.stackSize == 0) {
            slot.putStack(null);
        } else {
            slot.onSlotChanged();
        }
    }
    return transferredStack;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 7 with ItemArmor

use of net.minecraft.item.ItemArmor in project CompositeGear by TwilightWingsStudio.

the class RecipesDyingArmor method matches.

/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn) {
    ItemStack itemstack = ItemStack.EMPTY;
    List<ItemStack> list = Lists.<ItemStack>newArrayList();
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
        ItemStack itemstack1 = inv.getStackInSlot(i);
        if (!itemstack1.isEmpty()) {
            if (itemstack1.getItem() instanceof ItemArmor) {
                ItemArmor itemarmor = (ItemArmor) itemstack1.getItem();
                if (!(itemarmor instanceof ItemCompositeArmor) || !itemstack.isEmpty()) {
                    return false;
                }
                itemstack = itemstack1;
            } else {
                if (!net.minecraftforge.oredict.DyeUtils.isDye(itemstack1)) {
                    return false;
                }
                list.add(itemstack1);
            }
        }
    }
    return !itemstack.isEmpty() && !list.isEmpty();
}
Also used : ItemCompositeArmor(tws.zcaliptium.compositegear.common.items.ItemCompositeArmor) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack)

Example 8 with ItemArmor

use of net.minecraft.item.ItemArmor in project CompositeGear by TwilightWingsStudio.

the class RecipesDyingArmor method getCraftingResult.

/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv) {
    ItemStack itemstack = ItemStack.EMPTY;
    int[] aint = new int[3];
    int i = 0;
    int j = 0;
    ItemArmor itemarmor = null;
    for (int k = 0; k < inv.getSizeInventory(); ++k) {
        ItemStack itemstack1 = inv.getStackInSlot(k);
        if (!itemstack1.isEmpty()) {
            if (itemstack1.getItem() instanceof ItemArmor) {
                itemarmor = (ItemArmor) itemstack1.getItem();
                if (!(itemarmor instanceof ItemCompositeArmor) || !itemstack.isEmpty()) {
                    return ItemStack.EMPTY;
                }
                itemstack = itemstack1.copy();
                itemstack.setCount(1);
                if (itemarmor.hasColor(itemstack1)) {
                    int l = itemarmor.getColor(itemstack);
                    float f = (float) (l >> 16 & 255) / 255.0F;
                    float f1 = (float) (l >> 8 & 255) / 255.0F;
                    float f2 = (float) (l & 255) / 255.0F;
                    i = (int) ((float) i + Math.max(f, Math.max(f1, f2)) * 255.0F);
                    aint[0] = (int) ((float) aint[0] + f * 255.0F);
                    aint[1] = (int) ((float) aint[1] + f1 * 255.0F);
                    aint[2] = (int) ((float) aint[2] + f2 * 255.0F);
                    ++j;
                }
            } else {
                if (!net.minecraftforge.oredict.DyeUtils.isDye(itemstack1)) {
                    return ItemStack.EMPTY;
                }
                float[] afloat = net.minecraftforge.oredict.DyeUtils.colorFromStack(itemstack1).get().getColorComponentValues();
                int l1 = (int) (afloat[0] * 255.0F);
                int i2 = (int) (afloat[1] * 255.0F);
                int j2 = (int) (afloat[2] * 255.0F);
                i += Math.max(l1, Math.max(i2, j2));
                aint[0] += l1;
                aint[1] += i2;
                aint[2] += j2;
                ++j;
            }
        }
    }
    if (itemarmor == null) {
        return ItemStack.EMPTY;
    } else {
        int i1 = aint[0] / j;
        int j1 = aint[1] / j;
        int k1 = aint[2] / j;
        float f3 = (float) i / (float) j;
        float f4 = (float) Math.max(i1, Math.max(j1, k1));
        i1 = (int) ((float) i1 * f3 / f4);
        j1 = (int) ((float) j1 * f3 / f4);
        k1 = (int) ((float) k1 * f3 / f4);
        int k2 = (i1 << 8) + j1;
        k2 = (k2 << 8) + k1;
        itemarmor.setColor(itemstack, k2);
        return itemstack;
    }
}
Also used : ItemCompositeArmor(tws.zcaliptium.compositegear.common.items.ItemCompositeArmor) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack)

Example 9 with ItemArmor

use of net.minecraft.item.ItemArmor in project BuildCraft by BuildCraft.

the class EntityRobot method attackEntityFrom.

@Override
public boolean attackEntityFrom(DamageSource source, float f) {
    // Ignore hits from mobs or when docked.
    Entity src = source.getSourceOfDamage();
    if (src != null && !(src instanceof EntityFallingBlock) && !(src instanceof IMob) && currentDockingStation == null) {
        if (ForgeHooks.onLivingAttack(this, source, f)) {
            return false;
        }
        if (!worldObj.isRemote) {
            hurtTime = maxHurtTime = 10;
            int mul = 2600;
            for (ItemStack s : wearables) {
                if (s.getItem() instanceof ItemArmor) {
                    mul = mul * 2 / (2 + ((ItemArmor) s.getItem()).damageReduceAmount);
                } else {
                    mul *= 0.7;
                }
            }
            int energy = Math.round(f * mul);
            if (battery.getEnergyStored() - energy > 0) {
                battery.setEnergy(battery.getEnergyStored() - energy);
                return true;
            } else {
                onRobotHit(true);
            }
        }
        return true;
    }
    return false;
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) IMob(net.minecraft.entity.monster.IMob) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack)

Example 10 with ItemArmor

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

the class RenderBlockMannequinItems method renderChestStack.

public void renderChestStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelMannequin 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, 1, renderPlayer.modelArmorChestplate);
            if (i == 0) {
                bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 1, null));
            } else {
                bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 1, "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.bipedBody, armourBiped.bipedBody);
                setRotations(targetBiped.bipedLeftArm, armourBiped.bipedLeftArm);
                setRotations(targetBiped.bipedRightArm, armourBiped.bipedRightArm);
                armourBiped.bipedBody.showModel = true;
                armourBiped.bipedLeftArm.showModel = true;
                armourBiped.bipedRightArm.showModel = true;
                armourBiped.bipedBody.render(scale);
                armourBiped.bipedLeftArm.render(scale);
                armourBiped.bipedRightArm.render(scale);
                resetRotations(targetBiped.bipedBody);
                resetRotations(targetBiped.bipedLeftArm);
                resetRotations(targetBiped.bipedRightArm);
                armourBiped = ForgeHooksClient.getArmorModel(fakePlayer, stack, 1, renderPlayer.modelArmor);
                setRotations(targetBiped.bipedBody, armourBiped.bipedBody);
                armourBiped.bipedBody.showModel = true;
                armourBiped.bipedBody.render(scale);
                resetRotations(targetBiped.bipedBody);
            } else {
                try {
                    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)

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