How do I make a block constantly change a block underneath?

Started by jonathanpecany100 on Fri, 12/02/2022 - 20:16

Topic category: Help with modding (Java Edition)

Last seen on 22:54, 8. Dec 2022
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How do I make a block constantly change a block underneath?
Fri, 12/02/2022 - 20:16

Hey, I am new to using MCreator and I am trying to make a mod where after a random tick, it will change a block underneath, skipping the air block in the process.

For example, if my block is at Z 64 and there is air blocks between Z 59 to Z 63 and another block at Z 58. At a random tick, the Block at 64 will change the block at 58.

I am quite fluent in Java, so if code is needed, that is find. Just give steps to it so others may understand.

 

Bonus Question:

I don't want to spam topics so I will give a bonus question.

I need to make Vanilla Sheep eat a custom grass block I created. However, I can't find a way to edit the Sheep AI to do so. Unless I can use tags and assign a grass tag to my custom grass block and ot will make it where the sheep will turn it into a dirt block.

Last seen on 00:51, 27. Jan 2023
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
For the block changing, you…
Sat, 12/03/2022 - 18:41

For the block changing, you'll just need to use a while block and two custom variables; a boolean, and a number. (I'll call them 'found,' and 'sy.') 

  • Set sy to 1, and found to false. 
  • Make a while block that triggers while 'found' is false.
  • Then, inside the While block, check if the block at y - sy is solid. If it is, set found to true, and execute the procedure that changes the block. If it isn't solid, set sy to +1. You can also set a specific range, by setting found to true once sy exceeds a certain number.

For the sheep stuff, there isn't an easy way to change Vanilla AI, and there aren't any tags for grass blocks. Your best bet would probably be to make the block tick randomly and check if a sheep is directly above, if you really need this to work. However, it won't play the animation.

Last seen on 22:54, 8. Dec 2022
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thanks. You sure I can't…
Sat, 12/03/2022 - 21:06

Thanks. You sure I can't make sheep eat my custom grass as I really need the sheep to eat my custom grass.

Last seen on 22:54, 8. Dec 2022
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Even if I hard coded it. As…
Sat, 12/03/2022 - 22:52

Even if I hard coded it. As I am quite knowledgeable in Java.