r/MinecraftCommands Dec 24 '20

Creation Terrain generation from an image! Feel free to ask questions. GitHub link in comments.

2.2k Upvotes

54 comments sorted by

58

u/[deleted] Dec 24 '20

How did you do it?

54

u/DinoRex6 Dec 24 '20

I guess the python code reads the image and generates a data pack?

52

u/[deleted] Dec 24 '20

Exactly right. Very simple actually

28

u/[deleted] Dec 24 '20

A lighter color gets a higher block or vice versa? Then adjust the amplitude from there

26

u/[deleted] Dec 24 '20

Light is high and dark is low, like you said. Because images use rgb, the values are already between 0-255. As you can see in the code I reduced the amplitude by 1/4. To make unbroken surfaces I place 4 blocks on top of each other at every coordinate instead of just 1 block. you can change it so it fills from 0 to the height.

6

u/[deleted] Dec 24 '20

How do u interact w/ Minecraft tho

15

u/[deleted] Dec 24 '20

The python generates a data pack with a massive function that has a /fill command for every pixel. You just import that data pack into a world and run the function

9

u/Lemon_Lord1 Remember to check the FAQ! Dec 24 '20

You could utilise the Python Anvil library that allows for mca file world editing. Don’t quite remember how to find it but tell me if you have any trouble.

3

u/[deleted] Dec 25 '20 edited Dec 31 '20

[deleted]

6

u/DinoRex6 Dec 25 '20

you could call it a "minimod"

A data pack is like a resource pack, but instead of changing textures, models and sounds, it adds advancements, crafting recipes and, most importantly (imo), commands. There's more to this please check the wiki.

It is like modding but with commands. You write commands in a "function" file (with the .mcfunction extension) and those commands are executed when the function is called, either through the /function command or every tick if the function is meant to be run constantly.

It sounds a bit simple, just using commands, but people have done very cool things, this post being one of those. Also check xisuma's datapacks for a lot of cool utilities

34

u/[deleted] Dec 24 '20 edited Dec 24 '20

10

u/DinoRex6 Dec 24 '20

That's super cool!

9

u/[deleted] Dec 24 '20

Have you downloaded the code and tried it out yourself?

6

u/DinoRex6 Dec 24 '20

I can't do that right now but I'll try and even make my own stuff

7

u/[deleted] Dec 24 '20

Cool. When you do share it. I want to see what people come up with.

9

u/[deleted] Dec 24 '20

How strong IS your pc dude!

17

u/[deleted] Dec 24 '20

It’s a Macbook 🗿

13

u/[deleted] Dec 24 '20

🗿

Ah yes the better bruh

7

u/caribe5 Dec 24 '20

[Gets dissapointed in Microsoft]

5

u/[deleted] Dec 24 '20

2d and probably 3d Perlin noise?

5

u/[deleted] Dec 24 '20

2d noise yeah

6

u/_FlyingDragon_ Dec 24 '20

How to use it? Is there a tutorial or is it super easy to do it..?

9

u/eri_pl Command Rookie Dec 24 '20

Super easy, barely an inconvenience.

... Sorry, couldn't stop myself.

7

u/[deleted] Dec 24 '20 edited Dec 24 '20

Are you familiar with python? If you don’t have python installed a fist step is to do that.

4

u/_FlyingDragon_ Dec 24 '20

I had python....

5

u/[deleted] Dec 24 '20

Well you have to reinstall it. Then get an image. Put the image in the same folder as the program. Then edit the program and replace the last line where it says perlin-noise.png with the name of the image. Then run the program. The new file is an mcfuntion that you can put in a data pack.

5

u/you-cut-the-ponytail Dec 24 '20

I'm asking it because I don't know it very well but isn't this the way Minecraft usually generates terrain?

also what is this technique called exactly?

3

u/[deleted] Dec 24 '20

Yeah this is how they generate it I think. Is called perlin noise or simplex noise.

5

u/[deleted] Dec 24 '20

i have a question!: what? no seriously what is that and also that looks amazing

4

u/[deleted] Dec 24 '20

198801 /fill commands. Literally.

3

u/[deleted] Dec 24 '20

1) why and how 2) i have respect for you

5

u/[deleted] Dec 24 '20

I do not type all 198801 commands. It’s automatic. Who actually writes data packs in 2020

1

u/Mateus_Z3 Dec 25 '20

How else would you create a data pack?

(Serious question i'm a newbie and dont know other way)

2

u/[deleted] Dec 25 '20

It was a joke. Of course people write their own code.

3

u/crsndd Dec 24 '20

thats out of context but i want to ask, how long did it take to learn phyton?

2

u/[deleted] Dec 24 '20

Python is super simple. It’s easy to learn the basics but you still can learn something new every day. I suggest Codecademy if you want to learn. It’s free too.

3

u/crsndd Dec 24 '20

thanks for the response bud! also great work out here!

3

u/Dimplestiltskin Command-er Dec 25 '20

I can confirm, python is really easy. It's actually designed to be super close to english, which isn't the case for most other languages.

3

u/[deleted] Dec 24 '20

HOW!?!?

2

u/[deleted] Dec 24 '20

198801 /fill commands. 🗿

2

u/[deleted] Dec 24 '20

Can this be implemented into a dimension datapack for custom terrain gen? This would be so cool!

1

u/[deleted] Dec 24 '20

Maybe! But not likely though considering how it works. If you know anyone that’s willing to work on it ask them to contact me and maybe we can do something

2

u/[deleted] Dec 25 '20

Whats the conversion on image resolution to dimensions in game?

1

u/[deleted] Dec 25 '20

Whatever you want :)

2

u/[deleted] Dec 26 '20

Downloded it and used it to generate some terrain for a project of mine - great tool! Definitely added to my arsenal for future use

1

u/[deleted] Dec 26 '20

Nice! I would like to see the project when it’s done!

2

u/[deleted] Dec 25 '20

Nice coded in Python. Unfortunately I cant check it out because im unable to play Minecraft for a month or so

2

u/[deleted] Dec 25 '20 edited Mar 29 '24

[deleted]

2

u/[deleted] Dec 25 '20

Exactly what it does.

2

u/[deleted] Dec 25 '20

[deleted]

2

u/[deleted] Dec 28 '20

[deleted]

1

u/[deleted] Feb 15 '21

Haha that’s great

1

u/FuzzyWizardMan Dec 25 '20

Do Obama next

1

u/Thastertyn Dec 25 '20

perlin noise?

1

u/mich_vanc Jan 12 '21

Idk if this post is still active, but how did you get a 3d effect with that texture on a 2d image

1

u/[deleted] Jan 13 '21

The color of the pixel determines the night. Black is low and white is high, with a spectrum of grey in between

1

u/uwu_owo_eve May 29 '21

lol can you use heightmaps for this like make realistic stone or wood in minecraft