|
2 | 2 |
|
3 | 3 | import com.BookKeeper.InventoryNetwork.api.SchematicSyncApiImpl; |
4 | 4 | import com.BookKeeper.InventoryNetwork.api.SchematicSyncApiProvider; |
| 5 | +import com.BookKeeper.InventoryNetwork.ui.HelloWorldOverlay; |
5 | 6 | import com.BookKeeper.InventoryNetwork.ui.InventoryPanelOverlay; |
| 7 | +import com.BookKeeper.InventoryNetwork.ultralight.UltralightInventoryOverlay; |
6 | 8 | import net.fabricmc.api.ClientModInitializer; |
| 9 | +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; |
| 10 | +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; |
| 11 | +import net.minecraft.client.KeyMapping; |
| 12 | +import com.mojang.blaze3d.platform.InputConstants; |
| 13 | +import net.minecraft.resources.ResourceLocation; |
| 14 | +import org.lwjgl.glfw.GLFW; |
7 | 15 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; |
8 | 16 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; |
9 | 17 | import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; |
@@ -55,6 +63,15 @@ public class InventoryNetworkModClient implements ClientModInitializer { |
55 | 63 | // Tick counter for periodic tasks |
56 | 64 | private int tickCounter = 0; |
57 | 65 |
|
| 66 | + // Hello World overlay keybind |
| 67 | + private static KeyMapping helloWorldKey; |
| 68 | + |
| 69 | + // Ultralight Inventory overlay keybind |
| 70 | + private static KeyMapping ultralightInventoryKey; |
| 71 | + |
| 72 | + // Ultralight render mode toggle keybind |
| 73 | + private static KeyMapping ultralightRenderModeKey; |
| 74 | + |
58 | 75 | // Track if chest was open in previous tick (for detecting close) |
59 | 76 | private boolean wasChestOpen = false; |
60 | 77 |
|
@@ -128,6 +145,43 @@ public void onInitializeClient() { |
128 | 145 | // Register client tick event |
129 | 146 | ClientTickEvents.END_CLIENT_TICK.register(this::onClientTick); |
130 | 147 |
|
| 148 | + // Register Hello World keybind (H key) |
| 149 | + helloWorldKey = new KeyMapping( |
| 150 | + "key.inventorynetwork.helloworld", |
| 151 | + InputConstants.Type.KEYSYM, |
| 152 | + GLFW.GLFW_KEY_H, |
| 153 | + new KeyMapping.Category(ResourceLocation.fromNamespaceAndPath("inventorynetwork", "keys")) |
| 154 | + ); |
| 155 | + KeyBindingHelper.registerKeyBinding(helloWorldKey); |
| 156 | + |
| 157 | + // Register HUD render callback for Hello World overlay |
| 158 | + HudRenderCallback.EVENT.register((guiGraphics, tickCounter) -> { |
| 159 | + HelloWorldOverlay.render(guiGraphics); |
| 160 | + }); |
| 161 | + |
| 162 | + // Register Ultralight Inventory keybind (I key) |
| 163 | + ultralightInventoryKey = new KeyMapping( |
| 164 | + "key.inventorynetwork.ultralight_inventory", |
| 165 | + InputConstants.Type.KEYSYM, |
| 166 | + GLFW.GLFW_KEY_I, |
| 167 | + new KeyMapping.Category(ResourceLocation.fromNamespaceAndPath("inventorynetwork", "keys")) |
| 168 | + ); |
| 169 | + KeyBindingHelper.registerKeyBinding(ultralightInventoryKey); |
| 170 | + |
| 171 | + // Register HUD render callback for Ultralight Inventory overlay |
| 172 | + HudRenderCallback.EVENT.register((guiGraphics, tickCounter) -> { |
| 173 | + UltralightInventoryOverlay.render(guiGraphics); |
| 174 | + }); |
| 175 | + |
| 176 | + // Register Ultralight render mode toggle keybind (B key) |
| 177 | + ultralightRenderModeKey = new KeyMapping( |
| 178 | + "key.inventorynetwork.ultralight_rendermode", |
| 179 | + InputConstants.Type.KEYSYM, |
| 180 | + GLFW.GLFW_KEY_B, |
| 181 | + new KeyMapping.Category(ResourceLocation.fromNamespaceAndPath("inventorynetwork", "keys")) |
| 182 | + ); |
| 183 | + KeyBindingHelper.registerKeyBinding(ultralightRenderModeKey); |
| 184 | + |
131 | 185 | // Database removed - no shutdown hook needed |
132 | 186 | } |
133 | 187 |
|
@@ -210,6 +264,23 @@ private boolean handleOverlayMouseScroll(Screen screen, double mouseX, double mo |
210 | 264 | private void onClientTick(Minecraft client) { |
211 | 265 | tickCounter++; |
212 | 266 |
|
| 267 | + // Handle Hello World keybind |
| 268 | + while (helloWorldKey.consumeClick()) { |
| 269 | + HelloWorldOverlay.toggle(); |
| 270 | + } |
| 271 | + |
| 272 | + // Handle Ultralight Inventory keybind |
| 273 | + while (ultralightInventoryKey.consumeClick()) { |
| 274 | + UltralightInventoryOverlay.toggle(); |
| 275 | + } |
| 276 | + |
| 277 | + // Handle Ultralight render mode toggle keybind (only when overlay is visible) |
| 278 | + while (ultralightRenderModeKey.consumeClick()) { |
| 279 | + if (UltralightInventoryOverlay.isVisible()) { |
| 280 | + UltralightInventoryOverlay.toggleRenderMode(); |
| 281 | + } |
| 282 | + } |
| 283 | + |
213 | 284 | // Check if chest was closed (screen changed from chest to non-chest) |
214 | 285 | boolean isChestOpen = false; |
215 | 286 | Screen currentScreen = client.screen; |
|
0 commit comments