Kaynağa Gözat

Speed Craft -> Auto Craft

Unknown 5 yıl önce
ebeveyn
işleme
326e0ac43f

+ 2 - 1
src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java

@@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import me.shedaniel.cloth.api.ClientUtils;
 import me.shedaniel.cloth.hooks.ClothClientHooks;
+import me.shedaniel.math.impl.PointHelper;
 import me.shedaniel.rei.api.*;
 import me.shedaniel.rei.api.plugins.REIPluginV0;
 import me.shedaniel.rei.gui.ContainerScreenOverlay;
@@ -254,7 +255,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
         });
         ClothClientHooks.SCREEN_MOUSE_SCROLLED.register((minecraftClient, screen, v, v1, v2) -> {
             if (screen instanceof AbstractContainerScreen)
-                if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().isInside(ClientUtils.getMouseLocation()) && ScreenHelper.getLastOverlay().mouseScrolled(v, v1, v2))
+                if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().isInside(PointHelper.fromMouse()) && ScreenHelper.getLastOverlay().mouseScrolled(v, v1, v2))
                     return ActionResult.SUCCESS;
             return ActionResult.PASS;
         });

+ 1 - 0
src/main/java/me/shedaniel/rei/api/RecipeCategory.java

@@ -117,6 +117,7 @@ public interface RecipeCategory<T extends RecipeDisplay> {
      *
      * @return the amount of recipes, returns -1 if not fixed
      */
+    @Deprecated
     default int getFixedRecipesPerPage() {
         return -1;
     }

+ 3 - 3
src/main/java/me/shedaniel/rei/api/RecipeHelper.java

@@ -123,7 +123,7 @@ public interface RecipeHelper {
      * @param category the category of the display
      * @return the optional of speed crafting button area
      */
-    Optional<ButtonAreaSupplier> getSpeedCraftButtonArea(RecipeCategory category);
+    Optional<ButtonAreaSupplier> getAutoCraftButtonArea(RecipeCategory category);
     
     /**
      * Registers a speed crafting button area
@@ -131,7 +131,7 @@ public interface RecipeHelper {
      * @param category  the category of the button area
      * @param rectangle the button area
      */
-    void registerSpeedCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle);
+    void registerAutoCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle);
     
     /**
      * Removes the speed crafting button
@@ -139,7 +139,7 @@ public interface RecipeHelper {
      * @param category the category of the button
      */
     default void removeSpeedCraftButton(Identifier category) {
-        registerSpeedCraftButtonArea(category, bounds -> null);
+        registerAutoCraftButtonArea(category, bounds -> null);
     }
     
     /**

+ 2 - 1
src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java

@@ -269,7 +269,7 @@ public class RecipeViewingScreen extends Screen {
                 tab.setRenderer(categories.get(j), categories.get(j).getIcon(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * TABS_PER_PAGE == categories.indexOf(selectedCategory));
             }
         }
-        Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(selectedCategory);
+        Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getAutoCraftButtonArea(selectedCategory);
         int recipeHeight = selectedCategory.getDisplayHeight();
         List<RecipeDisplay> currentDisplayed = getCurrentDisplayed();
         for (int i = 0; i < currentDisplayed.size(); i++) {
@@ -346,6 +346,7 @@ public class RecipeViewingScreen extends Screen {
         return categoryPages;
     }
     
+    @SuppressWarnings("deprecation")
     private int getRecipesPerPage() {
         if (selectedCategory.getFixedRecipesPerPage() > 0)
             return selectedCategory.getFixedRecipesPerPage() - 1;

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

@@ -131,7 +131,7 @@ public class VillagerRecipeViewingScreen extends Screen {
         Rectangle recipeBounds = new Rectangle(bounds.x + 100 + (guiWidth - 100) / 2 - category.getDisplayWidth(display) / 2, bounds.y + bounds.height / 2 - category.getDisplayHeight() / 2, category.getDisplayWidth(display), category.getDisplayHeight());
         List<Widget> setupDisplay = category.setupDisplay(() -> display, recipeBounds);
         this.widgets.addAll(setupDisplay);
-        Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(category);
+        Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getAutoCraftButtonArea(category);
         if (supplier.isPresent() && supplier.get().get(recipeBounds) != null)
             this.widgets.add(new AutoCraftingButtonWidget(recipeBounds, supplier.get().get(recipeBounds), supplier.get().getButtonText(), () -> display, setupDisplay, category));
         

+ 46 - 0
src/main/java/me/shedaniel/rei/gui/widget/RecipeArrowWidget.java

@@ -0,0 +1,46 @@
+package me.shedaniel.rei.gui.widget;
+
+import com.mojang.blaze3d.platform.GlStateManager;
+import me.shedaniel.math.api.Rectangle;
+import me.shedaniel.rei.plugin.DefaultPlugin;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.Element;
+import net.minecraft.client.render.GuiLighting;
+import net.minecraft.util.math.MathHelper;
+
+import java.util.Collections;
+import java.util.List;
+
+public class RecipeArrowWidget extends WidgetWithBounds {
+    
+    private int x, y;
+    private boolean animated;
+    
+    public RecipeArrowWidget(int x, int y, boolean animated) {
+        this.x = x;
+        this.y = y;
+        this.animated = animated;
+    }
+    
+    @Override
+    public Rectangle getBounds() {
+        return new Rectangle(x, y, 24, 17);
+    }
+    
+    @Override
+    public void render(int mouseX, int mouseY, float delta) {
+        GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+        GuiLighting.disable();
+        MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
+        blit(x, y, 106, 91, 24, 17);
+        if (animated) {
+            int width = MathHelper.ceil((System.currentTimeMillis() / 250 % 24d) / 1f);
+            blit(x, y, 82, 91, width, 17);
+        }
+    }
+    
+    @Override
+    public List<? extends Element> children() {
+        return Collections.emptyList();
+    }
+}

+ 3 - 3
src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java

@@ -195,14 +195,14 @@ public class RecipeHelperImpl implements RecipeHelper {
     }
     
     @Override
-    public Optional<ButtonAreaSupplier> getSpeedCraftButtonArea(RecipeCategory category) {
+    public Optional<ButtonAreaSupplier> getAutoCraftButtonArea(RecipeCategory category) {
         if (!speedCraftAreaSupplierMap.containsKey(category.getIdentifier()))
             return Optional.ofNullable(bounds -> new Rectangle(bounds.getMaxX() - 16, bounds.getMaxY() - 16, 10, 10));
         return Optional.ofNullable(speedCraftAreaSupplierMap.get(category.getIdentifier()));
     }
     
     @Override
-    public void registerSpeedCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle) {
+    public void registerAutoCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle) {
         if (rectangle == null) {
             if (speedCraftAreaSupplierMap.containsKey(category))
                 speedCraftAreaSupplierMap.remove(category);
@@ -213,7 +213,7 @@ public class RecipeHelperImpl implements RecipeHelper {
     @SuppressWarnings("deprecation")
     @Override
     public void registerDefaultSpeedCraftButtonArea(Identifier category) {
-        registerSpeedCraftButtonArea(category, bounds -> new Rectangle(bounds.getMaxX() - 16, bounds.getMaxY() - 16, 10, 10));
+        registerAutoCraftButtonArea(category, bounds -> new Rectangle(bounds.getMaxX() - 16, bounds.getMaxY() - 16, 10, 10));
     }
     
     @SuppressWarnings("deprecation")

+ 2 - 29
src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java

@@ -259,33 +259,6 @@ public class DefaultPlugin implements REIPluginV0 {
                 return -1.0f;
             }
         });
-        //        displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler<CreativeInventoryScreen>() {
-        //            @Override
-        //            public Class<?> getBaseSupportedClass() {
-        //                return CreativeInventoryScreen.class;
-        //            }
-        //
-        //            @Override
-        //            public Rectangle getLeftBounds(CreativeInventoryScreen screen) {
-        //                return new Rectangle(2, 0, ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 2, MinecraftClient.getInstance().window.getScaledHeight());
-        //            }
-        //
-        //            @Override
-        //            public Rectangle getRightBounds(CreativeInventoryScreen screen) {
-        //                int startX = ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() + ScreenHelper.getLastContainerScreenHooks().rei_getContainerWidth();
-        //                return new Rectangle(startX, 0, MinecraftClient.getInstance().window.getScaledWidth() - startX - 2, MinecraftClient.getInstance().window.getScaledHeight());
-        //            }
-        //
-        //            @Override
-        //            public Rectangle getItemListArea(Rectangle rectangle) {
-        //                return new Rectangle(rectangle.x + 1, rectangle.y + 24, rectangle.width - 2, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().isSideSearchField() ? 27 + 22 : 27));
-        //            }
-        //
-        //            @Override
-        //            public float getPriority() {
-        //                return -0.9f;
-        //            }
-        //        });
     }
     
     @Override
@@ -301,8 +274,8 @@ public class DefaultPlugin implements REIPluginV0 {
         recipeHelper.registerWorkingStations(BREWING, new ItemStack(Items.BREWING_STAND));
         recipeHelper.registerWorkingStations(STONE_CUTTING, new ItemStack(Items.STONECUTTER));
         recipeHelper.registerWorkingStations(COMPOSTING, new ItemStack(Items.COMPOSTER));
-        recipeHelper.registerSpeedCraftButtonArea(COMPOSTING, bounds -> null);
-        recipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.CAMPFIRE, bounds -> new Rectangle(bounds.getMaxX() - 16, bounds.y + 6, 10, 10));
+        recipeHelper.registerAutoCraftButtonArea(CAMPFIRE, bounds -> null);
+        recipeHelper.registerAutoCraftButtonArea(COMPOSTING, bounds -> null);
         recipeHelper.registerScreenClickArea(new Rectangle(88, 32, 28, 23), CraftingTableScreen.class, CRAFTING);
         recipeHelper.registerScreenClickArea(new Rectangle(137, 29, 10, 13), InventoryScreen.class, CRAFTING);
         recipeHelper.registerScreenClickArea(new Rectangle(97, 16, 14, 30), BrewingStandScreen.class, BREWING);

+ 3 - 3
src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java

@@ -12,6 +12,7 @@ import me.shedaniel.math.api.Rectangle;
 import me.shedaniel.rei.api.Renderer;
 import me.shedaniel.rei.api.TransferRecipeCategory;
 import me.shedaniel.rei.gui.renderers.RecipeRenderer;
+import me.shedaniel.rei.gui.widget.RecipeArrowWidget;
 import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
 import me.shedaniel.rei.gui.widget.SlotWidget;
 import me.shedaniel.rei.gui.widget.Widget;
@@ -68,10 +69,9 @@ public class DefaultBlastingCategory implements TransferRecipeCategory<DefaultBl
                 blit(startPoint.x, startPoint.y, 0, 54, 82, 54);
                 int height = MathHelper.ceil((System.currentTimeMillis() / 250 % 14d) / 1f);
                 blit(startPoint.x + 2, startPoint.y + 21 + (14 - height), 82, 77 + (14 - height), 14, height);
-                int width = MathHelper.ceil((System.currentTimeMillis() / 250 % 24d) / 1f);
-                blit(startPoint.x + 24, startPoint.y + 18, 82, 91, width, 17);
             }
         }));
+        widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true));
         List<List<ItemStack>> input = recipeDisplay.getInput();
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStacks(input.get(0)), true, true, true));
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(recipeDisplay.getFuel()), true, true, true) {
@@ -89,7 +89,7 @@ public class DefaultBlastingCategory implements TransferRecipeCategory<DefaultBl
         Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
         GlStateManager.translatef(0, 0, 400);
         if (redSlots.contains(0)) {
-            DrawableHelper.fill(startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 0x30ff0000);
+            DrawableHelper.fill(startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 822018048);
         }
         GlStateManager.translatef(0, 0, -400);
     }

+ 2 - 2
src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java

@@ -64,13 +64,13 @@ public class DefaultBrewingCategory implements RecipeCategory<DefaultBrewingDisp
             }
         }));
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStack(new ItemStack(Items.BLAZE_POWDER)), false, true, true));
-        widgets.add(new SlotWidget(startPoint.x + 63, startPoint.y + 1, Renderer.fromItemStacks(recipeDisplay.getInput().get(0)), false, true, true) {
+        widgets.add(new SlotWidget(startPoint.x + 40, startPoint.y + 1, Renderer.fromItemStacks(recipeDisplay.getInput().get(0)), false, true, true) {
             @Override
             protected List<String> getExtraItemToolTips(ItemStack stack) {
                 return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.input"));
             }
         });
-        widgets.add(new SlotWidget(startPoint.x + 40, startPoint.y + 1, Renderer.fromItemStacks(recipeDisplay.getInput().get(1)), false, true, true) {
+        widgets.add(new SlotWidget(startPoint.x + 63, startPoint.y + 1, Renderer.fromItemStacks(recipeDisplay.getInput().get(1)), false, true, true) {
             @Override
             protected List<String> getExtraItemToolTips(ItemStack stack) {
                 return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.reactant"));

+ 2 - 2
src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java

@@ -10,6 +10,7 @@ import me.shedaniel.math.api.Point;
 import me.shedaniel.math.api.Rectangle;
 import me.shedaniel.rei.api.RecipeCategory;
 import me.shedaniel.rei.api.Renderer;
+import me.shedaniel.rei.gui.widget.RecipeArrowWidget;
 import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
 import me.shedaniel.rei.gui.widget.SlotWidget;
 import me.shedaniel.rei.gui.widget.Widget;
@@ -58,13 +59,12 @@ public class DefaultCampfireCategory implements RecipeCategory<DefaultCampfireDi
                 blit(startPoint.x, startPoint.y, 0, 167, 82, 54);
                 int height = MathHelper.ceil((System.currentTimeMillis() / 250 % 14d) / 1f);
                 blit(startPoint.x + 2, startPoint.y + 31 + (14 - height), 82, 77 + (14 - height), 14, height);
-                int width = MathHelper.ceil((System.currentTimeMillis() / 250 % 24d) / 1f);
-                blit(startPoint.x + 24, startPoint.y + 18, 82, 91, width, 17);
                 String text = I18n.translate("category.rei.campfire.time", MathHelper.floor(recipeDisplaySupplier.get().getCookTime() / 20d));
                 int length = MinecraftClient.getInstance().textRenderer.getStringWidth(text);
                 MinecraftClient.getInstance().textRenderer.draw(text, bounds.x + bounds.width - length - 5, startPoint.y + 54 - 8, ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
             }
         }));
+        widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true));
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 11, Renderer.fromItemStacks(recipeDisplaySupplier.get().getInput().get(0)), true, true, true));
         widgets.add(new SlotWidget(startPoint.x + 61, startPoint.y + 19, Renderer.fromItemStacks(recipeDisplaySupplier.get().getOutput()), false, true, true));
         return widgets;

+ 1 - 1
src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java

@@ -105,7 +105,7 @@ public class DefaultCraftingCategory implements TransferRecipeCategory<DefaultCr
             int i = getSlotWithSize(display, slot);
             int x = i % 3;
             int y = (i - x) / 3;
-            DrawableHelper.fill(startPoint.x + 1 + x * 18, startPoint.y + 1 + y * 18, startPoint.x + 1 + x * 18 + 16, startPoint.y + 1 + y * 18 + 16, 0x30ff0000);
+            DrawableHelper.fill(startPoint.x + 1 + x * 18, startPoint.y + 1 + y * 18, startPoint.x + 1 + x * 18 + 16, startPoint.y + 1 + y * 18 + 16, 822018048);
         }
         GlStateManager.translatef(0, 0, -400);
     }

+ 3 - 3
src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java

@@ -12,6 +12,7 @@ import me.shedaniel.math.api.Rectangle;
 import me.shedaniel.rei.api.Renderer;
 import me.shedaniel.rei.api.TransferRecipeCategory;
 import me.shedaniel.rei.gui.renderers.RecipeRenderer;
+import me.shedaniel.rei.gui.widget.RecipeArrowWidget;
 import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
 import me.shedaniel.rei.gui.widget.SlotWidget;
 import me.shedaniel.rei.gui.widget.Widget;
@@ -67,10 +68,9 @@ public class DefaultSmeltingCategory implements TransferRecipeCategory<DefaultSm
                 blit(startPoint.x, startPoint.y, 0, 54, 82, 54);
                 int height = MathHelper.ceil((System.currentTimeMillis() / 250 % 14d) / 1f);
                 blit(startPoint.x + 2, startPoint.y + 21 + (14 - height), 82, 77 + (14 - height), 14, height);
-                int width = MathHelper.ceil((System.currentTimeMillis() / 250 % 24d) / 1f);
-                blit(startPoint.x + 24, startPoint.y + 18, 82, 91, width, 17);
             }
         }));
+        widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true));
         List<List<ItemStack>> input = recipeDisplaySupplier.get().getInput();
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStacks(input.get(0)), true, true, true));
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(recipeDisplaySupplier.get().getFuel()), true, true, true) {
@@ -88,7 +88,7 @@ public class DefaultSmeltingCategory implements TransferRecipeCategory<DefaultSm
         Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
         GlStateManager.translatef(0, 0, 400);
         if (redSlots.contains(0)) {
-            DrawableHelper.fill(startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 0x30ff0000);
+            DrawableHelper.fill(startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 822018048);
         }
         GlStateManager.translatef(0, 0, -400);
     }

+ 3 - 3
src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java

@@ -12,6 +12,7 @@ import me.shedaniel.math.api.Rectangle;
 import me.shedaniel.rei.api.Renderer;
 import me.shedaniel.rei.api.TransferRecipeCategory;
 import me.shedaniel.rei.gui.renderers.RecipeRenderer;
+import me.shedaniel.rei.gui.widget.RecipeArrowWidget;
 import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
 import me.shedaniel.rei.gui.widget.SlotWidget;
 import me.shedaniel.rei.gui.widget.Widget;
@@ -67,10 +68,9 @@ public class DefaultSmokingCategory implements TransferRecipeCategory<DefaultSmo
                 blit(startPoint.x, startPoint.y, 0, 54, 82, 54);
                 int height = MathHelper.ceil((System.currentTimeMillis() / 250 % 14d) / 1f);
                 blit(startPoint.x + 2, startPoint.y + 21 + (14 - height), 82, 77 + (14 - height), 14, height);
-                int width = MathHelper.ceil((System.currentTimeMillis() / 250 % 24d) / 1f);
-                blit(startPoint.x + 24, startPoint.y + 18, 82, 91, width, 17);
             }
         }));
+        widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true));
         List<List<ItemStack>> input = recipeDisplaySupplier.get().getInput();
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStacks(input.get(0)), true, true, true));
         widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(recipeDisplaySupplier.get().getFuel()), true, true, true) {
@@ -88,7 +88,7 @@ public class DefaultSmokingCategory implements TransferRecipeCategory<DefaultSmo
         Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
         GlStateManager.translatef(0, 0, 400);
         if (redSlots.contains(0)) {
-            DrawableHelper.fill(startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 0x30ff0000);
+            DrawableHelper.fill(startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 822018048);
         }
         GlStateManager.translatef(0, 0, -400);
     }

BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/display.png