Only one instance of an item exists within the game so you'll get unexpected results if you (or other players in multiplayer) use the same item twice; you use an ItemStack and damage values/NBT if you want to store information about a particular item, the same goes for blocks (using block states or entities). You should also never directly cast entity coordinates to an int - use floor(), as otherwise you'll get an offset-by-one error at negative coordinates (int casts always round towards 0, while floor always rounds down; (int)-0.5 becomes 0 while floor(0.5) becomes -1, where block -1 corresponds to -1 to -0.000...1). Both of these have been the cause of various bugs in vanilla.
Also, this will crash the game on a dedicated server since the Minecraft class is client-side only, and is otherwise not thread safe since the integrated server and client run on separate threads (this has been the cause of even more bugs in vanilla), and you already have access to a player instance as a parameter to onItemRightClick():
Minecraft.getInstance().player.sendChatMessage("Explosion coordinates set: " + x + " " + y + " " + z);
Otherwise, you want to spawn a primed TNT entity (see BlockTNT, or TNTBlock, IDK what the exact name is in 1.14 as I mod 1.6.4, from which the example below is from, where posX + 0.5, etc are replaced with the player/set coordinates and par6EntityLivingBase is the player (this enables the game to know that you ignited the TNT so mobs will drop XP and rare drops when killed by it), but a lot of this code hasn't changed much):
Right now, I have this code executing to summon a primed TNT at x, y, z:
However, this does not work on a world that has cheats disabled. How do I summon TNT without using cheats?
BTW, the full method is: (for context)
I suggest taking a look at the TNTBlock to see how vanilla does it.
You should never use code like this in an item class:
Only one instance of an item exists within the game so you'll get unexpected results if you (or other players in multiplayer) use the same item twice; you use an ItemStack and damage values/NBT if you want to store information about a particular item, the same goes for blocks (using block states or entities). You should also never directly cast entity coordinates to an int - use floor(), as otherwise you'll get an offset-by-one error at negative coordinates (int casts always round towards 0, while floor always rounds down; (int)-0.5 becomes 0 while floor(0.5) becomes -1, where block -1 corresponds to -1 to -0.000...1). Both of these have been the cause of various bugs in vanilla.
Also, this will crash the game on a dedicated server since the Minecraft class is client-side only, and is otherwise not thread safe since the integrated server and client run on separate threads (this has been the cause of even more bugs in vanilla), and you already have access to a player instance as a parameter to onItemRightClick():
Otherwise, you want to spawn a primed TNT entity (see BlockTNT, or TNTBlock, IDK what the exact name is in 1.14 as I mod 1.6.4, from which the example below is from, where posX + 0.5, etc are replaced with the player/set coordinates and par6EntityLivingBase is the player (this enables the game to know that you ignited the TNT so mobs will drop XP and rare drops when killed by it), but a lot of this code hasn't changed much):
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
Thanks for this! The chat message is for debugging purposes at the moment; not final. I will try this out and get back to you!