Adding Frostwalker to Player Entity

Started by Sniket on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Adding Frostwalker to Player Entity

Hello guys

I have an item that gets consumed by a player that I want to add a similar effect to Frostwalker. I have tried many different things and have failed at every turn so far. 

Here is my code: https://imgur.com/a/CxoNSji

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
...Your approach is…
Wed, 11/08/2023 - 17:01

...Your approach is... technically sound, but there are better ways of going about it. Specifically targeting exact positions around the player can make it inaccurate, and means you have to code in every single position in the radius. Here's some general tips:

  • Don't use while brackets unless you absolutely have to. In your specific case, replacing your while bracket with an if bracket would probably fix the procedure. While brackets check if a condition within the procedure is true, (such as repeatedly running something until it returns true.) What you would instead want to do here is make the procedure run every player update tick, and use an if bracket for the timer instead. 
  • In general, while brackets can very easily cause crashes if they're not provided with an end condition. In your case, if this procedure runs every update tick: Each tick it checks the current value of the global timer. Since the value of the timer does not change within the procedure, it endlessly loops everything in the while bracket until the game crashes.
  • On that note, don't use a global variable for a timer unless you really need to, it's easier and generally more reliable to just add a custom potion effect. You can apply potion effects ambiently too, if you don't want them to be visible to the player.
  • Make sure you're using frosted ice instead of normal ice, (It looks like you're already doing this but it's hard to tell.) Frost Walker creates a special variety of ice that melts after a while, and it's separate from normal ice.
  • And lastly, consider using the "Check for block in 6*6*6 box" procedure template, and modifying it for your purposes. This template checks every block in a 6*6*6 box centered on a location. In your case, you could check if the currently selected block is water with air above it, and if it is, replace it with frosted ice. You can also configure the size to be smaller or larger, and can check that both of the x/z offsets aren't above a certain value so that it creates a circle instead of a square.

Good luck with your procedure! I could send an example screenshot if that would help.