Jump to content

Recommended Posts

Posted

can someone please tell me what's wrong with this code.

package net.minecraft.src;

 

public abstract class mod_Test extends BaseMod

{

  public static Block Test= new BlockTest(126, 1).setHardness(1.0F).setResistance(5.0F).setLightValue(1.0F).setBlockName("Test");

 

  public String Version()

  {

      return "1.2.5";

  }

 

  public mod_Test()

  {

      ModLoader.registerBlock(Test);

      Test.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/copper.png");

      ModLoader.addName(Test, "Test");

          ModLoader.addRecipe(new ItemStack(Test, 1), new Object[]{ "##", "##", Character.valueOf('#'), Block.dirt});

    }

}

Posted

sorry will use that next

it is giving me this error

Mods loaded: 1

ModLoader 1.2.5

 

      Minecraft has crashed!     

      ----------------------     

 

Minecraft has stopped running because it encountered a problem.

 

 

 

 

--- BEGIN ERROR REPORT 9f578458 --------

Generated 07/06/12 23:05

 

Minecraft: Minecraft 1.2.5

OS: Windows Vista (x86) version 6.0

Java: 1.7.0_03, Oracle Corporation

VM: Java HotSpot Client VM (mixed mode), Oracle Corporation

LWJGL: 2.4.2

OpenGL: ATI Radeon HD 4870 version 2.1.8543 Release, ATI Technologies Inc.

 

java.lang.InstantiationException

    at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

    at java.lang.Class.newInstance0(Class.java:372)

    at java.lang.Class.newInstance(Class.java:325)

    at net.minecraft.src.ModLoader.addMod(ModLoader.java:287)

    at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1279)

    at net.minecraft.src.ModLoader.init(ModLoader.java:849)

    at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:157)

    at net.minecraft.src.RenderManager.<init>(RenderManager.java:85)

    at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:12)

    at net.minecraft.client.Minecraft.startGame(Minecraft.java:424)

    at net.minecraft.client.Minecraft.run(Minecraft.java:786)

    at java.lang.Thread.run(Thread.java:722)

--- END ERROR REPORT 636c3076 ----------

Posted

Are you using an IDE? I know eclipse will warn you if you don't implement required functions and I believe you need a load() member function.

I use the constructor to read the config from file, and do all the block registering in load().

Posted

You extended BaseMod. BaseMod contains the abstract method load(). This means that any class that extends BaseMod (yours) must provide a load() method, or errors will occur. Because of the way ModLoader works, you can put statements in either the constructor or load, but by convention, put minecraft stuff in load and houskeeping for your code in the constructor. Or don't, it's just a convention.

Posted

well i did the code like this

package net.minecraft.src;

 

public abstract class mod_Test extends BaseMod

{

  public static Block Test= new BlockTest(126, 1).setHardness(1.0F).setBlockName("Test");

 

  public String Version()

  {

      return "1.7.3";

  }

  {

      BaseMod load = load();

  }

  public mod_Test()

  {

      ModLoader.registerBlock(Test);

      Test.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/copper.png");

      ModLoader.addName(Test, "Test");

          ModLoader.addRecipe(new ItemStack(Test, 1), new Object[]{ "dd", "dd", Character.valueOf('d'), Block.dirt});

    }

}


but it came up with this error

 


Mods loaded: 1

ModLoader 1.2.5

 

      Minecraft has crashed!     

      ----------------------     

 

Minecraft has stopped running because it encountered a problem.

 

 

 

 

--- BEGIN ERROR REPORT 9f578458 --------

Generated 08/06/12 10:01

 

Minecraft: Minecraft 1.2.5

OS: Windows Vista (x86) version 6.0

Java: 1.7.0_03, Oracle Corporation

VM: Java HotSpot Client VM (mixed mode), Oracle Corporation

LWJGL: 2.4.2

OpenGL: ATI Radeon HD 4870 version 2.1.8543 Release, ATI Technologies Inc.

 

java.lang.InstantiationException

    at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

    at java.lang.Class.newInstance0(Class.java:372)

    at java.lang.Class.newInstance(Class.java:325)

    at net.minecraft.src.ModLoader.addMod(ModLoader.java:287)

    at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1279)

    at net.minecraft.src.ModLoader.init(ModLoader.java:849)

    at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:157)

    at net.minecraft.src.RenderManager.<init>(RenderManager.java:85)

    at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:12)

    at net.minecraft.client.Minecraft.startGame(Minecraft.java:424)

    at net.minecraft.client.Minecraft.run(Minecraft.java:786)

    at java.lang.Thread.run(Thread.java:722)

--- END ERROR REPORT dc5872f7 ----------

Posted

wha... huh? do you even know what extending a class means? You have to provide the load method. You have to write it! It is abstract in the superclass, meaning it's just the method definition, it has no body. Take out that... thing, you just wrote, and add this method to your class.

public void load(){}

Also, read this tutorial, including the bit on abstract methods and classes.

http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

Posted

that's just made the console say

27 achievements

183 recipes

LWJGL Version: 2.4.2

Exception in thread "Minecraft main thread" java.lang.Error: Unresolved compilation problem:

    The method load() is undefined for the type BaseMod

 

    at net.minecraft.src.ModLoader.init(ModLoader.java:856)

    at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:157)

    at net.minecraft.src.RenderManager.<init>(RenderManager.java:85)

    at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:12)

    at net.minecraft.client.Minecraft.startGame(Minecraft.java:424)

    at net.minecraft.client.Minecraft.run(Minecraft.java:786)

    at java.lang.Thread.run(Thread.java:722)

as i say i'm new to modding but i want to give it a try i really do appresiate everyone's time.

Posted

no the code only says this

package net.minecraft.src;

 

public abstract class mod_Test extends BaseMod

{

  public static Block Test= new BlockTest(126, 1).setHardness(1.0F).setBlockName("Test");

 

 

  public String Version()

  {

      return "1.7.3";

  }

 

 

public void load (){};

 

 

  {

      ModLoader.registerBlock(Test);

      Test.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/copper.png");

      ModLoader.addName(Test, "Test");

          ModLoader.addRecipe(new ItemStack(Test, 1), new Object[]{ "dd", "dd", Character.valueOf('d'), Block.dirt});

    }

}

Posted

Well, looks like you deleted your mod_Test() constructor. Also, make sure you don't forget to save and recompile.

As you're new to modding, I must ask, are you new to Java as well? Or even to coding in general?

Posted

Ok, you're going to have a lot of trouble if you're just copying code out of a tutorial without knowing what it does. I'd recommend the MIT opencourseware stuff. It's free and pretty damn good. Granted it's in Python, not Java, but once you get the basics down, learning a new language isn't that hard.

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/Syllabus/

Here's a bunch of Java resources as well. http://netbeans.org/kb/articles/learn-java.html

Posted

  {

      BaseMod load = load();

  }

Basically, this tries to create a non-static initialization block that creates a local scratch variable called "load" of type BaseMod, and then tries to call the void-non-returning abstract superclass static method "load" and to assign that void non-existent return value to the scratch variable, which then would be discarded.

WHAT IN THE JESUS CHRIST FUCK

Posted

hey guys its me i just want to say thank you to all who posted thanks to all of you and your constant help and support i have finally been able to fix the error and make my first step into the modding world thank you :-)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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