Minecolonies & Mod Support

in #utopian-io6 years ago (edited)

Hey everyone,

University is keeping me quite busy, so I needed quite a while to pull together a new pull request.

Since Minecolonies is not only played as a standalone modification but also often combined with other mods.
For this reason, we tried to implement workers like the builder as generic as possible to allow other blocks and materials to be used.
One of the mods which is often combined with Minecolonies is one called Chisels and Bits, it basically allows the player to construct their own blocks out of micro-fragments of other blocks.
Until now our builder would request not existing parts of those blocks to reconstruct them, due to a missing component which combined those two.

First of all, I added a gradle dependency to our gradle file.
(In the future this will be replaced with a dependency which resolves the libs directly from maven, as soon as it's available).

Then I created a Check class and a Proxy to retrieve the data.

A proxy is necessary since we have no guarantees that this mod has been added to the game.

Therefore, the proxy always returns "false" or "null", "emptyList" etc.
Supposing that the mod is not installed.

We require 3 basic methods for this.

a) We need to check if a tile entity belongs to Chisel and Bits
b) We need to check if a block belongs to Chisel and Bits
c) We need to get the Bits of the tile entity.

The implementation of those methods is in the same class, but they are annotated as @Optinal which means that they won't be loaded if the mod is not present.
Therefore, if the mod is not present, the proxy methods will be called which always return the default.

The implementations are quite straightforward.
I get the BitAccess of the TileEntity, and then I visit bit for bit and store it in an ArrayList.

But that wasn't the main part of the integration.

Items in Minecraft have several ways to store data:

a) Via their registry name.
b) Via their metadata.
c) Via nbttagcompound.

a) is a good solution if you only need 1 block of a certain type.
(For example how to differentiate dirt from stone).

b) is a good choice if you have a limited amount of variations for a block.
(Maybe rotation or slightly different color).

c) Is the choice if there are a lot of differences you will need to save.

Chisel & Bits uses NbtTag data in their items and our Minecolonies System until now didn't support that.

For that reason I had to change:

  1. The equals and hash methods to take this into consideration.

  1. I had to retrieve the chisel and bits data at the right place to add the stacks to the required items list.

  1. At a huge amount of places, I had to take the NBT data into consideration when comparing itemStacks.

  1. I had to add it to the registration of the list which takes a string identification which also needs the nbtdata to be unique.

  1. And finally, I had to disable the normal blockData we would retrieve to avoid not existing bits to be added to the requirements list.

After that has been done I tested out our builder and he builds and requested nicely the correct amount of bits which were required for a certain build.

Before scanning.

Build site.

The request.

Aaaand, it worked!

I hope you liked today's post, this is the first Mod integration post I have done here on Steemit, nevertheless, we already support two other big mods which are:

TinkersConstruct and JEI.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @vladimir-simovic, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Excellent progress in your project @raycoms friend although you are full with the university is rewarding that you still worry about providing support and improve your work. Greetings from Venezuela

Hey @raycoms I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

great proggress in your project. you done a great job.praying that you can improve more dear. Best of luck😊💜💜

This is very interesting.

Congratz progress in your project
good work @raycoms

hello friends, visit my blog and reply any of my post and vote me i will reply on your post and will vote you too.
https://steemit.com/@fakheralamsher
thankyou..

Thanks Education for sharing

I got lost at some point...nice post still
I'll catch up.

Nice one there. I am encouraged by your post that no matter how busy one may be, one should find time to interact with steem people, for good. I like your style, I am doing same, even though I am terribly busy. I believe that no condition is permanent as long as one is alife. Well done my friend. I am following you, please be kind enough to follow back.

a very useful post📝

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

  • Pending payout - Ranked 6 with $ 238,35

Good post and very useful...
I like it very much... 👍👍👍

wow such a great read!!! keep up the great work

Your Post Has Been Featured on @Resteemable!
Feature any Steemit post using resteemit.com!
How It Works:
1. Take Any Steemit URL
2. Erase https://
3. Type re
Get Featured Instantly & Featured Posts are voted every 2.4hrs
Join the Curation Team Here | Vote Resteemable for Witness