Jump to content

Recommended Posts

Posted

Hi everybody,

 

I have bought wuppys Book and am following the tutorials and have so far set up eclipse and forge etc. I am currently at the stage of running the example mod that just prints dirt block to the console. Minecraft starts up ok and states that the example mod is running but 'dirt block' does not get printed to the console.

 

I assume it should get printed to the eclipse console and not the in game Minecraft console? I don't really want to move on till I get this sorted. I have some small experience with Java but not using an IDE.

Posted

I am on my mobile so can't post code at the moment sorry but yes it is just a system.out print

I will go through the output with a fine tooth comb tonight but I thought I was thorough yesterday.

 

Thanks

Posted

My bad!

 

This was in the console output after all:

 

[com.example.examplemod.ExampleMod:init:18]: DIRT BLOCK >> tile.dirt

 

Took a while to find though!

Posted

Hmmm this is pretty tricky isn't it? I have typed in the second example and it does not want to run at all.

 

package com.wuppy.samsmod;

import net.minecraft.init.Blocks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;

@Mod(modid = SamsMod.MODID, version = SamsMod.VERSION)
public class SamsMod
{
    public static final String MODID = "examplemod";
    public static final String VERSION = "1.0";
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
	// some example code
        System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
    }
}

 

It does not seem to like the import cpw commands, the @Mod line and the @EventHandler and the public void init line immediately after it.

 

I get the feeling that either the book is outdated or Forge has not loaded all the resources.

Posted

Hover over it and get your IDE to prompt you with hints.

Or import manually.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

The IDE appears to have a mind of its own and has seemingly made alterations all by itself. It has deleted all the cpw lines and replaced them.

 

I now have the following:

 

package com.wuppy.samsmod;

import net.minecraft.init.Blocks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;

@Mod(modid = SamsMod.MODID, version = SamsMod.VERSION)
public class SamsMod
{
    public static final String MODID = "examplemod";
    public static final String VERSION = "1.0";
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
	// some example code
        System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
    }
}

 

This runs without errors in the code but Minecraft does not run I get "Game Crashed!" in the console and looking through the crash report I found the following:

 

java.lang.IllegalArgumentException: Multiple entries with same key: examplemod=FMLMod:examplemod{1.0} and examplemod=FMLMod:examplemod{1.0}

Posted

I am getting there! sorry to be so impatient with the posting but I am away till tomorrow night and wanted to finish on a metaphorical full stop and not half way through a sentence.

 

My problem - obviously - was that I had the same ModId. Everything running fine now!

  • 5 years later...
Posted

I found this thread because I am using the same technique but wanting to write to the console (the Eclipse view) after the game has loaded and is running.  Seems like this would be a great way to analyze code while the game is in progress.  However, this does not appear to be working.  

 

I am trying to resolve an issue having to do with a random number generator that is selecting a number in a class that is derived from WorldGenAbstractTree and in the generate() method I want to see what a random number is.  It seems that that number is the same every time.  I plant a sapling, bonemeal it and get the same sized tree. 

 

Any suggestions or knowledge I should check out regarding how to troubleshoot code using the console?

 

Or perhaps I will have to look at tools in eclipse for monitoring variable values while a program is running if that is available.

 

 

Posted

Why not use the debugger and set a breakpoint at the desired location and inspect the variable?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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