[Tutorial] Math Utils

Started by sumeshi0216 on

Topic category: User side tutorials

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] Math Utils
Mon, 08/19/2024 - 16:19 (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.

The initial size is the size of the fixed-size array used internally for the list. Note that the size is not an actual size of the list.

When the current size of the list reaches the initial size, the fixed-size array will automatically be replaced with a larger array.

 

 

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 initial size is the size of the hash table used internally to store vectors. Note that the size is not an actual size of the map.

When the current size of the map reaches the initial size * the load factor, the size of the hash table will be expanded automatically.

 

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.

Moreover, when you add data to data lists, need to use the current size of the list. You can get the size using the data list procedures

Edited by sumeshi0216 on Mon, 08/19/2024 - 16:19
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

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.

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

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? 

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.

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.

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!

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

 

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
One more question: Could you…
Thu, 07/25/2024 - 09:47

One more question:

Could you also add a "get world seed" procedure block? I currently use another plugin with that feature but it isn´t available for 2024.2 and it would be a lot easier to have these things in one plugin

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It may be added to the…
Fri, 08/02/2024 - 06:22

It may be added to the plugin "Additions".

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh thanks that´s also fine
Fri, 08/09/2024 - 13:41

Oh thanks that´s also fine

Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I know this is probably too…
Thu, 08/15/2024 - 15:41

I know this is probably too much to ask, but would it be possible to potentially add a perlin noise procedure block to the plugin? I wrote a forum topic about it which can be read below. I know full well that this would probably be a lot of work, so I'm not expecting anything.

https://mcreator.net/forum/107416/idea-noise-texture-procedure-blocks

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If I find the methods that…
Fri, 08/16/2024 - 02:35

If I find the methods that make it possible, I will add new procedures to the plugin "Additions."