Okay, I have entities rendering, at least in a most basic fashion. Not really happy with the code at all though, gonna think about it and then go back and redo it. :/
Yeah, definitely gonna render entities next. Right now I'm trying to decide what kind of format I want to use for tracking what to draw for entities. Like, I could have the server tell the client about every single vertex... But that seems a little silly. Probably better to have it tell the client about shapes, and let the client figure out the vertexes? Not sure. :/
Anyway, thinking I'm going to implement rendering for Entities next? And maybe touch up my rendering pipeline a bunch while I'm at it? Say, go for specular refraction, transparency, HDR, bloom, and tonemapping, maybe? :/
Though, now that I think about it, If I make chunks entities I could simplify displaying them, maybe? Dunno. Regardless, for the moment, I implemented code to automatically tell the clients about new entities, and for telling the client about chunks that are not homogenous:
I was thinking of doing thinks like allowing players to make boats out of blocks... But those can probably just contain their own internal chunks anyway, I would expect. No need to mix chunks up in my entity system. :/
Even with LOD chunks, they're still likely going to work much the same way? They might be missing some components - I don't think they'll include any structural or temperature data, even once I've implemented that, for example - but I don't think that really matters. So, folding the chunks into the entity system in this light doesn't seem like it would be particularly useful. I'd just be adding a bit of extra overhead and complexity for no reason. :/
They're all the same. They have a chunkposition, and then a bunch of arrays of their components, and they're never missing any of these things, or containing any extra components, nor do any of these things really show up anywhere other than in a chunk. :/
In other news, I am rethinking making Chunks into Entities? Thing is, the Entity system is great for when you have a variety of different things with all sorts of weird overlap - Players and enemies and NPCs and bullets and traps and explosions and clouds of deadly gas and laser beams and machines and... Well, my chunks don't really have that.
Okay, made components responsible for most of their own networking, and then refactored my datagrams to be much more flexible, maintainable, and extensible. Now some more refactoring to clean up the code... XD
Now that I think about it, maybe I want to just make components responsible for their own networking entirely? Not sure. I guess the way this would work, is I have two different kinds of PositionComponent? So, on the client side, it just tracks position, nothing else, while on the Server side, it also tracks whether or not it's been changed, and sends that to the client? And I guess I would have the code for deciding whether a component should update the client all be handled elsewhere? :/
Well, 'got networking for entities working the way I want it to' may have been overly optimistic. I'm trying to neaten out my entity networking code a little. Making entities responsible for sending their own updates. Raises the question, though! Do I just have everything in range update every client every step, or do I have entities track whether or not they've changed, and only update the client if they have? :/
Okay, got networking for entities working the way I want to, did a bunch of refactors, and implemented direction and point lights as entities that can send their data to the client. Lots of progress, but The Code Is Still A Mess, as usual. :/
Honestly, the more I think about it, the more I like the idea of registering some kind of 'Network Endpoint' objects, and just addressing those directly. Not sure how I want them to work yet, though. :/
Hmm. Maybe I should give entities components to handle the networking. 'NetworkEndpoint' components, or whatever? And these components can deal with tracking all the other components attached to the entity that might be modified via the network? :/
Hmm. I'm leaning towards just addressing the components directly, but I'm not sure that fits either? Cause not all entity components will involve networking? behavior and camera components generally won't, for example. But I guess most of the others often will, at least on the client side? So.
Maybe I want to separate 'object that receives network updates' into it's own thing somehow? I'm not sure. :/
Well, I have an ECS that's satisfied with for now. Now I just need to figure out what I want to do for network code? I had been sending player position and movement direction updates via 'ModifyObjectDatagrams', which specify the objects id, it's registry id, the id of the field I wanted to modify, and then the new value for said field. If I'm going to just make everything entities, maybe I want to go 'EntityID, componentID, fieldID, fieldValue'? But I'm not sure yet. :/
Or maybe that, except dynamic? Like, some kind of system where an object can have components added and removed after it's been created? I don't know, that sounds crazy hard to code efficiently. Be really neat though. XD
Okay, so! Entity Component Systems are kind of neat, actually? Given me a bit of a new perspective on programming. I kind of feel like there should be direct language support for this kind of thing somehow, instead of something I have to implement on top of the language? But, there ain't. Not sure how it would work, either. Some kind of decent multiple inheritance for state would be my first guess. :/
Okay, so I started poking at my lighting system so i could properly send it's data to the clients - and I think I need to implement a proper entity component system. :/
Did a bit of refactoring and some bugfixes. I think I'm going to adopt a dev cycle? Nothing too fancy, just a basic 'New Features -> Bugfixing -> Optimization -> Cleanup & Refactoring -> Documentation -> Repeat.' And the optimization and documentation parts are going to be really light until I get the project to the point where it makes sense to put more effort into them. XD
Okay! I think I have full multiplayer support now? I still need to test the thing, but in theory, multiplayer should be supported as well as singleplayer is - that is to say, not very well, but still. XD
Sending chunk data to the client now. Need to work on my code for loading and unloading chunks, though. Also, apparently entire chunks worth of grass will occasionally go missing? No idea why that happens. :/
Did some more work on separating client and server, and in theory it should be a bit closer to allowing multiple players to use a server. And I eliminated some debug messages. Still nothing much to see though. XD
Yeah, I did that. Got datagrams for player movement direction and position working, so that gets sent back and forth between server and client. Nothing exciting to look at, but it works! XD
Alright, that works pretty well. But now I'm back to trying to figure out exactly what messages to even send. Like, I want to update entity positions every tick. Okay, so that's an ID for the datagram, an ID for the entity, and the new position? But what if I want to update some other field for an entity? Is that a new datagram? Or do I want one datagram, and also specify which field of the object I'm updating? :/
Okay, so I've been trying to figure out serialization to my satisfaction. Slow going, but I think I'm making progress. Currently trying to decide what to do with objects that need to be modified after their constructor - my current serialization algorithm doesn;t handle that well. :/
Yeah, the increased asynchronicity thing didn't work out, but that's fine, I can revisit it later if I need to. For now, I just implemented chunk loading and actually used that world generation, even if it's dead simple for the moment.
Alright, made a bunch of progress on my generation algorithms, and put together a cheap maven repo using gitlab. So, in theory, you can build the thing from downloading just one project now? Pretty sure it works. XD
Got point lighting working. Didn't figure out that refactoring to my satisfaction, but that I can come back and take another crack at that later I guess. Thinking about doing world generation and chunk loading next? :/
Working on implementing modules for rendering and tracking the game world, now. Going really well. I have my skybox rendering, along with the outline of a single cube - and I resolved tons of super annoying old architecture problems that had been bugging me for ages. Feeling good. XD
Alright, I managed to get to my games title screen via running modules in OSGI. I need to get a better handle on developing with OSGi though, currently I need to load like 12 different modules via command line to get the thing running from scratch, and that's a pain. Gonna take a look at Netbeans, I think, see if I can figure out how it does things. Or maybe some other open source desktop application built with OSGI, there are a few I know of. :/
Okay, so I decided to ignore all those examples and actually use OSGI. This is some enterprise shit, but it looks like it does precisely what I need? Here's hoping. It's what the IDE I use, Netbeans, is built on, along with Eclipse, and IntelliJ is built on something very similar or possibly the same thing, I hear.
Alright, fixed my weird bug. Lighting worldgen doesn't work right, so only the very tips of the terrain are lit up, but I'm going to work on that. First though, I'm going to try and implement a module loader and split the game up into modules. I have lots of examples of how to do this, between Forge, Fabric, Minetest, and Terasology, so hopefully I can figure it out. XD
Yeah, working on that. Made a bunch of progress. Fixed a dumb mistake that was disabling all lighting generation, and now I have some weird bugs. You know, as one does. XD
Alright, did that! Had some weird bugs because I broke the function calls for chunks looking up surrounding data from the world, but I figured that out and fixed it. Just doing some cleanup and a few minor optimizations now, and then I need to figure out what next. Probably sending ambient lighting data to the client? Not sure yet. :/
Anyway, now I'm back to optimization and refactoring. Currently, I'm looking at tacking my Chunk classes and trying to genericize them or whatever? Like, at the moment they're made of three components, Blocks, Sides, and Ambient Lighting Data. All of these are explicitly coded in the chunk, so you can;t add or remove them without trecoding a bunch of stuff. I think i can make some kind of generic framework that will allow easily adding or removing this kind of data from the Chunk class?
Turns out my Server loop was Busy. Fixed that, it runs properly now. I also added datagram prioritization on the client, compression for networking, and fixed a mistake that was causing my game to to crash when I tried to profile with VisualVM. Making Progress!
So I went and added networking with Netty. Works on my local client at least, but I get weird lag - like, I move faster or slower depending on which direction I go? So going forwards is like moving through Molasses, but going sideways is about normal speed? But only under certain conditions. :/
No work on array iteration yet, but I optimized world gen iteration. I had to increase the cap on how much data it can send from the server to the client to make that work, but now it runs buttery smooth. I'll need to optimize for sending less data though, I doubt it would work over a network at the moment, even if I added netcode. :/
Well, I ended up using VisualVM - it's actually really handy, once you figure out how to use it. Anyway, I optimized a couple of things, so rendering and loading chunks is much more efficient now. But, now it seems like I need to optimize my array iteration - I have that turning up as a bottleneck in half a dozen places. I already started using ZOrderCurves, I'll need to see if I can figure out how to improve beyond that. :/
Thinking of writing an integrated profiling framework or something for Omnicraft. I made a dead simple one, involving just a pair of 'System.currentTimeMillis()' calls, and it was actually really useful - writing something more thorough might be handy. Anybody have any experience with that kind of thing? :/
Well, I did some further optimization and things were running a lot better - so I implemented datagrams for sending data on light sources and sides to the client, and now it lags again. XD
Took a break from working on interval trees to try and make chunk loading and unloading on the client more efficient. I rewrote a bunch of stuff, and it's more elegant now, maybe, but I'm not sure if I actually made it more efficient. :/