Selaa lähdekoodia

Update to 19w11a

Unknown 6 vuotta sitten
vanhempi
sitoutus
add980448d

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+# v2.4.1.65
+- [Cloth](https://minecraft.curseforge.com/projects/cloth) is now required for REI to run
+- Update to 19w11a
+
 # v2.4.0.63
 - First implementation of [Cloth](https://minecraft.curseforge.com/projects/cloth), [Cloth](https://minecraft.curseforge.com/projects/cloth) is still not required for REI to boot but it will be a must have dependency when 19w11a comes.
 - Used [Cloth](https://minecraft.curseforge.com/projects/cloth) for hooking up [Mod Menu](https://minecraft.curseforge.com/projects/modmenu/) config. Example: [https://streamable.com/ivbsj](https://streamable.com/ivbsj)

+ 3 - 3
build.gradle

@@ -20,7 +20,7 @@ repositories {
     maven { url "https://tehnut.info/maven/" }
     maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
     maven { url "https://maven.jamieswhiteshirt.com/libs-release/" }
-    maven { url "https://minecraft.curseforge.com/api/maven"}
+    maven { url "https://minecraft.curseforge.com/api/maven" }
 }
 
 processResources {
@@ -49,10 +49,10 @@ dependencies {
     minecraft "com.mojang:minecraft:${project.minecraft_version}"
     mappings "net.fabricmc:yarn:${project.yarn_version}"
     modCompile "net.fabricmc:fabric-loader:${project.fabricloader_version}"
-    modCompile "com.jamieswhiteshirt:developer-mode:${project.developermode_version}"
+//    modCompile "com.jamieswhiteshirt:developer-mode:${project.developermode_version}"
     modCompile "info.tehnut.pluginloader:plugin-loader:${project.pluginloader_version}"
     modCompile "net.fabricmc:fabric:${project.fabric_version}"
-    modCompile "utils:Cloth:${cloth_version}"
+    modCompile "cloth:Cloth:${cloth_version}"
 
     compile "blue.endless:jankson:${project.jankson_version}"
     contained "blue.endless:jankson:${project.jankson_version}"

+ 5 - 5
gradle.properties

@@ -1,9 +1,9 @@
-mod_version=2.4.1.64
-minecraft_version=19w09a
-yarn_version=19w09a.10
-fabric_version=0.2.3.108
+mod_version=2.4.1.65
+minecraft_version=19w11a
+yarn_version=19w11a.1
+fabric_version=0.2.3.110
 fabricloader_version=0.3.7.109
 pluginloader_version=1.14-1.0.6-8
 developermode_version=1.0.3
 jankson_version=1.1.0
-cloth_version=0.1.0.4
+cloth_version=0.1.1.6

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

@@ -364,7 +364,7 @@ public class ContainerScreenOverlay extends ScreenComponent {
     }
     
     @Override
-    public boolean mouseScrolled(double amount) {
+    public boolean mouseScrolled(double i, double j, double amount) {
         if (!ScreenHelper.isOverlayVisible())
             return false;
         if (rectangle.contains(ClientHelper.getMouseLocation())) {
@@ -377,7 +377,7 @@ public class ContainerScreenOverlay extends ScreenComponent {
             return true;
         }
         for(IWidget widget : widgets)
-            if (widget.mouseScrolled(amount))
+            if (widget.mouseScrolled(i, j, amount))
                 return true;
         return false;
     }

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

@@ -348,9 +348,9 @@ public class RecipeViewingScreen extends Screen {
     }
     
     @Override
-    public boolean mouseScrolled(double amount) {
+    public boolean mouseScrolled(double i, double j, double amount) {
         for(InputListener listener : listeners)
-            if (listener.mouseScrolled(amount))
+            if (listener.mouseScrolled(i, j, amount))
                 return true;
         if (getBounds().contains(ClientHelper.getMouseLocation())) {
             if (amount > 0 && recipeBack.enabled)
@@ -364,7 +364,7 @@ public class RecipeViewingScreen extends Screen {
             else if (amount < 0 && categoryNext.enabled)
                 categoryNext.onPressed(0, 0, 0);
         }
-        return super.mouseScrolled(amount);
+        return super.mouseScrolled(i, j, amount);
     }
     
     @Override
@@ -389,11 +389,11 @@ public class RecipeViewingScreen extends Screen {
         return false;
     }
     
-    @Override
-    public InputListener getFocused() {
+    @Override //getFocused
+    public InputListener method_19357() {
         if (choosePageActivated)
             return recipeChoosePageWidget;
-        return super.getFocused();
+        return super.method_19357();
     }
     
 }

+ 4 - 4
src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java

@@ -7,10 +7,10 @@ import me.shedaniel.rei.client.ItemListOrdering;
 import me.shedaniel.rei.client.ScreenHelper;
 import me.shedaniel.rei.gui.widget.QueuedTooltip;
 import me.shedaniel.rei.gui.widget.TextFieldWidget;
+import net.minecraft.class_4185;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.InputListener;
 import net.minecraft.client.gui.Screen;
-import net.minecraft.client.gui.widget.ButtonWidget;
 import net.minecraft.client.render.GuiLighting;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.text.TranslatableTextComponent;
@@ -334,9 +334,9 @@ public class ConfigScreen extends Screen {
                 return false;
             }
         }));
-        addButton(new ButtonWidget(screenWidth / 2 - 100, screenHeight - 26, I18n.translate("gui.done")) {
+        addButton(new class_4185(screenWidth / 2 - 100, screenHeight - 26, I18n.translate("gui.done")) {
             @Override
-            public void onPressed(double double_1, double double_2) {
+            public void method_1826() {
                 try {
                     RoughlyEnoughItemsCore.getConfigManager().saveConfig();
                 } catch (IOException e) {
@@ -372,7 +372,7 @@ public class ConfigScreen extends Screen {
     }
     
     @Override
-    public InputListener getFocused() {
+    public InputListener method_19357() {
         return entryListWidget;
     }
     

+ 4 - 4
src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java

@@ -1,10 +1,10 @@
 package me.shedaniel.rei.gui.credits;
 
 import me.shedaniel.rei.client.ScreenHelper;
+import net.minecraft.class_4185;
 import net.minecraft.client.gui.ContainerScreen;
 import net.minecraft.client.gui.InputListener;
 import net.minecraft.client.gui.Screen;
-import net.minecraft.client.gui.widget.ButtonWidget;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.text.StringTextComponent;
 
@@ -34,9 +34,9 @@ public class CreditsScreen extends Screen {
         for(String line : I18n.translate("text.rei.credit.text").split("\n"))
             entryListWidget.creditsAddEntry(new CreditsEntry(new StringTextComponent(line)));
         entryListWidget.creditsAddEntry(new CreditsEntry(new StringTextComponent("")));
-        addButton(new ButtonWidget(screenWidth / 2 - 100, screenHeight - 26, I18n.translate("gui.done")) {
+        addButton(new class_4185(screenWidth / 2 - 100, screenHeight - 26, I18n.translate("gui.done")) {
             @Override
-            public void onPressed(double double_1, double double_2) {
+            public void method_1826() {
                 CreditsScreen.this.client.openScreen(parent);
                 ScreenHelper.getLastOverlay().onInitialized();
             }
@@ -58,7 +58,7 @@ public class CreditsScreen extends Screen {
     }
     
     @Override
-    public InputListener getFocused() {
+    public InputListener method_19357() {
         return entryListWidget;
     }
     

+ 2 - 2
src/main/java/me/shedaniel/rei/gui/widget/IWidget.java

@@ -28,11 +28,11 @@ public interface IWidget extends InputListener, Drawable {
     }
     
     @Override
-    default boolean mouseScrolled(double amount) {
+    default boolean mouseScrolled(double i, double j, double amount) {
         if (onMouseScrolled(amount))
             return true;
         for(IWidget widget : getListeners())
-            if (widget.mouseScrolled(amount))
+            if (widget.mouseScrolled(i, j, amount))
                 return true;
         return false;
     }

+ 59 - 0
src/main/java/me/shedaniel/rei/mixin/MixinBrewingRecipeRegistry.java

@@ -0,0 +1,59 @@
+package me.shedaniel.rei.mixin;
+
+import com.google.common.collect.Lists;
+import me.shedaniel.rei.plugin.BrewingRecipe;
+import me.shedaniel.rei.plugin.DefaultBrewingDisplay;
+import me.shedaniel.rei.plugin.DefaultPlugin;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemProvider;
+import net.minecraft.item.PotionItem;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionUtil;
+import net.minecraft.recipe.BrewingRecipeRegistry;
+import net.minecraft.recipe.Ingredient;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.Arrays;
+import java.util.List;
+
+@Mixin(BrewingRecipeRegistry.class)
+public class MixinBrewingRecipeRegistry {
+    
+    private static final List<BrewingRecipe> SELF_ITEM_RECIPES = Lists.newArrayList();
+    private static final List<Potion> REGISTERED_POTION_TYPES = Lists.newArrayList();
+    private static final List<Ingredient> SELF_POTION_TYPES = Lists.newArrayList();
+    
+    @Inject(method = "registerPotionType", at = @At("RETURN"))
+    private static void method_8080(Item item_1, CallbackInfo ci) {
+        if (item_1 instanceof PotionItem)
+            SELF_POTION_TYPES.add(Ingredient.ofItems(new ItemProvider[]{item_1}));
+    }
+    
+    @Inject(method = "registerItemRecipe", at = @At("RETURN"))
+    private static void method_8071(Item item_1, Item item_2, Item item_3, CallbackInfo ci) {
+        if (item_1 instanceof PotionItem && item_3 instanceof PotionItem)
+            SELF_ITEM_RECIPES.add(new BrewingRecipe(item_1, Ingredient.ofItems(new ItemProvider[]{item_2}), item_3));
+    }
+    
+    @Inject(method = "registerPotionRecipe", at = @At("RETURN"))
+    private static void registerPotionRecipe(Potion potion_1, Item item_1, Potion potion_2, CallbackInfo ci) {
+        if (!REGISTERED_POTION_TYPES.contains(potion_1))
+            rei_registerPotionType(potion_1);
+        if (!REGISTERED_POTION_TYPES.contains(potion_2))
+            rei_registerPotionType(potion_2);
+        SELF_POTION_TYPES.stream().map(Ingredient::getStackArray).forEach(itemStacks -> Arrays.stream(itemStacks).forEach(stack -> {
+            DefaultPlugin.registerBrewingDisplay(new DefaultBrewingDisplay(PotionUtil.setPotion(stack.copy(), potion_1), Ingredient.ofItems(new ItemProvider[]{item_1}), PotionUtil.setPotion(stack.copy(), potion_2)));
+        }));
+    }
+    
+    private static void rei_registerPotionType(Potion potion) {
+        REGISTERED_POTION_TYPES.add(potion);
+        SELF_ITEM_RECIPES.forEach(recipe -> {
+            DefaultPlugin.registerBrewingDisplay(new DefaultBrewingDisplay(PotionUtil.setPotion(recipe.input.getDefaultStack(), potion), recipe.ingredient, PotionUtil.setPotion(recipe.output.getDefaultStack(), potion)));
+        });
+    }
+    
+}

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

@@ -57,17 +57,17 @@ public class MixinContainerScreen extends Screen implements ContainerScreenHooks
     }
     
     @Override
-    public boolean mouseScrolled(double double_1) {
+    public boolean mouseScrolled(double i, double j, double double_1) {
         if (MinecraftClient.getInstance().currentScreen instanceof CreativePlayerInventoryScreen) {
             TabGetter tabGetter = (TabGetter) MinecraftClient.getInstance().currentScreen;
             if (tabGetter.rei_getSelectedTab() != ItemGroup.INVENTORY.getIndex())
-                return super.mouseScrolled(double_1);
+                return super.mouseScrolled(i, j, double_1);
         }
         ContainerScreenOverlay overlay = ScreenHelper.getLastOverlay();
         if (ScreenHelper.isOverlayVisible() && overlay.getRectangle().contains(ClientHelper.getMouseLocation()))
-            if (overlay.mouseScrolled(double_1))
+            if (overlay.mouseScrolled(i, j, double_1))
                 return true;
-        return super.mouseScrolled(double_1);
+        return super.mouseScrolled(i, j, double_1);
     }
     
     @Inject(method = "keyPressed(III)Z", at = @At("HEAD"), cancellable = true)

+ 2 - 2
src/main/java/me/shedaniel/rei/mixin/MixinCraftingTableScreen.java

@@ -26,8 +26,8 @@ public abstract class MixinCraftingTableScreen extends ContainerScreen {
     }
     
     @Override
-    public InputListener getFocused() {
-        return super.getFocused();
+    public InputListener method_19357() {
+        return super.method_19357();
     }
     
     @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)

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

@@ -29,9 +29,9 @@ public abstract class MixinCreativePlayerInventoryScreen extends AbstractPlayerI
     protected abstract boolean doRenderScrollBar();
     
     @Inject(method = "mouseScrolled", at = @At("HEAD"), cancellable = true)
-    public void mouseScrolled(double amount, CallbackInfoReturnable<Boolean> ci) {
+    public void mouseScrolled(double i, double j, double amount, CallbackInfoReturnable<Boolean> ci) {
         if (!doRenderScrollBar() && selectedTab == ItemGroup.INVENTORY.getIndex())
-            if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().getRectangle().contains(ClientHelper.getMouseLocation()) && ScreenHelper.getLastOverlay().mouseScrolled(amount)) {
+            if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().getRectangle().contains(ClientHelper.getMouseLocation()) && ScreenHelper.getLastOverlay().mouseScrolled(i, j, amount)) {
                 ci.setReturnValue(true);
                 ci.cancel();
             }

+ 2 - 2
src/main/java/me/shedaniel/rei/mixin/MixinPlayerInventoryScreen.java

@@ -27,8 +27,8 @@ public abstract class MixinPlayerInventoryScreen extends AbstractPlayerInventory
     }
     
     @Override
-    public InputListener getFocused() {
-        return super.getFocused();
+    public InputListener method_19357() {
+        return super.method_19357();
     }
     
     @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)

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

@@ -16,7 +16,6 @@ import net.minecraft.enchantment.EnchantmentHelper;
 import net.minecraft.item.ItemStack;
 import net.minecraft.item.Items;
 import net.minecraft.potion.PotionUtil;
-import net.minecraft.recipe.REIBrewingRecipeRegistry;
 import net.minecraft.recipe.Recipe;
 import net.minecraft.recipe.StonecuttingRecipe;
 import net.minecraft.recipe.cooking.BlastingRecipe;
@@ -41,6 +40,12 @@ public class DefaultPlugin implements REIPlugin {
     public static final Identifier BREWING = new Identifier("roughlyenoughitems", "plugins/brewing");
     public static final Identifier PLUGIN = new Identifier("roughlyenoughitems", "default_plugin");
     
+    private static final List<DefaultBrewingDisplay> BREWING_DISPLAYS = Lists.newArrayList();
+    
+    public static void registerBrewingDisplay(DefaultBrewingDisplay display) {
+        BREWING_DISPLAYS.add(display);
+    }
+    
     @Override
     public void onFirstLoad(PluginDisabler pluginDisabler) {
         if (!RoughlyEnoughItemsCore.getConfigManager().getConfig().loadDefaultPlugin) {
@@ -99,7 +104,7 @@ public class DefaultPlugin implements REIPlugin {
                 recipeHelper.registerDisplay(CAMPFIRE, new DefaultCampfireDisplay((CampfireCookingRecipe) recipe));
             else if (recipe instanceof StonecuttingRecipe)
                 recipeHelper.registerDisplay(STONE_CUTTING, new DefaultStoneCuttingDisplay((StonecuttingRecipe) recipe));
-        REIBrewingRecipeRegistry.registerDisplays(recipeHelper);
+        BREWING_DISPLAYS.stream().forEachOrdered(display -> recipeHelper.registerDisplay(BREWING, display));
         List<ItemStack> arrowStack = Arrays.asList(Items.ARROW.getDefaultStack());
         RoughlyEnoughItemsCore.getItemRegisterer().getItemList().stream().filter(stack -> stack.getItem().equals(Items.LINGERING_POTION)).forEach(stack -> {
             List<List<ItemStack>> input = new ArrayList<>();

+ 0 - 56
src/main/java/net/minecraft/recipe/REIBrewingRecipeRegistry.java

@@ -1,56 +0,0 @@
-package net.minecraft.recipe;
-
-import com.google.common.collect.Lists;
-import me.shedaniel.rei.api.RecipeHelper;
-import me.shedaniel.rei.plugin.BrewingRecipe;
-import me.shedaniel.rei.plugin.DefaultBrewingDisplay;
-import me.shedaniel.rei.plugin.DefaultPlugin;
-import net.minecraft.item.Item;
-import net.minecraft.potion.Potion;
-import net.minecraft.potion.PotionUtil;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class REIBrewingRecipeRegistry {
-    
-    public static void registerDisplays(RecipeHelper recipeHelper) {
-        List<Potion> registeredPotionTypes = Lists.newArrayList();
-        List<BrewingRecipe> potionItemConversions = Lists.newArrayList();
-        List<Ingredient> potionItems = REIPotionRecipeUtils.getPotionTypes();
-        REIPotionRecipeUtils.getItemRecipes().forEach(o -> {
-            try {
-                Item input = (Item) REIPotionRecipeUtils.getInputFromRecipe(o);
-                Item output = (Item) REIPotionRecipeUtils.getOutputFromRecipe(o);
-                Ingredient reagent = REIPotionRecipeUtils.getIngredientFromRecipe(o);
-                potionItemConversions.add(new BrewingRecipe(input, reagent, output));
-            } catch (Throwable throwable) {
-                throwable.printStackTrace();
-            }
-        });
-        REIPotionRecipeUtils.getPotionRecipes().forEach(o -> {
-            try {
-                Potion input = (Potion) REIPotionRecipeUtils.getInputFromRecipe(o);
-                Potion output = (Potion) REIPotionRecipeUtils.getOutputFromRecipe(o);
-                Ingredient ingredient = REIPotionRecipeUtils.getIngredientFromRecipe(o);
-                if (!registeredPotionTypes.contains(input))
-                    registerPotionType(recipeHelper, registeredPotionTypes, potionItemConversions, input);
-                if (!registeredPotionTypes.contains(output))
-                    registerPotionType(recipeHelper, registeredPotionTypes, potionItemConversions, output);
-                potionItems.stream().map(Ingredient::getStackArray).forEach(itemStacks -> Arrays.stream(itemStacks).forEach(stack -> {
-                    recipeHelper.registerDisplay(DefaultPlugin.BREWING, new DefaultBrewingDisplay(PotionUtil.setPotion(stack.copy(), input), ingredient, PotionUtil.setPotion(stack.copy(), output)));
-                }));
-            } catch (Throwable throwable) {
-                throwable.printStackTrace();
-            }
-        });
-    }
-    
-    private static void registerPotionType(RecipeHelper recipeHelper, List<Potion> list, List<BrewingRecipe> potionItemConversions, Potion potion) {
-        list.add(potion);
-        potionItemConversions.forEach(recipe -> {
-            recipeHelper.registerDisplay(DefaultPlugin.BREWING, new DefaultBrewingDisplay(PotionUtil.setPotion(recipe.input.getDefaultStack(), potion), recipe.ingredient, PotionUtil.setPotion(recipe.output.getDefaultStack(), potion)));
-        });
-    }
-    
-}

+ 0 - 36
src/main/java/net/minecraft/recipe/REIPotionRecipeUtils.java

@@ -1,36 +0,0 @@
-package net.minecraft.recipe;
-
-import com.google.common.collect.Lists;
-import me.shedaniel.cloth.api.ReflectionUtils;
-import net.minecraft.item.Item;
-import net.minecraft.potion.Potion;
-
-import java.util.List;
-
-public class REIPotionRecipeUtils {
-    
-    public static Object getInputFromRecipe(BrewingRecipeRegistry.Recipe o) throws Throwable {
-        return ReflectionUtils.getField(o, Object.class, 0).orElseThrow(ReflectionUtils.ReflectionException::new);
-    }
-    
-    public static Object getOutputFromRecipe(Object o) throws Throwable {
-        return ReflectionUtils.getField(o, Object.class, 2).orElseThrow(ReflectionUtils.ReflectionException::new);
-    }
-    
-    public static Ingredient getIngredientFromRecipe(Object o) throws Throwable {
-        return ReflectionUtils.getField(o, Ingredient.class, 1).orElseThrow(ReflectionUtils.ReflectionException::new);
-    }
-    
-    public static List<BrewingRecipeRegistry.Recipe<Item>> getItemRecipes() {
-        return ReflectionUtils.getStaticField(BrewingRecipeRegistry.class, List.class, 1).orElse(Lists.newArrayList());
-    }
-    
-    public static List<BrewingRecipeRegistry.Recipe<Potion>> getPotionRecipes() {
-        return ReflectionUtils.getStaticField(BrewingRecipeRegistry.class, List.class, 0).orElse(Lists.newArrayList());
-    }
-    
-    public static List<Ingredient> getPotionTypes() {
-        return ReflectionUtils.getStaticField(BrewingRecipeRegistry.class, List.class, 2).orElse(Lists.newArrayList());
-    }
-    
-}

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

@@ -2,7 +2,7 @@
   "id": "roughlyenoughitems",
   "name": "RoughlyEnoughItems",
   "description": "To allow players to view items and recipes. Version: ${version}",
-  "version": "2.4",
+  "version": "2.4.1",
   "side": "client",
   "authors": [
     "Danielshe"

+ 1 - 0
src/main/resources/roughlyenoughitems.client.json

@@ -8,6 +8,7 @@
     "MixinPlayerInventoryScreen",
     "MixinCraftingTableScreen",
     "MixinCreativePlayerInventoryScreen",
+    "MixinBrewingRecipeRegistry",
     "MixinTabGetter",
     "GhostSlotsHook"
   ],