
The contents of storage units and chests can now also be calculated to the island level, a great way for server operators to add some more competition to the game.
Hello everyone,
Here are some new changes to the SKYBLOCK.SK Minecraft Server add-on I want to show you guys today. Some quite big changes happened to SKYBLOCK.SK which increased the overall performance and the speed of some functions. One of the new changes is the increased speed of the island calculation process, which is in some cases almost 10 times faster than before. Another big change is the new getlang
function, which has replaced all variables for language translations.
1. Repository
https://github.com/Abwasserrohr/SKYBLOCK.SK
2. Index
- Repository
- Index
- New Features and changes
3.1. AddedgetTranslatableComponentFromItem
function
3.2. Added client based item translation tostore.sk
3.3. Language translations are now stored using metadata
3.4. Increased performance ofcalcisland
function
3.5. Add calculation for contents of chests and storage units tocalcisland
function
3.6. Added flag for storage unit access
3.7.store.sk
now uses metadata for configuration - Pull requests
- GitHub Account
- How to contribute
3. New Features
3.1. Added getTranslatableComponentFromItem
function
This new function is an exciting thing, it takes any ItemStack and returns a valid TranslateableComponent back. If you didn't know, TranslateableComponents can be sent to the client and the client then translates it depending on the client side language settings. The advantage here is big since there aren't any translations for items and blocks needed on the SKYBLOCK.SK side. The usage of it is quite simple, here is a small example:
This example above is going to send the player the current item amount and the name of the item the player is holding with the language of the client.
This could be something like:
You're currently holding 50 of Cobblestone in your hand.
I have seen that there is a variable set on line 108 of the openbook.sk file, where the function is in. This is a leftover I forgot to remove from testing and gets removed soon.
Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/181
3.2. Added client based item translation to store.sk
Now, there is finally a function for item based translations which is very useful, because there are some add-on's which needed this feature, it comes quite handy for store.sk
. While I also want to add these to the challenge.sk
functions, it is currently not possible because the ChatComponent feature for the item lore is added in the next upcoming update of Minecraft 1.14 which should be released in this quarter of the year.
But now back to the change. store.sk
sends messages to the player, which tells them, how much of which item has been bought or sold, this is very useful for the player to see what they have been doing in the shop. But without translations, it wouldn't have been looking that good, because the item names would either have to be translated or displayed in English. I'm very glad that I found this opportunity to use client-side translations since there is now no need to have all the Minecraft blocks and items translated. =)
Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/182
3.3. Language translations are now stored using metadata
Storing the translations for the language within the variables of Skript is completely fine for a single language, but as there are some other languages planned to be added, there would be quite a massive amount of these variables just from the language translations. While variables in Skript are quite efficient if the right database is selected, I can't control what the server operator chooses or how fast the connected database is. This is why I decided to store the translations only in the ram of the server as metadata.
Storing the data only in ram has multiple advantages over a file only or variable storage:
- The translation is almost instantly there, we don't have to load a file first
- The database doesn't get messed up with all the translation variables
- Slow databases don't suffer from too many variables at once
But there is also one big disadvantage: It takes some ram since they're saved there. But Minecraft itself needs much ram and the translations are not that big to make a difference at all.
Because there is now a function used to get the translations, it will be easier in the future to change the format of the translations and languages, since only the function has to be changed.
There isn't much to say about the change other than I didn't enjoy changing all the variables to the new function. :3 I really don't know how to do multiple commits at once, this is one place where it would have been nice but I don't see the option on the GitHub front end, maybe I missed something...^^
This is how the current state of the getlang
function looks like:
This function has 4 parameters and returns colored text.
- ID (text): The name of the translation
- Language code (text): The language code, example: en
- Prefix (text): A (colored) text which is added in front of the translation
- Suffix (text): A (colored) text which is added at the end of the translation
Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/185
3.4. Increased performance of calcisland
function
The calcisland
function was pretty slow and the new changes to it increased the performance. There are some reasons why it is now faster:
- Blocks are now looped differently (only x- and z-coordinate is looped first), within this loop, the y-coordinate is looped again, which speeds up the looping process.
- All chunks of the island are preloaded and kept loaded while the calculation is running
- The level calculation is now done at the end of the island calculation
These three changes are the main reason for the better performance.
Here are two videos where the increase of the speed can be seen easily:
These videos are displayed as big videos on Steemit, but on other platforms like Busy or Steempeak, they are side by side thanks to <div>
's with the pull-left
or pull-right
class. I currently don't have a program to edit the video files, otherwise, I would have made a side by side video in itself. =)
Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/191
3.5. Add calculation for contents of chests and storage units to calcisland
function
Some server operators may want to calculate the contents of chests and storage units as well as the blocks of the island. This has now been added for those who need it. It can be configured if needed.
Adding this feature to the already existing calcisland
function was pretty easy. Since we can check if the block, we're currently looping has an inventory, we know if it is a chest or a storage unit for example.
Then we only have to loop through the inventory. For storage units, it is a little bit more "work" to do. But here is the chest part:
There is not that much difference to looping through all the blocks of the island. Instead of blocks, all the slots of the inventory are being looped through and the items in the inventory are converted to their types, which then can be loaded from the configuration and added to the overall island experience.
Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/194
3.6. Added flag for storage unit access
Before, the storage system had no special flag for accessing it, which meant that even trusted players could have accessed them. Now, the island leader can change the flag as desired to prevent everyone from accessing the storage units or even let everyone access them.
Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/195
3.7. store.sk
now uses metadata for configuration
Temporary metadata is a great improvement for many parts of the configuration, which is saved within files anyway. It greatly reduces stress on the database, which is why the store.sk
add-on now uses metadata for its configuration part.
Within this pull request, also a daily limit for each player has been added, which can be changed by the server operator to limit the sells of each player to a specific amount of money.
Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/198
4. Pull requests
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/181
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/182
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/185
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/191
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/194
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/195
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/198
5. GitHub Account
https://github.com/Abwasserrohr
6. How to contribute
You're interested in contributing to SKYBLOCK.SK? Get in touch with me on Discord. I'm the sewage pipe there. I'm also looking forward to meeting beginners who haven't been used Skript yet. =)
Discord: https://discord.gg/FRuK5BC
Thank you for reading my contribution post. This time, some big changes have been made which aren't really visible to the player but are very important for the future to keep SKYBLOCK.SK simple to maintain and run.
Using the metadata to prevent many read/write actions for configurations will increase the performance of SKYBLOCK.SK and also hopefully increase the lifetime of the storage device.
If you have feedback about this contribution post, the new features I showed off today or SKYBLOCK.SK as a whole, feel free to share it with me in the commands. =)
Have a great Friday and then a nice weekend