Jump to content

Recommended Posts

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!

Posted

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

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