ImmersiveMC

ImmersiveMC

2M Downloads

Remove RNG Syncing

hammy275 opened this issue ยท 2 comments

commented

Instead of requesting the state of the tile entity at random intervals, the server should send updates to the client. This actually requires a pretty major refactoring, more specifically by doing the following:

  • Remove all syncing packets from our swap methods
  • Whenever a tile entity that supports immersion changes, send an update packet to all those tracking the chunk.
  • Whenever a client was farther than 20 blocks away but is now closer than 20 blocks away (or whatever range is decided on in #28), they should request a sync to the server We remove immersives further than 20 blocks away
commented

Closing this for now, since it seems the solution to this is in itself hack-y (requires looking at Vanilla packets). Will re-open if I have any ideas for how to handle this.

commented

Okay, I have a new way to handle this. It's still kinda hack-y, but it's far better than the RNG we're using now.

Each immersive category will be given a limit to how much each can hold. Here's the planned amount for each:

Crafting: -1/unlimited (doesn't need to sync data with the server continuously, so no need to limit it)
Furnace: 4
Brewing: 2
Chests: 4
Jukebox: 1

When an immersive is registered but we're already at the limit, we de-register the one closest to being removed. If during this check there is a tie, it doesn't matter which one we discard, as long as we get rid of one.

Instead of syncing when a swap takes place, we ask for a sync on all of them 10 times a second. It's fast enough for redstone, so it's fast enough for us.

Implementation checklist:

  • Remove syncs from Swap methods
  • Add code to AbstractImmersive to return a maximum amount of infos it can have
  • Add code to enforce the maximum. It's fine if it goes above the maximum for a tick or two, as long as it generally stays at the limit.
  • Change code to request immersives once every other tick