Jump to content

TileEntity networks

Sync Views

Recommended Posts

I was thinking about working on something that would require some fairly complex interactions between linked tileentities (so I guess kind of like LogisiticPipes, rather than normal Buildcraft pipes with the way it needs to know about everything to route stuff).


Ideally Id like this to work by forming a network which has references to all the relevant TileEntity instances, and runs its logic once per tick.


However not sure about some conceptual issues:

[*]If I have a separate Network object, how do I handle loading and saving of this object?


Its not part of any one TileEntity, they might not even be loaded and saved at the same time. Likewise it isn't really owned by any specific block, so cant be a TileEntity itself, and there needs to be a way for any loaded TileEntity in the network to find this object.


[*]How do I handle if the Network spans multiple chunks? My current idea is to make it so in the networks update method, it checks all the chunks for connected devices and only updates if there all loaded (it needs to get the TileEntity for each of those x/y/z's anyway since unloading/reloading a chunk changes the TileEntity object references unless there is also some way around that).


[*]When to recreate the network graph. Finding all connected devices provided all relevant chunks are loaded is easy, but when to update it. My best idea right now is to make every thing that might be part of the network, including blocks that are just acting as wires/connections be a TileEntity that just references the network (however 1. is solved). However won't such a large number of TileEntity instances that do nothing degrade performance? I know people complain about build craft pipes, logistic pipes, alternatives, paintings, item frames, etc. and blame them when the server lags, and I can think of many ways the simple presence of a number of TileEntity instances in the chunk might hurt performance, but I have no idea if this is truly a noticeable amount.


Link to comment
Share on other sites

Not looked through all the code, but looks like you did what I suggested and made the cable blocks a tile entity. Then on an entities first update it will attempt to create, join or merge networks (so things like the card reader are also like a cable, it cant connect to two separate unrelated networks).


Also as far as I can tell you never save the Network but just create it on demand (for both client and server?)? That was something I wanted to do so that the network can maintain state, although thinking about it I guess the devices etc. could store the relevant state for themselves in any situation I can think of. So if part of the network gets unloaded everything carries on but that bit doesn't send/get events?



Link to comment
Share on other sites

Think I got a basic network working. Had some issues with a multiple block machine. I didn't want to allow machines to allow through traffic, or confusing connected to multiple unique networks at once (for now at least, perhaps later I'll let machines have multiple terminals) so the machine would often just connect to itself and reject the cable connection lol. Think I solved that with a "TileEntity INetworkProxy.getReal()" method and more complex getAdjacentNetworks.


Didn't see any such things in your code, suspect when I test more tomorrow its going to give me lots of problems if the machine itself crosses a chunk boundary and is only partly loaded since I guess the proxy code (including for ISidedInventory) can fail giving me an object that claims to implement an interface but cant actually do anything with it...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.