[Open Source] SkyBlock Minecraft Addon - JetBoots | Inventory recovery added [New feature #11]

in #utopian-io6 years ago

Hello minecraft players and steemians,

I want to show two new add-ons within this post I added recently to SKYBLOCK.SK; A Minecraft game mode, where the players have to build on a flying island with limited resources. SKYBLOCK.SK is licenced under the MIT licence, feel free to use it as you want.

1. Repository

https://github.com/Abwasserrohr/SKYBLOCK.SK

2. Index

  1. Repository
  2. Index
  3. New Features
    3.1. Added JetBoots
    3.2. Added islandtoplist function
    3.3. Added inventory recovery
  4. Pull requests
  5. GitHub Account
  6. How to contribute

3. New Features

3.1. Added JetBoots

Players can now fly around the world using the JetBoots. The JetBoots are an add-on, which can disabled very easy by simply putting a "-" in front of the add-on file SkyBlock/addons/jetboots.sk.

This new add-on makes it possible to fly but with a cost. They have to be crafted out of 4 diamond blocks and two feathers, which makes them not only very expensive to create but also expensive in the maintenance. The server operator can define in the options of the add-on, how much should fuel fill up the JetBoots.

If a player flies around, the fuel is reduced by 1 every tick. This means that the JetBoots are going to consume 20 fuel per second. As a default setting, this is one coal per second. Coal is now way more useful than before, which helps economy.

For add-ons, I decided to also add options. This means that the server operator can change settings of a specific add-on no longer only directly in config.sk but also in the add-on file itself.

options:
  item_name: "&eJetBoots"

If the server operator wants to replace the name of the JetBoots, only this option has to be changed.

  fuelworth: 20
  flyspeed: 0.04

Here, the flying speed of the JetBoots and the fuel worth can be set up. If wanted, a server operator could set the fuelworth to 1, which would mean that the JetBoots consume 20 coal per second or give more to make it easier.

  fillinfo: "Fill &eJetBoots&r up with coal while wearing them."
  emptyinfo: "Your &eJetBoots&r are empty!"
  loadedinfo: "Your &eJetBoots&r have been filled up."

If someone wants to run the JetBoots without SKYBLOCK.SK, I added a fallback English translation directly into the options, which are used if there is no language translation available.

To make it possible to craft something like that, we have to register a shaped recipe, which means that the player has to put a specific shape of predefined items into the crafting table to get another predefined item out. This is how this can be done:


on load:
  set {_item} to diamond boots
  set name of {_item} to {@item_name}
  set line 1 of lore of {_item} to {@item_name}
  set line 2 of lore of {_item} to "&r0"
  register new shaped recipe for {_item} using air, air, air, diamond block, feather, diamond block, diamond block, feather, diamond block

I started with a {_item} variable, which I set to the item "diamond boots" and then I can change the name of the item and the lore (text below item name) of the variable to my needs.

I can then register a new shaped recipe for that item, which is stored in the variable. The shaped recipe is hard-coded into the add-on.

To make flying with the JetBoots something special, I added particle effects, I know that they aren't necessary but they look nice, I though. =D

I added a function called jetparticle, which only needs one parameter; A player, where the particles should appear.

function jetparticle(p:player):
  set {_l} to location of {_p}
  set {_x} to x-coord of {_l}
  set {_y} to y-coord of {_l}
  set {_z} to z-coord of {_l}
  set {_world} to {_p}'s world
  {_world}.spawnParticle(Particle.EXPLOSION_NORMAL!,{_x},{_y},{_z}, 0.5)

This function uses two Java classes from bukkit (server dependency), which allow the particle effects to be spawned. We need to spawn particles and make a particle effect above.

Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/94


3.2. Added islandtoplist function

Adding more and more functions, which reduce the size of SKYBLOCK.SK and clean up some parts, the islandtoplist function is one of multiple upcoming functions, which are going to replace most of the SkyBlock/SKYBLOCK.SK/Commands.sk parts with only functions. Many parts, which are still in Commands.sk are still from the first basic creation. The newly created functions are going to be easier to read and better to maintain.

Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/98


3.3. Added inventory recovery

The inventory recovery is a controversial function. Some hate it, some love it. But one thing is for sure, once somebody loses his diamond tools, which are packed full of enchantments, which may took hundreds of hours to get, some people may quit the game forever. To prevent such high losses, I added the inventory recovery. Thanks to @sausemaus for suggesting this feature. While this makes the game far more easier, the server operator can disable this add-on of course at any moment by putting a "-" in front of the SkyBlock/addons/recovery.sk. Also the prices for an inventory recovery can be set to a custom amount of money. Void and lava deaths can be expensive and people will be happy to see their valuable stuff again, no matter how much in-game money they have to pay. But it should be still affordable.

To show a little part of this add-on and how this works, here is the part where the variables get created on the death of the player.

on death of player:
  set {_uuid} to uuid of player

To identify the player, even if the name is changed, we need the uuid of the player.

  while {_s} is not set:
    set {_invuuid} to UUID.randomUUID()
    if {SR::recovery::time::%{_invuuid}%} is not set:
      set {_s} to true

Every inventory, which is stored on death gets its own uuid. To be sure that the uuid is unique and not some super rare case happens that we have two times the same random UUID, a while loop is used to be sure we have a unique uuid.

  add {_invuuid} to {SR::recovery::player::%{_uuid}%::*}

Then, the inventory uuid is assigned to the players uuid to make it possible to track all inventory uuids of this player down, as we need that to recover them.

  set {SR::recovery::time::%{_invuuid}%} to now

Storing everything forever is possible but not a good solution. This would fill up the space quickly with never used data. To prevent this from happening, the inventory is going to expiry at some point. The variable, which is set above is used to determine if the inventory is expired or not.

  set {SR::recovery::idp::%{_invuuid}%} to {_uuid}

Also assign a player uuid to the inventory uuid, that way we can know who owns it.

  set {SR::recovery::cause::%{_invuuid}%} to "%damage cause%"

There are different types of death. Not every death cause is going to remove all items or experience. There can be different prices for specific death causes like void death, which would be a guaranteed loss of all items and experience. Which would also allow a higher recovery price.

  loop all items in player's inventory:
    set {_item} to loop-item
    add loop-item to {SR::recovery::inv::%{_invuuid}%::*}

Then, the inventory is looped through; everything is saved within a variable.

  clear drops
  remove all 1 xp from drops

At the end, the drops of the players are cleared. This is needed to prevent duplication, since the player could get the drops back and also use the recovery.

Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/100

4. Pull requests

https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/94
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/98
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/100

5. GitHub Account

https://github.com/Abwasserrohr

6. How to contribute

Are you interested in contributing to SKYBLOCK.SK? I'm looking forward to meet you on the Discord linked below. =)

Discord: https://discord.gg/FRuK5BC


Thank you for reading my contribution post. People have been asking for these add-ons for a while now, I'm now looking forward to get more feedback by users who test SKYBLOCK.SK for new add-ons and functions. While this may take a time, I'm now going to follow the roadmap and reduce the size if possible and also create some functions which may come in handy for some server operators, if they want to modify SKYBLOCK.SK.

Feedback is highly appreciated. Just let me know what you think, thank you for taking the time. ^^

Keep on steeming

@immanuel94

Sort:  
  • Awesome post, great animated gifs and code samples.
  • Great to see taking community feedback and building it into the game
  • Keep up the great work.

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. =)
I'll try my best to always check on how the community feels about changes and also try to add new ideas in the future. :3

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

Hi, I see you're into minecraft modding, would you be interested in joining us in Minecolonies? =)

Hey @raycoms! =)

I'm more into server side modding only and give players a good experience just using Vanilla. With resource packs, plugins and skripts, like this one. I already do so much Minecraft stuff that I'm happy if I can do something else than Minecraft... ._. Another Minecraft project isn't healthy for me right now, sorry. =D

But I really like what you guys are doing there with Minecolonies, it's amazing!^^

I think I'm going to look into Hytale in the future and maybe join some open source projects there, since it looks like there are some fancy tools included to mod the hell out of it with less restrictions for server operators like Mojang does. :3

Have a great week.

die funktion ist sehr praktisch

Hallo @mcsiempre.

Ja, die sind durchaus sehr praktisch. =D Wenn auch teuer.^^

Coole Idee mit den LAgersystemen

Ich finde es cool das es jetzt auch lagersysteme gibt. Der preis ist angemessen dafür das man soviel damit machen kann

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

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!

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 60675.01
ETH 2605.91
USDT 1.00
SBD 2.64