aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/mixins
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-08 18:23:00 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-08 18:23:00 +0800
commit72e1653cbb38282f8dce59a00fb381e18bfc795d (patch)
tree468a1d03c3a7295b43f28e71b84856a512e72b3f /src/main/java/me/shedaniel/mixins
parent6d5101aad169bc5d4d8bcd638aee0d4ce71c120a (diff)
downloadRoughlyEnoughItems-72e1653cbb38282f8dce59a00fb381e18bfc795d.tar.gz
RoughlyEnoughItems-72e1653cbb38282f8dce59a00fb381e18bfc795d.tar.bz2
RoughlyEnoughItems-72e1653cbb38282f8dce59a00fb381e18bfc795d.zip
Craftable Only WIP
Diffstat (limited to 'src/main/java/me/shedaniel/mixins')
-rwxr-xr-xsrc/main/java/me/shedaniel/mixins/MixinContainerGui.java26
-rw-r--r--src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java18
-rwxr-xr-xsrc/main/java/me/shedaniel/mixins/MixinDoneLoading.java2
-rwxr-xr-xsrc/main/java/me/shedaniel/mixins/MixinKeyboardListener.java2
-rwxr-xr-xsrc/main/java/me/shedaniel/mixins/MixinRecipeManager.java1
5 files changed, 29 insertions, 20 deletions
diff --git a/src/main/java/me/shedaniel/mixins/MixinContainerGui.java b/src/main/java/me/shedaniel/mixins/MixinContainerGui.java
index b9bf0545b..50053998f 100755
--- a/src/main/java/me/shedaniel/mixins/MixinContainerGui.java
+++ b/src/main/java/me/shedaniel/mixins/MixinContainerGui.java
@@ -19,6 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
*/
@Mixin(ContainerGui.class)
public abstract class MixinContainerGui extends Gui implements IMixinContainerGui {
+
@Shadow
protected Slot focusedSlot;
@Shadow
@@ -40,32 +41,24 @@ public abstract class MixinContainerGui extends Gui implements IMixinContainerGu
@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)) {
+ for(GuiClick listener : Core.getListeners(GuiClick.class))
if (listener.onClick((int) p_mouseClicked_1_, (int) p_mouseClicked_3_, p_mouseClicked_5_)) {
ci.setReturnValue(true);
- handled = true;
+ ci.cancel();
}
- }
- if (handled)
- ci.cancel();
}
@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)) {
- if (listener.keyDown(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_))
- handled = true;
- }
- if (handled) {
- ci.setReturnValue(handled);
- ci.cancel();
- }
+ for(GuiKeyDown listener : Core.getListeners(GuiKeyDown.class))
+ if (listener.keyDown(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_)) {
+ ci.setReturnValue(true);
+ ci.cancel();
+ }
}
public boolean mouseScrolled(double p_mouseScrolled_1_) {
- for(MouseScrollListener listener : Core.getListeners(MouseScrollListener.class))
+ for(GuiMouseScroll listener : Core.getListeners(GuiMouseScroll.class))
if (listener.mouseScrolled(p_mouseScrolled_1_))
return true;
return super.mouseScrolled(p_mouseScrolled_1_);
@@ -100,4 +93,5 @@ public abstract class MixinContainerGui extends Gui implements IMixinContainerGu
public int getContainerWidth() {
return containerWidth;
}
+
}
diff --git a/src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java b/src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java
index 1385e374f..737f3c280 100644
--- a/src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java
+++ b/src/main/java/me/shedaniel/mixins/MixinCreativePlayerInventoryGui.java
@@ -1,6 +1,8 @@
package me.shedaniel.mixins;
import me.shedaniel.Core;
+import me.shedaniel.gui.REIRenderHelper;
+import me.shedaniel.listenerdefinitions.GuiClick;
import me.shedaniel.listenerdefinitions.GuiKeyDown;
import net.minecraft.client.gui.ingame.AbstractPlayerInventoryGui;
import net.minecraft.client.gui.ingame.CreativePlayerInventoryGui;
@@ -27,15 +29,13 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInve
@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.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;
+ ci.cancel();
+ return;
}
- if (handled)
- ci.cancel();
}
@Inject(method = "mouseScrolled(D)Z", at = @At("HEAD"), cancellable = true)
@@ -46,4 +46,14 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInve
}
}
+ @Inject(method = "mouseClicked(DDI)Z", at = @At("HEAD"), cancellable = true)
+ public void mouseClicked(double double_1, double double_2, int int_1, CallbackInfoReturnable<Boolean> ci) {
+ if (method_2469() == ItemGroup.INVENTORY.getId() && REIRenderHelper.isGuiVisible())
+ for(GuiClick guiClick : Core.getListeners(GuiClick.class))
+ if (guiClick.onClick((int) double_1, (int) double_2, int_1)) {
+ ci.setReturnValue(true);
+ ci.cancel();
+ }
+ }
+
}
diff --git a/src/main/java/me/shedaniel/mixins/MixinDoneLoading.java b/src/main/java/me/shedaniel/mixins/MixinDoneLoading.java
index 18d67479d..add3e214d 100755
--- a/src/main/java/me/shedaniel/mixins/MixinDoneLoading.java
+++ b/src/main/java/me/shedaniel/mixins/MixinDoneLoading.java
@@ -13,9 +13,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
*/
@Mixin(Bootstrap.class)
public class MixinDoneLoading {
+
@Inject(method = "initialize", at = @At("RETURN"))
private static void onBootstrapRegister(CallbackInfo ci) {
Core.LOGGER.info("REI: Done Loading");
Core.getListeners(DoneLoading.class).forEach(DoneLoading::onDoneLoading);
}
+
}
diff --git a/src/main/java/me/shedaniel/mixins/MixinKeyboardListener.java b/src/main/java/me/shedaniel/mixins/MixinKeyboardListener.java
index f7c69373e..2732db4dc 100755
--- a/src/main/java/me/shedaniel/mixins/MixinKeyboardListener.java
+++ b/src/main/java/me/shedaniel/mixins/MixinKeyboardListener.java
@@ -13,6 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
*/
@Mixin(Keyboard.class)
public class MixinKeyboardListener {
+
@Inject(method = "onChar", at = @At("RETURN"), cancellable = true)
private void onCharEvent(long p_onCharEvent_1_, int p_onCharEvent_3_, int p_onCharEvent_4_, CallbackInfo ci) {
boolean handled = false;
@@ -24,4 +25,5 @@ public class MixinKeyboardListener {
if (handled)
ci.cancel();
}
+
}
diff --git a/src/main/java/me/shedaniel/mixins/MixinRecipeManager.java b/src/main/java/me/shedaniel/mixins/MixinRecipeManager.java
index 8fffc11dd..cef555f8d 100755
--- a/src/main/java/me/shedaniel/mixins/MixinRecipeManager.java
+++ b/src/main/java/me/shedaniel/mixins/MixinRecipeManager.java
@@ -23,4 +23,5 @@ public class MixinRecipeManager {
listener.recipesLoaded(recipeManager);
}
}
+
}