[Tutorial] Math Utils

Started by sumeshi0216 on

Topic category: User side tutorials

Last seen on 12:12, 17. Jul 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] Math Utils
Wed, 07/17/2024 - 12:13 (edited)

Features

Math Utils adds the following variables.

  • Random Source
  • Vector
  • Vector List
  • Vector Map

 

Random Source

Random Source is a variable required to generate random numbers.

In order to generate random numbers,  you will need to create a random source. If the source is used without creating, errors will occur.

The seed is a number required to calculate random numbers, and it can fixes the sequence of those.

 

Next, get random numbers with the source.

Note that random numbers are not automatically synchronized between client and server side.

 

Vector

Vector is a variable which can have 3 numbers as X, Y and Z value.

In order to create a vector from numbers, do it like this. If a vector is not created, a zero vector (x, y, z) = (0, 0, 0) is used as an initial value.

For yaw and pitch values, vectors follow Minecraft's coordinate system.

 

These procedures can get each of numbers.

 

To do easy operations for vectors, these procedure are available.

The operations are done for each X/Y/Z component of numbers in vectors. For example, "(0, 1, 2) + (3, 4, 5)" is "(3, 5, 7)."

 

Vector List

Vector List can store vectors using index numbers.

You will need to create a vector list at first. If the list is used without creating, errors will occur.

 

Vector Map

Vector map can store vectors using string keys.

You will need to create a vector map at first. If the map is used without creating, errors will occur.

The load factor is a reference value to expand the map.

When the current size reaches the maximum size * the load factor, the map size will be expanded.

 

Data Element/List/Map

Data List/Map can store Data Elements. You can create data elements from boolean, double, float, int and string.

Note that a data list can only store one element type. For example, if you add a double element to a data list at first, after that only double can be added.

 

NBT Modifying

For version 1.3.0 and later, in order to add vectors, you will need to modify NBT as follows

 

This allows you to get vectors from NBT

Edited by sumeshi0216 on Wed, 07/17/2024 - 12:13
Last seen on 09:11, 17. Jul 2024
Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi, I have a question. What…
Sat, 07/06/2024 - 16:18

Hi, I have a question. What is the random source seed supposed to be (Integer, positive number etc.) and how does it work? I tried using the random number based on seed [ world seed + x + z ] for feature world gen but it was the same on every single world seed. It would really help to know more about the random source seed system. Will you update this plugin to 2024.2 when it releases? Thank you for making this plugin and hopefully helping me

Last seen on 12:12, 17. Jul 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm planning to add a…
Sun, 07/07/2024 - 03:34

I'm planning to add a procedure to create a random source from a block position. I'm still thinking about random source for seed values. 2024.2 will be released soon.

Last seen on 09:11, 17. Jul 2024
Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I´m looking forward to an…
Sun, 07/07/2024 - 09:52

I´m looking forward to an update with this feature. Thank you for helping

Last seen on 09:11, 17. Jul 2024
Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry to disturb again but…
Tue, 07/09/2024 - 14:37

Sorry to disturb again but it feels like the random source operation isn´t random. What pseudo random function do you use for this? If it isn´t Xorshift, could you add a "bitwise shift"-function to make a Xorshift generator possible in Mcreator? 

Last seen on 12:12, 17. Jul 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It seems linear congruential…
Wed, 07/10/2024 - 11:20

It seems linear congruential generators according to the source code.

Last seen on 12:12, 17. Jul 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Bit shifting will be added…
Wed, 07/10/2024 - 11:22

Bit shifting will be added in v1.3.0.

Last seen on 09:11, 17. Jul 2024
Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you so much :) Both…
Thu, 07/11/2024 - 17:27

Thank you so much :)

Both the lcg I manually programmed and the random source seemed to have an issue so I hope your plugin will help me trying the easiest alternative, the Xorshift. Great work!

Last seen on 09:11, 17. Jul 2024
Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you for updating so…
Sun, 07/14/2024 - 20:27

Thank you for updating so quickly.

I'll try the new operations soon and hope the Xorshift will work perfectly