aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-11 18:14:42 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-11 18:14:42 +0800
commit0b314135a82f18fa13ce1bcbe66e45ee5b3236a5 (patch)
treee50f48a106d535c418b89ddfc67f2d1f3013be69 /src/main/java/me/shedaniel/rei/gui
parent3dd1ea9403035bdc32612ec66210342b76c48001 (diff)
downloadRoughlyEnoughItems-0b314135a82f18fa13ce1bcbe66e45ee5b3236a5.tar.gz
RoughlyEnoughItems-0b314135a82f18fa13ce1bcbe66e45ee5b3236a5.tar.bz2
RoughlyEnoughItems-0b314135a82f18fa13ce1bcbe66e45ee5b3236a5.zip
Furnace Recipe + Scrolling in Recipe Window
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java25
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java18
2 files changed, 37 insertions, 6 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java
index 01eee72b2..a3ed1c4ed 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java
@@ -1,10 +1,10 @@
package me.shedaniel.rei.gui.widget;
import com.google.common.collect.Lists;
+import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.client.ClientHelper;
import me.shedaniel.rei.listeners.IMixinContainerGui;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.ContainerGui;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.render.GuiLighting;
import net.minecraft.client.render.item.ItemRenderer;
@@ -24,7 +24,7 @@ public class ItemSlotWidget extends Drawable implements HighlightableWidget {
private static final Identifier RECIPE_GUI = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
private List<ItemStack> itemList = new LinkedList<>();
- private boolean drawBackground, showToolTips;
+ private boolean drawBackground, showToolTips, clickToMoreRecipes;
private int x, y;
private IMixinContainerGui containerGui;
@@ -39,6 +39,12 @@ public class ItemSlotWidget extends Drawable implements HighlightableWidget {
this.x = x;
this.y = y;
this.containerGui = containerGui;
+ this.clickToMoreRecipes = false;
+ }
+
+ public ItemSlotWidget(int x, int y, List<ItemStack> itemList, boolean drawBackground, boolean showToolTips, IMixinContainerGui containerGui, boolean clickToMoreRecipes) {
+ this(x, y, itemList, drawBackground, showToolTips, containerGui);
+ this.clickToMoreRecipes = clickToMoreRecipes;
}
public boolean isDrawBackground() {
@@ -93,7 +99,7 @@ public class ItemSlotWidget extends Drawable implements HighlightableWidget {
protected ItemStack getCurrentStack() {
if (itemList.size() == 0)
return new ItemStack(Items.AIR);
- return itemList.get(MathHelper.clamp((int) (System.currentTimeMillis() / 500) % itemList.size(), 0, itemList.size() - 1));
+ return itemList.get(MathHelper.floor((System.currentTimeMillis() / 500 % (double) itemList.size()) / 1f));
}
public void setItemList(List<ItemStack> itemList) {
@@ -105,4 +111,17 @@ public class ItemSlotWidget extends Drawable implements HighlightableWidget {
return new Rectangle(this.x, this.y, 18, 18);
}
+ @Override
+ public boolean onMouseClick(int button, double mouseX, double mouseY) {
+ if (!clickToMoreRecipes)
+ return false;
+ if (getBounds().contains(mouseX, mouseY)) {
+ if (button == 0)
+ return ClientHelper.executeRecipeKeyBind(containerGui.getOverlay(), getCurrentStack().copy(), containerGui);
+ else if (button == 1)
+ return ClientHelper.executeUsageKeyBind(containerGui.getOverlay(), getCurrentStack().copy(), containerGui);
+ }
+ return false;
+ }
+
}
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java
index 8b6dca71e..b09afa46d 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
import com.mojang.blaze3d.platform.GlStateManager;
import me.shedaniel.rei.api.IRecipeCategory;
import me.shedaniel.rei.api.IRecipeDisplay;
+import me.shedaniel.rei.client.ClientHelper;
import me.shedaniel.rei.gui.ContainerGuiOverlay;
import me.shedaniel.rei.listeners.IMixinContainerGui;
import net.minecraft.client.MinecraftClient;
@@ -17,10 +18,8 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import java.awt.*;
-import java.util.ArrayList;
-import java.util.LinkedList;
+import java.util.*;
import java.util.List;
-import java.util.Map;
public class RecipeViewingWidget extends Gui {
@@ -49,6 +48,7 @@ public class RecipeViewingWidget extends Gui {
this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, guiWidth, guiHeight);
this.categoriesMap = categoriesMap;
this.categories = new LinkedList<>(categoriesMap.keySet());
+ Collections.reverse(categories);
this.selectedCategory = categories.get(0);
this.overlay = overlay;
this.tabs = new ArrayList<>();
@@ -234,6 +234,18 @@ public class RecipeViewingWidget extends Gui {
for(GuiEventListener listener : listeners)
if (listener.mouseScrolled(amount))
return true;
+ if (getBounds().contains(ClientHelper.getMouseLocation())) {
+ if (amount > 0 && recipeBack.enabled)
+ recipeBack.onPressed(0, 0, 0);
+ else if (amount < 0 && recipeNext.enabled)
+ recipeNext.onPressed(0, 0, 0);
+ }
+ if ((new Rectangle(bounds.x, bounds.y - 28, bounds.width, 28)).contains(ClientHelper.getMouseLocation())) {
+ if (amount > 0 && categoryBack.enabled)
+ categoryBack.onPressed(0, 0, 0);
+ else if (amount < 0 && categoryNext.enabled)
+ categoryNext.onPressed(0, 0, 0);
+ }
return super.mouseScrolled(amount);
}