
Craft: A simple Minecraft clone written in C using OpenGL shaders - sbjs
https://github.com/fogleman/Craft
======
tbrock
Fogleman has some really cool side projects in a variety of areas written in a
variety of languages... and I noticed he’s got two kids! As a new father, how
is this possible? Really boring/easy day job?

Having a daughter is an amazing experience that is rewarding in its own right
but something that really scares me about fatherhood is not being able to do
any deep work for the rest of my life.

Doing deep work is another part of living I really enjoy and I’m somewhat
petrified that I’ll never experience it again. Maybe it doesn’t matter.

~~~
fogleman
Fogleman here. Funny to see an old project in the #1 spot (again?).

I hesitate to comment about this being productive while having kids thing, but
some people seem to be implying that I must never spend time with my kids.
It's far from the truth. A week ago my son (age 5) and I went camping in the
backyard. Coincidentally, he and I have just recently started playing the real
Minecraft together on our own private server - every evening lately. (I had
never actually really gotten into the real Minecraft before, believe it or
not.) We've been playing lots of Thinkfun games like Rush Hour and Shape by
Shape. I actually still lay with my son while he falls asleep every night. My
daughter (age 7) and I walked to the playground and played for a while there
yesterday. We go out and check my vegetable garden daily, and my daughter
likes to play "baseball" (plastic bat and ball) in the backyard with me. I
work from home currently which is nice because there's no commute and I can
see my kids a lot. We have "dance parties" in my home office where there's
lots of open floor space. I could go on of course.

I fully understand the sentiment that time is short when it comes to spending
time with your kids before they are grown.

There are plenty of folks without kids who aren't super productive too - so
the whole thing seems a false dichotomy to me.

Frankly I don't even feel like I work that hard. Maybe "hard" is the wrong
word. A lot of people are constantly busy and have no free time. Yet they
don't seem so productive? I'm the opposite of that, somehow.

I know I'm under no obligation to defend myself - but there you go.

~~~
EpicEng
But from a time management perspective... just how? I have one child (4) and
work a day job. It's all I can do to find time to exercise and have an hour or
two for myself at night. Do you exclusively program in your free time?

~~~
tobarpal
My theory is that when you have children the sum of time spent at work,
commute, chores, exercise, child minding, sleeping is very close to 24 hours
per day. So any decrease in the time requirement for any of those means a big
difference in discretionary time. So no commute vs commute could triple your
discretionary time. Then, amazingly, you can be three times as "productive"
despite being in a very similar situation.

~~~
EpicEng
That is absolutely true. I just went from remote back to office and have been
trimming here and there to fit my workouts in.

~~~
cookiecaper
Similar situation here, and I've done this oscillation from remote to in-
office 4-5 times now. It's always a shock to realize how much time is consumed
on the processes of being physically present in the office. After a little
while, like everything else, you tend to forget. It's good to get scared
straight periodically.

------
Karrot_Kream
For folks who want something a bit less pedagogic and more fun to play as a
game, I highly recommend Minetest [1] which gives you a programmable layer on
top of the base Minetest engine to make Minecraft-like game modes.

