aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-31 15:32:33 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-31 15:32:33 +0800
commit2f95b698dee3368666cefe8890a015eb098dd77b (patch)
tree994981d645051f5360ea29dc0d7701a83cd1858a
parent40d345b6b0f0bea1e4313ad9cdb789762e160f8d (diff)
downloadRoughlyEnoughItems-2.2.0.15.tar.gz
RoughlyEnoughItems-2.2.0.15.tar.bz2
RoughlyEnoughItems-2.2.0.15.zip
Update to v2.2.0.15 & Fix Optifinev2.2.0.15
Fix #16
-rw-r--r--build.gradle2
-rw-r--r--src/main/java/me/shedaniel/rei/REIMixinInit.java2
-rw-r--r--src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java37
-rw-r--r--src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java53
-rw-r--r--src/main/java/me/shedaniel/rei/api/IRecipeCategory.java12
-rw-r--r--src/main/java/me/shedaniel/rei/api/IRecipeCategoryCraftable.java18
-rw-r--r--src/main/java/me/shedaniel/rei/api/SpeedCraftAreaSupplier.java4
-rw-r--r--src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java1
-rw-r--r--src/main/java/me/shedaniel/rei/client/ClientHelper.java41
-rw-r--r--src/main/java/me/shedaniel/rei/client/GuiHelper.java39
-rw-r--r--src/main/java/me/shedaniel/rei/client/KeyBindHelper.java13
-rw-r--r--src/main/java/me/shedaniel/rei/client/REIConfig.java6
-rw-r--r--src/main/java/me/shedaniel/rei/client/REIItemListOrdering.java4
-rw-r--r--src/main/java/me/shedaniel/rei/client/RecipeHelper.java89
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerGuiOverlay.java64
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java3
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/CraftableToggleButtonWidget.java12
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/HighlightableWidget.java10
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java43
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java35
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidgetGui.java (renamed from src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java)123
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SpeedCraftingButtonWidget.java42
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java6
-rw-r--r--src/main/java/me/shedaniel/rei/listeners/ClientLoaded.java7
-rw-r--r--src/main/java/me/shedaniel/rei/listeners/IListener.java4
-rw-r--r--src/main/java/me/shedaniel/rei/listeners/IMixinGuiContainer.java2
-rw-r--r--src/main/java/me/shedaniel/rei/listeners/RecipeSync.java9
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinGuiContainer.java27
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinGuiCrafting.java4
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinGuiInventory.java4
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinGuiRecipeBook.java4
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinKeyBinding.java4
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinNetHandlerPlayClient.java9
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinPotionBrewing.java21
-rw-r--r--src/main/java/me/shedaniel/rei/network/CreateItemsPacket.java6
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java15
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultCraftingCategory.java14
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java28
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java12
-rwxr-xr-xsrc/main/resources/assets/roughlyenoughitems/lang/en_us.json2
-rwxr-xr-xsrc/main/resources/assets/roughlyenoughitems/lang/fr_fr.json2
-rw-r--r--src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json2
-rw-r--r--src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json2
-rw-r--r--src/main/resources/riftmod.json11
44 files changed, 392 insertions, 456 deletions
diff --git a/build.gradle b/build.gradle
index 32df55344..e66b77786 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,7 +16,7 @@ apply plugin: 'org.spongepowered.mixin'
apply plugin: 'java'
group 'me.shedaniel'
-version '2.1.0.14'
+version '2.1.0.15'
archivesBaseName = 'RoughlyEnoughItems'
sourceCompatibility = 1.8
diff --git a/src/main/java/me/shedaniel/rei/REIMixinInit.java b/src/main/java/me/shedaniel/rei/REIMixinInit.java
index 39f3639e2..7b8eb00b6 100644
--- a/src/main/java/me/shedaniel/rei/REIMixinInit.java
+++ b/src/main/java/me/shedaniel/rei/REIMixinInit.java
@@ -1,5 +1,7 @@
package me.shedaniel.rei;
+import net.minecraft.client.Minecraft;
+import org.dimdev.rift.listener.client.ClientTickable;
import org.dimdev.riftloader.listener.InitializationListener;
import org.spongepowered.asm.launch.MixinBootstrap;
import org.spongepowered.asm.mixin.Mixins;
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index ad445e1d2..bf0268a90 100644
--- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -1,47 +1,28 @@
package me.shedaniel.rei;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import me.shedaniel.rei.api.IRecipePlugin;
import me.shedaniel.rei.client.ClientHelper;
import me.shedaniel.rei.client.ConfigHelper;
import me.shedaniel.rei.client.RecipeHelper;
-import me.shedaniel.rei.listeners.IListener;
-import me.shedaniel.rei.plugin.DefaultPlugin;
-import net.minecraft.util.ResourceLocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.dimdev.riftloader.listener.InitializationListener;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
public class RoughlyEnoughItemsCore {
public static final Logger LOGGER = LogManager.getFormatterLogger("REI");
- private static final List<IListener> listeners = Arrays.asList(new ClientHelper(), new RecipeHelper());
- private static final ConfigHelper configHelper = new ConfigHelper();
+ private static final RecipeHelper RECIPE_HELPER = new RecipeHelper();
+ private static final ClientHelper CLIENT_HELPER = new ClientHelper();
+ private static final ConfigHelper CONFIG_HELPER = new ConfigHelper();
- public static <T> List<T> getListeners(Class<T> listenerClass) {
- return listeners.stream().filter(listener -> {
- return listenerClass.isAssignableFrom(listener.getClass());
- }).map(listener -> {
- return listenerClass.cast(listener);
- }).collect(Collectors.toList());
+ public static ConfigHelper getConfigHelper() {
+ return CONFIG_HELPER;
}
- public static ConfigHelper getConfigHelper() {
- return configHelper;
+ public static RecipeHelper getRecipeHelper() {
+ return RECIPE_HELPER;
}
- private boolean removeListener(IListener listener) {
- if (!listeners.contains(listener))
- return false;
- listeners.remove(listener);
- return true;
+ public static ClientHelper getClientHelper() {
+ return CLIENT_HELPER;
}
}
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java
index 8f91e7e0e..ad3c15ba6 100644
--- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java
+++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java
@@ -3,6 +3,7 @@ package me.shedaniel.rei;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import me.shedaniel.rei.api.IRecipePlugin;
import net.minecraft.util.ResourceLocation;
@@ -10,7 +11,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.riftloader.ModInfo;
import org.dimdev.riftloader.RiftLoader;
-import org.dimdev.riftloader.listener.InitializationListener;
import java.io.File;
import java.io.FileReader;
@@ -24,14 +24,15 @@ import java.util.jar.JarFile;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
-public class RoughlyEnoughItemsPlugin implements InitializationListener {
+public class RoughlyEnoughItemsPlugin {
public static final Logger LOGGER = LogManager.getFormatterLogger("REI");
- private static final Map<ResourceLocation, IRecipePlugin> plugins = Maps.newHashMap();
+ private static final Map<String, IRecipePlugin> plugins = Maps.newHashMap();
private static JsonParser parser = new JsonParser();
- private static List<ResourceLocation> disablingPlugins;
+ private static List<String> disablingPlugins;
+ private static boolean loaded = false;
- public static IRecipePlugin registerPlugin(ResourceLocation resourceLocation, IRecipePlugin plugin) {
+ public static IRecipePlugin registerPlugin(String resourceLocation, IRecipePlugin plugin) {
plugins.put(resourceLocation, plugin);
RoughlyEnoughItemsPlugin.LOGGER.info("REI: Registered Plugin from %s by %s.", resourceLocation.toString(), plugin.getClass().getSimpleName());
return plugin;
@@ -41,24 +42,22 @@ public class RoughlyEnoughItemsPlugin implements InitializationListener {
return new LinkedList<>(plugins.values());
}
- public static ResourceLocation getPluginResourceLocation(IRecipePlugin plugin) {
- for(ResourceLocation ResourceLocation : plugins.keySet())
- if (plugins.get(ResourceLocation).equals(plugin))
- return ResourceLocation;
+ public static String getPluginResourceLocation(IRecipePlugin plugin) {
+ for(String resourceLocation : plugins.keySet())
+ if (plugins.get(resourceLocation).equals(plugin))
+ return resourceLocation;
return null;
}
public static void disablePlugin(ResourceLocation location) {
- if (disablingPlugins.stream().noneMatch(location1 -> {return location.equals(location1);}))
- disablingPlugins.add(location);
+ if (disablingPlugins.stream().noneMatch(location1 -> {return location.toString().equals(location1);}))
+ disablingPlugins.add(location.toString());
}
- @Override
- public void onInitialization() {
- discoverPlugins();
- }
-
- private void discoverPlugins() {
+ public static void discoverPlugins() {
+ if (loaded)
+ return;
+ loaded = true;
LOGGER.info("REI: Discovering Plugins.");
disablingPlugins = Lists.newArrayList();
Collection<ModInfo> modInfoCollection = RiftLoader.instance.getMods();
@@ -78,29 +77,27 @@ public class RoughlyEnoughItemsPlugin implements InitializationListener {
RoughlyEnoughItemsPlugin.LOGGER.error("REI: Failed to load plugin file from %s. (%s)", (Object) modInfo.id, (Object) e.getLocalizedMessage());
}
});
- plugins.forEach((location, plugin) -> plugin.onFirstLoad());
- plugins.keySet().stream().filter(location -> {
- return disablingPlugins.contains(location);
- }).collect(Collectors.toList()).forEach(location -> {
+ plugins.values().forEach(IRecipePlugin::onFirstLoad);
+ new LinkedList<>(plugins.keySet()).stream().filter(location -> disablingPlugins.contains(location)).forEach(location -> {
plugins.remove(location);
LOGGER.info("REI: Disabled REI plugin %s.", location.toString());
});
- LOGGER.info("REI: Discovered %d REI Plugins%s", plugins.size(), (plugins.size() > 0 ? ": " + String.join(", ", plugins.keySet().stream().map(ResourceLocation::toString).collect(Collectors.toList())) : "."));
+ LOGGER.info("REI: Discovered %d REI Plugins%s", plugins.size(), (plugins.size() > 0 ? ": " + String.join(", ", plugins.keySet().stream().collect(Collectors.toList())) : "."));
}
- private void loadPluginInfo(ModInfo modInfo, Reader reader) throws Exception {
+ private static void loadPluginInfo(ModInfo modInfo, Reader reader) throws Exception {
JsonElement infoElement = parser.parse(reader);
if (infoElement.isJsonArray())
for(JsonElement jsonElement : infoElement.getAsJsonArray())
- parseAndRegisterPlugin(modInfo.id, jsonElement);
+ parseAndRegisterPlugin(modInfo.id, jsonElement.getAsJsonObject());
else
- parseAndRegisterPlugin(modInfo.id, infoElement);
+ parseAndRegisterPlugin(modInfo.id, infoElement.getAsJsonObject());
reader.close();
}
- private void parseAndRegisterPlugin(String modId, JsonElement jsonElement) throws Exception {
- ResourceLocation location = new ResourceLocation(modId, jsonElement.getAsJsonObject().getAsJsonPrimitive("id").getAsString());
- Class<?> aClass = Class.forName(jsonElement.getAsJsonObject().getAsJsonPrimitive("initializer").getAsString());
+ private static void parseAndRegisterPlugin(String modId, JsonObject jsonObject) throws Exception {
+ String location = modId + ":" + jsonObject.getAsJsonPrimitive("id").getAsString();
+ Class<?> aClass = Class.forName(jsonObject.getAsJsonPrimitive("initializer").getAsString());
IRecipePlugin plugin = IRecipePlugin.class.cast(aClass.newInstance());
registerPlugin(location, plugin);
}
diff --git a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java
index dbc4a7204..ca531ca21 100644
--- a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java
+++ b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java
@@ -2,8 +2,7 @@ package me.shedaniel.rei.api;
import me.shedaniel.rei.gui.widget.IWidget;
import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
-import me.shedaniel.rei.gui.widget.RecipeViewingWidget;
-import me.shedaniel.rei.listeners.IMixinGuiContainer;
+import me.shedaniel.rei.gui.widget.RecipeViewingWidgetGui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
@@ -14,6 +13,7 @@ import net.minecraft.util.ResourceLocation;
import java.awt.*;
import java.util.Arrays;
import java.util.List;
+import java.util.function.Supplier;
public interface IRecipeCategory<T extends IRecipeDisplay> {
@@ -28,17 +28,21 @@ public interface IRecipeCategory<T extends IRecipeDisplay> {
return false;
}
- default public List<IWidget> setupDisplay(IMixinGuiContainer containerGui, T recipeDisplay, Rectangle bounds) {
+ default public List<IWidget> setupDisplay(Supplier<T> recipeDisplaySupplier, Rectangle bounds) {
return Arrays.asList(new RecipeBaseWidget(bounds));
}
default public void drawCategoryBackground(Rectangle bounds) {
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderHelper.disableStandardItemLighting();
- Minecraft.getInstance().getTextureManager().bindTexture(RecipeViewingWidget.CHEST_GUI_TEXTURE);
+ Minecraft.getInstance().getTextureManager().bindTexture(RecipeViewingWidgetGui.CHEST_GUI_TEXTURE);
new Gui() {
}.drawTexturedModalRect((int) bounds.getX(), (int) bounds.getY(), 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight());
}
+ default public boolean checkTags() {
+ return false;
+ }
+
}
diff --git a/src/main/java/me/shedaniel/rei/api/IRecipeCategoryCraftable.java b/src/main/java/me/shedaniel/rei/api/IRecipeCategoryCraftable.java
deleted file mode 100644
index d16f66654..000000000
--- a/src/main/java/me/shedaniel/rei/api/IRecipeCategoryCraftable.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package me.shedaniel.rei.api;
-
-import me.shedaniel.rei.gui.widget.IWidget;
-import me.shedaniel.rei.listeners.IMixinGuiContainer;
-import net.minecraft.client.gui.Gui;
-
-import java.awt.*;
-import java.util.List;
-
-public interface IRecipeCategoryCraftable<T extends IRecipeDisplay> {
-
- public boolean canAutoCraftHere(Class<? extends Gui> guiClass, T recipe);
-
- public boolean performAutoCraft(Gui gui, T recipe);
-
- public void registerAutoCraftButton(List<IWidget> widgets, Rectangle rectangle, IMixinGuiContainer parentGui, T recipe);
-
-}
diff --git a/src/main/java/me/shedaniel/rei/api/SpeedCraftAreaSupplier.java b/src/main/java/me/shedaniel/rei/api/SpeedCraftAreaSupplier.java
index 47e0a66cc..d4db1f072 100644
--- a/src/main/java/me/shedaniel/rei/api/SpeedCraftAreaSupplier.java
+++ b/src/main/java/me/shedaniel/rei/api/SpeedCraftAreaSupplier.java
@@ -6,4 +6,8 @@ public interface SpeedCraftAreaSupplier {
public Rectangle get(Rectangle bounds);
+ default String getButtonText() {
+ return "+";
+ }
+
}
diff --git a/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java b/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java
index 6dd998d47..e2ed4b83d 100644
--- a/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java
+++ b/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java
@@ -1,6 +1,5 @@
package me.shedaniel.rei.api;
-import me.shedaniel.rei.plugin.DefaultCraftingDisplay;
import net.minecraft.client.gui.Gui;
public interface SpeedCraftFunctional<T extends IRecipeDisplay> {
diff --git a/src/main/java/me/shedaniel/rei/client/ClientHelper.java b/src/main/java/me/shedaniel/rei/client/ClientHelper.java
index 84ecdd0ba..e4347b85b 100644
--- a/src/main/java/me/shedaniel/rei/client/ClientHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/ClientHelper.java
@@ -2,15 +2,12 @@ package me.shedaniel.rei.client;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import io.netty.buffer.Unpooled;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.IRecipeCategory;
import me.shedaniel.rei.api.IRecipeDisplay;
import me.shedaniel.rei.gui.ContainerGuiOverlay;
import me.shedaniel.rei.gui.widget.ConfigWidget;
-import me.shedaniel.rei.gui.widget.RecipeViewingWidget;
-import me.shedaniel.rei.listeners.ClientLoaded;
-import me.shedaniel.rei.listeners.IMixinGuiContainer;
+import me.shedaniel.rei.gui.widget.RecipeViewingWidgetGui;
import me.shedaniel.rei.network.CreateItemsPacket;
import me.shedaniel.rei.network.DeleteItemsPacket;
import net.minecraft.client.Minecraft;
@@ -32,7 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class ClientHelper implements ClientLoaded {
+public class ClientHelper {
private static List<ItemStack> itemList;
private static boolean cheating = false;
@@ -48,13 +45,11 @@ public class ClientHelper implements ClientLoaded {
String modid = location.getNamespace();
if (modid.equalsIgnoreCase("minecraft"))
return "Minecraft";
- return RiftLoader.instance.getMods().stream()
- .filter(modInfo -> modInfo.id.equals(modid) || (modInfo.name != null && modInfo.name.equals(modid)))
- .findFirst().map(modInfo -> {
- if (modInfo.name != null)
- return modInfo.name;
- return modid;
- }).orElse(modid);
+ return RiftLoader.instance.getMods().stream().filter(modInfo -> modInfo.id.equals(modid) || (modInfo.name != null && modInfo.name.equals(modid))).findFirst().map(modInfo -> {
+ if (modInfo.name != null)
+ return modInfo.name;
+ return modid;
+ }).orElse(modid);
}
return "";
}
@@ -100,27 +95,25 @@ public class ClientHelper implements ClientLoaded {
} else {
ResourceLocation location = IRegistry.ITEM.getKey(cheatedStack.getItem());
String tagMessage = cheatedStack.copy().getTag() != null && !cheatedStack.copy().getTag().isEmpty() ? cheatedStack.copy().getTag().toString() : "";
- String madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + Minecraft.getInstance().player.getScoreboardName() + " " +
- location.toString() + tagMessage + (cheatedStack.getCount() != 1 ? " " + cheatedStack.getCount() : "");
+ String madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + Minecraft.getInstance().player.getScoreboardName() + " " + location.toString() + tagMessage + (cheatedStack.getCount() != 1 ? " " + cheatedStack.getCount() : "");
if (madeUpCommand.length() > 256)
- madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + Minecraft.getInstance().player.getScoreboardName() + " " +
- location.toString() + (cheatedStack.getCount() != 1 ? " " + cheatedStack.getCount() : "");
+ madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + Minecraft.getInstance().player.getScoreboardName() + " " + location.toString() + (cheatedStack.getCount() != 1 ? " " + cheatedStack.getCount() : "");
Minecraft.getInstance().player.sendChatMessage(madeUpCommand);
return true;
}
}
- public static boolean executeRecipeKeyBind(ContainerGuiOverlay overlay, ItemStack stack, IMixinGuiContainer parent) {
- Map<IRecipeCategory, List<IRecipeDisplay>> map = RecipeHelper.getRecipesFor(stack);
+ public static boolean executeRecipeKeyBind(ContainerGuiOverlay overlay, ItemStack stack) {
+ Map<IRecipeCategory, List<IRecipeDisplay>> map = RecipeHelper.getInstance().getRecipesFor(stack);
if (map.keySet().size() > 0)
- Minecraft.getInstance().displayGuiScreen(new RecipeViewingWidget(Minecraft.getInstance().mainWindow, parent, map));
+ Minecraft.getInstance().displayGuiScreen(new RecipeViewingWidgetGui(Minecraft.getInstance().mainWindow, map));
return map.keySet().size() > 0;
}
- public static boolean executeUsageKeyBind(ContainerGuiOverlay overlay, ItemStack stack, IMixinGuiContainer parent) {
- Map<IRecipeCategory, List<IRecipeDisplay>> map = RecipeHelper.getUsagesFor(stack);
+ public static boolean executeUsageKeyBind(ContainerGuiOverlay overlay, ItemStack stack) {
+ Map<IRecipeCategory, List<IRecipeDisplay>> map = RecipeHelper.getInstance().getUsagesFor(stack);
if (map.keySet().size() > 0)
- Minecraft.getInstance().displayGuiScreen(new RecipeViewingWidget(Minecraft.getInstance().mainWindow, parent, map));
+ Minecraft.getInstance().displayGuiScreen(new RecipeViewingWidgetGui(Minecraft.getInstance().mainWindow, map));
return map.keySet().size() > 0;
}
@@ -129,8 +122,7 @@ public class ClientHelper implements ClientLoaded {
}
public static List<ItemStack> getInventoryItemsTypes() {
- List<NonNullList<ItemStack>> field_7543 = ImmutableList.of(Minecraft.getInstance().player.inventory.mainInventory, Minecraft.getInstance().player.inventory.armorInventory
- , Minecraft.getInstance().player.inventory.offHandInventory);
+ List<NonNullList<ItemStack>> field_7543 = ImmutableList.of(Minecraft.getInstance().player.inventory.mainInventory, Minecraft.getInstance().player.inventory.armorInventory, Minecraft.getInstance().player.inventory.offHandInventory);
List<ItemStack> inventoryStacks = new ArrayList<>();
field_7543.forEach(itemStacks -> itemStacks.forEach(itemStack -> {
if (!itemStack.getItem().equals(Items.AIR))
@@ -139,7 +131,6 @@ public class ClientHelper implements ClientLoaded {
return inventoryStacks;
}
- @Override
public void clientLoaded() {
IRegistry.ITEM.forEach(item -> {
if (!item.equals(Items.ENCHANTED_BOOK))
diff --git a/src/main/java/me/shedaniel/rei/client/GuiHelper.java b/src/main/java/me/shedaniel/rei/client/GuiHelper.java
index 4b228b3a6..253a51480 100644
--- a/src/main/java/me/shedaniel/rei/client/GuiHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/GuiHelper.java
@@ -3,17 +3,22 @@ package me.shedaniel.rei.client;
import com.google.common.collect.Lists;
import me.shedaniel.rei.gui.ContainerGuiOverlay;
import me.shedaniel.rei.gui.widget.TextFieldWidget;
+import me.shedaniel.rei.listeners.IMixinGuiContainer;
+import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
+import org.dimdev.rift.listener.client.ClientTickable;
import java.util.List;
-public class GuiHelper {
+public class GuiHelper implements ClientTickable {
public static TextFieldWidget searchField;
public static List<ItemStack> inventoryStacks = Lists.newArrayList();
private static boolean overlayVisible = true;
private static ContainerGuiOverlay overlay;
+ private static GuiContainer lastGuiContainer;
+ private static IMixinGuiContainer lastMixinGuiContainer;
public static boolean isOverlayVisible() {
return overlayVisible;
@@ -23,14 +28,6 @@ public class GuiHelper {
overlayVisible = !overlayVisible;
}
- public static ContainerGuiOverlay getOverlay(GuiContainer lastGui) {
- if (overlay == null) {
- overlay = new ContainerGuiOverlay(lastGui);
- overlay.onInitialized();
- }
- return overlay;
- }
-
public static ContainerGuiOverlay getLastOverlay() {
return overlay;
}
@@ -40,8 +37,28 @@ public class GuiHelper {
overlay.onInitialized();
}
- public static void resetOverlay() {
- overlay = null;
+ public static GuiContainer getLastGuiContainer() {
+ return lastGuiContainer;
+ }
+
+ public static void setLastGuiContainer(GuiContainer lastGuiContainer) {
+ GuiHelper.lastGuiContainer = lastGuiContainer;
+ }
+
+ public static IMixinGuiContainer getLastMixinGuiContainer() {
+ return lastMixinGuiContainer;
+ }
+
+ public static void setLastMixinGuiContainer(IMixinGuiContainer lastMixinGuiContainer) {
+ GuiHelper.lastMixinGuiContainer = lastMixinGuiContainer;
+ }
+
+ @Override
+ public void clientTick(Minecraft client) {
+ if (client.currentScreen instanceof GuiContainer && lastGuiContainer != client.currentScreen) {
+ GuiHelper.lastGuiContainer = (GuiContainer) client.currentScreen;
+ GuiHelper.lastMixinGuiContainer = (IMixinGuiContainer) lastGuiContainer;
+ }
}
}
diff --git a/src/main/java/me/shedaniel/rei/client/KeyBindHelper.java b/src/main/java/me/shedaniel/rei/client/KeyBindHelper.java
index 65ce788a1..6c253360d 100644
--- a/src/main/java/me/shedaniel/rei/client/KeyBindHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/KeyBindHelper.java
@@ -5,7 +5,6 @@ import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.listeners.IMixinKeyBinding;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
-import net.minecraft.util.ResourceLocation;
import org.dimdev.rift.listener.client.KeyBindingAdder;
import java.util.Collection;
@@ -13,9 +12,9 @@ impor