toolbox4minecraft / amidst

Advanced Minecraft Interface and Data/Structure Tracking
GNU General Public License v3.0
2.14k stars 239 forks source link

Map the End gateway portals, if possible #116

Open Treer opened 8 years ago

Treer commented 8 years ago

from reddit

Suggestion: Could you give the locations where the outer Gateways generate, perhaps with a line linking them to the corresponding spot around the center island and an indication of which order they appear in?

My understanding is that you can create up to 20 gateways, and the inner ones make a circle, but where the outer ones appear is not as easy to know in advance. Can AMIDST figure it out?

I don't know whether it can be determined by the seed, but seems worth looking into.

From the Minecraft wiki: endgatewaygeneration

An example of end gateway generation shown on a graph in X-Z coordinates. Blue dots represent the main island gateways, red dots represent the outer islands gateways. The lines display which gateways connect to each other.

sab39 commented 8 years ago

I've not made any attempt to look in the code or do any kind of scientific investigation, but based on my experience so far I have a few data points regarding the generation of the gateways.

The locations of the inner ends of the gateways seem to be precisely predictable: they are in an exact circle with radius 96 and at Y=75. The (X,Z) coordinates are (96,0), (91,29) and (77,56) and all the flipped/negated versions of those to make a circle.

The order in which they generate is not any straightforwardly obvious pattern: in my world the first six to generate in order were (-56,77), (91,29), (0,96), (29,91), (77,-56), (29,-91). If there's a logic to that order I'm not seeing it! However, I think the order of generation is based on the seed, because I made copies of my world to test the dragon fight in the 1.9 snapshots several times, and the (-56,77) gateway was always the first one generated, and always took me to the same place.

The coordinates of the outer points also seem to be somewhat unpredictable but all in the approximate range of the inner coordinates multiplied by 11ish. Specifically, my six gateways go to (-576,832), (984,312), (7,1016), (387,1217), (823,-577) and (304,1069).

For reference, my seed is -416870298798402092.

Treer commented 8 years ago

I think the order of generation is based on the seed, because I made copies of my world to test the dragon fight in the 1.9 snapshots several times, and the (-56,77) gateway was always the first one generated, and always took me to the same place.

Excellent. I'm pretty sure that means it can be done.

The generation order pattern can be found by picking apart the code, I tried a few weeks back but ran out of time before I found whether it was determined by the seed, now we know!

I did find how the outer gateways are calculated though - it casts a ray out until it hits land and builds the gateway there. If it goes too far without hitting land it creates one of the miniature islands for the portal to be above. The problem with this is Amidst only has a rough idea of the land (we know the island cores, but not their exact coastline), so while we should be able to get the inner gateways perfect and in the correct order, the outer ones will be an estimate.

It will also be worth checking if the height the ray is cast at can intersect with the miniature islands, since they can't be mapped from the seed. Hopefully it's cast at a height which the miniature islands don't spawn.

Regarding the outer gateways coords not being perfect... I never looked into how coastlines are generated, it might be possible to make the map more accurate but that's not on my list of priorities - it's probably lots of work with a large chance of no payoff.

sab39 commented 8 years ago

How did you get to look at the code to pick it apart? I'd be interested in seeing if I could figure out how the generation order is determined.

Treer commented 8 years ago

I've been using Enigma to deobfuscate the code.

I think it's been mostly abandoned, and it has a few bugs, but it does a nice job of helping you make the code readable. (AFAIK it's not designed to make compilable source, just readable code, they recommend MCP if you want compilable source)

I should mention I'm not a java expert and don't know if this is the best tool.

The problem with finding the generation order was that lots of code in 1.9 is new - including everything to do with the End, so mappings from previous versions can't be used to help deobfuscate the new code, I had to slowly pick my way in directions which might lead to the area of code that the generation order code would be located in.

I see the last post in that Enigma thread is a link to someone's attempt at mappings for 1.9, I've not looked at these, perhaps they already map the classes we need. If not then I imagine it's still a good starting point.

(A lot of the stuff in my own 1.9 mapping file is wrong - I tried to automatically bring mappings over from a previous version and it got the order of a lot of fields and enums wrong. Tip: get the enums right because then when you see a class that adds Blocks.BEDROCK and Blocks.ENDSTONE it gives you a pretty good idea of what you might be looking at)

MattSturgeon commented 7 years ago

IIRC the gateway portal on the outer ring side is generated dynamically the first time a main island gateway is used. It essentially searches for endstone that is closes to a spot x blocks on the line that goes from 0,0 through the gateway being used.

The location of the generated portal can actually be manipulated by players by placing blocks carefully before using the portal on the main island, however since this is unlikely, it is fair to assume the location will be roughly 1000 blocks from the main island gateway, on the line from the center through the gateway.

burgerindividual commented 4 years ago

I've been trying to figure this out, and it seems like it relies on other features being generated first, which modifies the Random. We'd have to do some sort of workaround with random advancing to get an accurate location of the gateways. If anyone else wants to implement this for if I fail, I'll attach the icon for them that I made. end_gateway

MattSturgeon commented 4 years ago

I was able to get the same random gateway to generate in the same location by generating the same seed in multiple world's, so they are seed based at least.

 it seems like it relies on other features being generated first to find the random ones The "normal" gateways essentially raytraces out from the one on the main island, finds the first non-empty chunk and then looks for the highest block in that chunk. Maybe the random gateways use some of those mechanisms (e.g. scanning for the highest block) hence why they need the terrain to exist first?

On Fri, May 15, 2020 at 4:15 PM +0100, "burgerguy" notifications@github.com wrote:

I've been trying to figure this out, and it seems like it relies on other features being generated first to find the random ones. We'd have to do some sort of workaround with random advancing to get an accurate location of the gateways. If anyone else wants to implement this for if I fail, I'll attach the icon for them that I made.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

burgerindividual commented 4 years ago

I got the random gateways to generate mostly correctly, now all I need are the normal ones.

MattSturgeon commented 4 years ago

The normal ones are a bit simpler. There's 20 fixed positions spread evenly around the main island. Each one generates its return portal when it is first used, and depends on the actual terrain rather than the seed (i.e. it's possible to manipulate the position by flying to the outer islands and changing the terrain, originally shown by Gnembon). This is shown visually by the image in the op, from the wiki. The exact code is in the end gateway tile entity class, but it basically ray traces out 1024 blocks and then looks for the first non-empty chunk along that ray.