[1]: [http://minetest.net/](http://minetest.net/)

~~~
BuckarooBanzay
For those interested in the educational part (as with minecraft) there is an
article about using it in schools:
[https://wiki.minetest.net/MinetestEDU](https://wiki.minetest.net/MinetestEDU)

~~~
dustfinger
Thank you for pointing out this article. I am going to be teaching my kids to
program and recently installed lord of the test so that we could have an
interesting environment to work in.

For other's interested, minetest has a channel [1] on freenode where you can
connect with the community in realtime.

[1] #minetest

------
louisstow
I actually compiled this project to Emscripten a few years back:

[http://s3-us-west-2.amazonaws.com/ingame-
data/emcraft/game.h...](http://s3-us-west-2.amazonaws.com/ingame-
data/emcraft/game.html)

Here's the code:
[https://github.com/louisstow/EmCraft](https://github.com/louisstow/EmCraft)

------
sytelus
My 5 year old kid is addicted to minecraft and there is no way to prevent
violence (you can always keep killing animals even in Creative + Peaceful
mode). The problem is that 5 year old have little context on consequence and
they really get intrigues in exercising new power they have. I'd like a _pre-
schooler mode_ which actively discourages any violence. May be if you try to
kill something, an alien would descend and take away all your assets. So
_only_ thing you can ever do in Minecraft is just build something :). If
someone can add this feature, it would be AWESOME!

~~~
dietr1ch
On Zelda you have little incentive to attack the Cuccos (chicken).

~~~
sytelus
MineCraft also has incentive: you get meat when you kill animals.

------
pome
Fogleman also have awesome Minecraft-clone[0] in Python/pyglet in just 900
lines of code.

[0]
[https://github.com/fogleman/Minecraft](https://github.com/fogleman/Minecraft)

------
srcmap
This is very cool. I got it build/running in < 3 minutes in Linux.

My boy love Minecraft. I like to use this as base to teach him more about
programming.

Any suggestion on small projects that can be addon / mod use this code as
base.

I am thinking a series of coding exercises that can be hack/add on to this:

Add a command/mod to:

1) Draw line, Square, Triangle. 2) Draw Circle, Ellipse, Cone, Cylinder 3)
Build Car, Airplane 4) Build Space Ship 5) Putting picture of his own face on
the block.

... Any other suggestions?

Each small projects take about 1-2 hours build on skill sets that learn
before. It should be simple and fun to do with goals of encourage kids to
learn programming.

My boy finished all the CS classes in Khan Academy and seems to enjoys them.

If anyone else has strong interested in this, I will see if I (we - group of
us) can develop this as a new Khan Academy CS class and contribute it to KA.

~~~
fogleman
Try running server.py locally.

Then check out builder.py which will send commands to your server to change
blocks. You can rapidly build all sorts of shapes with a few function calls.

