Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pastel Network Rearchitecturing (BE graph -> BlockPos graph) #658

Conversation

Azzyypaaras
Copy link
Collaborator

Go on.
Cry to your mama, eat your crayons.
You can't un-piss the pastel network.

image

This PR overhauls the internals of the pastel network to fix various issues with it - most notably the extremely problematic server freezes that have been an urgent issue.

To achieve this, a substantial internal overhaul was required. Of note for the major changes are:

  • The internal graph of the networks are now based on BlockPos objects instead of BlockEntities, this allows the graph to be serialized instead of needing to be reconstructed on the fly.
  • There is now a differentiation between the vertices of a network and its loaded nodes. A node need not be loaded for a network to consider it a part of itself and be valid for pathfinding. This is probably has positive effects for performance.
    _ Common code between Server and Client components of networks has increased.
  • The Server and Client components of networks are now kept more closely synchronized. Ahoy sailor be wary, tharr be janky hacks 'ere.

As a very pleasant side-effect of this overhaul, pastel nodes are now able to transfer items over unloaded chunks as long as the transmitter and receiver are loaded.

Further stress-testing before release would be good. While I am fairly certain everything works as intended, some extra testing is always good.

Footnote: This ordeal has only reinforced my hatred for PersistentState

…s not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not the end is not
…'t-unpiss-the-pastel-network

"Fluid" Transfer Pastel Nodes will be real in 2027
@Azzyypaaras Azzyypaaras requested review from DaFuqs and Noaaan January 14, 2025 03:35
@DaFuqs
Copy link
Owner

DaFuqs commented Jan 14, 2025

It arrived, ty!
I'll go through everything and leave my WIP notes on the way.

Copy link
Owner

@DaFuqs DaFuqs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of great improvements all around.
I'll run tests ingame and will look at why some things are the way they are. I am sure you had good reasons.

@DaFuqs
Copy link
Owner

DaFuqs commented Jan 14, 2025

  1. Adding a new node to a network changed the color of the whole network. IMO it should preserve the network UUID of the bigger of the previous networks to not change color all the time
  2. Having a Provider, Buffer and Gather node in the same network made items travel from Provider => Buffer => Gather, instead of Provider => Gather directly, despite there being room (no idea it was like that before already)

@DaFuqs
Copy link
Owner

DaFuqs commented Jan 14, 2025

Other than the things I found works perfect!

@DaFuqs
Copy link
Owner

DaFuqs commented Jan 14, 2025

The unpissing shall be real

@DaFuqs
Copy link
Owner

DaFuqs commented Jan 14, 2025

Inspired by your idea to sync network states I changed up the clientside to only ever store the network UUID and its graph. Literally everything else (manipulation of nodes, ticking, connections, ...) are all handled purely serverside now. the client classes are mostly mere holders for rendering now.

All changes on the server side that modify the graph are synced to the clientside. No more worries to keep everything in sync manually! Saves >100 loc and headaches. Network traffic has been drastically reduced.

@DaFuqs
Copy link
Owner

DaFuqs commented Jan 14, 2025

Oh yeah, the PastelNodeBlockEntities were changed a bit, too:

  • They do not hold a reference to their network anymore which prevented those from being garbage collected before
  • They keep their internal ID, so whenever you unlink & relink them, they use the same network color as before

TODO: when joining a world the nodes do not render yet. Fully functional, though, since all logic is ran serverside. DONE

@Azzyypaaras
Copy link
Collaborator Author

I took a look through things to make sure things works well, and everything looks great! Nothing popped up past a minor visual desync with upgrades - removing an upgrade will have its visuals remain on the node until rejoining the world.

I gave fixing it a short try but decided that you probably have a better idea of how to handle this since upgrades are in a bit of a middle spot when it comes to the server and client.

That aside, to unwind from the pastel pissing and also because I have lost control of my life and I just automatically fiddle with rendering whenever I get within 300 feet (omg feet) of client code. I made some minor visual improvements for nodes; the pastel network is a bit more colorful now.

@DaFuqs
Copy link
Owner

DaFuqs commented Jan 15, 2025

The node upgrade code is kind of cursed:

  • Reading the nodes nbt (like loading a chunk) will immediately always mark it as dirty again
  • If a node has an upgrade and nbt specifies it has none, the original upgrade is getting kept and not cleared
  • upgrade adding runs server- & clientside, but removing it only serverside

@DaFuqs DaFuqs merged commit a365649 into 1.20.1-aria-for-painters Jan 15, 2025
4 checks passed
@DaFuqs DaFuqs deleted the 1.20.1-go-on-cry-you-can't-unpiss-the-pastel-network branch February 7, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants