Jump to content

Generic Mod help?


n80sire
 Share

Recommended Posts

Hey guys, I'm a brand new modder and I am having trouble with this. Minecraft will crash after I finish up the genericBlock.

(I am using eclipse)

Here's my code, the parts highlighted in red are what eclipse show as wrong.

 

 

 

 

Generic.java

 

 

 

 

package tutorial.generic;

 

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;

 

@Mod(modid="Generic", name="Generic", version="0.0.0")

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Generic {

 

        // The instance of your mod that Forge uses.

        @Instance("Generic")

        public static Generic instance;

       

        // Says where the client and server 'proxy' code is loaded.

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

        {

                proxy.registerRenderers();

               

              [glow=red,2,300] GameRegistry.registerBlock(genericDirt, "genericDirt");

                LanguageRegistry.addName(genericDirt, "Generic Dirt");

                MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0);[/glow]

        }

       

        @PostInit

        public void postInit(FMLPostInitializationEvent event) {

                // Stub Method

        }

}

 

 

 

 

 

GenericBlock.java

 

 

 

 

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(500, material.ground);

        }

       

        @Override

        [glow=red,2,300]public void registerIcons(IconRegister iconRegister) {[/glow]

                this.blockIcon = iconRegister.registerIcon("generic:generic");

        }

 

}

 

 

 

 

 

Block.java

 

 

 

 

package net.minecraft.block;

    /**

    * Flag if block ID should use the brightest neighbor light value as its own

    */

    public static boolean[] useNeighborBrightness = new boolean[4096];

    public static final Block stone = (new BlockStone(1)).setHardness(1.5F).setResistance(10.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("stone");

    public static final BlockGrass grass = (BlockGrass)(new BlockGrass(2)).setHardness(0.6F).setStepSound(soundGrassFootstep).setUnlocalizedName("grass");

    public static final Block dirt = (new BlockDirt(3)).setHardness(0.5F).setStepSound(soundGravelFootstep).setUnlocalizedName("dirt");

[glow=green,2,300]    public final static Block genericDirt = (new GenericBlock(500)).setHardness(0.5F).setStepSound(soundGravelFootstep).setUnlocalizedName("genericDirt");[/glow]

    public static final Block cobblestone = (new Block(4, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("stonebrick").setCreativeTab(CreativeTabs.tabBlock);

    public static final Block planks = (new BlockWood(5)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setUnlocalizedName("wood");

    public static final Block sapling = (new BlockSapling(6)).setHardness(0.0F).setStepSound(soundGrassFootstep).setUnlocalizedName("sapling");

    public static final Block bedrock = (new Block(7, Material.rock)).setBlockUnbreakable().setResistance(6000000.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock);

    public static final BlockFluid waterMoving = (BlockFluid)(new BlockFlowing(8, Material.water)).setHardness(100.0F).setLightOpacity(3).setUnlocalizedName("water").disableStats();

    public static final Block waterStill = (new BlockStationary(9, Material.water)).setHardness(100.0F).setLightOpacity(3).setUnlocalizedName("water").disableStats();

    public static final BlockFluid lavaMoving = (BlockFluid)(new BlockFlowing(10, Material.lava)).setHardness(0.0F).setLightValue(1.0F).setUnlocalizedName("lava").disableStats();

 

 

 

Link to comment
Share on other sites

You need to create the object for that block in you mod class, it would be something like this in your Generic.java:

 

public final static Block genericDirt = new GenericBlock(id, "you texture path", Material.ground)

 

Take a look at the tutorials here:

http://www.minecraftforge.net/wiki/Basic_Blocks

 

And this one for texturing the block later:

http://www.minecraftforge.net/wiki/Icons_and_Textures

 

EDIT: Just noticed you have putted the object creation in the Block.java, don't do that(generally NEVER edit any vanilla files), put it in your Generic.java instead

Link to comment
Share on other sites

every place it says "//here"

 

 

package tutorial.generic;

 

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;

 

@Mod(modid="Generic", name="Generic", version="0.0.0")

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Generic {

//here

        // The instance of your mod that Forge uses.

        @Instance("Generic")

        public static Generic instance;

      //here, preferably here

        // Says where the client and server 'proxy' code is loaded.

        @SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")

        public static CommonProxy proxy;

      //here

        @PreInit

        public void preInit(FMLPreInitializationEvent event) {

                // Stub Method

        }

      //or here

        @Init

        public void load(FMLInitializationEvent event)

        {

                proxy.registerRenderers();

             

                GameRegistry.registerBlock(genericDirt, "genericDirt");

                LanguageRegistry.addName(genericDirt, "Generic Dirt");

                MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0);

        }

     

        @PostInit

        public void postInit(FMLPostInitializationEvent event) {

                // Stub Method

        }

}

 

 

but please learn to code before doing modding, if you couldnt figure it was because you didnt declare a variable you will clearly have much worst problem later on, sorry :(

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

ahhh, yeah well with help you can usually do fine, tough watch out wich question you ask because people end up asking stuff were you just know they have no idea what they're doing.

 

good modding

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

I would recommend at least having a basic understanding of java before making a mod :)

 

A good place to learn the basics of java programming would be:

http://thenewboston.org/list.php?cat=31

 

And if you have enough time, and the will to complete some more detailed tutorials, check out the online tutorials or free e-books from oracle them selves :)

 

Online tutorials: http://docs.oracle.com/javase/tutorial/

E-Books: http://www.oracle.com/technetwork/java/javase/downloads/java-se-7-tutorial-2012-02-28-1536013.html

 

For the E-Books, I would recommend the "getstartedtrail" and "essentialtrail". But keep in mind that these books are more advanced than the video tutorials I linked in the beginning of this post, but they will also give you a much better understanding of java(You could also just use them to look up some things that you find difficult) :)

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

 Share



×
×
  • Create New...

Important Information

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