aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me')
-rw-r--r--src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java28
-rw-r--r--src/main/java/me/shedaniel/rei/api/IRecipePlugin.java12
-rw-r--r--src/main/java/me/shedaniel/rei/api/ItemRegisterer.java (renamed from src/main/java/me/shedaniel/rei/api/IItemRegisterer.java)2
-rw-r--r--src/main/java/me/shedaniel/rei/api/PluginDisabler.java (renamed from src/main/java/me/shedaniel/rei/api/IPluginDisabler.java)2
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeHelper.java (renamed from src/main/java/me/shedaniel/rei/api/IRecipeHelper.java)4
-rw-r--r--src/main/java/me/shedaniel/rei/api/RelativePoint.java28
-rw-r--r--src/main/java/me/shedaniel/rei/client/ClientHelper.java20
-rw-r--r--src/main/java/me/shedaniel/rei/client/ItemRegistererImpl.java (renamed from src/main/java/me/shedaniel/rei/client/ItemListHelper.java)4
-rw-r--r--src/main/java/me/shedaniel/rei/client/PluginDisablerImpl.java (renamed from src/main/java/me/shedaniel/rei/plugin/PluginManager.java)6
-rw-r--r--src/main/java/me/shedaniel/rei/client/REIConfig.java3
-rw-r--r--src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java (renamed from src/main/java/me/shedaniel/rei/client/RecipeHelper.java)4
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java6
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java10
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java4
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java26
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinClientPlayNetworkHandler.java4
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java11
17 files changed, 116 insertions, 58 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index 604d22f2e..5c194ab14 100644
--- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -1,16 +1,12 @@
package me.shedaniel.rei;
import com.google.common.collect.Maps;
-import me.shedaniel.rei.api.IItemRegisterer;
-import me.shedaniel.rei.api.IPluginDisabler;
-import me.shedaniel.rei.api.IRecipeHelper;
+import me.shedaniel.rei.api.ItemRegisterer;
import me.shedaniel.rei.api.IRecipePlugin;
-import me.shedaniel.rei.client.ConfigHelper;
-import me.shedaniel.rei.client.GuiHelper;
-import me.shedaniel.rei.client.ItemListHelper;
-import me.shedaniel.rei.client.RecipeHelper;
+import me.shedaniel.rei.api.PluginDisabler;
+import me.shedaniel.rei.api.RecipeHelper;
+import me.shedaniel.rei.client.*;
import me.shedaniel.rei.plugin.DefaultPlugin;
-import me.shedaniel.rei.plugin.PluginManager;
import me.shedaniel.rei.update.UpdateChecker;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
@@ -36,13 +32,13 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer, ModInitiali
public static final Logger LOGGER = LogManager.getFormatterLogger("REI");
public static final Identifier DELETE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "delete_item");
public static final Identifier CREATE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "create_item");
- private static final RecipeHelper RECIPE_HELPER = new RecipeHelper();
- private static final PluginManager PLUGIN_MANAGER = new PluginManager();
- private static final ItemListHelper ITEM_LIST_HELPER = new ItemListHelper();
+ private static final RecipeHelperImpl RECIPE_HELPER = new RecipeHelperImpl();
+ private static final PluginDisablerImpl PLUGIN_DISABLER = new PluginDisablerImpl();
+ private static final ItemRegistererImpl ITEM_REGISTERER = new ItemRegistererImpl();
private static final Map<Identifier, IRecipePlugin> plugins = Maps.newHashMap();
private static ConfigHelper configHelper;
- public static IRecipeHelper getRecipeHelper() {
+ public static RecipeHelper getRecipeHelper() {
return RECIPE_HELPER;
}
@@ -50,12 +46,12 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer, ModInitiali
return configHelper;
}
- public static IItemRegisterer getItemRegisterer() {
- return ITEM_LIST_HELPER;
+ public static ItemRegisterer getItemRegisterer() {
+ return ITEM_REGISTERER;
}
- public static IPluginDisabler getPluginDisabler() {
- return PLUGIN_MANAGER;
+ public static PluginDisabler getPluginDisabler() {
+ return PLUGIN_DISABLER;
}
public static IRecipePlugin registerPlugin(Identifier identifier, IRecipePlugin plugin) {
diff --git a/src/main/java/me/shedaniel/rei/api/IRecipePlugin.java b/src/main/java/me/shedaniel/rei/api/IRecipePlugin.java
index a64ba67a4..16b7be3aa 100644
--- a/src/main/java/me/shedaniel/rei/api/IRecipePlugin.java
+++ b/src/main/java/me/shedaniel/rei/api/IRecipePlugin.java
@@ -1,18 +1,16 @@
package me.shedaniel.rei.api;
-import me.shedaniel.rei.client.RecipeHelper;
-
public interface IRecipePlugin {
- default public void onFirstLoad(IPluginDisabler pluginDisabler) {}
+ default public void onFirstLoad(PluginDisabler pluginDisabler) {}
- public void registerItems(IItemRegisterer itemRegisterer);
+ public void registerItems(ItemRegisterer itemRegisterer);
- public void registerPluginCategories(IRecipeHelper recipeHelper);
+ public void registerPluginCategories(RecipeHelper recipeHelper);
- public void registerRecipeDisplays(IRecipeHelper recipeHelper);
+ public void registerRecipeDisplays(RecipeHelper recipeHelper);
- public void registerSpeedCraft(IRecipeHelper recipeHelper);
+ public void registerSpeedCraft(RecipeHelper recipeHelper);
default public int getPriority() {
return 0;
diff --git a/src/main/java/me/shedaniel/rei/api/IItemRegisterer.java b/src/main/java/me/shedaniel/rei/api/ItemRegisterer.java
index 090e26742..43ee25d60 100644
--- a/src/main/java/me/shedaniel/rei/api/IItemRegisterer.java
+++ b/src/main/java/me/shedaniel/rei/api/ItemRegisterer.java
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
import java.util.List;
-public interface IItemRegisterer {
+public interface ItemRegisterer {
public List<ItemStack> getItemList();
diff --git a/src/main/java/me/shedaniel/rei/api/IPluginDisabler.java b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java
index 8663e76bd..7db97a6ed 100644
--- a/src/main/java/me/shedaniel/rei/api/IPluginDisabler.java
+++ b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java
@@ -2,7 +2,7 @@ package me.shedaniel.rei.api;
import net.minecraft.util.Identifier;
-public interface IPluginDisabler {
+public interface PluginDisabler {
default public void disablePluginFunctions(Identifier plugin, PluginFunction... functions) {
for(PluginFunction function : functions)
diff --git a/src/main/java/me/shedaniel/rei/api/IRecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
index 8d9651f32..0e1cdcf6e 100644
--- a/src/main/java/me/shedaniel/rei/api/IRecipeHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
@@ -9,9 +9,9 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
-public interface IRecipeHelper {
+public interface RecipeHelper {
- public static IRecipeHelper getInstance() {
+ public static RecipeHelper getInstance() {
return RoughlyEnoughItemsCore.getRecipeHelper();
}
diff --git a/src/main/java/me/shedaniel/rei/api/RelativePoint.java b/src/main/java/me/shedaniel/rei/api/RelativePoint.java
new file mode 100644
index 000000000..23339c96e
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/RelativePoint.java
@@ -0,0 +1,28 @@
+package me.shedaniel.rei.api;
+
+public class RelativePoint {
+
+ private double relativeX, relativeY;
+
+ public RelativePoint(double relativeX, double relativeY) {
+ this.relativeX = relativeX;
+ this.relativeY = relativeY;
+ }
+
+ public double getRelativeX() {
+ return relativeX;
+ }
+
+ public double getRelativeY() {
+ return relativeY;
+ }
+
+ public double getX(double width) {
+ return width * relativeX;
+ }
+
+ public double getY(double height) {
+ return height * relativeY;
+ }
+
+}
diff --git a/src/main/java/me/shedaniel/rei/client/ClientHelper.java b/src/main/java/me/shedaniel/rei/client/ClientHelper.java
index 87dc00895..d93b32844 100644
--- a/src/main/java/me/shedaniel/rei/client/ClientHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/ClientHelper.java
@@ -5,7 +5,7 @@ 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.api.IRecipeHelper;
+import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.gui.ContainerScreenOverlay;
import me.shedaniel.rei.gui.RecipeViewingScreen;
import me.shedaniel.rei.gui.config.ConfigScreen;
@@ -28,6 +28,7 @@ import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.registry.Registry;
import java.awt.*;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -38,7 +39,6 @@ public class ClientHelper implements ClientModInitializer {
private static final Identifier USAGE_KEYBIND = new Identifier("roughlyenoughitems", "usage_keybind");
private static final Identifier HIDE_KEYBIND = new Identifier("roughlyenoughitems", "hide_keybind");
public static FabricKeyBinding RECIPE, USAGE, HIDE;
- private static boolean cheating;
public static String getModFromItemStack(ItemStack stack) {
if (!stack.isEmpty()) {
@@ -67,11 +67,16 @@ public class ClientHelper implements ClientModInitializer {
}
public static boolean isCheating() {
- return cheating;
+ return RoughlyEnoughItemsCore.getConfigHelper().getConfig().cheating;
}
public static void setCheating(boolean cheating) {
- ClientHelper.cheating = cheating;
+ RoughlyEnoughItemsCore.getConfigHelper().getConfig().cheating = cheating;
+ try {
+ RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
public static void sendDeletePacket() {
@@ -106,14 +111,14 @@ public class ClientHelper implements ClientModInitializer {
}
public static boolean executeRecipeKeyBind(ContainerScreenOverlay overlay, ItemStack stack) {
- Map<IRecipeCategory, List<IRecipeDisplay>> map = IRecipeHelper.getInstance().getRecipesFor(stack);
+ Map<IRecipeCategory, List<IRecipeDisplay>> map = RecipeHelper.getInstance().getRecipesFor(stack);
if (map.keySet().size() > 0)
MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(MinecraftClient.getInstance().window, map));
return map.keySet().size() > 0;
}
public static boolean executeUsageKeyBind(ContainerScreenOverlay overlay, ItemStack stack) {
- Map<IRecipeCategory, List<IRecipeDisplay>> map = IRecipeHelper.getInstance().getUsagesFor(stack);
+ Map<IRecipeCategory, List<IRecipeDisplay>> map = RecipeHelper.getInstance().getUsagesFor(stack);
if (map.keySet().size() > 0)
MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(MinecraftClient.getInstance().window, map));
return map.keySet().size() > 0;
@@ -134,7 +139,7 @@ public class ClientHelper implements ClientModInitializer {
}
public static boolean executeViewAllRecipesKeyBind(ContainerScreenOverlay lastOverlay) {
- Map<IRecipeCategory, List<IRecipeDisplay>> map = IRecipeHelper.getInstance().getAllRecipes();
+ Map<IRecipeCategory, List<IRecipeDisplay>> map = RecipeHelper.getInstance().getAllRecipes();
if (map.keySet().size() > 0)
MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(MinecraftClient.getInstance().window, map));
return map.keySet().size() > 0;
@@ -142,7 +147,6 @@ public class ClientHelper implements ClientModInitializer {
@Override
public void onInitializeClient() {
- this.cheating = false;
registerFabricKeyBinds();
}
diff --git a/src/main/java/me/shedaniel/rei/client/ItemListHelper.java b/src/main/java/me/shedaniel/rei/client/ItemRegistererImpl.java
index d4ccb81e1..4e1c3ef26 100644
--- a/src/main/java/me/shedaniel/rei/client/ItemListHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/ItemRegistererImpl.java
@@ -1,7 +1,7 @@
package me.shedaniel.rei.client;
import com.google.common.collect.Lists;
-import me.shedaniel.rei.api.IItemRegisterer;
+import me.shedaniel.rei.api.ItemRegisterer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@@ -12,7 +12,7 @@ import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
-public class ItemListHelper implements IItemRegisterer {
+public class ItemRegistererImpl implements ItemRegisterer {
private final List<ItemStack> itemList = Lists.newLinkedList();
diff --git a/src/main/java/me/shedaniel/rei/plugin/PluginManager.java b/src/main/java/me/shedaniel/rei/client/PluginDisablerImpl.java
index ccc6e7e67..3e9b1224c 100644
--- a/src/main/java/me/shedaniel/rei/plugin/PluginManager.java
+++ b/src/main/java/me/shedaniel/rei/client/PluginDisablerImpl.java
@@ -1,15 +1,15 @@
-package me.shedaniel.rei.plugin;
+package me.shedaniel.rei.client;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import me.shedaniel.rei.api.IPluginDisabler;
+import me.shedaniel.rei.api.PluginDisabler;
import me.shedaniel.rei.api.PluginFunction;
import net.minecraft.util.Identifier;
import java.util.List;
import java.util.Map;
-public class PluginManager implements IPluginDisabler {
+public class PluginDisablerImpl implements PluginDisabler {
private static Map<Identifier, List<PluginFunction>> pluginDisabledFunctions = Maps.newHashMap();
diff --git a/src/main/java/me/shedaniel/rei/client/REIConfig.java b/src/main/java/me/shedaniel/rei/client/REIConfig.java
index 320cb7afb..6307fae2d 100644
--- a/src/main/java/me/shedaniel/rei/client/REIConfig.java
+++ b/src/main/java/me/shedaniel/rei/client/REIConfig.java
@@ -2,11 +2,13 @@ package me.shedaniel.rei.client;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import me.shedaniel.rei.api.RelativePoint;
public class REIConfig {
public static Gson GSON = new GsonBuilder().setPrettyPrinting().create();
+ public boolean cheating = false;
public REIItemListOrdering itemListOrdering = REIItemListOrdering.REGISTRY;
public boolean isAscending = true;
public boolean enableCraftableOnlyButton = true;
@@ -21,5 +23,6 @@ public class REIConfig {
public int maxRecipePerPage = 3;
public boolean fixRamUsage = false;
public boolean showUtilsButtons = false;
+ public RelativePoint choosePageDialogPoint = new RelativePoint(.5, .5);
}
diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
index 10a3b8cfe..ab0f1a1db 100644
--- a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
@@ -14,7 +14,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
-public class RecipeHelper implements IRecipeHelper {
+public class RecipeHelperImpl implements RecipeHelper {
private final AtomicInteger recipeCount = new AtomicInteger();
private final Map<Identifier, List<IRecipeDisplay>> recipeCategoryListMap = Maps.newHashMap();
@@ -172,7 +172,7 @@ public class RecipeHelper implements IRecipeHelper {
}).collect(Collectors.toList())));
Collections.reverse(plugins);
RoughlyEnoughItemsCore.getItemRegisterer().getModifiableItemList().clear();
- IPluginDisabler pluginDisabler = RoughlyEnoughItemsCore.getPluginDisabler();
+ PluginDisabler pluginDisabler = RoughlyEnoughItemsCore.getPluginDisabler();
plugins.forEach(plugin -> {
Identifier identifier = RoughlyEnoughItemsCore.getPluginIdentifier(plugin).orElseGet(() -> new Identifier("null"));
if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_ITEMS))
diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
index d3a066e29..ff1e13e6b 100644
--- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
@@ -52,7 +52,7 @@ public class RecipeViewingScreen extends Screen {
this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, 176, 186);
this.categoriesMap = categoriesMap;
this.categories = Lists.newArrayList();
- IRecipeHelper.getInstance().getAllCategories().forEach(category -> {
+ RecipeHelper.getInstance().getAllCategories().forEach(category -> {
if (categoriesMap.containsKey(category))
categories.add(category);
});
@@ -62,7 +62,7 @@ public class RecipeViewingScreen extends Screen {
}
public static SpeedCraftFunctional getSpeedCraftFunctionalByCategory(ContainerScreen containerScreen, IRecipeCategory category) {
- for(SpeedCraftFunctional functional : IRecipeHelper.getInstance().getSpeedCraftFunctional(category))
+ for(SpeedCraftFunctional functional : RecipeHelper.getInstance().getSpeedCraftFunctional(category))
for(Class aClass : functional.getFunctioningFor())
if (containerScreen.getClass().isAssignableFrom(aClass))
return functional;
@@ -205,7 +205,7 @@ public class RecipeViewingScreen extends Screen {
tab.setItem(categories.get(j).getCategoryIcon(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * 6 == categories.indexOf(selectedCategory));
}
}
- Optional<SpeedCraftAreaSupplier> supplier = IRecipeHelper.getInstance().getSpeedCraftButtonArea(selectedCategory);
+ Optional<SpeedCraftAreaSupplier> supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(selectedCategory);
final SpeedCraftFunctional functional = getSpeedCraftFunctionalByCategory(GuiHelper.getLastContainerScreen(), selectedCategory);
int recipeHeight = selectedCategory.getDisplayHeight();
List<IRecipeDisplay> currentDisplayed = getCurrentDisplayed();
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java
index f0bd6dd92..4fccaf633 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java
@@ -12,9 +12,12 @@ public abstract class DraggableWidget implements HighlightableWidget {
private Point midPoint, startPoint;
private int relateX, relateY;
+ public DraggableWidget(Point startingPoint) {
+ initWidgets(midPoint = startingPoint);
+ }
+
public DraggableWidget() {
- Window window = MinecraftClient.getInstance().window;
- initWidgets(midPoint = new Point(window.getScaledWidth() / 2, window.getScaledHeight() / 2));
+ this(new Point(MinecraftClient.getInstance().window.getScaledWidth() / 2, MinecraftClient.getInstance().window.getScaledHeight() / 2));
}
protected abstract void initWidgets(Point midPoint);
@@ -60,6 +63,7 @@ public abstract class DraggableWidget implements HighlightableWidget {
if (int_1 == 0)
if (dragged) {
dragged = false;
+ onMouseReleaseMidPoint(getMidPoint());
return true;
}
for(IWidget widget : getListeners())
@@ -68,4 +72,6 @@ public abstract class DraggableWidget implements HighlightableWidget {
return false;
}
+ public void onMouseReleaseMidPoint(Point midPoint) {}
+
}
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
index 0e5a9d6e8..14a2b1d60 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
@@ -2,7 +2,7 @@ package me.shedaniel.rei.gui.widget;
import com.google.common.collect.Lists;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
-import me.shedaniel.rei.api.IRecipeHelper;
+import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.client.ClientHelper;
import me.shedaniel.rei.client.GuiHelper;
import me.shedaniel.rei.client.REIItemListOrdering;
@@ -137,7 +137,7 @@ public class ItemListOverlay extends DrawableHelper implements IWidget {
stacks.addAll(os);
List<ItemStack> workingItems = RoughlyEnoughItemsCore.getConfigHelper().craftableOnly() && inventoryItems.size() > 0 ? new ArrayList<>() : new LinkedList<>(ol);
if (RoughlyEnoughItemsCore.getConfigHelper().craftableOnly()) {
- IRecipeHelper.getInstance().findCraftableByItems(inventoryItems).forEach(workingItems::add);
+ RecipeHelper.getInstance().findCraftableByItems(inventoryItems).forEach(workingItems::add);
workingItems.addAll(inventoryItems);
}
final List<ItemStack> finalWorkingItems = workingItems;
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java
index 731af93f7..7a0a11dee 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java
@@ -2,6 +2,10 @@ package me.shedaniel.rei.gui.widget;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.platform.GlStateManager;
+import me.shedaniel.rei.RoughlyEnoughItemsCore;
+import me.shedaniel.rei.api.RelativePoint;
+import me.shedaniel.rei.client.ClientHelper;
+import me.shedaniel.rei.client.ConfigHelper;
import me.shedaniel.rei.gui.RecipeViewingScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GuiLighting;
@@ -10,6 +14,7 @@ import net.minecraft.client.util.Window;
import net.minecraft.util.math.MathHelper;
import java.awt.*;
+import java.io.IOException;
import java.util.List;
import java.util.Optional;
@@ -25,12 +30,19 @@ public class RecipeChoosePageWidget extends DraggableWidget {
private ButtonWidget btnDone;
public RecipeChoosePageWidget(RecipeViewingScreen recipeViewingScreen, int currentPage, int maxPage) {
+ super(getPointFromConfig());
this.recipeViewingScreen = recipeViewingScreen;
this.currentPage = currentPage;
this.maxPage = maxPage;
initWidgets(getMidPoint());
}
+ private static Point getPointFromConfig() {
+ Window window = MinecraftClient.getInstance().window;
+ RelativePoint point = RoughlyEnoughItemsCore.getConfigHelper().getConfig().choosePageDialogPoint;
+ return new Point((int) point.getX(window.getScaledWidth()), (int) point.getY(window.getScaledHeight()));
+ }
+
@Override
public Rectangle getBounds() {
return bounds;
@@ -105,7 +117,7 @@ public class RecipeChoosePageWidget extends DraggableWidget {
@Override
public void onPressed(int button, double mouseX, double mouseY) {
recipeViewingScreen.page = MathHelper.clamp(getIntFromString(textFieldWidget.getText()).orElse(0) - 1, 0, recipeViewingScreen.getTotalPages(recipeViewingScreen.getSelectedCategory()) - 1);
- //recipeViewingScreen.choosePageActivated = false;
+ recipeViewingScreen.choosePageActivated = false;
recipeViewingScreen.onInitialized();
}
});
@@ -162,4 +174,16 @@ public class RecipeChoosePageWidget extends DraggableWidget {
return Optional.empty();
}
+ @Override
+ public void onMouseReleaseMidPoint(Point midPoint) {
+ ConfigHelper configHelper = RoughlyEnoughItemsCore.getConfigHelper();
+ Window window = MinecraftClient.getInstance().window;
+ configHelper.getConfig().choosePageDialogPoint = new RelativePoint(midPoint.getX() / window.getScaledWidth(), midPoint.getY() / window.getScaledHeight());
+ try {
+ configHelper.saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
}
diff --git a/src/main/java/me/shedaniel/rei/mixin/MixinClientPlayNetworkHandler.java b/src/main/java/me/shedaniel/rei/mixin/MixinClientPlayNetworkHandler.java
index 73f0c2b18..2d2b86554 100644
--- a/src/main/java/me/shedaniel/rei/mixin/MixinClientPlayNetworkHandler.java
+++ b/src/main/java/me/shedaniel/rei/mixin/MixinClientPlayNetworkHandler.java
@@ -1,7 +1,7 @@
package me.shedaniel.rei.mixin;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
-import me.shedaniel.rei.client.RecipeHelper;
+import me.shedaniel.rei.client.RecipeHelperImpl;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.packet.SynchronizeRecipesS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
@@ -14,7 +14,7 @@ public class MixinClientPlayNetworkHandler {
@Inject(method = "onSynchronizeRecipes", at = @At("RETURN"))
private void onUpdateRecipes(SynchronizeRecipesS2CPacket packetIn, CallbackInfo ci) {
- ((RecipeHelper) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(((ClientPlayNetworkHandler) ((Object) this)).getRecipeManager());
+ ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(((ClientPlayNetworkHandler) ((Object) this)).getRecipeManager());
}
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java
index 20a3aeb4a..cbedffe8e 100644
--- a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java
+++ b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java
@@ -3,7 +3,6 @@ package me.shedaniel.rei.plugin;
import com.google.common.collect.Lists;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.*;
-import me.shedaniel.rei.client.RecipeHelper;
import me.shedaniel.rei.listeners.IMixinRecipeBookGui;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Screen;
@@ -48,7 +47,7 @@ public class DefaultPlugin implements IRecipePlugin {
}
@Override
- public void onFirstLoad(IPluginDisabler pluginDisabler) {
+ public void onFirstLoad(PluginDisabler pluginDisabler) {
if (!RoughlyEnoughItemsCore.getConfigHelper().getConfig().loadDefaultPlugin) {
pluginDisabler.disablePluginFunction(PLUGIN, PluginFunction.REGISTER_ITEMS);
pluginDisabler.disablePluginFunction(PLUGIN, PluginFunction.REGISTER_CATEGORIES);
@@ -58,7 +57,7 @@ public class DefaultPlugin implements IRecipePlugin {
}
@Override
- public void registerItems(IItemRegisterer itemRegisterer) {
+ public void registerItems(ItemRegisterer itemRegisterer) {
Registry.ITEM.stream().forEach(item -> {
itemRegisterer.registerItemStack(item.getDefaultStack());
try {
@@ -78,7 +77,7 @@ public class DefaultPlugin implements IRecipePlugin {
}
@Override
- public void registerPluginCategories(IRecipeHelper recipeHelper) {
+ public void registerPluginCategories(RecipeHelper recipeHelper) {
recipeHelper.registerCategory(new DefaultCraftingCategory());
recipeHelper.registerCategory(new DefaultSmeltingCategory());
recipeHelper.registerCategory(new DefaultSmokingCategory());
@@ -89,7 +88,7 @@ public class DefaultPlugin implements IRecipePlugin {
}
@Override
- public void registerRecipeDisplays(IRecipeHelper recipeHelper) {
+ public void registerRecipeDisplays(RecipeHelper recipeHelper) {
for(Recipe recipe : recipeHelper.getRecipeManager().values())
if (recipe instanceof ShapelessRecipe)
recipeHelper.registerDisplay(CRAFTING, new DefaultShapelessDisplay((ShapelessRecipe) recipe));
@@ -123,7 +122,7 @@ public class DefaultPlugin implements IRecipePlugin {
}
@Override
- public void registerSpeedCraft(IRecipeHelper recipeHelper) {
+ public void registerSpeedCraft(RecipeHelper recipeHelper) {
recipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.CAMPFIRE, null);
recipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.STONE_CUTTING, null);
recipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.BREWING, null);