Procházet zdrojové kódy

No one have saw this coming

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel před 5 roky
rodič
revize
269ed23372

+ 1 - 1
.github/workflows/curseforge.yml

@@ -16,6 +16,6 @@ jobs:
         with:
           java-version: 1.8
       - name: Upload to CurseForge
-        run: ./gradlew clean build curseforge --refresh-dependencies --stacktrace
+        run: ./gradlew clean build releaseOnCf --refresh-dependencies --stacktrace
         env:
           danielshe_curse_api_key: ${{ secrets.CF_API_KEY }}

+ 25 - 5
build.gradle

@@ -21,6 +21,7 @@ version = forceVersion != "" ? forceVersion : project.mod_version
 def includeDep = true
 
 minecraft {
+    accessWidener = file("src/main/resources/rei.aw")
 }
 
 static def buildTime() {
@@ -111,6 +112,28 @@ task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
     }
 }
 
+def releaseChangelog = "No changelog"
+
+task releaseOnCf {
+    def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
+    df.setTimeZone(TimeZone.getTimeZone("UTC"))
+    def currentBranch = "git rev-parse --abbrev-ref HEAD".execute().in.readLines().join('\n')
+    def time = df.format(new Date())
+    def changes = new StringBuilder()
+    changes << "<h2>REI v$project.version for $project.supported_version</h2>Updated at <b>$time</b>.<br><a href=\"https://www.github.com/shedaniel/RoughlyEnoughItems/commits/$currentBranch\">Click here for changelog</a>"
+    def proc = "git log --max-count=200 --pretty=format:\"%s\"".execute()
+    proc.in.eachLine { line ->
+        def processedLine = line.toString()
+        if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
+            changes << "<br>- $processedLine"
+        }
+    }
+    proc.waitFor()
+    releaseChangelog = changes.toString()
+    println(releaseChangelog)
+    dependsOn tasks.getByName("curseforge")
+}
+
 curseforge {
     if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
         apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
@@ -118,10 +141,7 @@ curseforge {
             id = '310111'
             releaseType = 'beta'
             changelogType = "html"
-            def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
-            df.setTimeZone(TimeZone.getTimeZone("UTC"))
-            def time = df.format(new Date())
-            changelog = "<h2>REI v$project.version</h2>Updated at <b>$time</b>.<br><a href=\"https://gist.github.com/shedaniel/b7593e692319976f3349263208792922\">Click here for full changelog</a>"
+            changelog = releaseChangelog
             addGameVersion '1.16-Snapshot'
             addGameVersion 'Java 8'
             addGameVersion 'Fabric'
@@ -131,7 +151,7 @@ curseforge {
                 embeddedLibrary 'cloth-config'
             }
             mainArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}.jar")) {
-                displayName = "[Fabric 20w14a] v$project.version"
+                displayName = "[Fabric $project.supported_version] v$project.version"
             }
             afterEvaluate {
                 uploadTask.dependsOn("remapJar")

+ 2 - 1
gradle.properties

@@ -1,4 +1,5 @@
-mod_version=4.1.8-unstable
+mod_version=4.1.9-unstable
+supported_version=20w16a
 minecraft_version=20w16a
 yarn_version=20w16a+build.1
 fabricloader_version=0.8.2+build.194

+ 3 - 5
src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java

@@ -31,8 +31,6 @@ import me.shedaniel.rei.api.*;
 import me.shedaniel.rei.api.plugins.REIPluginV0;
 import me.shedaniel.rei.gui.ContainerScreenOverlay;
 import me.shedaniel.rei.impl.*;
-import me.shedaniel.rei.listeners.RecipeBookButtonWidgetHooks;
-import me.shedaniel.rei.listeners.RecipeBookGuiHooks;
 import me.shedaniel.rei.tests.plugin.REITestPlugin;
 import net.fabricmc.api.ClientModInitializer;
 import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
@@ -200,7 +198,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
                 Screen currentScreen = MinecraftClient.getInstance().currentScreen;
                 if (currentScreen instanceof CraftingScreen) {
                     RecipeBookWidget recipeBookGui = ((RecipeBookProvider) currentScreen).getRecipeBookWidget();
-                    RecipeBookGhostSlots ghostSlots = ((RecipeBookGuiHooks) recipeBookGui).rei_getGhostSlots();
+                    RecipeBookGhostSlots ghostSlots = recipeBookGui.ghostSlots;
                     ghostSlots.reset();
                     
                     List<List<ItemStack>> input = Lists.newArrayList();
@@ -306,7 +304,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
         ClothClientHooks.SYNC_RECIPES.register((minecraftClient, recipeManager, synchronizeRecipesS2CPacket) -> syncRecipes(lastSync));
         ClothClientHooks.SCREEN_ADD_BUTTON.register((minecraftClient, screen, abstractButtonWidget) -> {
             if (ConfigObject.getInstance().doesDisableRecipeBook() && screen instanceof HandledScreen && abstractButtonWidget instanceof TexturedButtonWidget)
-                if (((RecipeBookButtonWidgetHooks) abstractButtonWidget).rei_getTexture().equals(recipeButtonTex))
+                if (((TexturedButtonWidget) abstractButtonWidget).texture.equals(recipeButtonTex))
                     return ActionResult.FAIL;
             return ActionResult.PASS;
         });
@@ -376,7 +374,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
             ScreenHelper.getLastOverlay().lateRender(i, i1, v);
         });
         ClothClientHooks.SCREEN_KEY_PRESSED.register((minecraftClient, screen, i, i1, i2) -> {
-            if (screen.getFocused() != null && screen.getFocused() instanceof TextFieldWidget || (screen.getFocused() instanceof RecipeBookWidget && ((RecipeBookGuiHooks) screen.getFocused()).rei_getSearchField() != null && ((RecipeBookGuiHooks) screen.getFocused()).rei_getSearchField().isFocused()))
+            if (screen.getFocused() != null && screen.getFocused() instanceof TextFieldWidget || (screen.getFocused() instanceof RecipeBookWidget && ((RecipeBookWidget) screen.getFocused()).searchField != null && ((RecipeBookWidget) screen.getFocused()).searchField.isFocused()))
                 return ActionResult.PASS;
             if (shouldReturn(screen.getClass()))
                 return ActionResult.PASS;

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

@@ -31,7 +31,6 @@ import me.shedaniel.rei.api.widgets.Tooltip;
 import me.shedaniel.rei.impl.EmptyEntryStack;
 import me.shedaniel.rei.impl.FluidEntryStack;
 import me.shedaniel.rei.impl.ItemEntryStack;
-import me.shedaniel.rei.listeners.BucketItemHooks;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.fluid.Fluid;
 import net.minecraft.item.BucketItem;
@@ -140,7 +139,7 @@ public interface EntryStack {
             throw new IllegalArgumentException("EntryStack must be item!");
         Item item = stack.getItem();
         if (item instanceof BucketItem)
-            return EntryStack.create(((BucketItemHooks) item).getFluid(), 1000);
+            return EntryStack.create(((BucketItem) item).fluid, 1000);
         return EntryStack.empty();
     }
     

+ 16 - 15
src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java

@@ -40,7 +40,6 @@ import me.shedaniel.rei.impl.ClientHelperImpl;
 import me.shedaniel.rei.impl.InternalWidgets;
 import me.shedaniel.rei.impl.ScreenHelper;
 import me.shedaniel.rei.impl.Weather;
-import me.shedaniel.rei.listeners.ContainerScreenHooks;
 import me.shedaniel.rei.utils.CollectionUtils;
 import net.minecraft.block.Blocks;
 import net.minecraft.client.MinecraftClient;
@@ -307,7 +306,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
                 VillagerRecipeViewingScreen widget = (VillagerRecipeViewingScreen) MinecraftClient.getInstance().currentScreen;
                 return new Rectangle(widget.bounds.x, 3, widget.bounds.width, 18);
             }
-            return new Rectangle(((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getContainerLeft(), 3, ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getContainerWidth(), 18);
+            return new Rectangle(ScreenHelper.getLastHandledScreen().x, 3, ScreenHelper.getLastHandledScreen().backgroundWidth, 18);
         }
         return null;
     }
@@ -376,7 +375,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
             VillagerRecipeViewingScreen widget = (VillagerRecipeViewingScreen) MinecraftClient.getInstance().currentScreen;
             return new Rectangle(widget.bounds.x, window.getScaledHeight() - 22, widget.bounds.width - widthRemoved, 18);
         }
-        return new Rectangle(((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getContainerLeft(), window.getScaledHeight() - 22, ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getContainerWidth() - widthRemoved, 18);
+        return new Rectangle(ScreenHelper.getLastHandledScreen().x, window.getScaledHeight() - 22, ScreenHelper.getLastHandledScreen().backgroundWidth - widthRemoved, 18);
     }
     
     private Rectangle getCraftableToggleArea() {
@@ -427,21 +426,21 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
         if (OverlaySearchField.isSearching) {
             setZOffset(200);
             if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen) {
-                ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen;
-                int left = hooks.rei_getContainerLeft(), top = hooks.rei_getContainerTop();
-                for (Slot slot : ((HandledScreen<?>) MinecraftClient.getInstance().currentScreen).getScreenHandler().slots)
+                HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
+                int x = handledScreen.x, y = handledScreen.y;
+                for (Slot slot : handledScreen.getScreenHandler().slots)
                     if (!slot.hasStack() || !ENTRY_LIST_WIDGET.canLastSearchTermsBeAppliedTo(EntryStack.create(slot.getStack())))
-                        fillGradient(left + slot.x, top + slot.y, left + slot.x + 16, top + slot.y + 16, -601874400, -601874400);
+                        fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, -601874400, -601874400);
             }
             setZOffset(0);
         }
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
         this.renderWidgets(mouseX, mouseY, delta);
         if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
-            ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen;
+            HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
             for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas())
                 if (area.getScreenClass().equals(MinecraftClient.getInstance().currentScreen.getClass()))
-                    if (area.getRectangle().contains(mouseX - hooks.rei_getContainerLeft(), mouseY - hooks.rei_getContainerTop())) {
+                    if (area.getRectangle().contains(mouseX - handledScreen.x, mouseY - handledScreen.y)) {
                         String collect = CollectionUtils.mapAndJoinToString(area.getCategories(), identifier -> RecipeHelper.getInstance().getCategory(identifier).getCategoryName(), ", ");
                         TOOLTIPS.add(Tooltip.create(I18n.translate("text.rei.view_recipes_for", collect)));
                         break;
@@ -549,9 +548,11 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
             return true;
         }
         ItemStack itemStack = null;
-        if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen)
-            if (((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getHoveredSlot() != null && !((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getHoveredSlot().getStack().isEmpty())
-                itemStack = ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getHoveredSlot().getStack();
+        if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen) {
+            HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
+            if (handledScreen.focusedSlot != null && !handledScreen.focusedSlot.getStack().isEmpty())
+                itemStack = handledScreen.focusedSlot.getStack();
+        }
         if (itemStack != null && !itemStack.isEmpty()) {
             if (ConfigObject.getInstance().getRecipeKeybind().matchesKey(int_1, int_2))
                 return ClientHelper.getInstance().executeRecipeKeyBind(itemStack);
@@ -599,10 +600,10 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
             return true;
         }
         if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
-            ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen;
+            HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
             for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas())
-                if (area.getScreenClass().equals(MinecraftClient.getInstance().currentScreen.getClass()))
-                    if (area.getRectangle().contains(double_1 - hooks.rei_getContainerLeft(), double_2 - hooks.rei_getContainerTop())) {
+                if (area.getScreenClass().equals(handledScreen.getClass()))
+                    if (area.getRectangle().contains(double_1 - handledScreen.x, double_2 - handledScreen.y)) {
                         ClientHelper.getInstance().executeViewAllRecipesFromCategories(Arrays.asList(area.getCategories()));
                         MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                         return true;

+ 0 - 36
src/main/java/me/shedaniel/rei/listeners/AbstractInventoryScreenHooks.java

@@ -1,36 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.shedaniel.rei.listeners;
-
-import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
-import org.jetbrains.annotations.ApiStatus;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-@ApiStatus.Internal
-@Mixin(AbstractInventoryScreen.class)
-public interface AbstractInventoryScreenHooks {
-    @Accessor("drawStatusEffects")
-    boolean rei_doesOffsetGuiForEffects();
-}

+ 0 - 35
src/main/java/me/shedaniel/rei/listeners/BucketItemHooks.java

@@ -1,35 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.shedaniel.rei.listeners;
-
-import net.minecraft.fluid.Fluid;
-import net.minecraft.item.BucketItem;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-@Mixin(BucketItem.class)
-public interface BucketItemHooks {
-    @Accessor("fluid")
-    Fluid getFluid();
-}

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

@@ -1,51 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.shedaniel.rei.listeners;
-
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
-import net.minecraft.screen.slot.Slot;
-import org.jetbrains.annotations.ApiStatus;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-@ApiStatus.Internal
-@Mixin(HandledScreen.class)
-public interface ContainerScreenHooks {
-    
-    @Accessor("x")
-    int rei_getContainerLeft();
-    
-    @Accessor("y")
-    int rei_getContainerTop();
-    
-    @Accessor("backgroundWidth")
-    int rei_getContainerWidth();
-    
-    @Accessor("backgroundHeight")
-    int rei_getContainerHeight();
-    
-    @Accessor("focusedSlot")
-    Slot rei_getHoveredSlot();
-    
-}

+ 0 - 37
src/main/java/me/shedaniel/rei/listeners/RecipeBookButtonWidgetHooks.java

@@ -1,37 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.shedaniel.rei.listeners;
-
-import net.minecraft.client.gui.widget.TexturedButtonWidget;
-import net.minecraft.util.Identifier;
-import org.jetbrains.annotations.ApiStatus;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-@ApiStatus.Internal
-@Mixin(TexturedButtonWidget.class)
-public interface RecipeBookButtonWidgetHooks {
-    @Accessor("texture")
-    Identifier rei_getTexture();
-}

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

@@ -1,49 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.shedaniel.rei.listeners;
-
-import net.minecraft.client.gui.screen.recipebook.RecipeBookGhostSlots;
-import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
-import net.minecraft.client.gui.screen.recipebook.RecipeGroupButtonWidget;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import org.jetbrains.annotations.ApiStatus;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-import java.util.List;
-
-@ApiStatus.Internal
-@Mixin(RecipeBookWidget.class)
-public interface RecipeBookGuiHooks {
-    
-    @Accessor("ghostSlots")
-    RecipeBookGhostSlots rei_getGhostSlots();
-    
-    @Accessor("searchField")
-    TextFieldWidget rei_getSearchField();
-    
-    @Accessor("tabButtons")
-    List<RecipeGroupButtonWidget> rei_getTabButtons();
-    
-}

+ 3 - 6
src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java

@@ -31,15 +31,12 @@ import me.shedaniel.math.Rectangle;
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
 import me.shedaniel.rei.api.*;
 import me.shedaniel.rei.api.plugins.REIPluginV0;
-import me.shedaniel.rei.api.subsets.SubsetsRegistry;
 import me.shedaniel.rei.api.widgets.Panel;
 import me.shedaniel.rei.api.widgets.Tooltip;
 import me.shedaniel.rei.gui.RecipeViewingScreen;
 import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
 import me.shedaniel.rei.impl.ClientHelperImpl;
 import me.shedaniel.rei.impl.RenderingEntry;
-import me.shedaniel.rei.impl.ScreenHelper;
-import me.shedaniel.rei.listeners.ContainerScreenHooks;
 import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseCategory;
 import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseDisplay;
 import me.shedaniel.rei.plugin.blasting.DefaultBlastingDisplay;
@@ -305,13 +302,13 @@ public class DefaultPlugin implements REIPluginV0 {
             
             @Override
             public Rectangle getLeftBounds(HandledScreen<?> screen) {
-                return new Rectangle(2, 0, ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getContainerLeft() - 4, MinecraftClient.getInstance().getWindow().getScaledHeight());
+                return new Rectangle(2, 0, screen.x - 4, screen.height);
             }
             
             @Override
             public Rectangle getRightBounds(HandledScreen<?> screen) {
-                int startX = ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getContainerLeft() + ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen()).rei_getContainerWidth() + 2;
-                return new Rectangle(startX, 0, MinecraftClient.getInstance().getWindow().getScaledWidth() - startX - 2, MinecraftClient.getInstance().getWindow().getScaledHeight());
+                int startX = screen.x + screen.backgroundWidth + 2;
+                return new Rectangle(startX, 0, screen.width - startX - 2, screen.height);
             }
             
             @Override

+ 5 - 6
src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java

@@ -26,10 +26,9 @@ package me.shedaniel.rei.plugin;
 import com.google.common.collect.Ordering;
 import me.shedaniel.math.Rectangle;
 import me.shedaniel.rei.impl.ScreenHelper;
-import me.shedaniel.rei.listeners.AbstractInventoryScreenHooks;
-import me.shedaniel.rei.listeners.ContainerScreenHooks;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
+import net.minecraft.client.gui.screen.ingame.HandledScreen;
 import net.minecraft.entity.effect.StatusEffectInstance;
 
 import java.util.ArrayList;
@@ -41,15 +40,15 @@ import java.util.function.Supplier;
 public class DefaultPotionEffectExclusionZones implements Supplier<List<Rectangle>> {
     @Override
     public List<Rectangle> get() {
-        if (!(ScreenHelper.getLastHandledScreen() instanceof AbstractInventoryScreen) || !((AbstractInventoryScreenHooks) ScreenHelper.getLastHandledScreen()).rei_doesOffsetGuiForEffects())
+        if (!(ScreenHelper.getLastHandledScreen() instanceof AbstractInventoryScreen) || !((AbstractInventoryScreen) ScreenHelper.getLastHandledScreen()).drawStatusEffects)
             return Collections.emptyList();
         Collection<StatusEffectInstance> activePotionEffects = MinecraftClient.getInstance().player.getStatusEffects();
         if (activePotionEffects.isEmpty())
             return Collections.emptyList();
-        ContainerScreenHooks hooks = ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen());
+        HandledScreen<?> handledScreen = ScreenHelper.getLastHandledScreen();
         List<Rectangle> list = new ArrayList<>();
-        int x = hooks.rei_getContainerLeft() - 124;
-        int y = hooks.rei_getContainerTop();
+        int x = handledScreen.x - 124;
+        int y = handledScreen.y;
         int height = 33;
         if (activePotionEffects.size() > 5)
             height = 132 / (activePotionEffects.size() - 1);

+ 4 - 4
src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java

@@ -26,8 +26,8 @@ package me.shedaniel.rei.plugin;
 import com.google.common.collect.Lists;
 import me.shedaniel.math.Rectangle;
 import me.shedaniel.rei.impl.ScreenHelper;
-import me.shedaniel.rei.listeners.ContainerScreenHooks;
 import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.ingame.HandledScreen;
 import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
 import net.minecraft.client.recipebook.ClientRecipeBook;
 import net.minecraft.screen.AbstractRecipeScreenHandler;
@@ -42,11 +42,11 @@ public class DefaultRecipeBookExclusionZones implements Supplier<List<Rectangle>
     public List<Rectangle> get() {
         if (!MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() || !(MinecraftClient.getInstance().currentScreen instanceof RecipeBookProvider) || !(ScreenHelper.getLastHandledScreen().getScreenHandler() instanceof AbstractRecipeScreenHandler))
             return Collections.emptyList();
-        ContainerScreenHooks screenHooks = ((ContainerScreenHooks) ScreenHelper.getLastHandledScreen());
-        List<Rectangle> l = Lists.newArrayList(new Rectangle(screenHooks.rei_getContainerLeft() - 4 - 145, screenHooks.rei_getContainerTop(), 4 + 145 + 30, screenHooks.rei_getContainerHeight()));
+        HandledScreen<?> handledScreen = ScreenHelper.getLastHandledScreen();
+        List<Rectangle> l = Lists.newArrayList(new Rectangle(handledScreen.x - 4 - 145, handledScreen.y, 4 + 145 + 30, handledScreen.backgroundHeight));
         int size = ClientRecipeBook.getGroups((AbstractRecipeScreenHandler<?>) ScreenHelper.getLastHandledScreen().getScreenHandler()).size();
         if (size > 0)
-            l.add(new Rectangle(screenHooks.rei_getContainerLeft() - 4 - 145 - 30, screenHooks.rei_getContainerTop(), 30, size * 27));
+            l.add(new Rectangle(handledScreen.x - 4 - 145 - 30, handledScreen.y, 30, size * 27));
         return l;
     }
     

+ 5 - 5
src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java

@@ -30,7 +30,6 @@ import me.shedaniel.rei.RoughlyEnoughItemsNetwork;
 import me.shedaniel.rei.api.AutoTransferHandler;
 import me.shedaniel.rei.api.EntryStack;
 import me.shedaniel.rei.api.TransferRecipeDisplay;
-import me.shedaniel.rei.listeners.RecipeBookGuiHooks;
 import me.shedaniel.rei.server.ContainerInfo;
 import me.shedaniel.rei.server.ContainerInfoHandler;
 import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
@@ -43,6 +42,7 @@ import net.minecraft.item.ItemStack;
 import net.minecraft.network.PacketByteBuf;
 import net.minecraft.screen.ScreenHandler;
 import net.minecraft.util.collection.DefaultedList;
+
 import java.util.List;
 
 public class DefaultCategoryHandler implements AutoTransferHandler {
@@ -56,7 +56,7 @@ public class DefaultCategoryHandler implements AutoTransferHandler {
         if (!(context.getRecipe() instanceof TransferRecipeDisplay))
             return Result.createNotApplicable();
         TransferRecipeDisplay recipe = (TransferRecipeDisplay) context.getRecipe();
-        HandledScreen<?> screenWithHandler = context.getHandledScreen();
+        HandledScreen<?> handledScreen = context.getHandledScreen();
         ScreenHandler screenHandler = context.getScreenHandler();
         ContainerInfo<ScreenHandler> containerInfo = (ContainerInfo<ScreenHandler>) ContainerInfoHandler.getContainerInfo(recipe.getRecipeCategory(), screenHandler.getClass());
         if (containerInfo == null)
@@ -72,9 +72,9 @@ public class DefaultCategoryHandler implements AutoTransferHandler {
         if (!context.isActuallyCrafting())
             return Result.createSuccessful();
         
-        context.getMinecraft().openScreen(screenWithHandler);
-        if (screenWithHandler instanceof RecipeBookProvider)
-            ((RecipeBookGuiHooks) ((RecipeBookProvider) screenWithHandler).getRecipeBookWidget()).rei_getGhostSlots().reset();
+        context.getMinecraft().openScreen(handledScreen);
+        if (handledScreen instanceof RecipeBookProvider)
+            ((RecipeBookProvider) handledScreen).getRecipeBookWidget().ghostSlots.reset();
         PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
         buf.writeIdentifier(recipe.getRecipeCategory());
         buf.writeBoolean(Screen.hasShiftDown());

+ 2 - 3
src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java

@@ -27,7 +27,6 @@ import me.shedaniel.rei.api.AutoTransferHandler;
 import me.shedaniel.rei.api.RecipeDisplay;
 import me.shedaniel.rei.api.TransferRecipeDisplay;
 import me.shedaniel.rei.impl.ScreenHelper;
-import me.shedaniel.rei.listeners.RecipeBookGuiHooks;
 import me.shedaniel.rei.plugin.cooking.DefaultCookingDisplay;
 import me.shedaniel.rei.plugin.crafting.DefaultCraftingDisplay;
 import net.minecraft.client.gui.screen.Screen;
@@ -69,7 +68,7 @@ public class DefaultRecipeBookHandler implements AutoTransferHandler {
                     return Result.createSuccessful();
                 context.getMinecraft().openScreen(context.getHandledScreen());
                 if (context.getHandledScreen() instanceof RecipeBookProvider)
-                    ((RecipeBookGuiHooks) ((RecipeBookProvider) context.getHandledScreen()).getRecipeBookWidget()).rei_getGhostSlots().reset();
+                    ((RecipeBookProvider) context.getHandledScreen()).getRecipeBookWidget().ghostSlots.reset();
                 context.getMinecraft().interactionManager.clickRecipe(container.syncId, recipe, Screen.hasShiftDown());
                 ScreenHelper.getLastOverlay().init();
             }
@@ -83,7 +82,7 @@ public class DefaultRecipeBookHandler implements AutoTransferHandler {
                     return Result.createSuccessful();
                 context.getMinecraft().openScreen(context.getHandledScreen());
                 if (context.getHandledScreen() instanceof RecipeBookProvider)
-                    ((RecipeBookGuiHooks) ((RecipeBookProvider) context.getHandledScreen()).getRecipeBookWidget()).rei_getGhostSlots().reset();
+                    ((RecipeBookProvider) context.getHandledScreen()).getRecipeBookWidget().ghostSlots.reset();
                 context.getMinecraft().interactionManager.clickRecipe(container.syncId, recipe, Screen.hasShiftDown());
                 ScreenHelper.getLastOverlay().init();
             }

+ 0 - 0
src/main/resources/assets/roughlyenoughitems/.modassetroot


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

@@ -42,9 +42,9 @@
     "minecraft": "~1.16-Snapshot.20.16.a"
   },
   "mixins": [
-    "mixin.roughlyenoughitems.json",
-    "listeners.roughlyenoughitems.json"
+    "mixin.roughlyenoughitems.json"
   ],
+  "accessWidener": "rei.aw",
   "custom": {
     "rei:translators": {
       "English": "shedaniel",

binární
src/main/resources/icon.png


+ 0 - 17
src/main/resources/listeners.roughlyenoughitems.json

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

+ 12 - 0
src/main/resources/rei.aw

@@ -0,0 +1,12 @@
+accessWidener   v1  named
+accessible field net/minecraft/item/BucketItem fluid Lnet/minecraft/fluid/Fluid;
+accessible field net/minecraft/client/gui/screen/ingame/AbstractInventoryScreen drawStatusEffects Z
+accessible field net/minecraft/client/gui/screen/recipebook/RecipeBookWidget ghostSlots Lnet/minecraft/client/gui/screen/recipebook/RecipeBookGhostSlots;
+accessible field net/minecraft/client/gui/screen/recipebook/RecipeBookWidget searchField Lnet/minecraft/client/gui/widget/TextFieldWidget;
+accessible field net/minecraft/client/gui/screen/recipebook/RecipeBookWidget tabButtons Ljava/util/List;
+accessible field net/minecraft/client/gui/screen/ingame/HandledScreen x I
+accessible field net/minecraft/client/gui/screen/ingame/HandledScreen y I
+accessible field net/minecraft/client/gui/screen/ingame/HandledScreen backgroundWidth I
+accessible field net/minecraft/client/gui/screen/ingame/HandledScreen backgroundHeight I
+accessible field net/minecraft/client/gui/screen/ingame/HandledScreen focusedSlot Lnet/minecraft/screen/slot/Slot;
+accessible field net/minecraft/client/gui/widget/TexturedButtonWidget texture Lnet/minecraft/util/Identifier;