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:

  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

H2
H3
H4
3 columns
2 columns
1 column
19 Comments
Ecency