#Enchantment Table Mechanics

1 messages · Page 1 of 1 (latest)

glacial plank
#

I tried to recreate the enchantment table mechanics or how the enchantment table randomly selects enchantments basic on certain instructions found in this Wiki. I am using the latest stable 1.12.0-beta.1.21.0-stable, but this works in stable also, since I created this in stable first, and then just reupdated the code to work in latest version 1.12.0.

It consists of this javascript files:

#

utilities.js:

function randFloat(min, max) {
    return Math.random() * (max - min) + min;
}
function randInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
#

it produces similar to this output (i wrote it first in python for testing how it works):