Jelajahi Sumber

Fixed Crash + Downgraded Loom

Unknown 6 tahun lalu
induk
melakukan
028c0e3192

+ 2 - 2
build.gradle

@@ -1,12 +1,12 @@
 plugins {
-	id 'fabric-loom' version '0.2.0-SNAPSHOT'
+	id 'fabric-loom' version '0.1.0-SNAPSHOT'
 }
 
 sourceCompatibility = 1.8
 targetCompatibility = 1.8
 
 archivesBaseName = "RoughlyEnoughItems"
-version = "1.0-1"
+version = "1.0-2"
 
 minecraft {
 }

+ 0 - 1
src/main/java/me/shedaniel/mixins/MixinBrewingRecipeRegistry.java

@@ -15,7 +15,6 @@ public class MixinBrewingRecipeRegistry {
     
     @Inject(method = "registerPotionRecipe", at = @At("RETURN"))
     private static void registerPotionRecipe(Potion potion_1, Item item_1, Potion potion_2, CallbackInfo info) {
-        System.out.println("a");
         Core.getListeners(PotionCraftingAdder.class).forEach(potionCraftingAdder -> potionCraftingAdder.addPotionRecipe(potion_1, item_1, potion_2));
     }
     

+ 13 - 18
src/main/java/me/shedaniel/mixins/MixinGuiContainer.java → src/main/java/me/shedaniel/mixins/MixinContainerGui.java

@@ -4,7 +4,7 @@ import me.shedaniel.Core;
 import me.shedaniel.listenerdefinitions.*;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.ContainerGui;
-import net.minecraft.client.gui.GuiEventListener;
+import net.minecraft.client.gui.Gui;
 import net.minecraft.container.Slot;
 import net.minecraft.item.ItemStack;
 import org.spongepowered.asm.mixin.Mixin;
@@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
  * Created by James on 7/27/2018.
  */
 @Mixin(ContainerGui.class)
-public abstract class MixinGuiContainer implements GuiEventListener, IMixinContainerGui {
+public abstract class MixinContainerGui extends Gui implements IMixinContainerGui {
     @Shadow
     protected Slot focusedSlot;
     @Shadow
@@ -32,15 +32,14 @@ public abstract class MixinGuiContainer implements GuiEventListener, IMixinConta
     @Shadow
     protected int containerHeight;
     
-    @Inject(method = "draw", at = @At("RETURN"))
-    private void onRender(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_, CallbackInfo ci) {
-        for(DrawContainer listener : Core.getListeners(DrawContainer.class)) {
-            listener.draw(p_drawScreen_1_, p_drawScreen_2_, p_drawScreen_3_, (ContainerGui) MinecraftClient.getInstance().currentGui);
-        }
+    @Inject(method = "draw(IIF)V", at = @At("RETURN"))
+    public void draw(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_, CallbackInfo ci) {
+        Core.getListeners(DrawContainer.class).forEach(drawContainer ->
+                drawContainer.draw(p_drawScreen_1_, p_drawScreen_2_, p_drawScreen_3_, (ContainerGui) MinecraftClient.getInstance().currentGui));
     }
     
-    @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)
-    private void onMouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_, CallbackInfoReturnable<Boolean> ci) {
+    @Inject(method = "mouseClicked(DDI)Z", at = @At("HEAD"), cancellable = true)
+    private void mouseClick(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_, CallbackInfoReturnable<Boolean> ci) {
         boolean handled = false;
         for(GuiCickListener listener : Core.getListeners(GuiCickListener.class)) {
             if (listener.onClick((int) p_mouseClicked_1_, (int) p_mouseClicked_3_, p_mouseClicked_5_)) {
@@ -50,10 +49,9 @@ public abstract class MixinGuiContainer implements GuiEventListener, IMixinConta
         }
         if (handled)
             ci.cancel();
-        
     }
     
-    @Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
+    @Inject(method = "keyPressed(III)Z", at = @At("HEAD"), cancellable = true)
     private void onKeyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_, CallbackInfoReturnable<Boolean> ci) {
         boolean handled = false;
         for(GuiKeyDown listener : Core.getListeners(GuiKeyDown.class)) {
@@ -67,13 +65,10 @@ public abstract class MixinGuiContainer implements GuiEventListener, IMixinConta
     }
     
     public boolean mouseScrolled(double p_mouseScrolled_1_) {
-        boolean handled = false;
-        for(MouseScrollListener listener : Core.getListeners(MouseScrollListener.class)) {
-            if (listener.mouseScrolled(p_mouseScrolled_1_)) {
-                handled = true;
-            }
-        }
-        return handled;
+        for(MouseScrollListener listener : Core.getListeners(MouseScrollListener.class))
+            if (listener.mouseScrolled(p_mouseScrolled_1_))
+                return true;
+        return super.mouseScrolled(p_mouseScrolled_1_);
     }
     
     @Override

+ 54 - 0
src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java

@@ -0,0 +1,54 @@
+package me.shedaniel.mixins;
+
+import me.shedaniel.Core;
+import me.shedaniel.listenerdefinitions.GuiKeyDown;
+import net.minecraft.client.gui.ingame.AbstractPlayerInventoryGui;
+import net.minecraft.client.gui.ingame.CreativePlayerInventoryGui;
+import net.minecraft.client.gui.widget.TextFieldWidget;
+import net.minecraft.container.Container;
+import net.minecraft.container.Slot;
+import net.minecraft.item.ItemGroup;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(CreativePlayerInventoryGui.class)
+public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInventoryGui {
+    
+    @Shadow
+    public abstract int method_2469();
+    
+    @Shadow
+    protected abstract boolean doRenderScrollBar();
+    
+    public MixinCreativePlayerInventoryGui(Container container_1) {
+        super(container_1);
+    }
+    
+    @Inject(method = "keyPressed(III)Z", at = @At("HEAD"), cancellable = true)
+    public void keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_, CallbackInfoReturnable<Boolean> ci) {
+        boolean handled = false;
+        if (method_2469() != ItemGroup.SEARCH.getId()) {
+            if (method_2469() == ItemGroup.INVENTORY.getId()) {
+                for(GuiKeyDown listener : Core.getListeners(GuiKeyDown.class))
+                    if (listener.keyDown(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_)) {
+                        ci.setReturnValue(true);
+                        handled = true;
+                    }
+            }
+        }
+        if (handled)
+            ci.cancel();
+    }
+    
+    @Inject(method = "mouseScrolled(D)Z", at = @At("HEAD"), cancellable = true)
+    public void mouseScrolled(double p_mouseScrolled_1_, CallbackInfoReturnable<Boolean> ci) {
+        if (!this.doRenderScrollBar()) {
+            ci.setReturnValue(super.mouseScrolled(p_mouseScrolled_1_));
+            ci.cancel();
+        }
+    }
+    
+}

+ 0 - 93
src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java

@@ -1,93 +0,0 @@
-package me.shedaniel.mixins;
-
-import me.shedaniel.Core;
-import me.shedaniel.listenerdefinitions.GuiKeyDown;
-import net.minecraft.client.gui.ingame.AbstractPlayerInventoryGui;
-import net.minecraft.client.gui.ingame.CreativePlayerInventoryGui;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.container.Container;
-import net.minecraft.container.Slot;
-import net.minecraft.item.ItemGroup;
-import net.minecraft.util.math.MathHelper;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Overwrite;
-import org.spongepowered.asm.mixin.Shadow;
-
-import java.util.Objects;
-
-@Mixin(CreativePlayerInventoryGui.class)
-public abstract class MixinGuiContainerCreative extends AbstractPlayerInventoryGui {
-    
-    @Shadow
-    private boolean field_2888;
-    
-    @Shadow
-    public abstract int method_2469();
-    
-    @Shadow
-    protected abstract void setSelectedTab(ItemGroup itemGroup_1);
-    
-    @Shadow
-    protected abstract boolean method_2470(Slot slot_1);
-    
-    @Shadow
-    private TextFieldWidget searchBox;
-    
-    @Shadow
-    protected abstract void method_2464();
-    
-    @Shadow
-    protected abstract boolean doRenderScrollBar();
-    
-    @Shadow
-    private float scrollPosition;
-    
-    public MixinGuiContainerCreative(Container container_1) {
-        super(container_1);
-    }
-    
-    @Overwrite
-    public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) {
-        this.field_2888 = false;
-        if (method_2469() != ItemGroup.SEARCH.getId()) {
-            if (method_2469() != ItemGroup.INVENTORY.getId()) {
-                if (this.client.options.keyChat.matches(p_keyPressed_1_, p_keyPressed_2_)) {
-                    this.field_2888 = true;
-                    this.setSelectedTab(ItemGroup.SEARCH);
-                    return true;
-                }
-            } else for(GuiKeyDown listener : Core.getListeners(GuiKeyDown.class))
-                if (listener.keyDown(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_))
-                    return true;
-        } else {
-            boolean flag = !this.method_2470(this.focusedSlot) || this.focusedSlot != null && this.focusedSlot.hasStack();
-            if (flag && this.handleHotbarKeyPressed(p_keyPressed_1_, p_keyPressed_2_)) {
-                this.field_2888 = true;
-                return true;
-            } else {
-                String s = this.searchBox.getText();
-                
-                if (this.searchBox.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_)) {
-                    if (!Objects.equals(s, this.searchBox.getText()))
-                        this.method_2464();
-                    return true;
-                }
-            }
-        }
-        return super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_);
-    }
-    
-    @Overwrite
-    public boolean mouseScrolled(double p_mouseScrolled_1_) {
-        if (!this.doRenderScrollBar()) {
-            return super.mouseScrolled(p_mouseScrolled_1_);
-        } else {
-            int i = (((CreativePlayerInventoryGui.CreativeContainer) this.container).itemList.size() + 9 - 1) / 9 - 5;
-            this.scrollPosition = (float) ((double) this.scrollPosition - p_mouseScrolled_1_ / (double) i);
-            this.scrollPosition = MathHelper.clamp(this.scrollPosition, 0.0F, 1.0F);
-            ((CreativePlayerInventoryGui.CreativeContainer) this.container).method_2473(this.scrollPosition);
-            return true;
-        }
-    }
-    
-}

