diff options
author | Linnea Gräf <nea@nea.moe> | 2025-06-22 16:20:57 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-06-22 16:26:57 +0200 |
commit | d60276a4c153f35d5f55708999dcdeb498eed25a (patch) | |
tree | 96b08e05932f5d6e1897b4092bdd39ca785e85f4 | |
parent | c3094313212b260c3d5f869e65e58a518efdfbd9 (diff) | |
download | Firmament-d60276a4c153f35d5f55708999dcdeb498eed25a.tar.gz Firmament-d60276a4c153f35d5f55708999dcdeb498eed25a.tar.bz2 Firmament-d60276a4c153f35d5f55708999dcdeb498eed25a.zip |
fix: Clicking outside inventory bounds in custom screen layouts dropping items
-rw-r--r-- | src/texturePacks/java/moe/nea/firmament/mixins/custommodels/screenlayouts/ExpandScreenBoundaries.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/screenlayouts/ExpandScreenBoundaries.java b/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/screenlayouts/ExpandScreenBoundaries.java new file mode 100644 index 0000000..e2cae45 --- /dev/null +++ b/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/screenlayouts/ExpandScreenBoundaries.java @@ -0,0 +1,21 @@ +package moe.nea.firmament.mixins.custommodels.screenlayouts; + +import moe.nea.firmament.features.texturepack.CustomScreenLayouts; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.gui.screen.ingame.RecipeBookScreen; +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.CallbackInfoReturnable; + +@Mixin({HandledScreen.class, RecipeBookScreen.class}) +public class ExpandScreenBoundaries { + @Inject(method = "isClickOutsideBounds", at = @At("HEAD"), cancellable = true) + private void onClickOutsideBounds(double mouseX, double mouseY, int left, int top, int button, CallbackInfoReturnable<Boolean> cir) { + var background = CustomScreenLayouts.getMover(CustomScreenLayouts.CustomScreenLayout::getBackground); + if (background == null) return; + var x = background.getX() + left; + var y = background.getY() + top; + cir.setReturnValue(mouseX < (double) x || mouseY < (double) y || mouseX >= (double) (x + background.getWidth()) || mouseY >= (double) (y + background.getHeight())); + } +} |