Search in sources :

Example 26 with ItemArmor

use of net.minecraft.item.ItemArmor in project MorePlanets by SteveKunG.

the class BlockInfectedVines method onEntityCollidedWithBlock.

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
    if (entity instanceof EntityLivingBase) {
        EntityLivingBase living = (EntityLivingBase) entity;
        if (living instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;
            InventoryPlayer inventory = player.inventory;
            for (int i = 0; i < 4; i++) {
                if (!(inventory.armorInventory.get(i) != null && inventory.armorInventory.get(i).getItem() instanceof ItemArmor)) {
                    if (!player.capabilities.isCreativeMode) {
                        player.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
                        player.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
                    }
                }
            }
        }
        if (!(living instanceof EntityPlayer) && !(entity instanceof ISpaceMob && ((ISpaceMob) entity).getMobType() == EnumMobType.NIBIRU)) {
            living.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
            living.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
        }
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ISpaceMob(stevekung.mods.moreplanets.util.entity.ISpaceMob) PotionEffect(net.minecraft.potion.PotionEffect) ItemArmor(net.minecraft.item.ItemArmor) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 27 with ItemArmor

use of net.minecraft.item.ItemArmor in project Wurst-MC-1.12 by Wurst-Imperium.

the class AutoArmorMod method onUpdate.

@Override
public void onUpdate() {
    // wait for timer
    if (timer > 0) {
        timer--;
        return;
    }
    // check screen
    if (mc.currentScreen instanceof GuiContainer && !(mc.currentScreen instanceof InventoryEffectRenderer))
        return;
    // store slots and values of best armor pieces
    int[] bestArmorSlots = new int[4];
    int[] bestArmorValues = new int[4];
    // initialize with currently equipped armor
    for (int armorType = 0; armorType < 4; armorType++) {
        ItemStack oldArmor = WMinecraft.getPlayer().inventory.armorItemInSlot(armorType);
        if (!WItem.isNullOrEmpty(oldArmor) && oldArmor.getItem() instanceof ItemArmor)
            bestArmorValues[armorType] = ((ItemArmor) oldArmor.getItem()).damageReduceAmount;
        bestArmorSlots[armorType] = -1;
    }
    // search inventory for better armor
    for (int slot = 0; slot < 36; slot++) {
        ItemStack stack = WMinecraft.getPlayer().inventory.getStackInSlot(slot);
        if (WItem.isNullOrEmpty(stack) || !(stack.getItem() instanceof ItemArmor))
            continue;
        ItemArmor armor = (ItemArmor) stack.getItem();
        int armorType = WItem.getArmorType(armor);
        int armorValue = armor.damageReduceAmount;
        if (armorValue > bestArmorValues[armorType]) {
            bestArmorSlots[armorType] = slot;
            bestArmorValues[armorType] = armorValue;
        }
    }
    // equip better armor
    for (int armorType = 0; armorType < 4; armorType++) {
        // check if better armor was found
        int slot = bestArmorSlots[armorType];
        if (slot == -1)
            continue;
        // check if armor can be swapped
        // needs 1 free slot where it can put the old armor
        ItemStack oldArmor = WMinecraft.getPlayer().inventory.armorItemInSlot(armorType);
        if (WItem.isNullOrEmpty(oldArmor) || WMinecraft.getPlayer().inventory.getFirstEmptyStack() != -1) {
            // hotbar fix
            if (slot < 9)
                slot += 36;
            // swap armor
            if (!WItem.isNullOrEmpty(oldArmor))
                WPlayerController.windowClick_QUICK_MOVE(8 - armorType);
            WPlayerController.windowClick_QUICK_MOVE(slot);
            break;
        }
    }
    // set timer
    timer = 2;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) InventoryEffectRenderer(net.minecraft.client.renderer.InventoryEffectRenderer) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) ItemStack(net.minecraft.item.ItemStack)

Example 28 with ItemArmor

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

the class CommonEventHandler method onPlayerAttackTarget.

