Minecolonies & Mod Support
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:
- The equals and hash methods to take this into consideration.
- I had to retrieve the chisel and bits data at the right place to add the stacks to the required items list.
- At a huge amount of places, I had to take the NBT data into consideration when comparing itemStacks.
- I had to add it to the registration of the list which takes a string identification which also needs the nbtdata to be unique.
- 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
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
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
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😊💜💜
Wow excellent this post!
I got lost at some point...nice post still
I'll catch up.
great work!!!
praying for more and more improvement
minecraft
This is very interesting.
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..