game-design-driven / Create-Prepare-to-Dye

Create: Prepare to Dye an opinionated, minimalistic modpack centered around complex and interesting automation.
GNU General Public License v3.0
24 stars 19 forks source link

Extract settings with java mod #466

Open Discord-Github-Bridge opened 10 months ago

Discord-Github-Bridge commented 10 months ago

minecraft.getMinecraft().gamesettings as a variable that can be accessed in kubejs (even write to a file and read with kubejs)

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

GLFW_KEY_V something like that

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

there's probably a glfw function to translate it to the keyboard

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

https://www.glfw.org/docs/3.3/group__input.html#gaeaed62e69c3bd62b7ff8f7b19913ce4f

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

glfwGetKeyName

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

ok

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

so something like this?

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

int scancode = GLFW.glfwGetKeyScancode(GLFW.GLFW_KEY_V); String keyname = GLFW.glfwGetKeyName(GLFW.GLFW_KEY_V, scancode);

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

not familiar with scancodes

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

ok keyname is v

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

so ill make a function that returns this

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

so thats working

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

ok

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

so i have the key as a string 'v'

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

and i need to make it like this: GLFW.GLFW_KEY_V

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

but obviously that is a variable so

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

need to use a string as a variable name

Discord-Github-Bridge commented 10 months ago

yarden.zamir on Discord says

Use a map with the string as the key

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

does minecraft really not load options for you into a java object?

Discord-Github-Bridge commented 10 months ago

yarden.zamir on Discord says

Yea that does seem weird

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

i couldnt find a function to do that

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

there probably is

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

only stuff i can find on google is from 2013

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

gonna ask on the forge discord

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

how would this work?

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

Map<string, glfw...Key> map = Map.of(
"a", GLFW_KEY_A,
// ...
);

but honestly; I wouldn't recommend it unless you're planning on typing all the characters out. I'm sure there is a better way with Minecraft.getInstance()

Discord-Github-Bridge commented 10 months ago

yarden.zamir on Discord says

No of course not by hand. But I assume at that point you have the list of options no? Then you put each in the map with their mapping

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

uhhh

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

ok

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

ah yeah Options.class

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

not sure why i went all the way doing it manually without searching the mc source code for a function to do it

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

I've done that too often before

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

its literally right here: minecraft.options.getFile()

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

this returns a KeyMapping[] object: minecraft.options.keyMappings

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

let key, options = Ptdye.util.toCharKey(Ptdye.getOption("key_crafting_on_a_stick.key.open_curios")) 👀

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

i was thinking to do it all in java

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

Options being (R/L)shift/(R/L)ctrl

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

Sure

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

let key, options = Ptdye.getOption("key_crafting_on_a_stick.key.open_curios") ?

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

yeah

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

getKey

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

why would it return two things?

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

I'm not sure how keyBindings handle it

Discord-Github-Bridge commented 10 months ago

engineersmith_4628 on Discord says

but if you have shift or ctrl with the binding

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

oh

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

i see

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

ok

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

still working on this

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

been busy all day today

Discord-Github-Bridge commented 10 months ago

kikis2111 on Discord says

i figured out code hotswapping for intellij though so thats cool

Discord-Github-Bridge commented 10 months ago

yarden.zamir on Discord says

Donno what that means but sound cool