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

fix: fix threading issue for JEI loot crate integration #31

Merged
merged 1 commit into from
Jan 2, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.advanced.IRecipeManagerPlugin;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.world.item.ItemStack;

import java.util.List;
Expand All @@ -19,12 +20,16 @@ public enum LootCrateRecipeManagerPlugin implements IRecipeManagerPlugin {
private final WrappedLootCrateCache cache = new WrappedLootCrateCache(
crates -> {
if (FTBQuestsJEIIntegration.runtime != null && !crates.isEmpty()) {
FTBQuestsJEIIntegration.runtime.getIngredientManager().removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, crates);
Minecraft.getInstance().tell(() ->
FTBQuestsJEIIntegration.runtime.getIngredientManager().removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, crates)
);
}
},
crates -> {
if (FTBQuestsJEIIntegration.runtime != null && !crates.isEmpty()) {
FTBQuestsJEIIntegration.runtime.getIngredientManager().addIngredientsAtRuntime(VanillaTypes.ITEM_STACK, crates);
Minecraft.getInstance().tell(() ->
FTBQuestsJEIIntegration.runtime.getIngredientManager().addIngredientsAtRuntime(VanillaTypes.ITEM_STACK, crates)
);
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public List<WrappedLootCrate> getWrappedLootCrates() {
}

private void rebuildWrappedLootCrateCache() {
preRebuild.accept(crateStacks);
preRebuild.accept(List.copyOf(crateStacks));

wrappedLootCratesCache.clear();
crateStacks.clear();
Expand All @@ -49,7 +49,7 @@ private void rebuildWrappedLootCrateCache() {
}
}

postRebuild.accept(crateStacks);
postRebuild.accept(List.copyOf(crateStacks));
}

public void refresh() {
Expand Down
Loading