Search in sources :

Example 11 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project pnc-repressurized by TeamPneumatic.

the class SlotPneumaticArmor method isItemValid.

/**
 * Check if the stack is a valid item for this slot. Always true beside for
 * the armor slots.
 */
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
    Item item = par1ItemStack.getItem();
    // 0 & 1 are main & off hands
    EntityEquipmentSlot eq = EntityEquipmentSlot.values()[armorType + 2];
    return item.isValidArmor(par1ItemStack, eq, player);
}
Also used : Item(net.minecraft.item.Item) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot)

Example 12 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project Almura by AlmuraDev.

the class UIUserPanel method updateArmor.

private void updateArmor() {
    int maxArmor = 0;
    int currentDamage = 0;
    for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
        if (slot == EntityEquipmentSlot.MAINHAND || slot == EntityEquipmentSlot.OFFHAND) {
            continue;
        }
        final ItemStack stack = this.client.player.getItemStackFromSlot(slot);
        if (stack.getItem() instanceof ItemArmor) {
            maxArmor += ((ItemArmor) stack.getItem()).getArmorMaterial().getDurability(slot);
            currentDamage += stack.getItem().getDamage(stack);
        }
    }
    this.updateBarProperties(this.armorBar, maxArmor - currentDamage, maxArmor);
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack)

Example 13 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project SilentGems by SilentChaos512.

the class ToolHelper method addExampleRecipe.

public static void addExampleRecipe(Item item, EnumMaterialTier[] tiers, String[] lines, Object... extraParams) {
    // New ingredient-based recipes
    ConfigOptionToolClass config = item instanceof ITool ? ((ITool) item).getConfig() : null;
    for (EnumMaterialTier tier : tiers) {
        // Only add recipes for valid tiers
        if (config != null && !config.validTiers.contains(tier))
            continue;
        // Head parts for tier
        List<ItemStack> heads = new ArrayList<>();
        for (ToolPart part : ToolPartRegistry.getMains()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getTier() == tier && StackHelper.isValid(part.getCraftingStack()))
            heads.add(part.getCraftingStack());
        IngredientSL headIngredient = IngredientSL.from(heads.toArray(new ItemStack[0]));
        // Rods for tier
        List<ItemStack> rods = new ArrayList<>();
        for (ToolPart part : ToolPartRegistry.getRods()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getCompatibleTiers().contains(tier))
            rods.add(part.getCraftingStack());
        IngredientSL rodIngredient = IngredientSL.from(rods.toArray(new ItemStack[0]));
        // Armor frames
        List<ItemStack> frames = new ArrayList<>();
        if (item instanceof ItemGemArmor) {
            EntityEquipmentSlot slot = ((ItemGemArmor) item).armorType;
            for (ToolPart part : ToolPartRegistry.getValues()) if (part instanceof ArmorPartFrame && ((ArmorPartFrame) part).getSlot() == slot && part.getTier() == tier && !part.isBlacklisted(part.getCraftingStack()))
                frames.add(part.getCraftingStack());
        }
        IngredientSL frameIngredient = IngredientSL.from(frames.toArray(new ItemStack[0]));
        ResourceLocation recipeName = new ResourceLocation(item.getRegistryName().toString() + "_" + tier.name().toLowerCase() + "_example");
        ItemStack result = new ItemStack(item);
        NBTTagCompound tags = new NBTTagCompound();
        tags.setInteger(NBT_EXAMPLE_TOOL_TIER, tier.ordinal());
        result.setTagCompound(tags);
        // Super ugly, but I've got never better at the moment.
        List<Object> params = new ArrayList<>();
        for (String line : lines) params.add(line);
        if (recipeContainsKey(lines, "h")) {
            params.add('h');
            params.add(headIngredient);
        }
        if (recipeContainsKey(lines, "r")) {
            params.add('r');
            params.add(rodIngredient);
        }
        if (recipeContainsKey(lines, "a")) {
            params.add('a');
            params.add(frameIngredient);
        }
        for (Object obj : extraParams) params.add(obj);
        EXAMPLE_RECIPES.add(SilentGems.registry.recipes.makeShaped(recipeName.getResourcePath(), result, params.toArray()));
    }
}
Also used : IngredientSL(net.silentchaos512.lib.recipe.IngredientSL) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ITool(net.silentchaos512.gems.api.ITool) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ResourceLocation(net.minecraft.util.ResourceLocation) ConfigOptionToolClass(net.silentchaos512.gems.config.ConfigOptionToolClass) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) IRegistryObject(net.silentchaos512.lib.registry.IRegistryObject) ItemGemArmor(net.silentchaos512.gems.item.armor.ItemGemArmor) ItemStack(net.minecraft.item.ItemStack) ArmorPartFrame(net.silentchaos512.gems.api.tool.part.ArmorPartFrame)

Example 14 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project SilentGems by SilentChaos512.

the class EquipmentTooltips method getToughness.

private float getToughness(ItemStack stack, float defaultValue) {
    if (StackHelper.isEmpty(stack))
        return defaultValue;
    ItemArmor itemArmor = (ItemArmor) stack.getItem();
    EntityEquipmentSlot slot = itemArmor.armorType;
    UUID uuid = ItemArmor.ARMOR_MODIFIERS[slot.getIndex()];
    Multimap<String, AttributeModifier> multimap = stack.getAttributeModifiers(slot);
    for (Entry<String, AttributeModifier> entry : multimap.entries()) {
        String key = entry.getKey();
        AttributeModifier mod = entry.getValue();
        if (key.equals(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName()) && mod.getID().equals(uuid)) {
            return (float) mod.getAmount();
        }
    }
    return 0f;
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ItemArmor(net.minecraft.item.ItemArmor) UUID(java.util.UUID) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 15 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project SilentGems by SilentChaos512.

the class EquipmentTooltips method getProtection.

private float getProtection(ItemStack stack, float defaultValue) {
    if (StackHelper.isEmpty(stack))
        return defaultValue;
    ItemArmor itemArmor = (ItemArmor) stack.getItem();
    EntityEquipmentSlot slot = itemArmor.armorType;
    UUID uuid = ItemArmor.ARMOR_MODIFIERS[slot.getIndex()];
    Multimap<String, AttributeModifier> multimap = stack.getAttributeModifiers(slot);
    for (Entry<String, AttributeModifier> entry : multimap.entries()) {
        String key = entry.getKey();
        AttributeModifier mod = entry.getValue();
        if (key.equals(SharedMonsterAttributes.ARMOR.getName()) && mod.getID().equals(uuid)) {
            return (float) mod.getAmount();
        }
    }
    return 0f;
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ItemArmor(net.minecraft.item.ItemArmor) UUID(java.util.UUID) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Aggregations

EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)23 ItemStack (net.minecraft.item.ItemStack)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ArrayList (java.util.ArrayList)3 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)3 ItemArmor (net.minecraft.item.ItemArmor)3 BlockPos (net.minecraft.util.math.BlockPos)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IGuiTile (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile)2 IGuiItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem)2 IDarkSteelItem (crazypants.enderio.api.upgrades.IDarkSteelItem)2 IDarkSteelUpgrade (crazypants.enderio.api.upgrades.IDarkSteelUpgrade)2 UUID (java.util.UUID)2 Nullable (javax.annotation.Nullable)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 Item (net.minecraft.item.Item)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IBullet (blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet)1 TileEntityAlloySmelter (blusunrize.immersiveengineering.common.blocks.stone.TileEntityAlloySmelter)1