Checking the entity falls/jumps on top of the block

Started by Gux on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Checking the entity falls/jumps on top of the block

Hello, I want to make the block below break when the player jumps on it, (like turtle eggs break when jumping on them), I couldn't find how to do it and it's probably very easy, can you guys help?

Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Anybody?
Thu, 03/16/2023 - 16:38

Anybody?

Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello! I know this post is a…
Mon, 04/08/2024 - 18:35

Hello! I know this post is a year old, but I believe I can help.
If you want your egg to behave EXACTLY like turtle eggs, this is actually very easy.
Because turtle eggs break when standing OR jumping, you only need to detect the standing, as jumping is virtually the same.
If your egg is a full block tall, use a "entity walks on block" procedure.
If your egg is a unique height, use "entity collides in block" procedure.
The procedure should have an integer variable ( i named mine 'rand'). Set this int variable to a random decimal using the random [0,1) block. Then use if statements to detect whether the number is below a specific number*, and if so, break the "egg" block.  (NOTE: You may also want to check that the entity is not sneaking, as sneaking prevents turtle eggs from breaking)

*TO DETERMINE WHAT NUMBER YOU SHOULD USE
I recomend dividing your desired break chance by 20.
EXAMPLE: I want a 50% chance to break the egg every second. 50% is .5, and there are 20 ticks per second, so .5/20 is 0.025
So my if statement would read "IF rand < 0.025 AND entity is NOT sneaking" THEN break egg.

If you want this to work exclusively when jumped on, you could try also checking that the entities Y delta movement is <0 (falling), though I'm not 100% positive that will work.