diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2018-12-31 17:42:05 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2018-12-31 17:42:05 +0800 |
| commit | 1266857add2c1705f57141bfd4feacfc71bcc712 (patch) | |
| tree | 4696fabf49f99728fc7ae066d151795ec5fd9bb2 | |
| parent | aaa031a36408b96b6eef5351fd60e979112f0cea (diff) | |
| download | RoughlyEnoughItems-1266857add2c1705f57141bfd4feacfc71bcc712.tar.gz RoughlyEnoughItems-1266857add2c1705f57141bfd4feacfc71bcc712.tar.bz2 RoughlyEnoughItems-1266857add2c1705f57141bfd4feacfc71bcc712.zip | |
Fixed Crash + Downgraded Loom
| -rwxr-xr-x | build.gradle | 4 | ||||
| -rw-r--r-- | src/main/java/me/shedaniel/mixins/MixinBrewingRecipeRegistry.java | 1 | ||||
| -rwxr-xr-x | src/main/java/me/shedaniel/mixins/MixinContainerGui.java (renamed from src/main/java/me/shedaniel/mixins/MixinGuiContainer.java) | 31 | ||||
| -rw-r--r-- | src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java | 54 | ||||
| -rw-r--r-- | src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java | 93 | ||||
| -rwxr-xr-x | src/main/java/me/shedaniel/mixins/SettingsMixin.java | 8 | ||||
| -rwxr-xr-x | src/main/resources/fabric.mod.json | 4 | ||||
| -rw-r--r-- | src/main/resources/riftmod.json | 26 | ||||
| -rwxr-xr-x | src/main/resources/roughlyenoughitems.client.json | 4 |
9 files changed, 77 insertions, 148 deletions
diff --git a/build.gradle b/build.gradle index 7b686ef8a..74b8880d8 100755 --- a/build.gradle +++ b/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 { } diff --git a/src/main/java/me/shedaniel/mixins/MixinBrewingRecipeRegistry.java b/src/main/java/me/shedaniel/mixins/MixinBrewingRecipeRegistry.java index 606634ebb..bc36c8315 100644 --- a/src/main/java/me/shedaniel/mixins/MixinBrewingRecipeRegistry.java +++ b/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)); } diff --git a/src/main/java/me/shedaniel/mixins/MixinGuiContainer.java b/src/main/java/me/shedaniel/mixins/MixinContainerGui.java index 69adb45ad..a645bdd2d 100755 --- a/src/main/java/me/shedaniel/mixins/MixinGuiContainer.java +++ b/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 diff --git a/src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java b/src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java new file mode 100644 index 000000000..d9cfddfdd --- /dev/null +++ b/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(); + } + } + +} diff --git a/src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java b/src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java deleted file mode 100644 index 455266c8d..000000000 --- a/src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java +++ /dev/null @@ -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; - } - } - -} diff --git a/src/main/java/me/shedaniel/mixins/SettingsMixin.java b/src/main/java/me/shedaniel/mixins/SettingsMixin.java index bc7408d6e..5182f5ccd 100755 --- a/src/main/java/me/shedaniel/mixins/SettingsMixin.java +++ b/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]); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 949a448a5..6feb0ba7e 100755 --- a/src/main/resources/fabric.mod.json +++ b/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" diff --git a/src/main/resources/riftmod.json b/src/main/resources/riftmod.json deleted file mode 100644 index 2cc490162..000000000 --- a/src/main/resources/riftmod.json +++ /dev/null @@ -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" -}
\ No newline at end of file diff --git a/src/main/resources/roughlyenoughitems.client.json b/src/main/resources/roughlyenoughitems.client.json index 7a381b0e5..90a581009 100755 --- a/src/main/resources/roughlyenoughitems.client.json +++ b/src/main/resources/roughlyenoughitems.client.json @@ -5,11 +5,11 @@ "mixins": [ "MixinDoneLoading", "MixinBrewingRecipeRegistry", - "MixinGuiContainer", + "MixinContainerGui", "MixinMinecraftResize", "MixinKeyboardListener", "MixinRecipeManager", - "MixinGuiContainerCreative", + "MixinCreativePlayerInventoryGui", "MixinMinecraftClient" ], "injectors": { |
