Minecolonies & Shingle Slabs

in #utopian-io7 years ago

Hey everyone, do you remember our crazy good looking shingles I introduced here they looked so awesome that, 1 day after I finished themm our modeler told me that we can't use them yet since they look bad when roofs have uneven sizes.

And as you can see, the line of oak planks doesn't look very good.
So I had to code a slab block which adapts to the block next to it.

Now, @d3miurge made amazing block models:
To be exact, 6 amazing block models.

One for 4 blocks connecting at each side.

One when one block on each side is connected to it:

One when only 1 block is connected to one of the sides:

Another one when two blocks are connected but in a curve.

The 5th one when 4 blocks are connected.

And the last one for 3 blocks.

Now my main task was a) to implement that this block integrates into the minecraft world (As in registering a recipe, the block, item and connect the models with the blockstates).
And b) the bigger part: To make sure that the block adapts its appearance depending on the neighboring blocks.

For this reason I defined 4*6 blockStates.
Now, the difficult part of this is, that minecraft has a limited amount of spaces for blockStates since there is a limit on amount of states the world can store per block (which will change in 1.13).

Therefore I used the limited space to store the orientation of the block.
Facing North, East, West or South.
And a blockState called the variant.
I defined the 6 variants following what I described above:

After that I was finally ready to go to the tough part.

First of all I had the idea to store an array of boolean variables of the state of all 4 directly neighboring blocks (not considering up and down).
This way we only have to ask the server once about the state of the certain positions.

Then, I calculated how many blocks are connected at all.

Which was super easy with the array.

Following this I had to think about all possible edgecases with sub types:

Which are basically:

  • No Connected Blocks
  • 1 Connected Block
    • Connected North/South/West/East;
    • Is there a shingle block connecting under it;
  • 2 Connected Blocks
    • Connected North or South, or in a curve (all 4 curve cases);
  • 3 Connected Blocks
    • Connected North/South/West/East;
  • 4 Connected Blocks

Then I translated this into conditional statements.

Which basically now allows me to build a huge curve with the slabs and they will follow the right form!

And the roof from earlier?

Looking way better now as well.

I hope you liked this post, I was kinda afraid of this talk since I thought it's going to be a lot of headache, but after I sat down and planned my steps ahead, things started to get really easy after all.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

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!
  • You are generating more rewards than average for this category. Super!;)
  • 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

Thank you for the contribution. It has been approved.

Great work on the article - it's awesome to see that you have made every effort to engage with your audience, and explain why you did what you did. The screenshots also make the outcome a lot more interesting.

Please keep us posted on any further work!

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

thank you for posting.
i'm huge fan of Minecraft and also a programmer.
i would love to see posts of this kind on steemit.

If you'd be interested in working with us, feel free to contact me =)

Nice mod! Seems like you are a good programmer, I have to say I love your work and hope you stick to the mod and DO NOT loose hope in your project.

I am interested in your ideas and your insights, your post is very good and interesting, I had time to think like you in making post, your post is clearly accurate and clear meaning, I guided you from want to be the best like you, I am amazed to you, I am amazed dengab jepinteran you hopefully you continue to make and develop your logic and skill in making post, thank 😘

very good technology post.

Its a technologycaly post.i like it

Absolutely nice constructions. More power to your elbow.

You can upvote my post or resteemed

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 60336.09
ETH 2333.36
USDT 1.00
SBD 2.53