@SubscribeEvent
public boolean onPlayerAttackTarget(AttackEntityEvent event) {
    if (event.getEntityPlayer().getEntityWorld().isRemote) {
        return true;
    }
    // If we don't hate gem armor then don't execute following code.
    if (!ConfigurationCG.hateGemArmor) {
        return true;
    }
    Item itemHeld = event.getEntityPlayer().getHeldItemMainhand().getItem();
    int constantGemDmg = 0;
    if (itemHeld == ItemsCG.compositeMace) {
        constantGemDmg = 100;
    } else if (itemHeld == ItemsCG.compositeClub) {
        constantGemDmg = 50;
    } else {
        return true;
    }
    if (event.getTarget() instanceof EntityPlayer) {
        EntityPlayer targetPlayer = (EntityPlayer) event.getTarget();
        for (ItemStack itemstack : targetPlayer.getArmorInventoryList()) {
            if (itemstack != null && itemstack.getItem() instanceof ItemArmor) {
                ItemArmor armorPiece = (ItemArmor) itemstack.getItem();
                ItemArmor.ArmorMaterial material = armorPiece.getArmorMaterial();
                if (material == ArmorMaterial.DIAMOND) {
                    itemstack.damageItem(constantGemDmg, targetPlayer);
                } else {
                    String name = material.toString().toLowerCase();
                    for (String gem : GEMS) {
                        if (name.contains(gem)) {
                            itemstack.damageItem(constantGemDmg, targetPlayer);
                            break;
                        }
                    }
                }
            }
        }
    }
    return true;
}
Also used : Item(net.minecraft.item.Item) ItemArmor(net.minecraft.item.ItemArmor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ArmorMaterial(net.minecraft.item.ItemArmor.ArmorMaterial) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 29 with ItemArmor

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

the class CompositeGear method registerItemColorHandler.

@SideOnly(Side.CLIENT)
public void registerItemColorHandler() {
    modLog.info("Registering IItemColor handler for mod items.");
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {

        public int colorMultiplier(ItemStack stack, int tintIndex) {
            return tintIndex > 0 ? -1 : ((ItemArmor) stack.getItem()).getColor(stack);
        }
    }, ItemsCG.compositeHelmet, ItemsCG.compositeChestplate, ItemsCG.compositeLeggings, ItemsCG.compositeBoots, ItemsCG.compositeFaceplate, ItemsCG.ushankaHat, ItemsCG.balaclavaMask, ItemsCG.shemaghMask, ItemsCG.rubberGasmask, ItemsCG.respiratorMask, ItemsCG.respiratorMaskComposite, ItemsCG.compositeLightHelmet, ItemsCG.compositeLightVest, ItemsCG.compositeLightLeggings, ItemsCG.compositeLightBoots);
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 30 with ItemArmor

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

the class ModelScubaGear method renderTank.

private void renderTank(EntityLivingBase entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    ItemStack gearStack = entityIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
    IScubaGear gear = gearStack.getCapability(ScubaCapabilities.getGearCapability(), null);
    TextureManager tm = Minecraft.getMinecraft().getTextureManager();
    if (gear.getTanks().getRight() != null) {
        ScubaMaterial material = gear.getStackInSlot(1).getItem() == ItemRegistry.pinkScubaTank ? ScubaMaterial.PINK : ScubaMaterial.YELLOW;
        tm.bindTexture(ItemScubaGear.getArmorTexture(material));
        Tank2.rotateAngleX = 0F;
        Tank2.rotateAngleY = 0F;
        Tank2.rotateAngleZ = 0F;
        Tank2.renderWithRotation(scale);
        Tank2m1.rotateAngleX = 0F;
        Tank2m1.rotateAngleY = 0F;
        Tank2m1.rotateAngleZ = 0F;
        Tank2m1.renderWithRotation(scale);
        Tank2m2.rotateAngleX = 0F;
        Tank2m2.rotateAngleY = -1.570796F;
        Tank2m2.rotateAngleZ = 0F;
        Tank2m2.renderWithRotation(scale);
        Tank2m3.rotateAngleX = 0F;
        Tank2m3.rotateAngleY = -1.570796F;
        Tank2m3.rotateAngleZ = 0F;
        Tank2m3.renderWithRotation(scale);
        Tank2m4.rotateAngleX = 0F;
        Tank2m4.rotateAngleY = 0F;
        Tank2m4.rotateAngleZ = 0F;
        Tank2m4.renderWithRotation(scale);
        Tank2m5.rotateAngleX = 0F;
        Tank2m5.rotateAngleY = 0F;
        Tank2m5.rotateAngleZ = 0F;
        Tank2m5.renderWithRotation(scale);
        Tank2m6.rotateAngleX = 0F;
        Tank2m6.rotateAngleY = 0F;
        Tank2m6.rotateAngleZ = 0F;
        Tank2m6.renderWithRotation(scale);
        Tank2m7.rotateAngleX = 0F;
        Tank2m7.rotateAngleY = 0F;
        Tank2m7.rotateAngleZ = 0F;
        Tank2m7.renderWithRotation(scale);
    }
    if (gear.getTanks().getLeft() != null) {
        ScubaMaterial material = gear.getStackInSlot(0).getItem() == ItemRegistry.pinkScubaTank ? ScubaMaterial.PINK : ScubaMaterial.YELLOW;
        tm.bindTexture(ItemScubaGear.getArmorTexture(material));
        Tank1.rotateAngleX = 0F;
        Tank1.rotateAngleY = 0F;
        Tank1.rotateAngleZ = 0F;
        Tank1.renderWithRotation(scale);
        Tank1m1.rotateAngleX = 0F;
        Tank1m1.rotateAngleY = 0F;
        Tank1m1.rotateAngleZ = 0F;
        Tank1m1.renderWithRotation(scale);
        Tank1m2.rotateAngleX = 0F;
        Tank1m2.rotateAngleY = -1.570796F;
        Tank1m2.rotateAngleZ = 0F;
        Tank1m2.renderWithRotation(scale);
        Tank1m3.rotateAngleX = 0F;
        Tank1m3.rotateAngleY = -1.570796F;
        Tank1m3.rotateAngleZ = 0F;
        Tank1m3.renderWithRotation(scale);
        Tank1m4.rotateAngleX = 0F;
        Tank1m4.rotateAngleY = 0F;
        Tank1m4.rotateAngleZ = 0F;
        Tank1m4.renderWithRotation(scale);
        Tank1m5.rotateAngleX = 0F;
        Tank1m5.rotateAngleY = 0F;
        Tank1m5.rotateAngleZ = 0F;
        Tank1m5.renderWithRotation(scale);
        Tank1m6.rotateAngleX = 0F;
        Tank1m6.rotateAngleY = 0F;
        Tank1m6.rotateAngleZ = 0F;
        Tank1m6.renderWithRotation(scale);
        Tank1m7.rotateAngleX = 0F;
        Tank1m7.rotateAngleY = 0F;
        Tank1m7.rotateAngleZ = 0F;
        Tank1m7.renderWithRotation(scale);
    }
    Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(((ItemArmor) gearStack.getItem()).getArmorTexture(gearStack, entityIn, EntityEquipmentSlot.CHEST, null)));
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) ScubaMaterial(net.tropicraft.core.common.item.scuba.api.ScubaMaterial) ResourceLocation(net.minecraft.util.ResourceLocation) ItemArmor(net.minecraft.item.ItemArmor) IScubaGear(net.tropicraft.core.common.item.scuba.api.IScubaGear) 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