From 40733b679fc63216290259d09c9ee64cc74be5fc Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 10 Jun 2019 18:17:56 +0800 Subject: single thread recipe sync & fix bug Fix #105 --- gradle.properties | 4 ++-- src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java | 5 ++++- src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index d590a2d65..758ac90ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ mod_version=2.9.4 minecraft_version=1.14.2 -yarn_version=1.14.2+build.2 +yarn_version=1.14.2+build.3 fabricloader_version=0.4.7+build.147 jankson_version=1.1.0 cloth_events_version=0.3.1.23 -cloth_config_version=0.1.0 +cloth_config_version=0.2.0 modmenu_version=1.5.4-85 fabric_keybindings=0.1.0+59147463 diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index e967bf32c..e8d8b5c6b 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -43,6 +43,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.stream.Collectors; public class RoughlyEnoughItemsCore implements ClientModInitializer { @@ -53,6 +55,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { private static final ItemRegistry ITEM_REGISTRY = new ItemRegistryImpl(); private static final DisplayHelper DISPLAY_HELPER = new DisplayHelperImpl(); private static final Map plugins = Maps.newHashMap(); + private static final ExecutorService SYNC_RECIPES = Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "REI-SyncRecipes")); private static ConfigManagerImpl configManager; static { @@ -208,7 +211,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { private void registerClothEvents() { ClothClientHooks.SYNC_RECIPES.register((minecraftClient, recipeManager, synchronizeRecipesS2CPacket) -> { if (RoughlyEnoughItemsCore.getConfigManager().getConfig().registerRecipesInAnotherThread) - CompletableFuture.runAsync(() -> ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(recipeManager)); + CompletableFuture.runAsync(() -> ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(recipeManager), SYNC_RECIPES); else ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(recipeManager); }); diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 4d0ec388a..adc503287 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -289,7 +289,7 @@ public class RecipeViewingScreen extends Screen { int displayWidth = selectedCategory.getDisplayWidth(displaySupplier.get()); final Rectangle displayBounds = new Rectangle((int) getBounds().getCenterX() - displayWidth / 2, getBounds().y + 40 + recipeHeight * i + 7 * i, displayWidth, recipeHeight); widgets.addAll(selectedCategory.setupDisplay(displaySupplier, displayBounds)); - if (supplier.isPresent()) + if (supplier.isPresent() && supplier.get().get(displayBounds) != null) widgets.add(new SpeedCraftingButtonWidget(supplier.get().get(displayBounds), supplier.get().getButtonText(), functional, displaySupplier)); } if (choosePageActivated) -- cgit