diff options
author | nea <nea@nea.moe> | 2023-10-28 03:36:11 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2023-11-12 09:35:33 +0100 |
commit | e15406e22ef65b4933274df791632b6c17f594be (patch) | |
tree | e1625c713bf95e9f0cb65dfe9a7c9b9ceaa46402 /src/main/java/moe/nea | |
parent | 47fbb25ab280b6af9496780672780db78fe36f27 (diff) | |
download | Firmament-e15406e22ef65b4933274df791632b6c17f594be.tar.gz Firmament-e15406e22ef65b4933274df791632b6c17f594be.tar.bz2 Firmament-e15406e22ef65b4933274df791632b6c17f594be.zip |
Add Inventory Buttons
Diffstat (limited to 'src/main/java/moe/nea')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java | 11 | ||||
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java | 15 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java index 3972ffc..35856cb 100644 --- a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java +++ b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java @@ -35,6 +35,10 @@ public abstract class MixinHandledScreen<T extends ScreenHandler> { @Shadow public abstract T getScreenHandler(); + @Shadow + protected int y; + @Shadow + protected int x; @Unique PlayerInventory playerInventory; @@ -52,14 +56,17 @@ public abstract class MixinHandledScreen<T extends ScreenHandler> { @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) public void onMouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) { - if (ScreenClickEvent.Companion.publish(new ScreenClickEvent((HandledScreen<?>) (Object) this, mouseX, mouseY, button)).getCancelled()) { + if (HandledScreenClickEvent.Companion.publish(new HandledScreenClickEvent((HandledScreen<?>) (Object) this, mouseX, mouseY, button)).getCancelled()) { cir.setReturnValue(true); } } @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawForeground(Lnet/minecraft/client/gui/DrawContext;II)V", shift = At.Shift.AFTER)) public void onAfterRenderForeground(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { - HandledScreenForegroundEvent.Companion.publish(new HandledScreenForegroundEvent((HandledScreen<?>) (Object) this, mouseX, mouseY, delta)); + context.getMatrices().push(); + context.getMatrices().translate(-x, -y, 0); + HandledScreenForegroundEvent.Companion.publish(new HandledScreenForegroundEvent((HandledScreen<?>) (Object) this, context, mouseX, mouseY, delta)); + context.getMatrices().pop(); } @Inject(method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java index c42f819..b14717d 100644 --- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java +++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java @@ -6,6 +6,7 @@ package moe.nea.firmament.mixins.accessor; +import me.shedaniel.math.Rectangle; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.screen.slot.Slot; import org.jetbrains.annotations.Nullable; @@ -17,4 +18,18 @@ public interface AccessorHandledScreen { @Accessor("focusedSlot") @Nullable Slot getFocusedSlot_Firmament(); + + @Accessor("backgroundWidth") + int getBackgroundWidth_Firmament(); + + @Accessor("backgroundHeight") + int getBackgroundHeight_Firmament(); + + @Accessor("x") + int getX_Firmament(); + + @Accessor("y") + int getY_Firmament(); + + } |