From 69a855f33483c3a5273f6f337c95fb51aad5d2b4 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 26 Feb 2020 00:35:20 +0800 Subject: improved notice filtering Signed-off-by: shedaniel --- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java') diff --git a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index 2eb18a6ee..1e8b59921 100644 --- a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -15,6 +15,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsNetwork; import me.shedaniel.rei.api.*; import me.shedaniel.rei.gui.PreRecipeViewingScreen; import me.shedaniel.rei.gui.RecipeViewingScreen; +import me.shedaniel.rei.gui.StackToNoticeScreen; import me.shedaniel.rei.gui.VillagerRecipeViewingScreen; import me.shedaniel.rei.gui.config.RecipeScreenType; import me.shedaniel.rei.utils.CollectionUtils; @@ -37,6 +38,7 @@ import net.minecraft.util.Lazy; import net.minecraft.util.PacketByteBuf; import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; import java.time.LocalDateTime; @@ -156,7 +158,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { public boolean executeRecipeKeyBind(EntryStack stack) { Map, List> map = RecipeHelper.getInstance().getRecipesFor(stack); if (map.keySet().size() > 0) - openRecipeViewingScreen(map, stack); + openRecipeViewingScreen(map, null, stack); return map.keySet().size() > 0; } @@ -164,7 +166,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { public boolean executeUsageKeyBind(EntryStack stack) { Map, List> map = RecipeHelper.getInstance().getUsagesFor(stack); if (map.keySet().size() > 0) - openRecipeViewingScreen(map, stack); + openRecipeViewingScreen(map, stack, null); return map.keySet().size() > 0; } @@ -212,25 +214,28 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { @Override public void openRecipeViewingScreen(Map, List> map) { - openRecipeViewingScreen(map, null); + openRecipeViewingScreen(map, null, null); } - public void openRecipeViewingScreen(Map, List> map, EntryStack notice) { + @ApiStatus.Internal + public void openRecipeViewingScreen(Map, List> map, @Nullable EntryStack ingredientNotice, @Nullable EntryStack resultNotice) { Screen screen; if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.VILLAGER) { screen = new VillagerRecipeViewingScreen(map); - if (notice != null) - ((VillagerRecipeViewingScreen) screen).addMainStackToNotice(notice); } else if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.UNSET) { screen = new PreRecipeViewingScreen(ScreenHelper.getLastContainerScreen(), RecipeScreenType.UNSET, true, original -> { ConfigObject.getInstance().setRecipeScreenType(original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER); ConfigManager.getInstance().saveConfig(); - openRecipeViewingScreen(map, notice); + openRecipeViewingScreen(map, ingredientNotice, resultNotice); }); } else { screen = new RecipeViewingScreen(map); - if (notice != null) - ((RecipeViewingScreen) screen).addMainStackToNotice(notice); + } + if (screen instanceof StackToNoticeScreen) { + if (ingredientNotice != null) + ((StackToNoticeScreen) screen).addIngredientStackToNotice(ingredientNotice); + if (resultNotice != null) + ((StackToNoticeScreen) screen).addResultStackToNotice(resultNotice); } ScreenHelper.storeRecipeScreen(MinecraftClient.getInstance().currentScreen); MinecraftClient.getInstance().openScreen(screen); -- cgit