From 2077ebf086543587c4fc7ca9b125809609f749b9 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 3 Jan 2020 23:20:31 +0800 Subject: Compact the design and add cooking xp details --- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 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 1645c63c7..bb71355b0 100644 --- a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -74,13 +74,12 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { } @Override - public String getModFromIdentifier(Identifier identifier) { - if (identifier == null) + public String getModFromModId(String modid) { + if (modid == null) return ""; - Optional any = Optional.ofNullable(modNameCache.getOrDefault(identifier.getNamespace(), null)); - if (any.isPresent()) - return any.get(); - String modid = identifier.getNamespace(); + String any = modNameCache.getOrDefault(modid, null); + if (any != null) + return any; String s = FabricLoader.getInstance().getModContainer(modid).map(ModContainer::getMetadata).map(ModMetadata::getName).orElse(modid); modNameCache.put(modid, s); return s; @@ -138,7 +137,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); + openRecipeViewingScreen(map, stack); return map.keySet().size() > 0; } @@ -146,7 +145,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); + openRecipeViewingScreen(map, stack); return map.keySet().size() > 0; } @@ -199,13 +198,24 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { @Override public void openRecipeViewingScreen(Map, List> map) { - Screen screen = null; - if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.VILLAGER) + openRecipeViewingScreen(map, null); + } + + public void openRecipeViewingScreen(Map, List> map, EntryStack notice) { + Screen screen; + if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.VILLAGER) { screen = new VillagerRecipeViewingScreen(map); - else if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.UNSET) + if (notice != null) + ((VillagerRecipeViewingScreen) screen).addMainStackToNotice(notice); + } else if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.UNSET) { screen = new PreRecipeViewingScreen(map); - else + if (notice != null) + ((PreRecipeViewingScreen) screen).addMainStackToNotice(notice); + } else { screen = new RecipeViewingScreen(map); + if (notice != null) + ((RecipeViewingScreen) screen).addMainStackToNotice(notice); + } ScreenHelper.storeRecipeScreen(MinecraftClient.getInstance().currentScreen); MinecraftClient.getInstance().openScreen(screen); } -- cgit