Block replacement

Started by Taras Ogurtsov on

Topic category: Help with modding (Java Edition)

Last seen on 17:38, 16. Apr 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Block replacement

Hey, everybody. In my mod there are items that can be placed as a block, and I want to make it so that if a block in x y z replaceable (such as grass, snow, etc.) then it is replaced, not put a block on y + 1. Please help!

Last seen on 20:08, 17. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I imagine you would make a…
Mon, 02/05/2024 - 11:55

I imagine you would make a procedure with the global trigger 'player right clicks block,' then make a tag for blocks you want to be replaceable. If the block the player right clicked is replaceable, and the item in their main hand is one of your custom blocks, swing their main hand, place the block at the correct position, and shrink the item in their main hand for one if they don't have creative mode enabled.

Last seen on 17:38, 16. Apr 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I may have worded it wrong,…
Mon, 02/05/2024 - 19:12

I may have worded it wrong, but I want to know how to check if the block I click on is replaceable? Something like "Is the block in x y z replaceable?". I couldn't find anything like that in Block data.

Last seen on 17:38, 16. Apr 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, I think I've already…
Mon, 02/05/2024 - 20:02

Oh, I think I've already found the solution myself. Thanks for your help anyway!

Last seen on 14:04, 11. Apr 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could you share a picture of…
Mon, 02/05/2024 - 21:40

Could you share a picture of your procedure for those who want to do the same please ?

https://imgur.com/

Last seen on 20:08, 17. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Generally speaking, if a…
Tue, 02/06/2024 - 01:01

Generally speaking, if a block doesn't have a solid top surface, it's replaceable, so you could check for that. But I would recommend making a custom tag for what you want to be replaceable, just so you don't have to worry about any weird edge cases. 

Last seen on 17:38, 16. Apr 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here, as requested above, is…
Tue, 02/06/2024 - 09:28

Here, as requested above, is a screenshot of the whole procedure. I think you will find the information you need in it. It should be clarified that in this case only plant type blocks will be replaced. If you want to add other replaceable blocks to this list that are not plants, you must add the tag to which these blocks belong. If you still have more questions, I'd be happy to help you!

Last seen on 14:04, 11. Apr 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nice, i appreciate it :),…
Tue, 02/06/2024 - 13:07

nice, i appreciate it :), one question though, does the play buttom have synchronisation issue between client and server ?

I saw that you put them in an if statement client-side world

Last seen on 17:38, 16. Apr 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To be honest, I haven't…
Tue, 02/06/2024 - 14:07

To be honest, I haven't tested my mod in multiplayer yet, but in single player mode everything works fine. I added this check so that the sound plays correctly. There is an issue that if you just play the sound, it duplicates for some reason, but with this check the sound plays correctly.