Minecolonies & Some GUI abstractions

5개월 전

Hi everyone, as you guys now, abstracting and refactoring things is one of my big programming hobbies and while setting up some new features I noticed that I could save a whole lot of code if I would break this task down into abstracting the existing code and then in the next step using this for the new GUI.
In this first post, I will head into the abstraction work and the new features will be explained in the following post.

What is it about:

Now, for quite a while already we had GUIs displaying lists of items where the player was able to select certain items for certain actions and in one of these GUIs, we even had an input option to filter.

But, there were all scattered all over the place and had nothing in common. And while only one had the input filter, all of them could actually make use of this.

For this reason, I created one universal filterable GUI which will have the items, an on/off the trigger and input on top for filtering.

The first step of this was defining a building type which would define what kind of data would be needed on the server side.

Read and write the data from disk.

Besides that, it needs the methods to manipulate the ArrayList and finally a way to serialize it to send it to the client side.

Then I needed a client-side representation for it as well:

Where the add and remove methods would already do the synching to the server side.

And a method to deserialize it.

Also, I edited the existing message to make it more generic for this purpose.

And register it to the network.

Then, I created the abstract window class.

Which would take care of switching the pages, register the on/off button and set up the lists and the description label of the list?

When clicking on the switch button it would trigger it and change it to on/off depending on the previous state and also trigger the building view which as previously explained would then trigger the server update.

On open, most importantly it queries all items which fit the required description and filter.

After getting it from the blockList and from the exception list.

Those would be overridden by the final GUI.

On key typed, it would update the resources to update the filter.

Similar, in the update element of the list it would check if the item is contained in the list or not it would set the icons etc of the list.

And finally, to create a working worker I just had to make sure to extend the right classes and override the list of blocks.

Resulting in this very simple composter window.
This will make it way easier for new devs to enter and create simple GUIs for a worker which requires this functionality.

Extra bits:

Since people asked, we also added a config option to turn on/off the holiday special.

With the config option (using the forge config annotation)

And then checking for the feature where we activate it.

Besides that, we also added the new Student model for the library which looks similar to the monk which you saw at the beginning of the post.

Where I only adjusted the model output to the real output, which is a pain nonetheless.

Another issue I fixed was that people were complaining that request manipulation was only slowly synched to the client.
For that reason, I added functionality to the methods taking care of that on the client side so they don't have to wait for the server to sync the updated data over.

I hope you liked this update as much as I did, in this refactor we added an additional 300 lines but in this case we added a lot of additional functionality to the GUI (filtering) and made the code way easier to understand, if you check out my upcoming post you're going to see how much we really earned from this.

Pull requests:




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:  trending
  • I'm glad you like refactoring and I'm sure others are as well. ;-)
  • Great story telling, you made me wonder what does the student really look like?
  • Very few comments in the first pr, much better in the second one.

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? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.


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

@raycoms, Keep up this development and hope that you are enjoying this Gaming Development. Stay blessed. 🙂

Muy buen trabajo amigo felicidades suerte sigueme o dame un boto es un buen blog sigue asi :D

Hey, @raycoms!

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!

Hi, @raycoms!

You just got a 8.15% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Congratulations @raycoms!
Your post was mentioned in the Steem Hit Parade in the following category:

  • Pending payout - Ranked 9 with $ 82,19

Niccee post written by you