Tau-ri-Dev / Mod-JSG-1.12.2

Just Stargate Mod for Minecraft (1.12.2)

Home Page:https://JustSGMod.eu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transport Rings scan code uses inefficient method.

VirgilCore opened this issue · comments

As is probably known, the ring transporters have a major lag issue when they scan for other rings in range. This is because currently, the code for this checks every single block in the given radius for transport rings. This is an incredibly inefficient method, and I have a solution which would fix the issue.

The solution:
Instead of searching every block in the given radius, instead, when a ring platform is created or changed, add it to a list or table containing its name, address, and coordinates. Then, when doing the scan, instead of searching blocks in the radius, check the list of known ring platforms, and compare the position of each to the position of the rings that are scanning, if the distance is within the radius, it becomes available to dial, if not, it does not appear in the list on the controller.

I beleive that this system would be much cheaper on the processor, since it would only have to check from a list of known ring platforms rather than every single block in the radius.

Rings will be later stored in SGnetwork file. But I'm not capable of recoding the whole rings system just because of that. When we will have devs, its possible.

Also notice, that in the 1.20 version the rings system will be written from sratch, so no MrJake's code and no looping trough entire world :)