Universes icon

Universes -----

A multi-world plugin for 1.14+



Universe Nethers 2.1
Hello all,

Today I bring you a bug fix that is about a week overdue. I delayed pushing out the update because I wanted to test it in the environment where the bug was discovered to make sure I had actually fixed the problem. To do that, I needed to wait for the server's owner, who graciously allowed me to investigate and test on his server, to have more time to test. So we tested today and the fixes proved successful.

So, what exactly did I fix?

Well, just one bug. This one was a logic error that was directly my fault and caused the coordinates when entering the nether to be drastically wrong. I'll try my best to explain this in laymens terms.

Many programming languages have two kinds of division: integer division and decimal division. Integer division is dividing using whole numbers. No matter the numbers being divided, the result will be a whole number. This means doing 8 / 3 will give you 2. Decimal division is dividing using decimals. To do decimal division, the numbers being divided must be decimals. The result will also be a decimal. This means, doing 8.0 / 3.0 will give you 2.6666. Notice how I added a decimal point and a zero to each number. In Java, and many other languages, 8 and 8.0 are not the same thing. In Java they have different types. 8 is an Integer and 8.0 is a Double--aka a short decimal.

In Minecraft, the X, Y, and Z coordinates are decimals. When I was initially writing the code for the nether/overworld distance ratio, I confused decimal division for something called modulo division. Modulo division is like doing long division out on paper to find the remainder. In code, modulo division uses a percent sign. So, modulo division between 8 and 3 would look like this: 8 % 3. If you do the division by hand, you will get an answer of 2 with a remainder of 2. In the code, modulo only cares about the remainder. So, the result would be 2. Therein lays the problem.

Let's say I am at an X coordinate of 738 in the overworld and I enter a nether portal. The X value is divided by 8 for a result of 92.25. My X in the nether will be around 92. If we instead use modulo division, we get 92 with a remainder of 2. As I said, modulo only cares about the remainder. That means, my X in the nether is set to 2. My X will also be set to 2 is my overworld X coordinate is 138, 338, and so on. Now, if I leave the nether, my X coordinate, which was changed to 2 when I entered, is multiplied by 8. So, whether you entered the nether at an X of 138, 338, or 738, you'll exit the nether at an X of 16.

To give an idea of the scale of this error, if you enter the nether at an X of 738,000, there is a remainder of 0. So you wind up at an X of 0 in the nether. Leaving the nether from that portal will bring you out to an X of 0. (0 * 8 = 0). That puts you out more than 700,000 blocks off.

So, I replaced the modulo division I had erroneously used with regular division.

Simply put:
My math was wrong, so I fixed it.
----------, Aug 21, 2020
Resource Information
Author:
----------
Total Downloads: 8,378
First Release: Jun 6, 2019
Last Update: Jun 14, 2024
Category: ---------------
All-Time Rating:
32 ratings
Find more info at discord.gg...
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings