Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
I decided to make my own tutorial about using InitParse, because I noticed there aren't really other tutorials except Ninjasupeatsninja's one.
So let me start.
InitParse is a class written by Processor. The class only has one single method to parse the world data you receive from the "init" message (or "reset", I will explain later). That explains why it's called InitParse. The method returns an array of DataChunk objects. The DataChunk object (part of the class) can store all properties of a block. So you basically receive an array of all blocks in a world.
Step 1: InitParse class
▼View
Step 2: Block class
▼View
Step 3: Three dimensional array
▼View
Step 4: Parse world data
▼View
Step 5: Updating the array
▼View
Step 6: Loading the world
▼View
Now you are done! Here's a small explanation how to use the block array:
Using the array
▼View
Let me know if you need any help, or if you have some feedback for the tutorial.
Offline
Why are you using null for an empty space? There is a block there with ID 0; you're just making life harder for yourself.
Also you can compact the code in Step 5 by checking the message type against an array containing all of the block types. It'll be something similar to the code in this post.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
Why are you using null for an empty space? There is a block there with ID 0; you're just making life harder for yourself.
You're right. I just changed it because I also realized it isn't really a good idea. It's a reference type so it's null by default. ¯\_(ツ)_/¯
Also you can compact the code in Step 5 by checking the message type against an array containing all of the block types. It'll be something similar to the code in this post.
I knew there was a shorter way to do that. I just didn't know how I could do it. The "br" message also confused me a lot, but I see you just added a case for that. Thanks anyway, I changed it with credits to you.
Offline
Note to OP and anyone else updating their mapdata in realtime: you gotta listen for "bn" as well, when an NPC gets placed.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
Note to OP and anyone else updating their mapdata in realtime: you gotta listen for "bn" as well, when an NPC gets placed.
Nice catch, it used to be there in my old code, just forgot that yours was made before the npc update.
I've added the "bn" message to the array, thanks.
Offline
If you want, you can add another int to the Block class and have it start collecting the ID of the player who places each block.
Just make sure you default it to -1 or something, since 0 is a valid user ID.
Btw OP, you don’t need that initialisation loop in the deserialiser class, for the same reason - the default value of an int is already 0.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
Step 5: Updating the array
repeating
blockTypes.Contains(m.Type)
Offline
Excellent information here. It was useful for me. Thank you!
Offline
Excellent information here. It was useful for me. Thank you!
Just woot ok
~meow~
Posting Goal: 2000
#Joe Griffin
Thanks HG for the signature and avatar!!!
Offline
I should actually fix the flaws in this.
Excellent information here. It was useful for me. Thank you!
That's nice to hear. Glad it was helpful for you.
Just woot ok
This post was not needed.
Offline
Excellent topic!
Offline
Thank you for this very helpful tutorial, Latif ! However when I try to get a block id from a world I've just entered in it returns me 0 whereas when I start putting random blocks it does return me the correct id. I've put the code from Step 4 in the (if m.Type == "init") block though :/
I've tried to make it so it is a switch like step 4 but it doesn't seem to resolve anything at all. Does anybody have some idea on what I've done wrong ? Thank you.
Offline
you can use this
Offline
you can use this
▼Hidden text
Damn, it's working now . Thank you
Offline
[ Started around 1732453993.9651 - Generated in 0.134 seconds, 12 queries executed - Memory usage: 1.66 MiB (Peak: 1.88 MiB) ]