Unknown 6 rokov pred
rodič
commit
8bde829657

+ 4 - 0
CHANGELOG.md

@@ -1,4 +1,7 @@
 View full changelog [here](https://github.com/shedaniel/RoughlyEnoughItems/blob/1.14/CHANGELOG.md).
+## v2.9-beta+build.107 (BETA)
+- Fixed: Crashing when clicking tabs
+- Added: Buttons to switch category page
 ## v2.9-beta+build.106 (BETA)
 - Using: [HammerLib](https://minecraft.curseforge.com/projects/hammer-lib) as a simple opengl scissors api
 - New: Mod Name of category new shows in category tooltips
@@ -9,6 +12,7 @@ View full changelog [here](https://github.com/shedaniel/RoughlyEnoughItems/blob/
 - Fixed: Button Width Rendering issues when the width is an odd number
 - Changed: Mod Name changed from `RoughlyEnoughItems` to `Roughly Enough Items`
 - Changed: Lots of internal refractors
+- Fixed: Enchanting books not showing its maximum level
 ## v2.8.2+build.104
 - Fixed [#81](https://github.com/shedaniel/RoughlyEnoughItems/issues/81): Scrolling unaffected by exclusion zones.
 - Added [#82](https://github.com/shedaniel/RoughlyEnoughItems/issues/82): Close search after pressing "Enter"

+ 25 - 11
src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java

@@ -16,6 +16,7 @@ import net.minecraft.client.render.GuiLighting;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.sound.SoundEvents;
 import net.minecraft.text.StringTextComponent;
+import net.minecraft.text.TranslatableTextComponent;
 import net.minecraft.util.math.MathHelper;
 import org.lwjgl.BufferUtils;
 import org.lwjgl.glfw.GLFW;
@@ -32,6 +33,7 @@ import static me.shedaniel.rei.gui.RecipeViewingScreen.getSpeedCraftFunctionalBy
 
 public class VillagerRecipeViewingScreen extends Screen {
     
+    private static final int TABS_PER_PAGE = 8;
     private final Map<RecipeCategory, List<RecipeDisplay>> categoryMap;
     private final List<RecipeCategory> categories;
     private final List<Widget> widgets;
@@ -42,7 +44,6 @@ public class VillagerRecipeViewingScreen extends Screen {
     private int selectedCategoryIndex, selectedRecipeIndex;
     private double scroll;
     private int tabsPage;
-    private static final int TABS_PER_PAGE = 9;
     
     public VillagerRecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> map) {
         super(new StringTextComponent(""));
@@ -117,6 +118,7 @@ public class VillagerRecipeViewingScreen extends Screen {
                                 return false;
                             selectedCategoryIndex = getId() + tabsPage * TABS_PER_PAGE;
                             scroll = 0;
+                            selectedRecipeIndex = 0;
                             VillagerRecipeViewingScreen.this.init();
                             return true;
                         }
@@ -126,6 +128,26 @@ public class VillagerRecipeViewingScreen extends Screen {
                 tab.setRenderer(categories.get(j), categories.get(j).getIcon(), categories.get(j).getCategoryName(), tab.getId() + tabsPage * TABS_PER_PAGE == selectedCategoryIndex);
             }
         }
+        ButtonWidget w, w2;
+        this.widgets.add(w = new ButtonWidget(bounds.x + 2, bounds.y - 16, 10, 10, new TranslatableTextComponent("text.rei.left_arrow")) {
+            @Override
+            public void onPressed() {
+                tabsPage--;
+                if (tabsPage < 0)
+                    tabsPage = MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1;
+                VillagerRecipeViewingScreen.this.init();
+            }
+        });
+        this.widgets.add(w2 = new ButtonWidget(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10, new TranslatableTextComponent("text.rei.right_arrow")) {
+            @Override
+            public void onPressed() {
+                tabsPage++;
+                if (tabsPage > MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1)
+                    tabsPage = 0;
+                VillagerRecipeViewingScreen.this.init();
+            }
+        });
+        w.enabled = w2.enabled = categories.size() > TABS_PER_PAGE;
         
         this.widgets.add(new ClickableLabelWidget(bounds.x + 4 + scrollListBounds.width / 2, bounds.y + 6, categories.get(selectedCategoryIndex).getCategoryName()) {
             @Override
@@ -142,22 +164,14 @@ public class VillagerRecipeViewingScreen extends Screen {
             @Override
             public void render(int mouseX, int mouseY, float delta) {
                 GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-                int colour = getDefaultColor();
-                if (clickable && isHovered(mouseX, mouseY))
-                    colour = getHoveredColor();
-                font.draw((isHovered(mouseX, mouseY) ? "§n" : "") + text, x - font.getStringWidth(text) / 2, y, colour);
+                font.draw((isHovered(mouseX, mouseY) ? "§n" : "") + text, x - font.getStringWidth(text) / 2, y, getDefaultColor());
                 if (clickable && getTooltips().isPresent())
                     if (!focused && isHighlighted(mouseX, mouseY))
                         ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n")));
                     else if (focused)
                         ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(new Point(x, y), getTooltips().get().split("\n")));
             }
-    
-            @Override
-            public int getHoveredColor() {
-                return -1;
-            }
-    
+            
             @Override
             public int getDefaultColor() {
                 return 4210752;

+ 9 - 0
src/main/java/me/shedaniel/rei/listeners/ContainerScreenHooks.java

@@ -1,17 +1,26 @@
 package me.shedaniel.rei.listeners;
 
+import net.minecraft.client.gui.ContainerScreen;
 import net.minecraft.container.Slot;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
 
+@Mixin(ContainerScreen.class)
 public interface ContainerScreenHooks {
     
+    @Accessor("left")
     int rei_getContainerLeft();
     
+    @Accessor("top")
     int rei_getContainerTop();
     
+    @Accessor("containerWidth")
     int rei_getContainerWidth();
     
+    @Accessor("containerHeight")
     int rei_getContainerHeight();
     
+    @Accessor("focusedSlot")
     Slot rei_getHoveredSlot();
     
 }

+ 6 - 0
src/main/java/me/shedaniel/rei/listeners/CreativePlayerInventoryScreenHooks.java

@@ -1,5 +1,11 @@
 package me.shedaniel.rei.listeners;
 
+import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(CreativePlayerInventoryScreen.class)
 public interface CreativePlayerInventoryScreenHooks {
+    @Accessor("selectedTab")
     int rei_getSelectedTab();
 }

+ 7 - 0
src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java

@@ -1,17 +1,24 @@
 package me.shedaniel.rei.listeners;
 
 import net.minecraft.client.gui.recipebook.GroupButtonWidget;
+import net.minecraft.client.gui.recipebook.RecipeBookGui;
 import net.minecraft.client.gui.widget.RecipeBookGhostSlots;
 import net.minecraft.client.gui.widget.TextFieldWidget;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
 
 import java.util.List;
 
+@Mixin(RecipeBookGui.class)
 public interface RecipeBookGuiHooks {
     
+    @Accessor("ghostSlots")
     RecipeBookGhostSlots rei_getGhostSlots();
     
+    @Accessor("searchField")
     TextFieldWidget rei_getSearchField();
     
+    @Accessor("tabButtons")
     List<GroupButtonWidget> rei_getTabButtons();
     
 }

+ 0 - 43
src/main/java/me/shedaniel/rei/mixin/MixinContainerScreen.java

@@ -1,43 +0,0 @@
-package me.shedaniel.rei.mixin;
-
-import me.shedaniel.rei.listeners.ContainerScreenHooks;
-import net.minecraft.client.gui.ContainerScreen;
-import net.minecraft.container.Slot;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-
-@Mixin(ContainerScreen.class)
-public class MixinContainerScreen implements ContainerScreenHooks {
-    
-    @Shadow protected int left;
-    @Shadow protected int top;
-    @Shadow protected int containerWidth;
-    @Shadow protected int containerHeight;
-    @Shadow protected Slot focusedSlot;
-    
-    @Override
-    public int rei_getContainerLeft() {
-        return left;
-    }
-    
-    @Override
-    public int rei_getContainerTop() {
-        return top;
-    }
-    
-    @Override
-    public int rei_getContainerWidth() {
-        return containerWidth;
-    }
-    
-    @Override
-    public int rei_getContainerHeight() {
-        return containerHeight;
-    }
-    
-    @Override
-    public Slot rei_getHoveredSlot() {
-        return focusedSlot;
-    }
-    
-}

+ 0 - 16
src/main/java/me/shedaniel/rei/mixin/MixinCreativePlayerInventoryScreen.java

@@ -1,16 +0,0 @@
-package me.shedaniel.rei.mixin;
-
-import me.shedaniel.rei.listeners.CreativePlayerInventoryScreenHooks;
-import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-
-@Mixin(CreativePlayerInventoryScreen.class)
-public class MixinCreativePlayerInventoryScreen implements CreativePlayerInventoryScreenHooks {
-    @Shadow private static int selectedTab;
-    
-    @Override
-    public int rei_getSelectedTab() {
-        return selectedTab;
-    }
-}

+ 0 - 38
src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java

@@ -1,38 +0,0 @@
-package me.shedaniel.rei.mixin;
-
-import me.shedaniel.rei.listeners.RecipeBookGuiHooks;
-import net.minecraft.client.gui.recipebook.GroupButtonWidget;
-import net.minecraft.client.gui.recipebook.RecipeBookGui;
-import net.minecraft.client.gui.widget.RecipeBookGhostSlots;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import org.spongepowered.asm.mixin.Final;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-
-import java.util.List;
-
-@Mixin(RecipeBookGui.class)
-public class MixinRecipeBookGui implements RecipeBookGuiHooks {
-    
-    @Shadow @Final protected RecipeBookGhostSlots ghostSlots;
-    
-    @Shadow private TextFieldWidget searchField;
-    
-    @Shadow @Final private List<GroupButtonWidget> tabButtons;
-    
-    public RecipeBookGhostSlots rei_getGhostSlots() {
-        return ghostSlots;
-    }
-    
-    @Override
-    public TextFieldWidget rei_getSearchField() {
-        return searchField;
-    }
-    
-    @Override
-    public List<GroupButtonWidget> rei_getTabButtons() {
-        return tabButtons;
-    }
-    
-    
-}

+ 2 - 1
src/main/resources/fabric.mod.json

@@ -38,7 +38,8 @@
     "cloth-config": ">=0.1.0"
   },
   "mixins": [
-    "roughlyenoughitems.mixins.json"
+    "mixin.roughlyenoughitems.mixins.json",
+    "listeners.roughlyenoughitems.mixins.json"
   ],
   "custom": {
     "modmenu:clientsideOnly": true

+ 15 - 0
src/main/resources/listeners.roughlyenoughitems.mixins.json

@@ -0,0 +1,15 @@
+{
+  "required": true,
+  "package": "me.shedaniel.rei.listeners",
+  "minVersion": "0.7.11",
+  "compatibilityLevel": "JAVA_8",
+  "mixins": [],
+  "client": [
+    "ContainerScreenHooks",
+    "CreativePlayerInventoryScreenHooks",
+    "RecipeBookGuiHooks"
+  ],
+  "injectors": {
+    "defaultRequire": 1
+  }
+}

+ 1 - 4
src/main/resources/roughlyenoughitems.mixins.json → src/main/resources/mixin.roughlyenoughitems.mixins.json

@@ -5,10 +5,7 @@
   "compatibilityLevel": "JAVA_8",
   "mixins": [],
   "client": [
-    "MixinContainerScreen",
-    "MixinBrewingRecipeRegistry",
-    "MixinRecipeBookGui",
-    "MixinCreativePlayerInventoryScreen"
+    "MixinBrewingRecipeRegistry"
   ],
   "injectors": {
     "defaultRequire": 1