Post news Report RSS My worst code design decision, and seecret minecraft update

Minecraft Alpha has been updated to version 1.0.1 (I just arbitrarily decided that the previous version was 1.0.0. :D), with some bug fixes (does the mouse work better in linux now?) and a metric tonne of Seecret features, including six new crafting recipes.

Posted by on

First of all, calling blocks “Tiles” in the codebase is horribly confusing. Also, TileEntities being named similar to Entities doesn’t help at all.

But the worst piece of design is older than that, dating all the way back to the cave game test build. It’s a walking null pointer exception waiting to happen.

I keep a static Tile[256] list that maps a byte value to a Tile instance, which is used to do all the block logic. For example, to find out what material a block is (say, id 40) I’d go Tile.tiles[40].getMaterial(). Works fine.
But for some reason, I decided to make air have a null block, and be identified instead by its id, 0. This means that everywhere I want to do something with a Tile instance, I have to do something like “int id = level.getTileAt(x, y, z); if (id==0) return false; else return Tile.tiles[id].getMaterial()==Material.rock;” when checking for rock instead of just a simple “return level.getTileAt(x, y, z).getMaterial()==Material.rock;”

A couple of months ago, I made the effort to try to fix this, mainly by removing the ability to even ASK for a raw block type byte from the level, but it was really surprising how many places relied on those bytes. The renderer and level generators, primarely, act on the raw bytes a lot for speed. And additionally, there are a lot of places that rely on a Tile.tiles[getTileAt(x, y, z)]==null to check for air spaces.

The problem is just big and scary enough for my laziness to prevent me from fixing it, and it’s not dangerous enough to force me to fix it (either the game works, or it doesn’t. It can’t corrupt saves or anything like that).

also, Minecraft Alpha has been updated to version 1.0.1 (I just arbitrarily decided that the previous version was 1.0.0. :D), with some bug fixes (does the mouse work better in linux now?) and a metric tonne of features, including six new crafting recipes.

You need to explore new areas for some of the new stuff, but not for everything. Dig deep.

(development blog link #1 #2)

as the seecret friday update has long since passed, here is a picture of what is new. electricity! buttons! switches! wires! etc.

seecret friday update items!

Post comment Comments
Riccars
Riccars - - 270 comments

I wish he would just tell us the secret sometimes

Reply Good karma Bad karma+1 vote
Ichiman94
Ichiman94 - - 522 comments

the secret is the new "red ore"->red "wire", iron door, lever, button, torch like "powersource"

Reply Good karma Bad karma+1 vote
Kizzycocoa Author
Kizzycocoa - - 1,827 comments

go to the official forums. they solve it within 5-50 minutes. mainly due to hacking saves, decompiling the JAR file for textures and reading scripts in-game.

Reply Good karma+1 vote
Tilranus
Tilranus - - 168 comments

red diamond, stone and wood stairs, iron doors, now you can haul lava in the bucket, leavers, buttons, and switch plates, lights that can turn on with the switch or leaver, new recipes.

Though if ya ask me seeing that diamond dust is going to be out he sould work on new tools and armor to match.

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: