diff --git a/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb b/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb index 7fdc54ce..b78b6495 100644 --- a/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb +++ b/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb @@ -1,2 +1,2 @@ -// 1.21.1 2024-10-08T16:36:37.283985 Languages: en_us for mod: justdirethings -96bc43e5eceb21c7648659daa43d1b5415e229bc assets/justdirethings/lang/en_us.json +// 1.21.1 2024-10-18T20:02:46.3102567 Languages: en_us for mod: justdirethings +c7f1cc2b04789bf34333113ee3c1fcd58eb116b2 assets/justdirethings/lang/en_us.json diff --git a/src/generated/resources/assets/justdirethings/lang/en_us.json b/src/generated/resources/assets/justdirethings/lang/en_us.json index 7898e093..08b9b999 100644 --- a/src/generated/resources/assets/justdirethings/lang/en_us.json +++ b/src/generated/resources/assets/justdirethings/lang/en_us.json @@ -319,6 +319,7 @@ "justdirethings.jumpboost.detailtext": "Jump Higher", "justdirethings.key.category": "Just Dire Things", "justdirethings.key.toggle_tool": "Toggle Tool Abilities", + "justdirethings.key.toolUI": "Open Tool Settings UI", "justdirethings.lavaimmunity.detailtext": "No Damage from Lava or Fire", "justdirethings.lavaimmunity.flavortext": "Fancy a swim?", "justdirethings.lavarepair.detailtext": "Drop item in Lava to repair it", diff --git a/src/main/java/com/direwolf20/justdirethings/client/KeyBindings.java b/src/main/java/com/direwolf20/justdirethings/client/KeyBindings.java index 2226c83a..4bcff1c5 100644 --- a/src/main/java/com/direwolf20/justdirethings/client/KeyBindings.java +++ b/src/main/java/com/direwolf20/justdirethings/client/KeyBindings.java @@ -26,10 +26,12 @@ public class KeyBindings { private static final Logger LOGGER = LoggerFactory.getLogger(KeyBindings.class); private static final KeyConflictContextGadget CONFLICT_CONTEXT_GADGET = new KeyConflictContextGadget(); + private static final KeyConflictContextConfigScreen CONFLICT_CONTEXT_CONFIG = new KeyConflictContextConfigScreen(); private static final List keyMappings = new ArrayList<>(); public static KeyMapping toggleTool = createBinding("toggle_tool", GLFW.GLFW_KEY_V); + public static KeyMapping toolUI = createBindingGUI("toolUI", -1); /*public static KeyMapping undo = createBinding("undo", GLFW.GLFW_KEY_U); public static KeyMapping anchor = createBinding("anchor", GLFW.GLFW_KEY_H); public static KeyMapping range = createBinding("range", GLFW.GLFW_KEY_R);*/ @@ -40,6 +42,12 @@ private static KeyMapping createBinding(String name, int key) { return keyBinding; } + private static KeyMapping createBindingGUI(String name, int key) { + KeyMapping keyBinding = new KeyMapping(getKey(name), CONFLICT_CONTEXT_CONFIG, InputConstants.Type.KEYSYM.getOrCreate(key), getKey("category")); + keyMappings.add(keyBinding); + return keyBinding; + } + @SubscribeEvent public static void registerKeyMappings(RegisterKeyMappingsEvent event) { LOGGER.debug("Registering {} keybinding for {}", keyMappings.size(), JustDireThings.MODID); @@ -69,4 +77,17 @@ public boolean conflicts(IKeyConflictContext other) { return other == this || other == KeyConflictContext.IN_GAME; } } + + public static class KeyConflictContextConfigScreen implements IKeyConflictContext { + @Override + public boolean isActive() { + Player player = Minecraft.getInstance().player; + return !KeyConflictContext.GUI.isActive() && player != null; + } + + @Override + public boolean conflicts(IKeyConflictContext other) { + return other == this || other == KeyConflictContext.IN_GAME; + } + } } diff --git a/src/main/java/com/direwolf20/justdirethings/client/events/EventKeyInput.java b/src/main/java/com/direwolf20/justdirethings/client/events/EventKeyInput.java index db4eb242..b50afe7b 100644 --- a/src/main/java/com/direwolf20/justdirethings/client/events/EventKeyInput.java +++ b/src/main/java/com/direwolf20/justdirethings/client/events/EventKeyInput.java @@ -10,6 +10,7 @@ import com.direwolf20.justdirethings.common.items.interfaces.ToggleableTool; import com.direwolf20.justdirethings.common.network.data.LeftClickPayload; import com.direwolf20.justdirethings.common.network.data.ToggleToolPayload; +import com.direwolf20.justdirethings.common.network.data.ToolSettingsGUIPayload; import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; @@ -41,6 +42,10 @@ public static void handleEventInput(ClientTickEvent.Post event) { if (mc.player == null) return; + if (KeyBindings.toolUI.consumeClick()) { + PacketDistributor.sendToServer(new ToolSettingsGUIPayload()); + } + KeyMapping keyMapping = KeyBindings.toggleTool; ItemStack portalGun = PortalGunV2.getPortalGunv2(mc.player); if (!portalGun.isEmpty()) { diff --git a/src/main/java/com/direwolf20/justdirethings/client/screens/ToolSettingScreen.java b/src/main/java/com/direwolf20/justdirethings/client/screens/ToolSettingScreen.java index 2935fc09..7f93fe14 100644 --- a/src/main/java/com/direwolf20/justdirethings/client/screens/ToolSettingScreen.java +++ b/src/main/java/com/direwolf20/justdirethings/client/screens/ToolSettingScreen.java @@ -40,7 +40,7 @@ public class ToolSettingScreen extends AbstractContainerScreen abilities = EnumSet.noneOf(Ability.class); int buttonsStartX = getGuiLeft() + 5; int buttonsStartY = getGuiTop() + 15; diff --git a/src/main/java/com/direwolf20/justdirethings/common/network/PacketHandler.java b/src/main/java/com/direwolf20/justdirethings/common/network/PacketHandler.java index 076125d0..c35cfea1 100644 --- a/src/main/java/com/direwolf20/justdirethings/common/network/PacketHandler.java +++ b/src/main/java/com/direwolf20/justdirethings/common/network/PacketHandler.java @@ -40,6 +40,7 @@ public static void registerNetworking(final RegisterPayloadHandlersEvent event) registrar.playToServer(InventoryHolderMoveItemsPayload.TYPE, InventoryHolderMoveItemsPayload.STREAM_CODEC, InventoryHolderMoveItemsPacket.get()::handle); registrar.playToServer(ExperienceHolderPayload.TYPE, ExperienceHolderPayload.STREAM_CODEC, ExperienceHolderPacket.get()::handle); registrar.playToServer(ExperienceHolderSettingsPayload.TYPE, ExperienceHolderSettingsPayload.STREAM_CODEC, ExperienceHolderSettingsPacket.get()::handle); + registrar.playToServer(ToolSettingsGUIPayload.TYPE, ToolSettingsGUIPayload.STREAM_CODEC, ToolSettingsGUIPacket.get()::handle); //Going to Client registrar.playToClient(ClientSoundPayload.TYPE, ClientSoundPayload.STREAM_CODEC, ClientSoundPacket.get()::handle); diff --git a/src/main/java/com/direwolf20/justdirethings/common/network/data/ToolSettingsGUIPayload.java b/src/main/java/com/direwolf20/justdirethings/common/network/data/ToolSettingsGUIPayload.java new file mode 100644 index 00000000..e32a06da --- /dev/null +++ b/src/main/java/com/direwolf20/justdirethings/common/network/data/ToolSettingsGUIPayload.java @@ -0,0 +1,22 @@ +package com.direwolf20.justdirethings.common.network.data; + +import com.direwolf20.justdirethings.JustDireThings; +import io.netty.buffer.ByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +public record ToolSettingsGUIPayload( + +) implements CustomPacketPayload { + public static final ToolSettingsGUIPayload INSTANCE = new ToolSettingsGUIPayload(); + public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "tool_settings_gui")); + + @Override + public Type type() { + return TYPE; + } + + public static final StreamCodec STREAM_CODEC = StreamCodec.unit(INSTANCE); +} + diff --git a/src/main/java/com/direwolf20/justdirethings/common/network/handler/ToolSettingsGUIPacket.java b/src/main/java/com/direwolf20/justdirethings/common/network/handler/ToolSettingsGUIPacket.java new file mode 100644 index 00000000..fdeed034 --- /dev/null +++ b/src/main/java/com/direwolf20/justdirethings/common/network/handler/ToolSettingsGUIPacket.java @@ -0,0 +1,25 @@ +package com.direwolf20.justdirethings.common.network.handler; + +import com.direwolf20.justdirethings.common.containers.ToolSettingContainer; +import com.direwolf20.justdirethings.common.network.data.ToolSettingsGUIPayload; +import net.minecraft.network.chat.Component; +import net.minecraft.world.SimpleMenuProvider; +import net.minecraft.world.entity.player.Player; +import net.neoforged.neoforge.network.handling.IPayloadContext; + +public class ToolSettingsGUIPacket { + public static final ToolSettingsGUIPacket INSTANCE = new ToolSettingsGUIPacket(); + + public static ToolSettingsGUIPacket get() { + return INSTANCE; + } + + public void handle(final ToolSettingsGUIPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Player sender = context.player(); + sender.openMenu(new SimpleMenuProvider( + (windowId, playerInventory, playerEntity) -> new ToolSettingContainer(windowId, playerInventory, sender), Component.translatable(""))); + + }); + } +} diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java index 733d5870..f3eda3d5 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java @@ -387,6 +387,7 @@ protected void addTranslations() { //Keys add("justdirethings.key.category", "Just Dire Things"); add("justdirethings.key.toggle_tool", "Toggle Tool Abilities"); + add("justdirethings.key.toolUI", "Open Tool Settings UI"); //Abilities add(Ability.MOBSCANNER.getLocalization(), "Mob Scanner"); diff --git a/src/main/resources/assets/justdirethings/patchouli_books/justdirethingsbook/en_us/entries/tool_basics.json b/src/main/resources/assets/justdirethings/patchouli_books/justdirethingsbook/en_us/entries/tool_basics.json index 6570cf0d..c095802b 100644 --- a/src/main/resources/assets/justdirethings/patchouli_books/justdirethingsbook/en_us/entries/tool_basics.json +++ b/src/main/resources/assets/justdirethings/patchouli_books/justdirethingsbook/en_us/entries/tool_basics.json @@ -14,7 +14,7 @@ }, { "type": "patchouli:text", - "text": "Shift-Click the tool when it's in your hand to configure it. From here, you can toggle on or off specific upgrades by clicking on them.$(br2)Right click the upgrade to change some settings (if they have any) or assign a hotkey. If the ability is passive, the hotkey will toggle its activation. If the ability is active, the hotkey will trigger it." + "text": "Shift-Click the tool when it's in your hand to configure it (there is also a hotkey for this screen). From here, you can toggle on or off specific upgrades by clicking on them.$(br2)Right click the upgrade to change some settings (if they have any) or assign a hotkey. If the ability is passive, the hotkey will toggle its activation. If the ability is active, the hotkey will trigger it." }, { "type": "patchouli:text",