aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kubatech/loaders/TCLoader.java
blob: a4141d4ba529eab739c44748b2876df98e090557 (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
/*
 * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in
 * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have
 * received a copy of the GNU Lesser General Public License along with this library. If not, see
 * <https://www.gnu.org/licenses/>.
 */

package kubatech.loaders;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.stream.Collectors;

import kubatech.api.LoaderReference;
import kubatech.api.enums.ItemList;
import kubatech.api.utils.ItemID;
import kubatech.loaders.item.items.TeaUltimate;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.ThaumcraftApiHelper;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.crafting.InfusionRecipe;
import thaumcraft.api.research.ResearchCategories;
import thaumcraft.api.research.ResearchItem;
import thaumcraft.api.research.ResearchPage;
import cpw.mods.fml.common.registry.GameRegistry;

public class TCLoader {

    public static void load() {}

    public static void register() {
        if (!LoaderReference.GTNHCoreMod || !LoaderReference.DraconicEvolution) return;
        registerRecipe();
        registerResearch();
    }

    private static InfusionRecipe ultimateTeaRecipe = null;

    private static void registerRecipe() {
        if (ultimateTeaRecipe != null) return;
        final ItemStack[] components = new ItemStack[] {
                // ItemList.LegendaryBlackTea.get(1),
                // ItemList.LegendaryButterflyTea.get(1),
                ItemList.LegendaryEarlGrayTea.get(1), // MApiary
                ItemList.LegendaryGreenTea.get(1), // EIG
                // ItemList.LegendaryLemonTea.get(1),
                // ItemList.LegendaryMilkTea.get(1),
                // ItemList.LegendaryOolongTea.get(1),
                ItemList.LegendaryPeppermintTea.get(1), // HTGR
                ItemList.LegendaryPuerhTea.get(1), // EEC
                // ItemList.LegendaryRedTea.get(1),
                // ItemList.LegendaryWhiteTea.get(1),
                ItemList.LegendaryYellowTea.get(1), // IApiary
                ItemList.BlackTea.get(1), ItemList.EarlGrayTea.get(1), ItemList.GreenTea.get(1),
                ItemList.LemonTea.get(1), ItemList.MilkTea.get(1), ItemList.OolongTea.get(1),
                ItemList.PeppermintTea.get(1), ItemList.PuerhTea.get(1), ItemList.WhiteTea.get(1),
                ItemList.YellowTea.get(1) };

        final HashSet<ItemID> componentsHashed = Arrays.stream(components)
                .map(stack -> ItemID.create_NoCopy(stack, true, false, true))
                .collect(Collectors.toCollection(HashSet::new));

        // noinspection unchecked
        ThaumcraftApi.getCraftingRecipes().add(
                ultimateTeaRecipe = new InfusionRecipe(
                        "KT_UltimateTea",
                        ItemList.LegendaryUltimateTea.get(1),
                        10,
                        new AspectList().add(Aspect.MAGIC, 100).add(Aspect.HEAL, 100).add(Aspect.PLANT, 100)
                                .add(Aspect.EXCHANGE, 100),
                        GameRegistry.findItemStack("DraconicEvolution", "dezilsMarshmallow", 1),
                        components) {

                    @Override
                    public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world,
                            EntityPlayer player) {
                        if (!central.isItemEqual(getRecipeInput())) return false;
                        if (!ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), this.research))
                            return false;
                        if (componentsHashed.size() > input.size()) return false;
                        HashSet<ItemID> hashedInputs = input.stream()
                                .map(stack -> ItemID.create_NoCopy(stack, true, false, true))
                                .collect(Collectors.toCollection(HashSet::new));
                        return hashedInputs.containsAll(componentsHashed);
                    }
                });
    }

    private static ResearchItem ultimateTeaResearch = null;

    private static void registerResearch() {
        if (ultimateTeaResearch == null) {
            ultimateTeaResearch = new ResearchItem(
                    "KT_UltimateTea",
                    "NEWHORIZONS",
                    new AspectList().add(Aspect.MAGIC, 1).add(Aspect.HEAL, 1).add(Aspect.PLANT, 1)
                            .add(Aspect.EXCHANGE, 1),
                    -2,
                    4,
                    2,
                    ItemList.LegendaryUltimateTea.get(1)) {

                @Override
                public String getName() {
                    return TeaUltimate.getUltimateTeaDisplayName(super.getName());
                }
            };
            ultimateTeaResearch.setPages(new ResearchPage("KT.research.ultimatetea") {

                @Override
                public String getTranslatedText() {
                    return TeaUltimate.getUltimateTeaDisplayName(super.getTranslatedText());
                }
            }, new ResearchPage(ultimateTeaRecipe));
            ultimateTeaResearch.setParents("INFUSION", "DEZILSMARSHMALLOW");
            ThaumcraftApi.addWarpToResearch("KT_UltimateTea", 20);
        }
        ResearchCategories.addResearch(ultimateTeaResearch);
    }
}