Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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");
}

Why don't you remake your block.

 

public static Block testBlock;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
testBlock = new Block(//stuff).setUnlocalizedName("testBlock");
}

ids? ...

  • Author

@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.

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?

  • Author

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);

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.

  • Author

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.

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.