diff --git a/src/main/java/io/wispforest/owo/mixin/ui/HandledScreenMixin.java b/src/main/java/io/wispforest/owo/mixin/ui/HandledScreenMixin.java index 8fc57f01..4878e907 100644 --- a/src/main/java/io/wispforest/owo/mixin/ui/HandledScreenMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/ui/HandledScreenMixin.java @@ -64,20 +64,6 @@ private void clearSlotScissors(DrawContext context, Slot slot, CallbackInfo ci) GlStateManager._disableScissorTest(); } - // TODO: [1.21.2-Porting] Figure out f such is still needed and how to handle such -// @Inject(method = "drawSlotHighlight", at = @At(value = "HEAD")) -// private static void enableSlotDepth(DrawContext context, int x, int y, int z, CallbackInfo ci) { -// if (!owo$inOwoScreen) return; -// RenderSystem.enableDepthTest(); -// context.getMatrices().translate(0, 0, 300); -// } -// -// @Inject(method = "drawSlotHighlight", at = @At("TAIL")) -// private static void clearSlotDepth(DrawContext context, int x, int y, int z, CallbackInfo ci) { -// if (!owo$inOwoScreen) return; -// context.getMatrices().translate(0, 0, -300); -// } - @ModifyVariable(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/SimpleOption;getValue()Ljava/lang/Object;", ordinal = 0), ordinal = 3) private int doNoThrow(int slotId, @Local() Slot slot) { return (((Object) this instanceof BaseOwoHandledScreen) && slot != null) ? slot.id : slotId; diff --git a/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java b/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java index 2ff6d0c9..ab806ffb 100644 --- a/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java +++ b/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java @@ -13,6 +13,7 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.slot.Slot; import net.minecraft.text.Text; @@ -330,4 +331,44 @@ public void updateY(int y) { ((SlotAccessor) this.slot).owo$setY(y - BaseOwoHandledScreen.this.y); } } + + @Override + protected void drawSlotHighlightBack(DrawContext context) { + context.translate(0, 0, getOffsetAmount(true)); + + super.drawSlotHighlightBack(context); + } + + @Override + protected void drawSlotHighlightFront(DrawContext context) { + super.drawSlotHighlightFront(context); + + context.translate(0, 0, -getOffsetAmount(true)); + } + + @Override + protected void drawItem(DrawContext context, ItemStack stack, int x, int y, @Nullable String amountText) { + var offset = getOffsetAmount(false); + + context.translate(0, 0, offset); + + super.drawItem(context, stack, x, y, amountText); + + context.translate(0, 0, -offset); + } + + @Override + protected void drawMouseoverTooltip(DrawContext context, int x, int y) { + var offset = getOffsetAmount(false); + + context.translate(0, 0, offset); + + super.drawMouseoverTooltip(context, x, y); + + context.translate(0, 0, offset); + } + + protected int getOffsetAmount(boolean slotRendering) { + return 300; + } } diff --git a/src/main/resources/owo.accesswidener b/src/main/resources/owo.accesswidener index 29dc5223..15f60296 100644 --- a/src/main/resources/owo.accesswidener +++ b/src/main/resources/owo.accesswidener @@ -9,4 +9,8 @@ transitive-accessible class net/minecraft/item/ItemGroup$EntriesImpl transitive-accessible class net/minecraft/client/gui/DrawContext$ScissorStack transitive-extendable method net/minecraft/client/gui/widget/CheckboxWidget (IIILnet/minecraft/text/Text;Lnet/minecraft/client/font/TextRenderer;ZLnet/minecraft/client/gui/widget/CheckboxWidget$Callback;)V -accessible class net/minecraft/registry/RegistryOps$CachedRegistryInfoGetter \ No newline at end of file +accessible class net/minecraft/registry/RegistryOps$CachedRegistryInfoGetter + +extendable method net/minecraft/client/gui/screen/ingame/HandledScreen drawSlotHighlightBack (Lnet/minecraft/client/gui/DrawContext;)V +extendable method net/minecraft/client/gui/screen/ingame/HandledScreen drawSlotHighlightFront (Lnet/minecraft/client/gui/DrawContext;)V +extendable method net/minecraft/client/gui/screen/ingame/HandledScreen drawItem (Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V \ No newline at end of file