Jump to content

[1.7.2] Block not appearing in CreativeTabs.tabBlock


Sessional

Recommended Posts

I'm working in 1.7.2 forge right now. I am currently running 1027 and can not seem to get a block to appear in the game.

 

I've followed several different tutorials and have not been able to get any of them to work. The ones for 1.6.4 were a little off but usually had some follow up text to change to 1.7.2.

 

Currently I have it in CreativeTabs.tabFood because the list is shorter, but I have not been able to get it to appear in any tab. There is not a single error in the start up output (except something about an rt.jar or something) and there is no problems until I try to find it in the creative inventory or use /give player 500 1, which in theory should give me my block. I get a red message saying "No item with id 500" or something similar.

 

I have managed to get an item to appear in the food tab without a single problem using almost identical code.

 

This code is in the preinitialization event:

Block testblock = new TestBlock();
Block.blockRegistry.addObject(500, "testblock", testblock);

 

This class extends net.minecraft.block.Block:

public TestBlock() {
    super(Material.ground);
    setCreativeTab(CreativeTabs.tabFood);
    setBlockTextureName("testmod:BlockTut");
}

Link to comment
Share on other sites

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	testBlock = new BlockStone().setBlockName("testblock").setBlockTextureName("testmod:BlockTut");
	Block.blockRegistry.addObject(500, "testblock", testBlock);

	Item testitem = new TestItem();
	Item.itemRegistry.addObject(501, "testitem", testitem);
}

 

In 1.7 there is no setUnlocalizedName method (at least that I saw...) There is a setBlockName which I'm assuming is the same thing as the previous method. The id (as far as I can tell should be registering at 500.

Link to comment
Share on other sites

Are mods not meant to use the GameRegistry or at least GameData to register blocks and items in a manner that lets Minecract/Forge/FML worry about the id's?

 

Also I think it might need to be in the FMLPreInitializationEvent event now, I am not sure if it works fully in the other 2 events?

Link to comment
Share on other sites

Apparently to get it to show up inside the creative inventory you need an ItemBlock instance instead of just having a "Block".

 

I have no idea what the difference is between GameData.itemRegistry and Item.itemRegistry or any other variables. I honestly have no idea if forge manages the item ids or not. This is my first day tinkering with forge and it's got an interesting learning curve if you start on 1.7.2 - things are way different than the tutorials say.

 

testBlock = new BlockStone().setBlockName("testblock").setBlockTextureName("testmod:BlockTut");
GameData.blockRegistry.add(500, "testblock", testBlock);

ItemBlock itemBlock = (ItemBlock) new ItemBlock(testBlock).setUnlocalizedName("testBlock").setCreativeTab(CreativeTabs.tabBlock).setTextureName("testmod:BlockTut");
GameData.itemRegistry.add(502, "testblockitem", itemBlock);

Link to comment
Share on other sites

This is all I needed along with the textures/blocks/tutorial_block.png and lang/en_US.lang file:

@Mod(modid = ExampleMod.MODID, name=ExampleMod.NAME, version = ExampleMod.VERSION)
public class ExampleMod
{
    public static final String MODID = "examplemod";
    public static final String NAME = "An example mod";
    public static final String VERSION = "1.0";
    
    public static Block tutorialBlock;
    
    @EventHandler
    public void preinit(FMLPreInitializationEvent event)
    {

        tutorialBlock = new TutorialBlock(Material.rock);
        tutorialBlock.setBlockName("tutorialBlock").setCreativeTab(CreativeTabs.tabMisc).setStepSound(Block.soundTypeStone).setBlockTextureName(MODID+":tutorial_block");
        GameRegistry.registerBlock(tutorialBlock,"tutorialBlock");

 

The block class is a simple subclass of Block that calls the super-constructor.

And it just works. The block shows up in the creative tab, I can place and break it, and it looks pretty.

 

More code to be added when I think of what I want it to do.

Link to comment
Share on other sites

Alrighty. Looked at your post:

 

What version of 1.7.2 are you using? This method seems to have been renamed in my Block.class. Did it return the "unlocalized name"? If you tell me what it's purpose was I can track it down.

brokenObsidianBlock.func_149739_a()

 

Thanks for the response.

 

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.