Jump to content

Block Doesn't Show - Beginner


rpthomps

Recommended Posts

So, my son wanted to make mods and to be honest, i am interested as well. I have setup Eclipse with Forge and watched some tutorials and I am trying to make a basic block appear in the Creative Tab. When I compile and run Minecraft I don't see a block. I will paste my code below but I was thinking that I need to pass an ID to the block. Eclipse doesn't find a method to pass those parameters. Or perhaps I need a texture or image file? Not sure...any help would be appreciated.

 

Thanks

 

package com.Jackmods.jack1mod;

 

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

 

 

  public class jack1mod {

    @Mod.EventHandler

    public void preInit(FMLPreInitializationEvent event)

    {

 

    }

    @Mod.EventHandler

    public void Init(FMLInitializationEvent event)

    {

     

      modItems.init();

 

      modBlocks.init();

     

    }

    @Mod.EventHandler

    public void postInit(FMLPostInitializationEvent event)

    {

     

    }

}

 

class JackBlock extends Block {

 

  protected JackBlock(int i, Material materialIn) {

 

    super(i, materialIn);

    // TODO Auto-generated constructor stub

    setCreativeTab(CreativeTabs.tabMisc);

  }

}

 

public class modBlocks {

 

 

  public static Block JackBlock = new JackBlock(500, Material.rock).setUnlocalizedName("JackBlock");

  public static void init(){

 

 

  RegisterHelper.registerBlock(JackBlock);

  }

}

 

public class RegisterHelper {

 

  public static void registerBlock(Block block)

  {

      GameRegistry.registerBlock(block, block.getUnlocalizedName());

  }

 

  public static void registerItem(Item item){

      GameRegistry.registerItem(item, item.getUnlocalizedName());

  }

 

}

Link to comment
Share on other sites

public static Block JackBlock = new JackBlock(500, Material.rock).setUnlocalizedName("JackBlock");

 

From this I can tell you're on 1.6.4, Please do NOT start modding for 1.6.4, update to 1.7.10 or more preferably 1.8. There's tutorials for both versions, if you can't get it to work after updating, post again and we'll try to help, most people here do not support 1.6.4.

Link to comment
Share on other sites

That would be 1.8, So be sure you set up your workspace right and you are following a 1.8 tutorial. Eclipse should be showing you an error at this part because IDs were removed in 1.7

super(i, materialIn);

 

Also you are missing the @Mod annotation on the main mod class file

Example:

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) public class RandomUtilities {

Link to comment
Share on other sites

So, I found a tutorial for 1.8 and followed it and it worked. I made an item called test_item. I ran it, as shown in the tutorial and it worked. Yay!. Now, I wanted to change the code to call test_item, jack_cat instead. So, I changed all references from test_item to jack_cat. I even changed the version from 1.0 to 1.1 in my reference file. When I run minecraft it doesn't recognize any of the changes. Is there some kind of refresh I have to do?

 

Thanks again. Code below.

 

package com.Jacksmod.init;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.item.Item;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

import com.Jacksmod.Reference;

 

public class JackItems {

 

  public static Item jack_cat;

 

  public static void init(){

    jack_cat = new Item().setUnlocalizedName("jack_cat");

  }

 

  public static void register(){

    GameRegistry.registerItem(jack_cat, jack_cat.getUnlocalizedName().substring(5));

 

  }

 

  public static void registerRenders()

  {

    registerRender(jack_cat);

  }

 

  public static void registerRender(Item item)

  {

    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID+":"+item.getUnlocalizedName().substring(5),"inventory"));

  }

}

 

 

package com.Jacksmod.proxy;

 

import com.Jacksmod.init.JackItems;

 

public class clientproxy extends commonproxy {

 

  @Override

  public void registerRenders(){

    JackItems.registerRenders();

  }

}

 

package com.Jacksmod.proxy;

 

public class commonproxy {

  public void registerRenders(){

   

  }

}

package com.Jacksmod;

 

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.SidedProxy;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

 

import com.Jacksmod.init.JackItems;

import com.Jacksmod.proxy.commonproxy;

 

@Mod(modid = Reference.MOD_ID,name = Reference.MOD_NAME, version = Reference.VERSION)

public class mainmod {

 

  @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS,serverSide = Reference.SERVER_PROXY_CLASS)

  public static commonproxy proxy;

 

 

  @EventHandler

  public void preInit(FMLPreInitializationEvent event){

   

    JackItems.init();

    JackItems.register();

  }

  @EventHandler

  public void Init(FMLInitializationEvent event){

   

    proxy.registerRenders();

  }

  @EventHandler

  public void postInit(FMLPostInitializationEvent event){

 

  }

}

 

package com.Jacksmod;

 

public class Reference {

  public static final String MOD_ID = "Jack";

  public static final String MOD_NAME = "JackMod";

  public static final String VERSION = "1.1";

 

  public static final String CLIENT_PROXY_CLASS = "com.Jacksmod.proxy.clientproxy";

  public static final String SERVER_PROXY_CLASS = "com.Jacksmod.proxy.commonproxy";

}

 

Link to comment
Share on other sites

when you want to rename a class in eclipse do the following

right click the class in the package explorer

from the dropdown select refactor then rename

 

 

items are remembered in a list by their name, if you change this the map will no longer know what the old items/ blocks where as they are no longer registered

these old items will be removed from the map

to prevent this, leave the old items in the mod, but remove them from the creative tabs and recipes

create the new items as new items

I also noticed you are registering the item by the first 5 letters of its unlocalized name, this isnt a good idea as you may end up with 2 items being registered with the same name

 

 

Link to comment
Share on other sites

to prevent this, leave the old items in the mod, but remove them from the creative tabs and recipes

create the new items as new items

 

No, remove the old items, this mod isn't even released yet, it won't matter, there is no point having junk coffee like that.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

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.



×
×
  • Create New...

Important Information

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