Railcraft

Railcraft

34M Downloads

[Feature Request] Special Anchor (chunkloader)

Terpo opened this issue ยท 16 comments

commented

Hello,

is there any chance to add a special kind of chunkloader?

  • anchor does not force load after server restart
  • anchor activates if any player is nearby (not just the owner)
  • anchor stays online until next restart or out of fuel

Now you may ask: Why would someone need something like this?
I'm admin of a small private server. The server has enough power, but there is something really weird when it comes to chunk unloading. After a player left the server, some parts of the base stays loaded. I talked with ProfMobius about it because even a /chunkpurge command does not unload these chunks. (picture: http://blog.terpo.org/upload/mc/chunkpurge.png)

I'm logging the serveroverload on our homepage. The more bases are loaded, the higher is the overload.
Two examples:
[13:38:19] Running 2115ms behind, skipping 42 tick(s)
[16:52:28] Running 20883ms behind, skipping 417 tick(s)

Here are two charts of a testserver. I did only join, teleport to a base and left the server.
http://blog.terpo.org/upload/mc/serverload.html
I also tried this on different PCs and the TPS is at max. 20ms. The whole server is stopping for this period of time.

As you can see, adding chunkloaders stabilizes the server, but I don't want to load all bases with admin anchors.

Hopefully that is enough information for you :)

commented

I'm trying to add the anchor myself but my knowledge in modding is not that great. Adding another block to your alpha machines is not possible. So I put it into gamma for the moment.

Everytime I put the anchor down I'm getting the following message in the log:
http://blog.terpo.org/upload/mc/rcmodding/rclog.txt

The anchor itself is an admin anchor with a few lines of the personal anchor.
http://blog.terpo.org/upload/mc/rcmodding/rcanchor.txt

So, I dont know why the anchor throw an error.
I have a working build that I will test with my modpack on a LAN server in the next days.

commented

You need to add it's entry to the Machine Tile Registry class.

commented

Interesting interaction. I'm fairly certain I've seen this happen on a few servers before but we never found a solution. Worth mentioning is that it happened even without chunkloaders in some areas.

On another note, love your special anchor. Could defiantly see a use for them.
If your planning to submit them to railcraft I would directly request the possibility to set their size of the area they load.

commented

I did a video about some interesting chunk loading behavior:

http://youtu.be/Bs1hv4gtVxQ

Personal anchor do the same. If another player (not the owner) logs in after a server restart the chunkloader itself is offline but the chunks are still loaded.

For me it is ok to restart our server simply two times every morning. This would unload every loaded chunk to 100%. It also works for the personal anchors (tested it).

The other main question is.... why are the chunks already loaded after the first restart. Without a chunk loader that will not happen. So it seems that chunkloaders load up the chunks and deactivate after it.
Now the question is: How can I tell the anchor to be ignored completly after server restart. This would also solve a double restart. Does forge save tickets when the server shuts down? So is there a ticket after restart or does every anchor gets a new one?

commented

It extends the normal world anchor. So it should also work with sentinels. With this, you can specifiy 3x3 or 1x1 to 1x25 chunks.

I am not sure about a recipe and / or fuel usage. This anchor is quite powerful, so the costs should be the same as the world anchor. On the other hand is a very special purpose of using it. So it would also be possible to ignore fuel, but make the recipe more expensive, or don't even specify a recipe.

commented

The initial chunk load is apparently caused by a (debatable) bug in RailCraft, its ChunkManager.ticketsLoaded() loads the chunks before evaluating whether the requirements are met by instantiating the tile entity.

TileAnchorWorld.meetsTicketRequirements() would have to be decoupled from the tile entities, otherwise chunk loaders like the personal anchor or yours will always have to first load the chunk + te, check it and then unforce the ticket, which of course doesn't work well due to Vanilla keeping chunks loaded if they ping each other enough.

commented

Hmm...I admit I never thought about that angle. The special "ticket requirements" were all added long after the initialization code was written. But on that note, I didn't think that Personal Anchors were even fed to the initializer. However if they are, it should be a simple matter of ignoring the ticket before it gets to the chunk load stage. Additionally, tickets can also have arbitrary NBT data tagged to them.

commented

Yes, some clean-up could be done here I think.

commented

On the note of TileAnchorWorld.meetsTicketRequirements(), if this returns false, the ticket was already discarded. So there would be no ticket present at load time anyway.

commented

Thanks player, I may have to take a look on it. In the last days I added the methods for the textures.
Yesterday I updated our whole modpack so that I will test the chunkloader in a real environment.

commented

I think it would be a good idea to test this change in my server environment. (Just if it helps or not).

commented

It is working perfectly. After a server restart only world -and admin anchors are loaded. Personal anchors and my ones do not load, and this bases are completly unloaded.

When someone comes in range of these two anchors they will activate :).

commented

So these chunks that staying loaded aren't currently being loaded by anything other than, for example: "hopper chunkloaders"? In other word, you aren't currently running explicit chunkloaders, but the chunks stay loaded because of chunk-thrashing? And you want chunkloaders to reduce the thrashing?

commented

I can't figure out whats causing the chunks to stay loaded. There are no explicit chunkloaders in most of those bases. Yes, I want a higher TPS rate with chunkloaders when it helps to prevent massive server lag spikes. Another thing is, that these loaded chunks are not predictable. ex.: Boilers cool down even if there is a barrel full of charcoal next to it (not everytime but often). I did a video about it for EnderIO because I found out a cross mod problem that shows the problem: https://www.youtube.com/watch?v=U-b0sxdrjA0

Minecraft stops being fun when the server stops for 8 or more seconds every 30 seconds or so.

commented

Your argument is valid, your use case is specific and reasonable. I see no reason to deny the request. ;)

Now someone just needs to write some code.

commented

Most of the code should already be there. Your anchors have the most whats needed.