#How would one implement this idea?

123 messages · Page 1 of 1 (latest)

rose steeple
#

I want to make a mod where the block that gets broken by the player is the block the crosshairs x axis perpendicular to the left. I suck at explaining so let me just demonstrate it instead.

suppose a player is in the middle of a 3x3 cube facing north. The players crosshair is on the block infront of him. when the player digs the block, nothing happens to that block, but the block to the players west gets broken instead.

if u still dont get it I can draw it for you haha, I just really want to implement this mod for a task in my mind.

chrome flare
#

just... face player little west and not to the server/client systems only renderer?

chrome flare
#

i mean rotate the view player seeing

rose steeple
#

I dont want that

chrome flare
#

but don't rotate actual player

#

why?

#

you just want to move its crosshair ON THE SCREEN not rotating it?

rose steeple
#

no, I just want to break a block without actually looking at that block in all simplicity.,..

chrome flare
#

i think they want to just move crosshair

rose steeple
#

but the block in question is simple the block perpendicular to the actual targetted block

rose steeple
rose steeple
chrome flare
#

why not use freecam mods?

#

some freecam mods allows breaking block

rose steeple
chrome flare
#

moving crosshair won't work if method i mentioned wont work

rose steeple
#

can someone test it with me?

#

and idk what freecam to use then

#

what if the server doesnt allow breaking blocks in freecam

small matrix
#

Sounds like !!cheats

#

Oops

#

!!cheats

sick riverBOT
#

We do not support hacked clients, cheats, or modifications that are intended to give you the upper hand in a server, competitive or otherwise.
See rule 1 in #welcome and the Discord TOS: https://discordapp.com/terms

rose steeple
#

s not a cheat actually, just a genious strat for a server

#

but I wont get more into it

#

unless u wanna join me haha

#

hacked clients are they just mods?

small matrix
#

A genious strat that can't be done in vanilla and needs a mod is kinda like a cheat, no?

small matrix
rose steeple
#

I want to write a hacked client then I guess. I wont ask more about it here since I know you cant talk about it here, but jump into my dms cause this idea could actually be rlly cool

chrome flare
#

already theres plenty of them

#

supporting freecam

#

freelook

#

or both

rose steeple
#

I can show u guys what my idea is on the specific server if u want

chrome flare
#

fixed angle freelook?

#

but it will be easy to implement

#

yes i read

#

why not? just turn on freecam and break block

rose steeple
#

the goal is that I will be walking sideways and have the mod break the block to that side without actually looking at it

chrome flare
#

oh

rose steeple
#

and the pickaxe clears a huge space, so I can just look at the same spot all the time

chrome flare
#

i recommend you just modifying existing freelook mod

#

and lock its pitch/yaw

#

OR i think there is already pitch/yaw locker?

rose steeple
#

Ill try it i guess

rose steeple
#

@summer lance How to walk sideways?

#

I cant figure out how to make a mod that makes me walk to the right

small matrix
#

Set the right keybind to be pressed

rose steeple
#

this was my approach

#

but didnt work:

small matrix
#

It's like, client.gameOptions.right or something

rose steeple
#
package bear.modid;

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.MinecraftClient;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;

public class Mod2 implements ClientModInitializer {

    // Toggle state for auto-move right
    private static boolean autoRightEnabled = false;
    // Key binding instance for the right arrow key
    private static KeyBinding toggleKey;

    @Override
    public void onInitializeClient() {
        // Register a key binding to toggle the auto-move-right mode.
        toggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.autoright.toggle",                // The translation key of the keybinding's name
                InputUtil.Type.KEYSYM,                 // The type of the keybinding, in this case a keyboard key
                GLFW.GLFW_KEY_RIGHT,                   // The default key code (right arrow)
                "category.autoright"                   // The translation key of the keybinding's category
        ));

        // Register a client tick event to update the player's movement input.
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            // Toggle the mode when the key is pressed
            while (toggleKey.wasPressed()) {
                autoRightEnabled = !autoRightEnabled;
            }
            // If the mode is enabled and the player exists, force moving to the right.
            if (autoRightEnabled && client.player != null) {
                // This sets the player's lateral movement input to simulate holding the "move right" key.
                client.player.input.movementSideways = 1.0F;
            }
        });
    }
}
small matrix
#

