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

Hi there,

 

I just recently got back into modding and have starting making a basic mod for 1.9. Right now I have simply added a basic item and block as well as a creative tab.

 

My problem is that while the game says the block is registered, it doesn't appear in my creative tab and I cannot give it to myself (through /give).

 

Here is my preInit code:

 

    public void preInit(FMLPreInitializationEvent e) {
        AtlantisMod.cTab = new ModCreativeTab();
        ModItems.registerItems();
        ModBlocks.registerBlocks();}

 

 

Here is my ModBlocks code:

 

public class ModBlocks {
    public static final Set<Block> blocks = new HashSet<>();

    public static Block decorativeStone;

    public static void registerBlocks() {
        // Register Blocks
        decorativeStone = registerBlock(new BlockDecorativeStone("decorativeStone"));
    }

    private static <O extends Block> O registerBlock(O block) {
        GameRegistry.register(block);
        blocks.add(block);
        return block;
    }
}

 

 

And here is both my BlockDecorativeStone and BlockBasic code:

 

public class BlockBasic extends Block {
    public BlockBasic(Material material, MapColor mapColor, String blockName) {
            super(material, mapColor);
            setBlockName(this, blockName);
            setCreativeTab(AtlantisMod.cTab);
            System.out.println("TEST: registered");
        }

    private void setBlockName(Block block, String blockName) {
        block.setRegistryName(blockName);
        block.setUnlocalizedName(block.getRegistryName().toString());
    }

    public BlockBasic(Material materialIn, String blockName) {
        this(materialIn, materialIn.getMaterialMapColor(), blockName);
    }

    public BlockBasic(String blockName) {
        this(Material.rock, Material.rock.getMaterialMapColor(), blockName);
    }
}

 

 

public class BlockDecorativeStone extends BlockBasic {
    public BlockDecorativeStone(String blockName) {
        super(blockName);
    }
}

 

 

I even have this at the end of my postInit code:

 

System.out.println("TEST: " + ModBlocks.decorativeStone.getRegistryName().toString());

 

 

It appears that the game registers the block and it executes all fine and dandy like. It will output both "registered" and "TEST: atlantis:decorativeStone" into the console; I just cannot get it to appear in game for some reason. Am I missing something?

No signature for you!

  • Author

You are not registering an ItemBlock for your Block, hence it cannot exist in item form (e.g. it can only exist placed down as an actual Block in the world).

Create an ItemBlock instance, set it's registry name to the registry name of your block and register it after you've registered your Block.

 

Well I'm an idiot. that makes perfect sense.

No signature for you!

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.