Jump to content

How to make a block


HaiDozo

Recommended Posts

I've been searching, on and off, for DAYS for a tutorial on how to make a block.

I've searched this forum and also google, with no luck.

I'm looking for a tutorial for 1.9 using blockstates and not using deprecated methods like registerBlock() or setBlockTextureName().

 

I'm sure there's a tutorial somewhere, right? Anyone know?

Link to comment
Share on other sites

Hi

 

May the luck was not on your side, but within two seconds of googling I found this:

 

http://modwiki.temporal-reality.com/mw/index.php/Main_Page

 

Happy coding

Sincerely -pick

 

Great, thanks! :D

It might help me with stuff, however looking at the block tutorial, I've already done what's in the tutorial and it's not working. The block is not ingame, neither as /give or in the creative menu (which I have put it in).

 

I do have an item working so I have the basics done and working.

 

My code (simplified) is like:

 

The main class calls proxy stuff. CommonProxy.preInit() calls BlockManager.createBlocks() which does:

[snip...]

GameRegistry.register(clinkerBrickBlock = new ClinkerBricks());

 

and the block class is:

 

[snip imports...]

 

public class ClinkerBricks extends Block{

    public ClinkerBricks() {

        this("clinker_bricks", Material.rock);

    }

 

    public ClinkerBricks(String name, Material material) {

        super(material);

        this.setRegistryName(name);

        this.setUnlocalizedName(this.getRegistryName().toString());

        this.setCreativeTab(CreativeTabs.tabBlock);

    }

}

 

 

That's the correct chain of events to register a block, right?

Registering it twice crashes with "already registered that name" error, so the registering goes through, but it doesn't show up ingame. I don't even care about textures right now, I just wanna see that sweet, sweet black/magenta checker pattern  ;)

This is so basic that I'm embarrased, but I'm not getting it to work  :-[

 

Any thoughts?

Link to comment
Share on other sites

Did you register an ItemBlock? Because if you don't, your Block can only exist placed down in the world.

 

Ah! I did not do that. Didn't know it was a thing. Looking for tutorials about the relation of blocks and ItemBlock: can't find any xD My google-fu must suck, or are there generally not many detailed tutorials available?

 

I took a shot in the dark: saw something about registering ItemBlock(this) so I threw

GameRegistry.register(new ItemBlock(this), getRegistryName());

into the constructor of my block and it works! :D

 

Textures next! It's going slow but I'm making progress! :D

 

Thansk again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.