Minecraft Friends
📎 1 file 6,103 chars
đź“„
pasted-code-1791721017138.txt
txt 147 lines
â–¶
Minecraft Mod Development Prompt — One-Key F5 PvP

Create a fully functional Minecraft Java Edition mod called One-Key F5 PvP.

1. Main Feature: Instant Back View

Implement a dedicated keybind that instantly switches between first-person view and third-person back view.

Required behavior:

* When the player is in first person, pressing the configured key switches directly to third-person back view (camera behind the player’s character).
* Pressing the same key again returns directly to first person.
* Never cycle through all three camera perspectives.
* Never switch to third-person front view.
* The toggle must work instantly, without animations, delays, or unnecessary camera transitions.
* The player should be able to check behind their character during PvP combat with a single keypress.

Expected behavior

Current perspective	Key pressed	Result
First person	Toggle key	Third-person back
Third-person back	Toggle key	First person
Third-person front	Toggle key	First person

If the player is already in third-person front view, pressing the toggle key should switch directly to first person.

2. Customizable Keybind

Add a configurable keybind through Minecraft’s Controls settings.

Requirements:

* Choose a sensible default key, such as R, provided it does not conflict with an essential Minecraft control.
* Allow the player to assign any available key through Minecraft’s standard keybind screen.
* Display the keybind under a category named One-Key F5 PvP.
* Support keyboard input correctly.
* Use the game’s normal keybinding system and handle key presses without repeatedly toggling while the key is held down.
* Avoid conflicts with other mods as much as possible.

3. Mod Menu Compatibility

Make the mod compatible with the Mod Menu mod for Fabric.

Requirements:

* Display One-Key F5 PvP in the installed-mods list.
* Add a clickable Configure button to the mod’s Mod Menu entry.
* Clicking Configure must open the mod’s configuration screen.
* Do not add a fake configuration button that does nothing.
* If Mod Menu is not installed, the mod must still work normally.
* Keep Mod Menu integration optional so it does not become a mandatory dependency unless absolutely necessary.

4. Configuration Screen

Create a clean, modern configuration screen accessible from Mod Menu.

Include these settings:

Enable Mod

* Toggle: ON / OFF.
* When OFF, the custom toggle key must not change the player’s camera.
* When ON, the keybind works normally.
* Disabling the mod must not forcibly change the player’s current camera perspective.

Enable One-Key Toggle

* Toggle: ON / OFF.
* When OFF, the custom keybind does nothing.
* When ON, pressing the configured key switches between first person and third-person back view.

Custom Keybind

* Provide a button that opens or uses Minecraft’s standard keybinding assignment interface.
* Show the currently assigned key.

Reset to Defaults

* Restore all mod settings and the default keybind.
* Ask for confirmation if appropriate.

Save Settings

* Save changes persistently.
* Settings must remain after restarting Minecraft.
* Apply changes immediately when appropriate.

Use clear labels, proper spacing, readable text, and Minecraft’s native GUI styling. Do not create a fake UI or placeholder buttons.

5. Technical Requirements

* Target Minecraft Java Edition 1.21.11.
* Use the Fabric mod loader and the matching Fabric API version.
* Integrate with the official Mod Menu API where needed.
* Use the correct Minecraft client camera perspective APIs for the selected version.
* Do not simulate key presses or repeatedly invoke the normal F5 cycling behavior.
* Set the camera perspective directly to the appropriate first-person or third-person-back state.
* Ensure the implementation runs entirely on the client; a server-side installation must not be required.
* Avoid unnecessary permissions, networking, telemetry, or external services.

6. Edge Cases and Reliability

Handle the following correctly:

* The player changes perspective using the normal F5 key.
* The player changes the custom keybind in Controls.
* The mod is disabled while third-person view is active.
* The player opens a menu or pauses the game.
* The player respawns or changes dimensions.
* Another mod changes the camera perspective.
* The custom key is held down instead of tapped.
* The configuration file is missing, invalid, or contains outdated values.

Do not crash if Mod Menu is absent. Do not overwrite unrelated Minecraft settings. Avoid repeatedly toggling the camera when a key is held.

7. Build and Delivery

Deliver a complete, working Fabric mod project containing:

