diff options
author | Raven Szewczyk <git@eigenraven.me> | 2024-05-25 14:42:41 +0100 |
---|---|---|
committer | Raven Szewczyk <git@eigenraven.me> | 2024-05-25 14:42:41 +0100 |
commit | 8aa595f083b5c3e43246119fca5f4263f81e851b (patch) | |
tree | 157d2b528e4b4ea0321022ebfee398f559a9e121 /src/main/java/kubatech/loaders/TCLoader.java | |
parent | 14a97a5a177399cd8df7f246856c08fcda441afd (diff) | |
download | GT5-Unofficial-8aa595f083b5c3e43246119fca5f4263f81e851b.tar.gz GT5-Unofficial-8aa595f083b5c3e43246119fca5f4263f81e851b.tar.bz2 GT5-Unofficial-8aa595f083b5c3e43246119fca5f4263f81e851b.zip |
Migrate kubatech source code
Diffstat (limited to 'src/main/java/kubatech/loaders/TCLoader.java')
-rw-r--r-- | src/main/java/kubatech/loaders/TCLoader.java | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/src/main/java/kubatech/loaders/TCLoader.java b/src/main/java/kubatech/loaders/TCLoader.java new file mode 100644 index 0000000000..7d6abe5132 --- /dev/null +++ b/src/main/java/kubatech/loaders/TCLoader.java @@ -0,0 +1,151 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.stream.Collectors; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import com.kuba6000.mobsinfo.api.utils.ItemID; + +import cpw.mods.fml.common.registry.GameRegistry; +import kubatech.api.LoaderReference; +import kubatech.api.enums.ItemList; +import kubatech.loaders.item.items.TeaUltimate; +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; + +public class TCLoader { + + public static final String TCCategoryKey = "KUBATECH"; + + public static void init() { + /* + * ResearchCategories.registerCategory( + * TCCategoryKey, + * new ResourceLocation(Tags.MODID, "textures/gui/green_tea.png"), + * new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png")); + */ + if (!LoaderReference.GTNHCoreMod || !LoaderReference.DraconicEvolution) return; + registerRecipe(); + registerResearch(); + } + + private static InfusionRecipe ultimateTeaRecipe = null; + + @SuppressWarnings("unchecked") + 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.createNoCopy(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.createNoCopy(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" /* TCCategoryKey */, + 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); + } +} |