STEEM.CRAFT | #4 | Added support for loading of older world versions, biome & gamerule changing functions

in #utopian-io5 years ago (edited)
I created a new world with the steemworlds addon which is used to demonstrate some new changes. It is a little forest area with a mine. It is possible to visit it using /visit immanuel94 mine

Hello, Steemians and Minecraft players,

it is now already 18 days ago since my last post about changes on STEEM.CRAFT. This is mostly because I needed to find ways how to retrieve older versions of worlds without actually storing extra data to the blockchain. In this contribution post, I want to show you guys world loading of any world revision that happened before, biome- and gamerule changing of the steemworld.

1. Repository

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

2. Index

  1. Repository
  2. Index
  3. New features and changes
    3.1 steemworlds.sk: Any steem world revision can now be loaded
    3.2 steemworlds.sk: Added biome changing
    3.3 steemworlds.sk: Added functions to change and get a gamerule of a world.
  4. Pull requests
  5. GitHub Account
  6. How to contribute

3. New features and changes

3.1 steemworlds.sk: Any steem world revision can now be loaded

A big advantage over normal storage is that the blockchain stores everything as it is, this allows us to easily get older states of a world by searching for the data. On normal servers, the data would just be overwritten. Here, we can search the transaction history of the player using a Steem node to search for older steemworld comments, which hold all the data of the previous versions of the world.

Here is a little example of my world, which has already a lot of revisions:

As you have seen in the video, I was able to get older versions of the world and then also load it easily using commands. The command to get older versions is just for testing which gets replaced soon with a user-friendly GUI menu.

To allow this process to work for different situations, I created a function called getSteemWorldRevisions. It is able to find any revisions made to a world.

Since it is required to loop through the transaction history of an account, it can be useful to know the creation date before starting with searching, since then it is possible to stop searching once the first world change (creation) of the world has been found.

Here, the whole search process can be seen, here is a little list of what it does:

  1. Since we can only request a maximum amount of 1000 transaction at once, use 1000 as a limit.
  2. Do a while loop until we have all revisions of the world found:
    2.1 Load the latest 1000 transactions of the user and loop through them
    2.2 Check all comment operations for their permlink if it matches:
    2.2.1 Add the matching comment to {_revisions} and check if it reached the creation date: stop while loop
  3. Return {_revisions}

While this looks pretty simple, it took me a while to realize how I can get the latest transactions and then the following ones. But now, I know. The steem node is returning the id of every transaction and is counting up.
For example, if I have 2000 transactions, I will get the latest transactions by using -1 as a start parameter, then, I get the latest 1000 transactions which have an index key for their number, like 2000,1999,1998 and so on. Once this loop is done, I can go forward by simply taking the lowest number and reducing it by 1 to use it as next start value. In my case, I would then go forward with 999.

I have also created a really big comment section for this within the commit to explain it for people who are new to Steem and are interested in contributing to STEEM.CRAFT.

My first idea was to store the block ids of all previous changes in the final comment, while this would have been possible, it would grow over time and eventually get bigger than the allowed size limit only because of revision data. Storing this data is also unnecessary and a reason why I decided to search the history of the user instead of storing everything on the blockchain.

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

3.2 steemworlds.sk: Added biome changing

Changing the biome empowers the player to change the world as they wish.

By looping through all x- and z-axis of the steemworld within the world border, it is possible to change the biome.

Because changing the biome within a thread is unsafe, it is necessary to do it in the main thread, to prevent lags, it will wait every 50 changes for 1 tick. This reduces lags coming from this process.

Later, I found out that I could refresh chunks which allows sending chunks again to the client after changing it.

This little change removes the need to teleport the player away and then back to the chunks, which is very useful.

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

3.3 steemworlds.sk: Added functions to change and get a gamerule of a world.

This function will allow the GUI menu, which is coming soon, to change the gamerules of the world.

Here is a video that shows what the gamerule randomTickSpeed does (increase the random tick speed, which changes plant growing):

I later also added a function which allows getting gamerule values back, which is needed for specific tasks.

Changing the gamerules can be quite useful, some players may want to have a random tick speed set to 0 to disable any plants from growing or blocks from changing. Also fixing a specific time or weather can be useful, which is why I added this function to steemworlds.sk.

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

4. Pull requests

https://github.com/Abwasserrohr/STEEM.CRAFT/pull/23
https://github.com/Abwasserrohr/STEEM.CRAFT/pull/34
https://github.com/Abwasserrohr/STEEM.CRAFT/pull/36


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 revision loading will be very useful for players to view older versions of their world to either just look how the world looked before or to revert to older versions due to mistakes made before.

All the changes I showed today will be later available through a GUI menu which makes it easy to view and change any settings and values.

If you have any new ideas, feedback or bugs you have found, just tell me here in the comments, I appreciate it. :)

Have a great week,

@immanuel94

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

Sort:  

Thank you for your contribution. A cool update to the Steem.Craft project. I really loved the contribution post as it has all the information required.


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, @codingdefined! Keep up the good work!

Schön, dass du echt noch Zeit findest, das weiterzuentwickeln. Ich hoffe wirklich, dass noch mehr auf den Zug aufspringen und verstehen, was da eigentlich passiert...

Ich bin mir sicher, dass das nur eine Sache der Zeit ist, bis mehr Leute darauf aufmerksam werden, spätestens mit Libra werden sicher mehr Leute aufmerksam auch solche Sachen werden, denke ich... :)

Cool das man jetzt verschiedene einstellungen hat

Danke für dein Feedback, @jongartv! :)

Wenn du Ideen hast, melde dich gerne. ^^

Echt nice Features! Weiter so!

kann das jeder machen?

Ja, das kann jeder machen und nutzen. :)

Als Spieler auf einem Server, welcher dieses Script nutzt, kann man sich zuerst mit /steemconnect <steemname> connecten und danach mit /visit <steemname> <weltname> eine eigene Welt erstellen.

Nice :D

Nice :D

Congratulations! Your post has been selected as a daily Steemit truffle! It is listed on rank 5 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 8 SBD worth and should receive 145 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

Congratulations @immanuel94! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You got more than 800 replies. Your next target is to reach 900 replies.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Hi @immanuel94!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 3.391 which ranks you at #6887 across all Steem accounts.
Your rank has dropped 99 places in the last three days (old rank 6788).

In our last Algorithmic Curation Round, consisting of 179 contributions, your post is ranked at #151.

Evaluation of your UA score:
  • You're on the right track, try to gather more followers.
  • The readers appreciate your great work!
  • Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!

Feel free to join our @steem-ua Discord server

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.029
BTC 57400.65
ETH 3108.60
USDT 1.00
SBD 2.42