* All Java source files.
* Correct fabric.mod.json metadata.
* Correct Gradle build files and wrapper files.
* Mod Menu integration and configuration screen implementation.
* Persistent configuration handling.
* A README with installation and usage instructions.
* A compiled .jar file ready to place in the Minecraft mods folder.

Build the project against the exact target Minecraft version. Resolve all compilation errors before delivery.

Do not claim the mod was tested or compiled unless the build and relevant tests actually succeeded. If the build fails, provide the complete error output and fix the underlying cause.

8. Acceptance Tests

The mod is complete only when all of these tests pass:

1. Pressing the custom key in first person immediately switches to third-person back.
2. Pressing it again immediately returns to first person.
3. No keypress in the custom toggle cycles through third-person front view.
4. The mod appears in Mod Menu when Mod Menu is installed.
5. The Configure button opens a working settings screen.
6. Both the master enable switch and the one-key toggle switch work.
7. Settings persist after restarting Minecraft.
8. The custom keybind can be changed in Controls.
9. The mod works without Mod Menu installed.
10. The compiled JAR loads successfully on the specified Minecraft and Fabric versions.

Priority: Correct camera behavior first, reliable configuration second, Mod Menu integration third, and visual polish fourth.
Kodari AI
KodariOct 11 at 12:31 pm 2
OneKeyF5PvP
A Fabric client-side mod for Minecraft 1.21.11 that adds an instant camera toggle between first-person and third-person back view via a customizable keybind. Features a dedicated keybinding under "One-Key F5 PvP" category, persistent configuration with enable/disable toggles, Mod Menu integration with a functional Configure button opening a settings screen, and robust edge case handling including key-hold prevention and perspective changes from other sources. Works without Mod Menu installed and never cycles through third-person front view.
  1. Implement the client-only perspective toggle with an assignable keybind.

  2. Add persistent settings and an optional Mod Menu configuration screen.

  3. Create the Fabric project metadata, assets, and usage README.

Created the One-Key F5 PvP Fabric 1.21.11 client mod. The default R key switches directly between first-person and third-person back view; the Mod Menu Configure screen provides both toggles, Controls access for rebinding, and reset. Settings persist, and Mod Menu remains optional.

The Gradle build configuration and README are included. I haven’t verified a build or generated a JAR or Gradle wrapper binary. To get the JAR in Kodari, click Compile in the top bar, click Compile in the build window, then Download after it succeeds.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
README.md
settings.gradle
Code
11 323
src/client/java/com/kodari/onekeyf5pvp/OneKeyF5PvPClient.java
package com.kodari.onekeyf5pvp;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.option.Perspective;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

public final class OneKeyF5PvPClient implements ClientModInitializer {
    public static final String MOD_ID = "onekeyf5pvp";
    public static final KeyBinding TOGGLE_CAMERA = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.onekeyf5pvp.toggle_camera",
            GLFW.GLFW_KEY_R,
            KeyBinding.Category.create(Identifier.of(MOD_ID, "main"))
    ));

    private static boolean keyWasDown;

    @Override
    public void onInitializeClient() {
        OneKeyF5PvPConfig.load();
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            boolean keyPressed = TOGGLE_CAMERA.wasPressed();
            while (TOGGLE_CAMERA.wasPressed()) {
                keyPressed = true;
            }

            boolean keyDown = TOGGLE_CAMERA.isPressed();
            if (keyPressed && !keyWasDown
                    && OneKeyF5PvPConfig.enabled
                    && OneKeyF5PvPConfig.oneKeyToggle
                    && client.player != null
                    && client.currentScreen == null) {
                Perspective current = client.options.getPerspective();
                client.options.setPerspective(current == Perspective.FIRST_PERSON
                        ? Perspective.THIRD_PERSON_BACK
                        : Perspective.FIRST_PERSON);
            }
            keyWasDown = keyDown;
        });
    }

    public static void resetToDefaults() {
        OneKeyF5PvPConfig.enabled = true;
        OneKeyF5PvPConfig.oneKeyToggle = true;
        TOGGLE_CAMERA.setBoundKey(TOGGLE_CAMERA.getDefaultKey());
        KeyBinding.updateKeysByCode();
        OneKeyF5PvPConfig.save();
        net.minecraft.client.MinecraftClient.getInstance().options.write();
    }
}