Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklist Thaumcraft clusters + made the file more readable #63

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/main/java/witchinggadgets/common/WGContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,23 @@ public static void preInit() {
preInitItems();
preInitBlocks();
}

private static boolean clusterBlacklist(Materials material) {
return material.equals(Materials.Iron) || material.equals(Materials.Copper)
Dream-Master marked this conversation as resolved.
Show resolved Hide resolved
|| material.equals(Materials.Tin)
|| material.equals(Materials.Silver)
|| material.equals(Materials.Lead)
|| material.equals(Materials.Cinnabar)
|| material.equals(Materials.Gold);
}

// final static String UUIDBASE = "424C5553-5747-1694-4452-";

private static void initClusters() {
HashSet<String> L = new HashSet<>();
for (Entry<String, Materials> entry : Materials.getMaterialsMap().entrySet()) {
Materials material = entry.getValue();
if (!b.contains(material.mDefaultLocalName)
if (!b.contains(material.mDefaultLocalName) && !clusterBlacklist(material)
&& !OreDictionary.getOres("ore" + material.mDefaultLocalName.replaceAll(" ", "")).isEmpty()) {
Integer rgb = ((material.getRGBA()[0] & 0x0ff) << 16) | ((material.getRGBA()[1] & 0x0ff) << 8)
| (material.getRGBA()[2] & 0x0ff);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/witchinggadgets/common/WGResearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ public static void registerResearch() {
// PURECINNABAR
researchAspects = new AspectList().add(Aspect.METAL, 5).add(Aspect.ORDER, 1).add(Aspect.POISON, 1);
pages = new ResearchPage[] { new ResearchPage("witchinggadgets_research_page.PURECINNABAR.1"),
new ResearchPage((CrucibleRecipe) WGContent.recipeList.get("PURECINNABAR")) };
new ResearchPage((CrucibleRecipe) WGContent.recipeList.get("PURECINNABAR")),
new ResearchPage((CrucibleRecipe) WGContent.recipeList.get("PURECINNABAR.2")) };
getResearchItem(
"PURECINNABAR",
"WITCHGADG",
Expand Down
85 changes: 85 additions & 0 deletions src/main/java/witchinggadgets/common/recipes/WGResearchUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package witchinggadgets.common.recipes;

import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;

import org.apache.commons.lang3.ArrayUtils;

import gregtech.api.util.GTUtility;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.crafting.CrucibleRecipe;
import thaumcraft.api.crafting.IArcaneRecipe;
import thaumcraft.api.crafting.InfusionRecipe;
import thaumcraft.api.research.ResearchCategories;
import thaumcraft.api.research.ResearchItem;
import thaumcraft.api.research.ResearchPage;

public class WGResearchUtils {

public static void addResearchPage(final String research, ResearchPage page) {
ResearchItem ri = ResearchCategories.getResearch(research);
ri.setPages(ArrayUtils.add(ri.getPages(), page));
}

public static void refreshResearchPages(final String research) {
ResearchItem target = ResearchCategories.getResearch(research);
ResearchPage[] pages = target.getPages();
for (int x = 0; x < pages.length; x++) {
if (pages[x].recipe != null) {
if (pages[x].recipe instanceof IRecipe) {
IRecipe recipe = (IRecipe) pages[x].recipe;
for (Object craft : CraftingManager.getInstance().getRecipeList()) {
if (craft instanceof IRecipe) {
IRecipe theCraft = (IRecipe) craft;
if (theCraft.getRecipeOutput() != null
&& GTUtility.areStacksEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) {
pages[x] = new ResearchPage(theCraft);
break;
}
}
}
} else if (pages[x].recipe instanceof IArcaneRecipe) {
IArcaneRecipe recipe = (IArcaneRecipe) pages[x].recipe;
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
if (craft instanceof IArcaneRecipe) {
IArcaneRecipe theCraft = (IArcaneRecipe) craft;
if (theCraft.getRecipeOutput() != null
&& GTUtility.areStacksEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) {
pages[x] = new ResearchPage(theCraft);
break;
}
}
}
} else if (pages[x].recipe instanceof CrucibleRecipe) {
CrucibleRecipe recipe = (CrucibleRecipe) pages[x].recipe;
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
if (craft instanceof CrucibleRecipe) {
CrucibleRecipe theCraft = (CrucibleRecipe) craft;
if (theCraft.getRecipeOutput() != null
&& GTUtility.areStacksEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) {
pages[x] = new ResearchPage(theCraft);
break;
}
}
}
} else if (pages[x].recipe instanceof InfusionRecipe) {
InfusionRecipe recipe = (InfusionRecipe) pages[x].recipe;
if (recipe.getRecipeOutput() instanceof ItemStack) {
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
if (craft instanceof InfusionRecipe) {
InfusionRecipe theCraft = (InfusionRecipe) craft;
if (theCraft.getRecipeOutput() instanceof ItemStack && GTUtility.areStacksEqual(
((ItemStack) theCraft.getRecipeOutput()),
(ItemStack) recipe.getRecipeOutput())) {
pages[x] = new ResearchPage(theCraft);
break;
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.item.ItemStack;

import gregtech.api.util.GTUtility;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.crafting.CrucibleRecipe;
Expand All @@ -11,6 +12,7 @@
import witchinggadgets.common.recipes.alchemic.WG_alchemic_crystal_capsule;
import witchinggadgets.common.recipes.alchemic.WG_alchemic_pure_cinnabar;
import witchinggadgets.common.recipes.alchemic.WG_alchemic_rose_vine;
import witchinggadgets.common.recipes.alchemic.WG_alchemic_tc_clusters;
import witchinggadgets.common.recipes.alchemic.WG_alchemic_transmogrify;

public class WG_alchemic_recipes {
Expand All @@ -28,6 +30,7 @@ public static void registeralchemic() {
}

WG_alchemic_clusters.registerClusters();
WG_alchemic_tc_clusters.registerExistingClusters();

}

Expand All @@ -37,4 +40,12 @@ public static CrucibleRecipe registerAlchemyRecipe(String tag, String tagAddon,
WGContent.recipeList.put(tag + tagAddon, crucibleRecipe);
return crucibleRecipe;
}

public static void removeCrucibleRecipe(final ItemStack output) {
ThaumcraftApi.getCraftingRecipes().removeIf(recipe -> {
if (recipe instanceof CrucibleRecipe) return ((CrucibleRecipe) recipe).getRecipeOutput() != null
&& GTUtility.areStacksEqual(((CrucibleRecipe) recipe).getRecipeOutput(), output);
return false;
});
}
}
Loading