Jump to content

Extending Base Blocks


Recommended Posts

I'm completely new to modding MC, but I have an idea I'd like to try out for a little racetrack I put together on a friend's server. I've looked around the different MC Forge tuts and think I have a basic understanding of how it works.

I'd like to make a simple sign block that when you right click it, it starts a timer, when you right click again, it stops, and a third time it resets the time. I know how to write the logic in Java, but what I'm wondering is if I can just inherit from the existing Sign block when creating my new block and then just override the right click method to do what I want it to. Along those same lines, would any block be extensible if you knew the name of the block?

Link to comment
Share on other sites

You'll need to extend both the block (defining sign behavior) and the tile entity class (holding the current data for each instance of each timer-sign in the world). You need to wrap your head around the first idea, that there is one and only one block instance for each type of block (although "sign" might have both "wall" and "floor" subclasses).


A block by itself is allocated only 4 bits of data (called metadata) pertaining to each occurrence in the world. If your block needs more data at each occurrence, then it needs a tile entity (entry into a sparse data structure for the unusual blocks in the world).


Your block class will probably have all of the "thinking" logic, and your tile entity will hold the extra data with get & set methods.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

there is one and only one block instance for each type of block (although "sign" might have both "wall" and "floor" subclasses).


Not sure how the classing is done, but at the block-ID point (its possible they use the same class, the way redstone (and a few other blocks) ore do), wall and floor signs are two different blocks.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

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.

  • Create New...

Important Information

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