diff options
author | DoKM <mcazzyman@gmail.com> | 2021-08-09 22:43:33 +0200 |
---|---|---|
committer | DoKM <mcazzyman@gmail.com> | 2021-08-09 22:43:33 +0200 |
commit | 8f010423e71ff5017104762511ef08f67eb5a87a (patch) | |
tree | b926e52df8095a453e5f6960b6ba2d354e272906 /src | |
parent | 9b3b7163d0e2643e4dce82299315ec8bde8a0420 (diff) | |
download | NotEnoughUpdates-8f010423e71ff5017104762511ef08f67eb5a87a.tar.gz NotEnoughUpdates-8f010423e71ff5017104762511ef08f67eb5a87a.tar.bz2 NotEnoughUpdates-8f010423e71ff5017104762511ef08f67eb5a87a.zip |
Fixed not being able to use keybinds while hovering over locked slots
Took way longer than it could have cause i couldnt find out why something was null smh
Diffstat (limited to 'src')
3 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java index 256cf03f..cd128ebe 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java @@ -79,6 +79,14 @@ public class SlotLocking { private boolean lockKeyHeld = false; private Slot pairingSlot = null; + private Slot realSlot = null; + + public void setRealSlot(Slot slot){ + realSlot = slot; + } + + public Slot getRealSlot(){ return realSlot;} + public void loadConfig(File file) { try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { config = GSON.fromJson(reader, SlotLockingConfig.class); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java index e527e18e..3ed16e76 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -101,7 +101,10 @@ public abstract class MixinGuiContainer extends GuiScreen { @Inject(method="drawScreen", at=@At("RETURN")) public void drawScreen(CallbackInfo ci) { if(theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) { + SlotLocking.getInstance().setRealSlot(theSlot); theSlot = null; + } else if( theSlot == null){ + SlotLocking.getInstance().setRealSlot(null); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index a4af51ca..5ca9b316 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -8,6 +8,7 @@ import com.mojang.authlib.Agent; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.util.TexLoc; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -433,7 +434,11 @@ public class Utils { } public static Slot getSlotUnderMouse(GuiContainer container) { - return (Slot) getField(GuiContainer.class, container, "theSlot", "field_147006_u"); + Slot slot = (Slot) getField(GuiContainer.class, container, "theSlot", "field_147006_u"); + if(slot == null){ + slot = SlotLocking.getInstance().getRealSlot(); + } + return slot; } public static void drawTexturedRect(float x, float y, float width, float height) { |