+ 4 - 4
src/main/java/me/shedaniel/mixins/SettingsMixin.java

@@ -19,8 +19,8 @@ import java.util.List;
 
 @Mixin(GameOptions.class)
 public class SettingsMixin {
-    @Shadow
-    public KeyBinding[] keyBindings;
+    
+    @Shadow public KeyBinding[] keysAll;
     
     public SettingsMixin() {
         System.out.println("loaded");
@@ -34,9 +34,9 @@ public class SettingsMixin {
     private void processNewBindings(List<KeyBinding> newBindings) {
         List<KeyBinding> toAdd = new ArrayList<>();
         toAdd.addAll(newBindings);
-        for(KeyBinding keyBinding : keyBindings)
+        for(KeyBinding keyBinding : keysAll)
             toAdd.add(keyBinding);
-        keyBindings = (KeyBinding[]) toAdd.toArray(new KeyBinding[0]);
+        keysAll = (KeyBinding[]) toAdd.toArray(new KeyBinding[0]);
     }
     
 }

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

@@ -1,7 +1,7 @@
 {
   "id": "roughlyenoughitems",
   "name": "RoughlyEnoughItems",
-  "description": "This is an example description! Tell everyone what your mod is about!",
+  "description": "To allow players to view items and recipes.",
   "version": "1.0-SNAPSHOT",
   "side": "client",
   "authors": [
@@ -11,7 +11,7 @@
     "me.shedaniel.Core"
   ],
   "requires": {
-    "fabric": "*"
+
   },
   "mixins": {
     "client": "roughlyenoughitems.client.json"

+ 0 - 26
src/main/resources/riftmod.json

@@ -1,26 +0,0 @@
-{
-  "id": "roughlyenoughitems",
-  "name": "RoughlyEnoughItems",
-  "version": "1.0-SNAPSHOT",
-  "authors": [
-    "ZenDarva",
-    "Danielshe"
-  ],
-  "listeners": [
-    "me.shedaniel.Core",
-    "me.shedaniel.listeners.InitListener",
-    "me.shedaniel.listeners.DrawContainerListener",
-    "me.shedaniel.listeners.ResizeListener",
-    "me.shedaniel.library.KeyBindManager",
-    {
-      "class": "me.shedaniel.plugin.VanillaPlugin",
-      "side": "client"
-    },
-    {
-      "class": "me.shedaniel.ClientListener",
-      "side": "client"
-    }
-  ],
-  "url": "https://shedaniel.me",
-  "description": "An AEI fork to look like JEI"
-}

+ 2 - 2
src/main/resources/roughlyenoughitems.client.json

@@ -5,11 +5,11 @@
   "mixins": [
     "MixinDoneLoading",
     "MixinBrewingRecipeRegistry",
-    "MixinGuiContainer",
+    "MixinContainerGui",
     "MixinMinecraftResize",
     "MixinKeyboardListener",
     "MixinRecipeManager",
-    "MixinGuiContainerCreative",
+    "MixinCreativePlayerInventoryGui",
     "MixinMinecraftClient"
   ],
   "injectors": {