Topic category: Help with Minecraft modding (Java Edition)
Hi everyone,
I'm working on a mod using MCreator, and I’ve created a command called /manamax that should allow me to either add or set the value of a player variable called manaMax.
It takes two parameters:
- A string:
action(eitheraddorset) -
A number:
amount
I also created a procedure that's called when the command is executed. Inside the procedure, I check the value of the action parameter, and then either add to or set the value of manaMax.
However, I'm having two issues:
1. add adds double the amount
When I run /manamax add 5, it increases manaMax by 10 instead of 5.
➡️ I double-checked my procedure and I’m only using Set manaMax to manaMax + number once.
➡️ I also confirmed that the procedure is only called once from the command.
2. Other vanilla commands like /gamemode and /tp are throwing errors
After I added this custom command, the normal Minecraft commands started showing errors in the chat or stopped working entirely.
➡️ I suspect it’s something wrong with how I'm handling the parameters in my procedure.
Extra notes:
- My command is set to
normal type, with permission level 2. - In the procedure, I use:
Get command string parameter "action"Get command number parameter "amount"
Any idea why:
addis doubling the result?- My command could be breaking vanilla commands?
Thanks in advance!
I have no clue why vanilla commands would be breaking, but I do have a thought about why add is doubling the result.
In general, when something created with MCreator runs twice, it is because of client-server weirdness. Generally, to fix it, you can put the entire procedure in an if block that has the condition 'not' 'is provided world client-side'
Under most circumstances, the procedure will still work normally, even when effecting players / playing singleplayer, it will just reduce wierdness.