Open Kristopher38 opened 4 years ago
Do you tested this with one player on server? It bug may bound with dimension update mechanics: entities are not updated if dimension not contains players. For check it try follow:
I've tested this with your instructions on singleplayer as well as on multiplayer server, and also the other way around (from the nether to the overworld) and the drone still only starts moving when I enter the chunk in which it stopped execution.
Also note that, with my test setup, if I enter the portal before the drone does (with long runway for the drone, so the dimension for me finishes loading before the drone enters the portal), the drone runs continuously, i.e. I can see it seamlessly going out of the portal and flying straight. That means the chunk the drone is in before it enters the portal isn't unloaded when the only player exits the dimension, so it continues to fly straight into the portal.
There is also a way to provide stronger evidence to support this, e.g. setting up a stationary drone/robot with chunkloader upgrade near the exit of the portal, so the chunk with the portal in dimension where the drone exits it is always loaded, and then starting the drone from the other dimension to enter the portal (basically the setup in the first post, only that additionally in step 4. you place the drone/robot with chunkloader upgrade running in the same chunk that the exit portal is in). Drone entity still gets processed after exiting the portal on the other end, i.e. it has already finished moving when the player enters the dimension, even though there were no players in that dimension, but the chunk with the portal exit was loaded, which allowed it to move beyond that chunk.
My point is, it's not an issue with entity processing in dimensions without players. I believe it's a problem with with chunk loading when switching dimensions, but maybe someone else could provide more insight on this.
I looked into this a bit, and I made a fix here. In short, the problem was that entities changing dimensions actually get "cloned" into a new entity instead of just moving the old one, which made the chunkloader not even realize it was supposed to be on. I fixed it by tracking when a drone was changing dimensions, and if it had an active chunkloader, record its address so I can enable the chunkloader on the newly cloned drone.
I could PR that, but EntityTravelToDimensionEvent
is only on 1.12, so 1.7.10 would still have the bug. I didn't see anything in 1.7 that serves the same purpose as that event, so I'm not sure what to do about that.
I don't like that the chunkloader upgrade code doesn't store whether or not it's supposed to be enabled. This would make resolving the issue much simpler - instead of relying on ChunkloaderUpgradeHandler.restoredTickets
and Forge's own chunkloader ticket tracking system in onConnect
, we could simply check the chunkloader upgrade's own flag for whether or not it is meant to be enabled.
In this case, I would also extend the chunkloader upgrade's API with isEnabled
and setEnabled
(the latter aliased to setActive
); this way, isActive
would tell us if a chunkloader is actually active, while isEnabled
would merely inform us of the user's current intent.
Versions: Minecraft: 1.12.2 Forge: 14.23.5.2768 OpenComputers: 1.7.5.192 Pure forge install without any third-party launchers, with only OpenComputers installed
Description: Drones with chunkloader upgrade stop operating after going to a dimension where portal exit isn't in a loaded chunk. That applies to going from the overworld to the nether/the end and vice versa. The drone resumes operation after the chunk that the drone ended up in gets loaded, e.g. a player loads it. If the chunk that the drone teleports to after going through a portal is loaded before the drone goes through, the drone runs as intended without a halt. This happens on singleplayer as well as on multiplayer server. I've tested it a bit and according to the logs (from locally hosted multiplayer server), the drone actually loads the dimension that it gets teleported into after going through a portal and even generates chunks around itself if it's a fresh area and fresh portal that wasn't used before. The issue is, after that the dimension gets immediately unloaded. I believe this could be the same issue as described in this issue, only that it's not an incompatibility with another mod, but rather an issue within OpenComputers itself.
Logs generated when going through a fresh portal:
Logs generated when going through an already-generated portal (on the exit end, notice the timestamps):
How to reproduce:
chunkloader.setActive(true) -- make sure the chunkloader upgrade is running drone.setStatusText(tostring(chunkloader.isActive())) -- verify it by setting status text drone.move(40, 0, 0) -- move 40 units east while true do drone.swing(0) -- do some action to yield end