1. Adding a block to the block directory - 16Byte/PixelCraft GitHub Wiki

First Thing's First! We have to add a block!

In order to add a block we're going to need to add a new script in the Scripts/Blocks Directory

Once you're in there, right click and select create new C# script and name it "BlockEmerald".

After that go ahead and double click the script and it should open in your favourite text editor, it doesn't matter what your's is; it can even be notepad.

Time to start coding!

This is where it starts to get fun. Once you're there go ahead and delete the two functions in the class like so.

Now let's make this script know it's a block by replacing inheriting from the block class rather than the MonoBehaviour class and we'll also add the block constructor. If you've made Java Minecraft mods you'll know what I mean.

You're going to want to write this in the class,

public BlockEmerald() : base() {

}

This is how it should look after inheriting from the block class and adding this line of code.

It will build the block! If you were to open the block class you'll probably understand how this works.

Pretty easy right? Yup! That's how I designed this project because I know other people want to learn how to make a minecraft game also.

Now let's learn how to add textures(UVs) to the block!

First things first in the Assets folder you will see a file called "tile" that is all the currently supported tiles that you can use in the game! You can edit the two that are blank to add your own textures!

It looks something like this,

Now let's go back into the script and add this. The texture part we're going to want to use is x = 2 and y = 3 because we want the emerald texture.

if you type in

public override, you'll find everything you can modify on the block. Right now we're only worried about,

public override Tile TexturePosition(Block.Direction direction) { return base.TexturePosition(direction); }

first thing is first, we need to delete Block.Direction and just leave it as (Direction direction)

Next we need to add this inside the override, Tile tile = new Tile();

Then we can, return Tile;

Once we've done that we can edit the block's textures.

Now let's just remember that we need x = 2 and y = 3 for the emerald class referring to the tile sheet above.

so in between Tile tile = new Tile(); and return tile; we're going to want to write, tile.x = 2; tile.y = 3;

that will find the texture we want to use and wrap it around the texture.

It should look like this when you're done!

Congratulations! You've made a block! Now in the future tutorial we'll call your block back so you can see it! :)