Skip to content

Commit

Permalink
fix: ensure JEI is called from the main thread for loot crate rebuilding
Browse files Browse the repository at this point in the history
  • Loading branch information
desht committed Dec 31, 2024
1 parent 00d6378 commit d236455
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [21.1.2]

### Fixed
* Fixed threading bug with JEI integration

## [21.1.1]

### Added
Expand Down
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enabled_platforms=fabric,neoforge

archives_base_name=ftb-xmod-compat
readable_name=FTB XMod Compat
mod_version=21.1.1
mod_version=21.1.2
maven_group=dev.ftb.mods
curseforge_id=889915

Expand Down

0 comments on commit d236455

Please sign in to comment.