STEEM.CRAFT | #3 | Added custom world size, spawn point & faster world saving

in utopian-io •  6 years ago 
Thanks to the new adjustable world size, I added a little park area to my world, which is stored on the Steem Blockchain.

Hello, Steemians and Minecraft players,

this time, I have some major improvements to the steemworlds.sk addon for STEEM.CRAFT to show off. These changes will improve the local server performance, allow bigger worlds, customizable spawn locations and faster world saving times for Minecraft worlds that are going to be saved on the Steem Blockchain.

1. Repository

https://github.com/Abwasserrohr/STEEM.CRAFT

2. Index

  1. Repository
  2. Index
  3. New features and changes
    3.1 Most API requests are now done within a thread
    3.2 steemworlds.sk: World size can now be adjusted
    3.3 steemworlds.sk: The world spawn can now be changed
    3.4 steemworlds.sk: Data of worlds can now be loaded using a new function
    3.5 steemworlds.sk: Unchanged chunks are now skipped on world save to Blockchain
  4. Pull requests
  5. GitHub Account
  6. How to contribute

3. New features and changes

3.1 Most API requests are now done within a thread

While the API servers by Steemit are really fast, this doesn't have to be the case, in some cases and if the server operator decides to change the API server to his own or another server which is slower, it could halt the server quite badly. To prevent this from happening, almost all function which requests the API now call another function in a thread to prevent the server from being halted.

While a small server with a very low amount of people could have used it like it was, once there are multiple players visiting, commenting and saving worlds, it is important that everything runs within a thread to prevent bad user experience for other players.

Pull request: https://github.com/Abwasserrohr/STEEM.CRAFT/pull/18

3.2 steemworlds.sk: World size can now be adjusted

Having limitations is not really that great, increasing the world size to allow bigger buildings to be made, saved and loaded can be a big deal for some players. While the size of these worlds will slow down the saving and loading process and also will require a good amount of resources, it will be possible to do that, if necessary.

This function will do the job. It will multiply the size input with 32 and then set the world size to it. Now, you might ask: Why do you multiply it by 32? Does that make any sense?!

Yes! It does because, in Minecraft, every chunk is sized 16x16 blocks and STEEM.CRAFT stores worlds per chunk. The main reason here to use 32 is to give the player exactly the world border which is also going to be saved to Blockchain. That way, it is not possible to accidentally not saving something to the Steem Blockchain.

In the case, somebody wants a world which has a radius of 3 chunks, the function has to be called with the following parameters:

Multiplying the right amount in the functions itself will reduce the amount of work on the scripts where it is used and prevent mistakes.

Pull request: https://github.com/Abwasserrohr/STEEM.CRAFT/pull/16

3.3 steemworlds.sk: The world spawn can now be changed

Now with the customizable sizes, players may want to also change the spawn location of their world. This is now possible with this change. The changeable world location is not only saved locally on the server but will also be broadcasted into the comment of the steemworld once it is saved.

I decided to create two functions which serialize locations by my own to make the size as small as possible because it matters on Blockchain to make the transactions small.

Initially, I wanted to use a valid json for the spawn location, which not only would look better but also easier usable by other apps. I decided against it for now because it would increase the size of the transaction. While it is true that the transactions are already big and the spawn location wouldn't make that much of a difference, but for smaller accounts, it will make a difference.

Instead of having {"x":0,"y":1,"z":0,"yaw":0,"pitch":0}, there will be just a string out of the necessary variables like this: 0_1_0_0_0, since the locations have just 5 variable points, we don't need more than that. Of course, in theory, the name of the world needed to be saved too, but since we already have the world name saved in the comment itself, it doesn't have to be saved again here.

While the size makes some difference, there would be no problem at all to change the current model to the json one, depending on the feedback I get from people using it later on.

Because I use functions to serialize and deserialize these strings, only two functions would have to be changed to use either json or the custom string, which is also why I use functions here.

Pull request: https://github.com/Abwasserrohr/STEEM.CRAFT/pull/19

3.4 steemworlds.sk: Data of worlds can now be loaded using a new function

I needed this function for the world saving (saveSteemWorld) function because I wanted to only broadcast chunks which actually have changed to the Blockchain and skip chunks which are the same on the Blockchain and the local server.

While there was already world loading in the loadSteemWorld function, there was no general one which gave me the opportunity to just get the world data in variables. With this new loadSteemWorldData function, I can load just the needed data without overwriting the world with the loadSteemWorld.

