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

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.

H2
H3
H4
3 columns
2 columns
1 column
17 Comments
Ecency