[https://github.com/fogleman/Craft/blob/master/builder.py](https://github.com/fogleman/Craft/blob/master/builder.py)

~~~
hwc
I really want something like that for vanilla minecraft. here's the closest
I've come: [https://github.com/HalCanary/mc-
labyrinth](https://github.com/HalCanary/mc-labyrinth)

------
_bxg1
Very cool. The beauty and draw of Minecraft have always come from the way it
emerges from such simple elements. Reimplementing it in any language would be
quite fun, I'd think. It's almost the new Doom.

~~~
ilaksh
As someone who built a Minecraft-like project (but I was careful not to call
it a Minecraft clone because it was missing many core features) in JavaScript
several years ago and a fan of actual Minecraft, I feel I need to say
something.

This is not a Minecraft clone. 99% of the projects out there that claim to be
Minecraft clones are not close enough to be called clones either.

The real draw of Minecraft comes from a number of core features, most
importantly the crafting and the survival needs that motivate the crafting and
building. Minecraft would not have become a hit if it was just a creative
sandbox alone. This project has neither of those aspects of the game. Another
thing missing is the diversity of biomes. And another thing-- all of the
underground features like caves and mines are missing.

So it doesn't have Mine or Craft, don't call it a clone. You wouldn't call
something an IBM clone if it was missing core features of that computer.

I think people do the part with just the blocks and rudimentary generation and
call it a clone, it's almost like they are giving themselves credit for
recreating Minecraft when they haven't even implemented 1/3 of the features,
and they didn't even recognize the most important ones.

~~~
jklinger410
>So it doesn't have Mine or Craft, don't call it a clone

It does both of those things. You can mine blocks for resources and then make
new blocks out of those resources.

Your other points may be relatively salient, but a beta/alpha clone of a game
does not have to implement every feature for it to be a clone.

It seems like you've taken this too seriously and really did not need to say
anything. It's not really a productive point.

Say you've managed to brow beat OP down to calling his clone something like "A
Minecraft-esque Resource Building Game." What have you done, at that point?
Nothing. Calling something a Minecraft clone might be sensitive for you, and
others, but it does not automatically make that sensitivity valid in any sense
just because you feel it.

------
kuwze
A great place to find stuff like this is r/tinycode[0].

[0]: [https://www.reddit.com/r/tinycode/](https://www.reddit.com/r/tinycode/)

~~~
sbjs
I actually found it here

[https://github.com/uhub/awesome-c](https://github.com/uhub/awesome-c)

------
sbjs
I don't understand how 3d games are written or know what shaders are, so this
is complete magic to me, and I'm surprised it's only 5k lines of C code!

~~~
bena
Shaders are basically transformations performed by the graphics card. Or
sometimes not. It gets real vague at times because like a lot of things there
are no hard lines.

You take a point and figure out if it needs to be colored differently based on
certain criteria. Like if it was in shadow, or if it's being hit by a bright
light, or you just want a sepia tone across everything. You can even shift
everything. Take the screen and distort it according to some kind of function.
Like make it all wavy.

3d games are no more or less conceptually different than 2d games in a lot of
regards. There are more things to track and be aware of, but you're
effectively doing a lot of the same things.

If you've ever messed around with making 2d games, you can even begin simple
experimentation by just making another layer of depth. Like LittleBigPlanet,
it's ostensibly a 2D game presented with 3D graphics. But it allows you to
shift between 3 layers to give you _some_ depth.

~~~
gameswithgo
> Or sometimes not.

No, shaders are always done by the 3d card =)

~~~
bena
I wanted to be careful because shaders don't really just shade anymore and I
was pretty sure if I limited to just graphics cards, there will be someone
that pops up that says the first shaders were actually blah blah blah.

Basically, I knew I was going to be slightly wrong about something somewhere.

~~~
sbjs
It backfired ;)

~~~
bena
C'est la vie.

I mean, effectively anything you can do with a GPU shader, can be done by the
CPU, so it seemed reasonable to me that you could make something functionally
equivalent for the CPU and call it a shader.

It started feeling like the difference between "programming language" and
"scripting language" in my head.

------
sergiotapia
Interesting choice of sqlite, what's the story on concurrent updates these
days? Last I tried to use it for a project was in 2009 and even at a measly 3
concurrent people, sqlite had trouble with data lock errors.

How does sqlite mesh well with Craft multiplayer?

------
andrew_wc_brown
I'm working on a Modded Minecraft series using AWS

If anyone has an interest in playing on my server ping me. We could use a few
more players.

[https://medium.com/@andrewbrown_78670/2018-modded-
minecraft-...](https://medium.com/@andrewbrown_78670/2018-modded-minecraft-
server-on-aws-introduction-considerations-syllabus-e55545265a88)

------
pwaai
is there a realistic mining/digging simulator? I love minecraft but sometimes
I wish I was digging a real mine with buttresses

~~~
mLuby
Yeah, it's called Primitive Technology.
[https://youtu.be/VVV4xeWBIxE](https://youtu.be/VVV4xeWBIxE)

~~~
pwaai
dayum dat RTX ray tracing is real

------
partycoder
This has a much brighter future than Minecraft on Linux or Mac (completely
neglected after Microsoft acquisition).

------
everyone
I'm assuming this runs about a jillion times faster than actual Minecraft?
They should re-write minecraft like this; its performance has always been so
awful.

~~~
matrixagent
They did. These days “Minecraft” officially refers to the new version, while
what you are talking about is called “Minecraft: Java Edition”. As of now,
both are maintained, though people are afraid that Java Edition is being
phased out in favor of the new one. Main reasons for people preferring the
Java Edition is modability and availability of an official server software for
self-hosting.

------
a_r_8
I fondly remember looking through this a few years ago as it was one of the
first posts I found at the top of HN

------
enriquto
The screenshot is an infuriatingly aliased image, wouldn't it be easy to fix?

~~~
Quequau
That repo hasn't been updated in years. I doubt Michael is going to be up for
correcting an image in a defunct repo.

------
simplify
I am in awe at how the executable is less than 1mb to download.

------
nautilus12
Can microsoft come after him for this?

~~~
bachmeier
They could sue Github's parent company for hosting it.

~~~
nautilus12
Lol

