aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/forestry/bees/items/output/GTPPComb.java
blob: c77c7fcb8a853fcdb4421de2fea6d0af6ddb439e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package gtPlusPlus.xmod.forestry.bees.items.output;

import static gregtech.api.enums.Mods.Forestry;
import static gregtech.api.enums.Mods.GTPlusPlus;
import static gregtech.api.util.GTRecipeConstants.CHEMPLANT_CASING_TIER;
import static gtPlusPlus.api.recipe.GTPPRecipeMaps.chemicalPlantRecipes;

import java.util.List;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import gregtech.api.enums.GTValues;
import gregtech.api.util.GTModHandler;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.xmod.forestry.bees.handler.GTPPCombType;
import gtPlusPlus.xmod.forestry.bees.handler.GTPPDropType;
import gtPlusPlus.xmod.forestry.bees.handler.GTPPPropolisType;
import gtPlusPlus.xmod.forestry.bees.registry.GTPP_Bees;

public class GTPPComb extends Item {

    @SideOnly(Side.CLIENT)
    private IIcon secondIcon;

    public GTPPComb() {
        super();
        this.setCreativeTab(Tabs.tabApiculture);
        this.setHasSubtypes(true);
        this.setUnlocalizedName("gtpp.comb");
        GameRegistry.registerItem(this, "gtpp.comb", GTPlusPlus.ID);
    }

    public ItemStack getStackForType(GTPPCombType type) {
        return new ItemStack(this, 1, type.mID);
    }

    public ItemStack getStackForType(GTPPCombType type, int count) {
        return new ItemStack(this, count, type.mID);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void getSubItems(Item item, CreativeTabs tabs, List list) {
        for (GTPPCombType type : GTPPCombType.values()) {
            if (type.mShowInList) {
                list.add(this.getStackForType(type));
            }
        }
    }

    @Override
    @SideOnly(Side.CLIENT)
    public boolean requiresMultipleRenderPasses() {
        return true;
    }

    @Override
    public int getRenderPasses(int meta) {
        return 2;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister par1IconRegister) {
        this.itemIcon = par1IconRegister.registerIcon("forestry:beeCombs.0");
        this.secondIcon = par1IconRegister.registerIcon("forestry:beeCombs.1");
    }

    @Override
    public IIcon getIcon(ItemStack stack, int pass) {
        return (pass == 0) ? itemIcon : secondIcon;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public int getColorFromItemStack(ItemStack stack, int pass) {
        int colour = GTPPCombType.get(stack.getItemDamage())
            .getColours()[0];

        if (pass >= 1) {
            colour = GTPPCombType.get(stack.getItemDamage())
                .getColours()[1];
        }

        return colour;
    }

    @Override
    public String getItemStackDisplayName(ItemStack stack) {
        return GTPPCombType.get(stack.getItemDamage())
            .getName();
    }

    public static void initCombsRecipes() {

        addChemicalRecipe(
            GTPPCombType.DRAGONBLOOD,
            new ItemStack[] { GTModHandler.getModItem(Forestry.ID, "refractoryWax", 1L, 0),
                GTPP_Bees.propolis.getStackForType(GTPPPropolisType.DRAGONBLOOD),
                GTPP_Bees.drop.getStackForType(GTPPDropType.DRAGONBLOOD) },
            new int[] { 3000, 1500, 500 });
        addChemicalRecipe(
            GTPPCombType.FORCE,
            new ItemStack[] { GTModHandler.getModItem(Forestry.ID, "beeswax", 1L, 0),
                GTPP_Bees.propolis.getStackForType(GTPPPropolisType.FORCE),
                GTPP_Bees.drop.getStackForType(GTPPDropType.FORCE) },
            new int[] { 5000, 3000, 1000 });
    }

    public static void addChemicalRecipe(GTPPCombType aInputStack, ItemStack[] aOutputs, int[] aChances) {
        Material aMat = aInputStack.mMaterial;
        long aEU = aMat.vVoltageMultiplier;
        int aTier = Math.max(aMat.vTier / 2, 1);
        GTValues.RA.stdBuilder()
            .itemInputs(aInputStack.getStackForType(aTier))
            .itemOutputs(aOutputs)
            .duration(aTier * 20 * 60)
            .eut(aEU)
            .metadata(CHEMPLANT_CASING_TIER, aTier)
            .addTo(chemicalPlantRecipes);

    }
}