aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java38
-rw-r--r--src/main/java/me/shedaniel/rei/api/ClientHelper.java8
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeCategory.java9
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderable.java52
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderer.java13
-rw-r--r--src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java28
-rw-r--r--src/main/java/me/shedaniel/rei/client/ConfigObject.java2
-rw-r--r--src/main/java/me/shedaniel/rei/client/RecipeScreenType.java16
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java22
-rw-r--r--src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java133
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java15
-rw-r--r--src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java270
-rw-r--r--src/main/java/me/shedaniel/rei/gui/renderables/EmptyRenderer.java13
-rw-r--r--src/main/java/me/shedaniel/rei/gui/renderables/ItemStackRenderer.java69
-rw-r--r--src/main/java/me/shedaniel/rei/gui/renderables/RecipeRenderer.java13
-rw-r--r--src/main/java/me/shedaniel/rei/gui/renderables/SimpleRecipeRenderer.java87
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java4
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java5
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java12
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java12
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java153
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java14
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java26
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SlotWidget.java203
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java43
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultBlastingCategory.java15
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java14
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultCampfireCategory.java6
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultCraftingCategory.java8
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java39
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java15
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultSmokingCategory.java15
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultStoneCuttingCategory.java6
-rw-r--r--src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java2
34 files changed, 1139 insertions, 241 deletions
diff --git a/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java b/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java
new file mode 100644
index 000000000..36d56329d
--- /dev/null
+++ b/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java
@@ -0,0 +1,38 @@
+package com.zeitheron.hammercore.client.utils;
+
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.util.Window;
+import org.lwjgl.opengl.GL11;
+
+/**
+ * This is originally the part of Hammer Lib, repacked in REI with permission.
+ * Adapted GL scissor for minecraft pixel resolution and adjusts (0;0) as left-top corner.
+ *
+ * @author Zeitheron
+ */
+public class Scissors {
+ public static void begin() {
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ }
+
+ public static void scissor(int x, int y, int width, int height) {
+ Window window = MinecraftClient.getInstance().window;
+
+ int sw = window.getWidth();
+ int sh = window.getHeight();
+ float dw = window.getScaledWidth();
+ float dh = window.getScaledHeight();
+
+ x = Math.round(sw * (x / dw));
+ y = Math.round(sh * (y / dh));
+
+ width = Math.round(sw * (width / dw));
+ height = Math.round(sh * (height / dh));
+
+ GL11.glScissor(x, sh - height - y, width, height);
+ }
+
+ public static void end() {
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java
index 86c234872..d4648bbaa 100644
--- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java
@@ -5,8 +5,10 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.Identifier;
import java.util.List;
+import java.util.Map;
public interface ClientHelper extends ClientModInitializer {
static ClientHelper getInstance() {
@@ -19,6 +21,8 @@ public interface ClientHelper extends ClientModInitializer {
List<ItemStack> getInventoryItemsTypes();
+ void openRecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> map);
+
void registerFabricKeyBinds();
boolean tryCheatingStack(ItemStack stack);
@@ -33,6 +37,10 @@ public interface ClientHelper extends ClientModInitializer {
String getFormattedModFromItem(Item item);
+ String getFormattedModFromIdentifier(Identifier identifier);
+
+ String getModFromIdentifier(Identifier identifier);
+
FabricKeyBinding getRecipeKeyBinding();
FabricKeyBinding getUsageKeyBinding();
diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
index 80b7aa167..8304fde90 100644
--- a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
+++ b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
@@ -1,6 +1,7 @@
package me.shedaniel.rei.api;
import me.shedaniel.rei.gui.RecipeViewingScreen;
+import me.shedaniel.rei.gui.renderables.RecipeRenderer;
import me.shedaniel.rei.gui.widget.CategoryBaseWidget;
import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
import me.shedaniel.rei.gui.widget.Widget;
@@ -20,8 +21,16 @@ public interface RecipeCategory<T extends RecipeDisplay> {
ItemStack getCategoryIcon();
+ default Renderer getIcon() {
+ return Renderable.fromItemStackSupplier(this::getCategoryIcon);
+ }
+
String getCategoryName();
+ default RecipeRenderer getSimpleRenderer(T recipe) {
+ return Renderable.fromRecipe(recipe::getInput, recipe::getOutput);
+ }
+
default List<Widget> setupDisplay(Supplier<T> recipeDisplaySupplier, Rectangle bounds) {
return Collections.singletonList(new RecipeBaseWidget(bounds));
}
diff --git a/src/main/java/me/shedaniel/rei/api/Renderable.java b/src/main/java/me/shedaniel/rei/api/Renderable.java
new file mode 100644
index 000000000..9059af798
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/Renderable.java
@@ -0,0 +1,52 @@
+package me.shedaniel.rei.api;
+
+import me.shedaniel.rei.gui.renderables.EmptyRenderer;
+import me.shedaniel.rei.gui.renderables.ItemStackRenderer;
+import me.shedaniel.rei.gui.renderables.SimpleRecipeRenderer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.math.MathHelper;
+
+import java.util.List;
+import java.util.function.Supplier;
+
+public interface Renderable {
+
+ static ItemStackRenderer fromItemStackSupplier(Supplier<ItemStack> supplier) {
+ return new ItemStackRenderer() {
+ @Override
+ public ItemStack getItemStack() {
+ return supplier.get();
+ }
+ };
+ }
+
+ static ItemStackRenderer fromItemStack(ItemStack stack) {
+ return new ItemStackRenderer() {
+ @Override
+ public ItemStack getItemStack() {
+ return stack;
+ }
+ };
+ }
+
+ static EmptyRenderer empty() {
+ return EmptyRenderer.INSTANCE;
+ }
+
+ static SimpleRecipeRenderer fromRecipe(Supplier<List<List<ItemStack>>> input, Supplier<List<ItemStack>> output) {
+ return new SimpleRecipeRenderer(input, output);
+ }
+
+ static ItemStackRenderer fromItemStacks(List<ItemStack> stacks) {
+ return new ItemStackRenderer() {
+ @Override
+ public ItemStack getItemStack() {
+ if (stacks.isEmpty())
+ return ItemStack.EMPTY;
+ return stacks.get(MathHelper.floor((System.currentTimeMillis() / 500 % (double) stacks.size()) / 1f));
+ }
+ };
+ }
+
+ void render(int x, int y, double mouseX, double mouseY, float delta);
+}
diff --git a/src/main/java/me/shedaniel/rei/api/Renderer.java b/src/main/java/me/shedaniel/rei/api/Renderer.java
new file mode 100644
index 000000000..569285d84
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/Renderer.java
@@ -0,0 +1,13 @@
+package me.shedaniel.rei.api;
+
+import net.minecraft.client.gui.DrawableHelper;
+
+public abstract class Renderer extends DrawableHelper implements Renderable {
+ public int getBlitOffset() {
+ return this.blitOffset;
+ }
+
+ public void setBlitOffset(int offset) {
+ this.blitOffset = offset;
+ }
+}
diff --git a/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java
index febe35b4e..832375918 100644
--- a/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java
+++ b/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java
@@ -9,7 +9,9 @@ import me.shedaniel.rei.api.ClientHelper;
import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.RecipeDisplay;
import me.shedaniel.rei.api.RecipeHelper;
+import me.shedaniel.rei.gui.PreRecipeViewingScreen;
import me.shedaniel.rei.gui.RecipeViewingScreen;
+import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl;
@@ -54,6 +56,14 @@ public class ClientHelperImpl implements ClientHelper {
}
@Override
+ public String getFormattedModFromIdentifier(Identifier identifier) {
+ String mod = getModFromIdentifier(identifier);
+ if (mod.equalsIgnoreCase(""))
+ return "";
+ return "§9§o" + mod;
+ }
+
+ @Override
public FabricKeyBinding getRecipeKeyBinding() {
return recipe;
}
@@ -78,12 +88,14 @@ public class ClientHelperImpl implements ClientHelper {
return nextPage;
}
+ @Override
public String getModFromItem(Item item) {
if (item.equals(Items.AIR))
return "";
return getModFromIdentifier(Registry.ITEM.getId(item));
}
+ @Override
public String getModFromIdentifier(Identifier identifier) {
if (identifier == null)
return "";
@@ -147,7 +159,7 @@ public class ClientHelperImpl implements ClientHelper {
public boolean executeRecipeKeyBind(ItemStack stack) {
Map<RecipeCategory, List<RecipeDisplay>> map = RecipeHelper.getInstance().getRecipesFor(stack);
if (map.keySet().size() > 0)
- MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(MinecraftClient.getInstance().window, map));
+ openRecipeViewingScreen(map);
return map.keySet().size() > 0;
}
@@ -155,7 +167,7 @@ public class ClientHelperImpl implements ClientHelper {
public boolean executeUsageKeyBind(ItemStack stack) {
Map<RecipeCategory, List<RecipeDisplay>> map = RecipeHelper.getInstance().getUsagesFor(stack);
if (map.keySet().size() > 0)
- MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(MinecraftClient.getInstance().window, map));
+ openRecipeViewingScreen(map);
return map.keySet().size() > 0;
}
@@ -174,11 +186,21 @@ public class ClientHelperImpl implements ClientHelper {
public boolean executeViewAllRecipesKeyBind() {
Map<RecipeCategory, List<RecipeDisplay>> map = RecipeHelper.getInstance().getAllRecipes();
if (map.keySet().size() > 0)
- MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(MinecraftClient.getInstance().window, map));
+ openRecipeViewingScreen(map);
return map.keySet().size() > 0;
}
@Override
+ public void openRecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> map) {
+ if (RoughlyEnoughItemsCore.getConfigManager().getConfig().screenType == RecipeScreenType.VILLAGER)
+ MinecraftClient.getInstance().openScreen(new VillagerRecipeViewingScreen(map));
+ else if (RoughlyEnoughItemsCore.getConfigManager().getConfig().screenType == RecipeScreenType.UNSET)
+ MinecraftClient.getInstance().openScreen(new PreRecipeViewingScreen(map));
+ else
+ MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(map));
+ }
+
+ @Override
public void onInitializeClient() {
ClientHelperImpl.instance = (ClientHelperImpl) this;
registerFabricKeyBinds();
diff --git a/src/main/java/me/shedaniel/rei/client/ConfigObject.java b/src/main/java/me/shedaniel/rei/client/ConfigObject.java
index af100f3fc..3522b6f3b 100644
--- a/src/main/java/me/shedaniel/rei/client/ConfigObject.java
+++ b/src/main/java/me/shedaniel/rei/client/ConfigObject.java
@@ -48,6 +48,8 @@ public class ConfigObject {
public boolean lightGrayRecipeBorder = false;
+ public RecipeScreenType screenType = RecipeScreenType.UNSET;
+
@Comment(
"The location of choose page dialog, will automatically be set to your last location so there is no need to change this.")
public RelativePoint choosePageDialogPoint = new RelativePoint(.5, .5);
diff --git a/src/main/java/me/shedaniel/rei/client/RecipeScreenType.java b/src/main/java/me/shedaniel/rei/client/RecipeScreenType.java
new file mode 100644
index 000000000..4975e3576
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/client/RecipeScreenType.java
@@ -0,0 +1,16 @@
+package me.shedaniel.rei.client;
+
+import net.minecraft.client.resource.language.I18n;
+
+import java.util.Locale;
+
+public enum RecipeScreenType {
+ UNSET,
+ ORIGINAL,
+ VILLAGER;
+
+ @Override
+ public String toString() {
+ return I18n.translate("text.rei.config.recipe_screen_type." + name().toLowerCase());
+ }
+}
diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
index f1b6fb700..71a274151 100644
--- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
+++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
@@ -27,13 +27,15 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.GameMode;
import java.awt.*;
-import java.util.*;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
import java.util.stream.Collectors;
public class ContainerScreenOverlay extends AbstractParentElement implements Drawable {
- private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui" + "/recipecontainer.png");
+ private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
private static final List<QueuedTooltip> QUEUED_TOOLTIPS = Lists.newArrayList();
public static String searchTerm = "";
private static int page = 0;
@@ -43,7 +45,6 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
private Window window;
private CraftableToggleButtonWidget toggleButtonWidget;
private ButtonWidget buttonLeft, buttonRight;
- private int lastLeft;
public static ItemListOverlay getItemListOverlay() {
return itemListOverlay;
@@ -59,7 +60,6 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
this.window = MinecraftClient.getInstance().window;
DisplayHelper.DisplayBoundsHandler boundsHandler = RoughlyEnoughItemsCore.getDisplayHelper().getResponsibleBoundsHandler(MinecraftClient.getInstance().currentScreen.getClass());
this.rectangle = RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel ? boundsHandler.getLeftBounds(MinecraftClient.getInstance().currentScreen) : boundsHandler.getRightBounds(MinecraftClient.getInstance().currentScreen);
- this.lastLeft = getLeft();
widgets.add(itemListOverlay = new ItemListOverlay(page));
itemListOverlay.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, false);
@@ -306,6 +306,10 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
RecipeViewingScreen widget = (RecipeViewingScreen) MinecraftClient.getInstance().currentScreen;
return new Rectangle(widget.getBounds().x, window.getScaledHeight() - 22, widget.getBounds().width - widthRemoved, 18);
}
+ if (MinecraftClient.getInstance().currentScreen instanceof VillagerRecipeViewingScreen) {
+ VillagerRecipeViewingScreen widget = (VillagerRecipeViewingScreen) MinecraftClient.getInstance().currentScreen;
+ return new Rectangle(widget.bounds.x, window.getScaledHeight() - 22, widget.bounds.width - widthRemoved, 18);
+ }
return new Rectangle(ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft(), window.getScaledHeight() - 22, ScreenHelper.getLastContainerScreenHooks().rei_getContainerWidth() - widthRemoved, 18);
}
@@ -427,16 +431,6 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
GuiLighting.disable();
}
- private int getLeft() {
- if (MinecraftClient.getInstance().currentScreen instanceof RecipeViewingScreen) {
- RecipeViewingScreen widget = (RecipeViewingScreen) MinecraftClient.getInstance().currentScreen;
- return widget.getBounds().x;
- }
- if (MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen())
- return ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 147 - 30;
- return ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft();
- }
-
private int getTotalPage() {
return itemListOverlay.getTotalPage();
}
diff --git a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
new file mode 100644
index 000000000..68ddc78a0
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
@@ -0,0 +1,133 @@
+package me.shedaniel.rei.gui;
+
+import com.google.common.collect.Lists;
+import me.shedaniel.rei.RoughlyEnoughItemsCore;
+import me.shedaniel.rei.api.ClientHelper;
+import me.shedaniel.rei.api.RecipeCategory;
+import me.shedaniel.rei.api.RecipeDisplay;
+import me.shedaniel.rei.client.RecipeScreenType;
+import me.shedaniel.rei.client.ScreenHelper;
+import me.shedaniel.rei.gui.widget.ButtonWidget;
+import me.shedaniel.rei.gui.widget.HighlightableWidget;
+import me.shedaniel.rei.gui.widget.Widget;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.audio.PositionedSoundInstance;
+import net.minecraft.client.gui.Element;
+import net.minecraft.client.gui.Screen;
+import net.minecraft.client.render.GuiLighting;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.sound.SoundEvents;
+import net.minecraft.text.TranslatableTextComponent;
+import net.minecraft.util.Identifier;
+
+import java.awt.*;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class PreRecipeViewingScreen extends Screen {
+
+ private static final Identifier IDENTIFIER = new Identifier("roughlyenoughitems", "textures/gui/screenshot.png");
+ private final List<Widget> widgets;
+ private boolean original;
+ private Map<RecipeCategory, List<RecipeDisplay>> map;
+
+ public PreRecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> map) {
+ super(new TranslatableTextComponent("text.rei.recipe_screen_type.selection"));
+ this.widgets = Lists.newArrayList();
+ this.original = true;
+ this.map = map;
+ }
+
+ @Override
+ protected void init() {
+ this.children.clear();
+ this.widgets.clear();
+ this.widgets.add(new ButtonWidget(width / 2 - 100, height - 40, 200, 20, I18n.translate("text.rei.select")) {
+ @Override
+ public void onPressed() {
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().screenType = original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER;
+ try {
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ ClientHelper.getInstance().openRecipeViewingScreen(map);
+ }
+ });
+ this.widgets.add(new ScreenTypeSelection(width / 2 - 200 - 5, height / 2 - 112 / 2 - 10, 0));
+ this.widgets.add(new ScreenTypeSelection(width / 2 + 5, height / 2 - 112 / 2 - 10, 112));
+ this.children.addAll(widgets);
+ }
+
+ @Override
+ public void render(int int_1, int int_2, float float_1) {
+ this.renderBackground();
+ this.drawCenteredString(this.font, this.title.getFormattedText(), this.width / 2, 20, 16777215);
+ int i = 30;
+ for(String s : this.font.wrapStringToWidthAsList(I18n.translate("text.rei.recipe_screen_type.selection.sub"), width - 30)) {
+ this.drawCenteredString(this.font, "§7" + s, width / 2, i, -1);
+ i += 10;
+ }
+ super.render(int_1, int_2, float_1);
+ this.widgets.forEach(widget -> {
+ GuiLighting.disable();
+ widget.render(int_1, int_2, float_1);
+ });
+ }
+
+ @Override
+ public boolean keyPressed(int int_1, int int_2, int int_3) {
+ if ((int_1 == 256 || this.minecraft.options.keyInventory.matchesKey(int_1, int_2)) && this.shouldCloseOnEsc()) {
+ MinecraftClient.getInstance().openScreen(ScreenHelper.getLastContainerScreen());
+ ScreenHelper.getLastOverlay().init();
+ return true;
+ }
+ return super.keyPressed(int_1, int_2, int_3);
+ }
+
+ public class ScreenTypeSelection extends HighlightableWidget {
+
+ private Rectangle bounds;
+ private int u, v;
+
+ public ScreenTypeSelection(int x, int y, int v) {
+ this.bounds = new Rectangle(x - 4, y - 4, 208, 120);
+ this.u = 0;
+ this.v = v;
+ }
+
+ @Override
+ public Rectangle getBounds() {
+ return bounds;
+ }
+
+ @Override
+ public void render(int i, int i1, float delta) {
+ MinecraftClient.getInstance().getTextureManager().bindTexture(IDENTIFIER);
+ blit(bounds.x + 4, bounds.y + 4, u, v, 200, 112);
+ if (original == (v == 0)) {
+ fillGradient(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + 2, 0xFFFFFFFF, 0xFFFFFFFF);
+ fillGradient(bounds.x, bounds.y + bounds.height - 2, bounds.x + bounds.width, bounds.y + bounds.height, 0xFFFFFFFF, 0xFFFFFFFF);
+ fillGradient(bounds.x, bounds.y, bounds.x + 2, bounds.y + bounds.height, 0xFFFFFFFF, 0xFFFFFFFF);
+ fillGradient(bounds.x + bounds.width - 2, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, 0xFFFFFFFF, 0xFFFFFFFF);
+ }
+ }
+
+ @Override
+ public boolean mouseClicked(double double_1, double double_2, int int_1) {
+ if (isHighlighted(double_1, double_2)) {
+ minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+ original = (v == 0);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public List<? extends Element> children() {
+ return Collections.emptyList();
+ }
+ }
+}
diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
index 16af460f4..2bb1b4486 100644
--- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
@@ -43,16 +43,15 @@ public class RecipeViewingScreen extends Screen {
public int largestWidth, largestHeight;
public boolean choosePageActivated;
public RecipeChoosePageWidget recipeChoosePageWidget;
- private Window window;
private Rectangle bounds;
private RecipeCategory selectedCategory;
private ButtonWidget recipeBack, recipeNext, categoryBack, categoryNext;
- public RecipeViewingScreen(Window window, Map<RecipeCategory, List<RecipeDisplay>> categoriesMap) {
+ public RecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> categoriesMap) {
super(new StringTextComponent(""));
this.categoryPages = 0;
- this.window = window;
this.widgets = Lists.newArrayList();
+ Window window = MinecraftClient.getInstance().window;
this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, 176, 186);
this.categoriesMap = categoriesMap;
this.categories = Lists.newArrayList();
@@ -119,11 +118,11 @@ public class RecipeViewingScreen extends Screen {
this.children.clear();
this.tabs.clear();
this.widgets.clear();
- this.largestWidth = window.getScaledWidth() - 100;
- this.largestHeight = window.getScaledHeight() - 40;
+ this.largestWidth = width - 100;
+ this.largestHeight = height - 40;
this.guiWidth = MathHelper.clamp(getCurrentDisplayed().stream().map(display -> selectedCategory.getDisplayWidth(display)).max(Integer::compareTo).orElse(150) + 30, 0, largestWidth);
this.guiHeight = MathHelper.floor(MathHelper.clamp((selectedCategory.getDisplayHeight() + 7d) * (getRecipesPerPage() + 1d) + 40d, 186d, (double) largestHeight));
- this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, guiWidth, guiHeight);
+ this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight);
this.page = MathHelper.clamp(page, 0, getTotalPages(selectedCategory) - 1);
widgets.add(categoryBack = new ButtonWidget((int) bounds.getX() + 5, (int) bounds.getY() + 5, 12, 12, new TranslatableTextComponent("text.rei.left_arrow")) {
@@ -235,7 +234,7 @@ public class RecipeViewingScreen extends Screen {
int j = i + categoryPages * 6;
if (categories.size() > j) {
TabWidget tab;
- tabs.add(tab = new TabWidget(i, this, new Rectangle(bounds.x + 4 + 28 * i, bounds.y - 28, 28, 28)) {
+ tabs.add(tab = new TabWidget(i, new Rectangle(bounds.x + 4 + 28 * i, bounds.y - 28, 28, 28)) {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (getBounds().contains(mouseX, mouseY)) {
@@ -250,7 +249,7 @@ public class RecipeViewingScreen extends Screen {
return false;
}
});
- tab.setItem(categories.get(j).getCategoryIcon(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * 6 == categories.indexOf(selectedCategory));
+ tab.setRenderer(categories.get(j), categories.get(j).getIcon(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * 6 == categories.indexOf(selectedCategory));
}
}
Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(selectedCategory);
diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
new file mode 100644
index 000000000..e53168df6
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
@@ -0,0 +1,270 @@
+package me.shedaniel.rei.gui;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.mojang.blaze3d.platform.GlStateManager;
+import com.zeitheron.hammercore.client.utils.Scissors;
+import me.shedaniel.rei.api.*;
+import me.shedaniel.rei.client.ScreenHelper;
+import me.shedaniel.rei.gui.renderables.RecipeRenderer;
+import me.shedaniel.rei.gui.widget.*;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.audio.PositionedSoundInstance;
+import net.minecraft.client.gui.Element;