Because doing work twice isn't that nice, I decided to take the needed parts out of loadSteemWorld, use these in the new loadSteemWorldData function and then replacing the old loadSteemWorld parts with this new function in both loadSteemWorld and the saveSteemWorld functions.

The loadSteemWorldData function has two great advantages: The loadSteemWorld is now smaller and easier to understand and the world loading doesn't have to be done twice in loadSteemWorld and saveSteemWorld.

Pull request: https://github.com/Abwasserrohr/STEEM.CRAFT/pull/21

3.5 steemworlds.sk: Unchanged chunks are now skipped on world save to Blockchain

Since the loadSteemWorldData function is now a thing, it is easier to do this task than before. By loading the current world state from the Steem Blockchain, both Blockchain version and local server version are compared on saving the chunks. If both versions are the same, it will skip the chunk and use the previous chunk version in the new version to save resources and improve world save speed.

I made a quick video while I still was testing things out and you can see that this new feature allowed me to not broadcast any new chunks since all of them were still the same as before. There is nothing else going on but I wanted to show that the skipping process actually works.

While it doesn't skip the waiting just yet if all chunks have been skipped, that might be added in the future.

Pull request: https://github.com/Abwasserrohr/STEEM.CRAFT/pull/22

4. Pull requests

https://github.com/Abwasserrohr/STEEM.CRAFT/pull/16
https://github.com/Abwasserrohr/STEEM.CRAFT/pull/18
https://github.com/Abwasserrohr/STEEM.CRAFT/pull/19
https://github.com/Abwasserrohr/STEEM.CRAFT/pull/21
https://github.com/Abwasserrohr/STEEM.CRAFT/pull/22


5. GitHub Account

https://github.com/Abwasserrohr


6. How to contribute

If you want to contribute to STEEM.CRAFT, contact me here in the comments or on Discord. Please contact me directly, I'm the sewage pipe on Discord. I look forward to meeting people who want to get in touch with Skript and Minecraft.
Of course, you can also start forking STEEM.CRAFT, creating pull requests and improve it without contacting me.

Discord: https://discord.gg/FRuK5BC


Thank you for reading my contribution post.

The new features and changes now give players the opportunity to build bigger things in their worlds and storing them also on the Blockchain to visit and edit it on other servers too.

Skipping not changed chunks will not only reduces the saving time for smaller worlds but especially players with very big worlds will see a big impact of that change, if not every chunk has been changed.

Because almost all API request functions now use a separate thread, the game will no longer halt for short times, even if multiple players try to visit, load or save worlds at the same time, which is great. :)

Have a great Friday and a nice weekend,

@immanuel94

STEEM.CRAFT IS NOT A OFFICIAL MINECRAFT PRODUCT.
NOT APPROVED BY OR ASSOCIATED WITH MOJANG.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  • Awesome post with a video, images, code samples and explanations of coding choices.
  • Commit messages are exceptional
  • Comment in the code are over the top.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for reviewing my contribution post. =)

Thank you for your review, @helo! Keep up the good work!

Cool das es so ein feature auch mal gibt, kann bestimmt nützlich sein und so eine idee hatte glaube ich noch keienr

Ja, das hoffe ich mal, dass die Features für die meisten Spieler sehr nützlich sein könnten... :3

Toll, daß ihr euch die Zeit nehmt hier immer weiter zu bauen. Bin leider zu wenig drin im Skripten als dass ich helfen könnte. Aber ich mache fleißig Werbung für euch!

Danke für deine Unterstützung. =)

für was genau ist das gut?

Wenn man z. B. auf verschiedenen Servern spielt und auf beiden auf die eigene Welt zugreifen möchte, dann wird einem das ermöglicht. Auch sind die Welten sicher vor einem Serverausfall und können selbst, wenn der Server komplett gelöscht wurde wieder aus der Blockchain geladen werden. :)

Hi @immanuel94!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Congratulations! Your post has been selected as a daily Steemit truffle! It is listed on rank 14 of all contributions awarded today. You can find the TOP DAILY TRUFFLE PICKS HERE.

I upvoted your contribution because to my mind your post is at least 7 SBD worth and should receive 187 votes. It's now up to the lovely Steemit community to make this come true.

I am TrufflePig, an Artificial Intelligence Bot that helps minnows and content curators using Machine Learning. If you are curious how I select content, you can find an explanation here!

Have a nice day and sincerely yours,
trufflepig
TrufflePig

Hey, @immanuel94!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!