pop4959 / ChunkyBorder

An add-on for Chunky which lets you create and manage world borders.
GNU General Public License v3.0
46 stars 11 forks source link

Realistic Earth Border Wrapping #45

Closed Twelve0001 closed 2 years ago

Twelve0001 commented 2 years ago

On an Earth map, going to the Max Z would bring you straight to antarctica; not very realistic.

Very easy to fix. Add an option called "Realistic Earth Border Wrapping."

Math for this would be pretty simple, its simply:

        } else if (location.getZ() <= minZ) {

            location.setZ(location.getZ() - 3); // so you dont fall off into the void
            location.setX(location.getX() * -1); //yeah thats literally it

        } else if (location.getZ() >= maxZ) {

            location.setZ(location.getZ() + 3); // so you dont fall off into the void
            location.setX((location.getX()) * -1); //yeah thats literally it
        }

yeah, literally just multiple the X coordinate by -1. that's it.

Twelve0001 commented 2 years ago

i already tried doing it myself, but i dont really have experience with plug-ins.

Twelve0001 commented 2 years ago

i actually did figure out how to do it, but its not configurable.

pop4959 commented 2 years ago

I'm just trying to understand, is this the same or different than #39?

Looks like you are wrapping the X axis, which that issue suggests adding support for both directions (X and Z).

If that's not the case, would you be able to explain more how you would like this to wrap (maybe with a picture of the world)?

Thanks!

Twelve0001 commented 2 years ago

I'm just trying to understand, is this the same or different than #39?

Looks like you are wrapping the X axis, which that issue suggests adding support for both directions (X and Z).

If that's not the case, would you be able to explain more how you would like this to wrap (maybe with a picture of the world)?

Thanks!

This is different, ill see if i can explain it better. opera_67nUXYhMn5

currently, if i walked into the world border with wrapping on the +Z axis, i would be tped from (getZ) to (minZ). in an earth map, realisticly, (because, yknow, earth is a globe), you wouldn't be tped from Greenland to Antarctica

Twelve0001 commented 2 years ago

so if i walked into the red circle where my cursor is, i would be tped from 1000 to -1000. (getX * -1)

pop4959 commented 2 years ago

Oh gotcha. So this would basically be a separate "Earth" wrap setting.

Seems like this is also a similar idea to UV mapping (you basically want the teleport to follow the UV axes rather than XZ).

Twelve0001 commented 2 years ago

Oh gotcha. So this would basically be a separate "Earth" wrap setting.

Seems like this is also a similar idea to UV mapping (you basically want the teleport to follow the UV axes rather than XZ).

mhm, as far as i know you just multiply by -1

pop4959 commented 2 years ago

Sounds good. I'll look at implementing this along with #39 when I find the time (which should be sooner rather than later, I have had other features prioritized until now + just being busy).

Thanks again for the suggestion!

Twelve0001 commented 2 years ago

I managed to make it myself (although not modular). Result is pretty epic.

https://user-images.githubusercontent.com/83358470/187045534-5699ff05-68c9-4b13-98f3-8ecc6b9a83c4.mp4

pop4959 commented 2 years ago

Neat!

Just as a heads-up, I think the way I want to handle the config for this is to change wrap from being a boolean (true/false) to an enum (x/z/both/radial/world or something like that?). That way the user can easily select between wrap types.

Feel free to make a PR for this yourself if you want, but if not, I can take care of this for you when I get to it.

Twelve0001 commented 2 years ago

i did the math very wrong, this is what it actually should be:

        if (location.getX() <= minX) {

            location.setX(maxX - 2);

        } else if (location.getX() >= maxX) {

            location.setX(minX + 2);

        } else if (location.getZ() <= minZ) {

            if (location.getX() >= 0) {

                location.setZ(location.getZ() + 2);
                location.setX(location.getX() - maxX);
                location.setYaw(location.getYaw() + 180);

            } else {

                location.setZ(location.getZ() + 2);
                location.setX(location.getX() + maxX);
                location.setYaw(location.getYaw() + 180);
            }

        } else if (location.getZ() >= maxZ) {

            if (location.getX() >= 0) {

                location.setZ(location.getZ() - 2);
                location.setX(location.getX() - maxX);
                location.setYaw(location.getYaw() + 180);

            } else {

                location.setZ(location.getZ() - 2);
                location.setX(location.getX() + maxX);
                location.setYaw(location.getYaw() + 180);
            }
        }
Twelve0001 commented 2 years ago

Neat! to Just as a heads-up, I think the way I want to handle the config for this is to change wrap from being a boolean (true/false) to an enum (x/z/both/radial/world or something like that?). That way the user can easily select between wrap types.

Feel free to make a PR for this yourself if you want, but if not, I can take care of this for you when I get to it.

im not a plugin developer, i pretty much only do stuff with fabric. I'm not certain how adding config options work.

pop4959 commented 2 years ago

All good. 👍 I think I should have time for this this weekend (+ generally want to get through the issue backlog here).

Twelve0001 commented 2 years ago

i did the math very wrong, this is what it actually should be:

        if (location.getX() <= minX) {

            location.setX(maxX - 2);

        } else if (location.getX() >= maxX) {

            location.setX(minX + 2);

        } else if (location.getZ() <= minZ) {

            if (location.getX() >= 0) {

                location.setZ(location.getZ() + 2);
                location.setX(location.getX() - maxX);
                location.setYaw(location.getYaw() + 180);

            } else {

                location.setZ(location.getZ() + 2);
                location.setX(location.getX() + maxX);
                location.setYaw(location.getYaw() + 180);
            }

        } else if (location.getZ() >= maxZ) {

            if (location.getX() >= 0) {

                location.setZ(location.getZ() - 2);
                location.setX(location.getX() - maxX);
                location.setYaw(location.getYaw() + 180);

            } else {

                location.setZ(location.getZ() - 2);
                location.setX(location.getX() + maxX);
                location.setYaw(location.getYaw() + 180);
            }
        }

update: made the yaw adjust 180 degrees which makes the whole thing feel much smoother

pop4959 commented 2 years ago

Added in efd6415. Use the earth wrap type.