Skip to content

Commit

Permalink
Fix NPE on IC2 recycler blacklist (GTNewHorizons#3403)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexdoru authored Oct 22, 2024
1 parent abdd147 commit b587aa1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
16 changes: 15 additions & 1 deletion src/main/java/gregtech/api/util/GTModHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,26 @@ public static boolean addScrapboxDrop(float aChance, ItemStack aOutput) {
return true;
}

// temporary buffer list to fix NPE if you try to access the recyclerBlacklist too early
private static List<RecipeInputItemStack> tempRecyclerBlackList = new ArrayList<>();

/**
* Adds an Item to the Recycler Blacklist
*/
public static boolean addToRecyclerBlackList(ItemStack aRecycledStack) {
if (aRecycledStack == null) return false;
Recipes.recyclerBlacklist.add(new RecipeInputItemStack(aRecycledStack));
final RecipeInputItemStack iRecipeInput = new RecipeInputItemStack(aRecycledStack);
if (Recipes.recyclerBlacklist == null) {
tempRecyclerBlackList.add(iRecipeInput);
return true;
}
if (tempRecyclerBlackList != null) {
for (RecipeInputItemStack recipe : tempRecyclerBlackList) {
Recipes.recyclerBlacklist.add(recipe);
}
tempRecyclerBlackList = null;
}
Recipes.recyclerBlacklist.add(iRecipeInput);
return true;
}

Expand Down
13 changes: 3 additions & 10 deletions src/main/java/gregtech/common/GTProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,22 +814,15 @@ public GTProxy() {
.getRegisteredFluidContainerData()) {
onFluidContainerRegistration(new FluidContainerRegistry.FluidContainerRegisterEvent(tData));
}
try {
for (String tOreName : OreDictionary.getOreNames()) {
ItemStack tOreStack;
for (Iterator<ItemStack> i$ = OreDictionary.getOres(tOreName)
.iterator(); i$.hasNext(); registerOre(new OreDictionary.OreRegisterEvent(tOreName, tOreStack))) {
tOreStack = i$.next();
}
for (String tOreName : OreDictionary.getOreNames()) {
for (ItemStack itemStack : OreDictionary.getOres(tOreName)) {
registerOre(new OreDictionary.OreRegisterEvent(tOreName, itemStack));
}
} catch (Throwable e) {
e.printStackTrace(GTLog.err);
}
}

public void onPreLoad() {
GTLog.out.println("GTMod: Preload-Phase started!");
GTLog.ore.println("GTMod: Preload-Phase started!");

GregTechAPI.sPreloadStarted = true;
this.mIgnoreTcon = OPStuff.ignoreTinkerConstruct;
Expand Down

0 comments on commit b587aa1

Please sign in to comment.