aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java
diff options
context:
space:
mode:
authorAnthony Hilyard <anthony.hilyard@gmail.com>2021-10-25 13:17:00 -0700
committerAnthony Hilyard <anthony.hilyard@gmail.com>2021-10-25 13:17:00 -0700
commit730ec4f0faaf99e231279fdc026566f9970afb23 (patch)
treee84bd462ed7c482e958924d242853f5904f8e51f /src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java
parentec4c5aebf3b5b5af872c6b168c02bedd2bd5a9e3 (diff)
downloadIceberg-730ec4f0faaf99e231279fdc026566f9970afb23.tar.gz
Iceberg-730ec4f0faaf99e231279fdc026566f9970afb23.tar.bz2
Iceberg-730ec4f0faaf99e231279fdc026566f9970afb23.zip
Fixed crash issue in creative inventory. Fixed tooltip rendering issue.
Enabled mixins.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java
index 225499f..fdd3c9d 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java
@@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@@ -22,6 +21,7 @@ import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
@Mixin(Screen.class)
@@ -35,17 +35,19 @@ public class ScreenMixin extends AbstractContainerEventHandler
private final List<GuiEventListener> children = Lists.newArrayList();
@SuppressWarnings("unchecked")
- @Inject(method = "renderTooltipInternal",
- at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/entity/ItemRenderer;blitOffset:F", ordinal = 2, shift = Shift.AFTER),
- locals = LocalCapture.CAPTURE_FAILEXCEPTION)
+ @Inject(method = "renderTooltipInternal", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void renderTooltipInternal(PoseStack poseStack, List<ClientTooltipComponent> components, int x, int y, CallbackInfo info, int tooltipWidth, int tooltipHeight, int postX, int postY)
{
- if (!components.isEmpty())
+ if ((Screen)(Object)this instanceof AbstractContainerScreen)
{
- if ((Screen)(Object)this instanceof AbstractContainerScreen)
+ if (!components.isEmpty())
{
- ItemStack tooltipStack = ((AbstractContainerScreen<AbstractContainerMenu>)(Object)this).hoveredSlot.getItem();
- RenderTooltipEvents.POST.invoker().onPost(tooltipStack, components, poseStack, x, y, font, tooltipWidth, tooltipHeight, false);
+ Slot hoveredSlot = ((AbstractContainerScreen<AbstractContainerMenu>)(Object)this).hoveredSlot;
+ if (hoveredSlot != null)
+ {
+ ItemStack tooltipStack = hoveredSlot.getItem();
+ RenderTooltipEvents.POST.invoker().onPost(tooltipStack, components, poseStack, x, y, font, tooltipWidth, tooltipHeight, false);
+ }
}
}
}