|
5 | 5 | import de.hysky.skyblocker.SkyblockerMod; |
6 | 6 | import de.hysky.skyblocker.annotations.Init; |
7 | 7 | import de.hysky.skyblocker.config.SkyblockerConfigManager; |
| 8 | +import de.hysky.skyblocker.mixins.accessors.AbstractContainerScreenAccessor; |
8 | 9 | import de.hysky.skyblocker.utils.Constants; |
9 | 10 | import de.hysky.skyblocker.utils.Location; |
10 | 11 | import de.hysky.skyblocker.utils.Utils; |
|
16 | 17 | import net.minecraft.client.KeyMapping; |
17 | 18 | import net.minecraft.client.Minecraft; |
18 | 19 | import net.minecraft.client.gui.GuiGraphicsExtractor; |
| 20 | +import net.minecraft.client.gui.screens.Screen; |
19 | 21 | import net.minecraft.client.player.LocalPlayer; |
20 | 22 | import net.minecraft.client.renderer.RenderPipelines; |
21 | 23 | import net.minecraft.commands.CommandBuildContext; |
22 | 24 | import net.minecraft.network.chat.Component; |
23 | 25 | import net.minecraft.resources.Identifier; |
24 | 26 | import net.minecraft.world.InteractionHand; |
25 | 27 | import net.minecraft.world.InteractionResult; |
| 28 | +import net.minecraft.world.inventory.Slot; |
26 | 29 | import net.minecraft.world.entity.Entity; |
27 | 30 | import net.minecraft.world.entity.decoration.ItemFrame; |
28 | 31 | import net.minecraft.world.entity.player.Player; |
@@ -124,7 +127,13 @@ public static void handleKeyPressed(ItemStack heldItem) { |
124 | 127 | } |
125 | 128 |
|
126 | 129 | public static void handleHotbarKeyPressed(LocalPlayer player) { |
127 | | - if (Minecraft.getInstance().screen != null) return; |
| 130 | + Screen currentScreen = Minecraft.getInstance().screen; |
| 131 | + if (currentScreen instanceof AbstractContainerScreenAccessor containerScreen) { |
| 132 | + Slot hoveredSlot = containerScreen.getFocusedSlot(); |
| 133 | + if (hoveredSlot == null || hoveredSlot.container != player.getInventory()) return; |
| 134 | + } else if (currentScreen != null) { |
| 135 | + return; |
| 136 | + } |
128 | 137 | while (itemProtection.consumeClick()) { |
129 | 138 | ItemStack heldItem = player.getMainHandItem(); |
130 | 139 | handleKeyPressed(heldItem); |
|
0 commit comments