Jump to content

Recommended Posts

Posted

I have started on the tutorials yesterday.  I got everything setup following the tutorials in the wiki.  Now I am on http://www.minecraftforge.net/wiki/Basic_Blocks trying to create my first block.  I seem to be running into errors by the end of the tutorial, and have even resorted to copy/pasting the code at the bottom to ensure that everything was correct, but still run into the same errors in Generic, GenericBlock, and GenericOre classes:

 

 

 

package tutorial.generic;

// This Import list will grow longer with each additional tutorial.
// It's not pruned between full class postings, unlike other tutorial code.
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="Generic", name="Generic", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Generic {
        // See Basic items tutorial for Generic Ingot
        public final static Item genericIngot = new GenericItem(5001)
                .setMaxStackSize(16).setIconIndex(1).setItemName("specificItem");
       
        public final static Block genericDirt = new GenericBlock(500, 0, Material.ground)
                .setHardness(0.5F).setStepSound(Block.soundGravelFootstep)
                .setBlockName("genericDirt").setCreativeTab(CreativeTabs.tabDeco);
        public final static Block genericOre = new GenericOre(501, 1);
       
        @Instance("Generic")
        public static Generic instance;
       
        @SidedProxy(clientSide="tutorial.generic.client.ClientProxy",
                        serverSide="tutorial.generic.CommonProxy")
        public static CommonProxy proxy;
       
        @PreInit
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
       
        @Init
        public void load(FMLInitializationEvent event) {
                // See Basic items tutorial for Generic Ingot
                LanguageRegistry.addName(genericIngot, "Generic Ingot");
               
                LanguageRegistry.addName(genericDirt, "Generic Dirt");
                MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0);
                GameRegistry.registerBlock(genericDirt, "genericDirt");
               
                LanguageRegistry.addName(genericOre, "Generic Ore");
                MinecraftForge.setBlockHarvestLevel(genericOre, "pickaxe", 3);
                GameRegistry.registerBlock(genericOre, "genericOre");
                // End Basic Blocks
               
                proxy.registerRenderers();
        }
       
        @PostInit
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}

 

 

 

 

 

package tutorial.generic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

public class GenericBlock extends Block {

        public GenericBlock (int id, int texture, Material material) {
                super(id, texture, material);
        }
       
        @Override
        public String getTextureFile () {
                return CommonProxy.BLOCK_PNG;
        }

}

 

 

 

 

 

package tutorial.generic;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockOre;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.block.material.Material;

public class GenericOre extends BlockOre {
        public GenericOre(int id, int texture, Material material) {
                super(id, texture, material);
               
                setHardness(4.0F); // 33% harder than diamond
                setStepSound(Block.soundStoneFootstep);
                setBlockName("genericOre");
                setCreativeTab(CreativeTabs.tabBlock);
        }
       
        @Override
        public String getTextureFile () {
                return CommonProxy.BLOCK_PNG;
        }
       
        public int idDropped(int par1, Random random, int par2) {
                return Generic.genericIngot.itemID;
        }
}

 

 

 

I am also getting this error since I opened back up Eclipse this morning:

 

 

Description	Resource	Path	Location	Type
Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 	Minecraft		Build path	JRE System Library Problem

 

 

 

In the "Materials" section I am unable to locate net.minecraft.src.Material also.  I am not sure if it is because I am new, or if this tutorial was written for a different version of MC, but could really use some advice here.

 

I just downloaded the most recent releases of both Eclipse and Forge yesterday to start modding, btw.

Posted

Seems to me your problem lies mainly in the fact that you haven't installed any JDK (Java Development Kit) this is essential since without it you can't develop Java applications. You'll have to install it, you can get the latest version here:

 

http://www.oracle.com/technetwork/java/javase/downloads/index.html

 

You should look after a download called "Java Platform (JDK) 7u17". Also the path to Material is net.minecraft.block.material.Material if I recall correctly ;)

Posted

This was installed yesterday, but I forgot that I moved the forge directory this morning to a more permanent place on my hard drive.  I am just going to follow the steps again and start over.

 

Thanks :)

Posted

Okay, I reinstalled everything, and I am still getting the error about JavaSE-1.6.  However, per the tutorial:

 

You should also be able to use Java 7 (JDK 1.7), but doing so means that all users of your mod must also be using Java 7.

 

So, I am using the most recent 1.7.  After everything is installed I can launch Minecraft from Eclipse, and everything runs, so I don't guess that the warnings are of much concern.

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.