Topic category: Advanced modding
I am new to the world of coding and have been repeating confusing myself with placing and aligning commands in order to make them do what I want. I want to know how to code an item so that when I right-click the item all of a specific block in the dimension will change into a different block. For example, I right click my custom item and all the stone blocks in the world transform into diamond blocks. I want to make it so that the specific pre-existing blocks change and not any stone placed after I used the item and the code finished executing.
If you're also up to the challenge, I would love it if you explained to me how to convert a specific block like before, but now only on a specific y level. Again, for example I want my stone blocks to convert into diamond blocks. But now, I want only the stone blocks on Y level 9 to change into diamond blocks and not on any other level.
Sure. But just be aware, you will have to create a custom stone block first.
Basically, in the triggers for your block there will be one that says "When player right-clicks on block". Click on the green plus symbol on the right side of it to create a new procedure. For Your procedure, it should be like this:
Go to the flow control area and get a block that says "If (something) do (insert block)".
Then go to the logic area and find the red equals block (insert item) = (insert item). Then in the entity data section find the "item in main hand of: Event/target entity". put this in the first end of the red equals block. Them go to minecraft components and find the red block with a grey square. Click on it to insert your own item. Put this in the other end of the red equals block.
after that, go to the block management area and grab the block at the top which should say "Place (choice block) at x: (x) y: (y) z: (z)". Change the empty slot to a diamond block. Then assemble these blocks as follows:
On trigger:
If: (item in main hand of: Event/target entity) = (Custom Item)
do: Place (Diamond_block) at x: (x) y: (y) z: (z)
For creating a custom stone block, will that create an entirely different block from the world generated stone, or will it make all the stone in the world possessing that procedure.
Also, is it required to place in the coordinates because I'm using your procedure out without imputing the x y and z and it's not working. I want all the custom stone blocks to change not just ones at a specific x y and z. Do you know how to do that
If the procedure looks like this, you've done it right and it should work.
However, if this is not to your satisfaction, I figured out a procedure for the item, that would work on ordinary stone.
PS, You need to open the image above in a new tab.
Thank you so much!! I looked at the picture for your previous comment. Thats what I did, but it requires an input for the x y and z to work. Can you please send your new procedure for affecting ordinary stone.
Sure!
follow this procedure.
https://imgur.com/a/zF672Vs
By the way, you must do this procedure for "when right-clicked on block". Don't worry about the xyz coordinates, as these will be at the block location. Also, you can replace the procedure with this one, as it is simpler.
https://imgur.com/a/ZnF6cya
Thank you for your help this far!! I understand how your procedure works with right clicking the block and changing it. I just want to know one more thing. This code that you've shown me changes one block that the player right clicks. How would one go about changing all the stone blocks in the generated world, not just the ones the player has right clicked. If you don't know how to do it, that's fine!
Do you mean how would you change every stone block into diamond when you click on one?
Yes!! Thats what I would like to know please .
Um, I don't exactly know how, but I will do my best to see.