Executing a command with variables in it

Started by Kahanvi on

Topic category: Help with modding (Java Edition)

Last seen on 09:03, 17. Sep 2022
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Executing a command with variables in it

Hello, I want to make an item appear on a block thanks to a command. To do this, I make the block appear and then make the item appear on it and I use the player's coordinates to base the placement of these two elements.
First of all, I want to say that I know that the "Spawn item/gem" block exists and that I can simply use it, the problem is that when it appears, the items make a small random jump (which I did not find clearly in the java code) and therefore the item is not perfectly centered or even on the ground next to the block.
So I don't want to use this technique. So I went for the "/summon item ~ ~ ~ {Item:{id: "mymod:item",Count:1b}}" technique, where I need the player's coordinates.

Therein lies my problem, I can't seem to execute a command that has a variable in it. I tried to fix it by two issues that failed. (I want to say that I don't know java at all)
With the block language: I simply took the "Execute command /" block and then with several "crete text with" blocks hooked up that allow me to form the command (thus giving something very ugly). But this doesn't make the item appear at all.
I then tried to lock the procedure and then modify the java code by modifying the paranthesis, several times but without success: the game tells me an error (modified code or not) of paranthesis at the end of the line.

I have a lot of trouble to understand my error. Thanks for your help.

Bloc codeJava code

Last seen on 09:03, 17. Sep 2022
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
btw, i take into account the…
Sun, 07/31/2022 - 22:44

btw, i take into account the resolution of the code but also a more optimized way to make an item appear perfectly at coordinates, without making it jump.

Last seen on 09:03, 17. Sep 2022
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Found what's wrong, I'm just…
Mon, 08/01/2022 - 07:37

Found what's wrong, I'm just dumb. Not thnaks for ur help

Last seen on 13:50, 18. Apr 2024
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
may i ask how you fixed…
Tue, 02/13/2024 - 03:07

may i ask how you fixed it
try it yourself but with Create text with it does not work 
and looking for a way to fix this