Can you add java right after the first 3 `

rose steeple
#

there

small matrix
#

Ty I can't read without syntax highlighting

rose steeple
#

I find it so confusing, I can never find out what the class names are for the minecraft features like walking, digging etc

small matrix
#

You can set MinecraftClient.getInstance().options.rightKey to be pressed with setPressed(bool)

small matrix
#

Check the relevant options' usages and you're bound to find what you're looking for, if it has an option

rose steeple
#

like this?

small matrix
#

That will give you the KeyBinding class

#

Which has a setPressed method

rose steeple
#

how do I just make it go right?

#

ohh

#
MinecraftClient.getInstance().options.rightKey.setPressed(true);
#

like that?

#

@small matrix

small matrix
#

Yeah

rose steeple
#

but it still doesnt work

small matrix
#

If you press rightKey afterwards it'll be cancelled out

rose steeple
small matrix
rose steeple
# small matrix What's your code right now?
package bear.modid;

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.MinecraftClient;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;

public class Mod2 implements ClientModInitializer {

    // Toggle state for auto-move right
    private static boolean autoRightEnabled = false;
    // Key binding instance for the right arrow key
    private static KeyBinding toggleKey;

    @Override
    public void onInitializeClient() {
        // Register a key binding to toggle the auto-move-right mode.
        toggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.autoright.toggle",                // The translation key of the keybinding's name
                InputUtil.Type.KEYSYM,                 // The type of the keybinding, in this case a keyboard key
                GLFW.GLFW_KEY_RIGHT,                   // The default key code (right arrow)
                "category.autoright"                   // The translation key of the keybinding's category
        ));

        // Register a client tick event to update the player's movement input.
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            // Toggle the mode when the key is pressed
            while (toggleKey.wasPressed()) {
                autoRightEnabled = !autoRightEnabled;
            }
            // If the mode is enabled and the player exists, force moving to the right.
            if (autoRightEnabled && client.player != null) {
                // This sets the player's lateral movement input to simulate holding the "move right" key.
                MinecraftClient.getInstance().options.rightKey.setPressed(true);
            }
        });
    }
}
```'
small matrix
#

while (toggleKey.wasPressed()) will keep firing while the key is held down

#

So if you hold for more than 1 tick it'll keep turning on and off with each tick

#

Perhaps you're landing on the off ticks after releasing?

rose steeple
#

so I dont have to time it everytime to be on

#

also I tried pressing like 100 times, still nothing happens

small matrix
#

Hmm

rose steeple
#

OHH

#

I know

small matrix
#

Are you sure the code is being reached

rose steeple
#

options.rightKey this is just the rightarrow key right? its not my "d" key...

#

cause I use wasd afterall

small matrix
#

options.rightKey is supposed to be your d key

rose steeple
#

or like is rightKey = d?

small matrix
#

It doesn't matter if you change the key it's bound to

#

It'll still be represented by the rightKey variable

#

Did you perhaps bind both right movement and your custom toggle keybinding to GLFW_KEY_RIGHT

rose steeple
#

huh okasy

#

doesnt work tho ;-;

rose steeple
#

my toggle key is right arrow key

#

not d

small matrix
#

I was wondering if it could be a conflict with another keybinding that uses right arrow

rose steeple
#

its not

small matrix
#

Ok, lemme try it

rose steeple
#

nvm!

#

its working now

small matrix
#

Huh

rose steeple
#

but when I press the button again, it wont stop

small matrix
#

Because you're only setting it to be pressed

rose steeple
rose steeple
small matrix
#

You need another method call to setPressed(false)

#

client.options.rightKey.setPressed(autoRightEnabled); should be a better solution

#

You can also remove autoRightEnabled from the if statement right above

rose steeple
#

smart

#

but doesnt work

rose steeple
#

nope, now Ill try

#

YAYY tyy