Hi, I have just added a new block to my mod, which was working fine before, but when I add it, it crashes every time I launch it. The weird part is, I get no errors in Eclipse
Source Code:
package therocksmod;
//Imports
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import therocksmod.commonproxy.CommonProxy;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
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.registry.GameRegistry;
@Mod(modid = rocksmod.modid, version = rocksmod.version)
public class rocksmod
{
@SidedProxy(clientSide = "therocksmod.client.clientproxy.ClientProxy", serverSide = "therocksmod.CommonProxy")
//Variables declared
public static CommonProxy proxy;
public static final String modid = "therocksmod";
public static final String version = "1.0.0";
public static CreativeTabs rocksMod = new CreativeTabs("rocksMod") {
public Item getTabIconItem() {
return smallRock;
}
};
//Item declarations
public static Item smallRock;
public static Item largeRock;
public static Item mediumRock;
public static Item obsidRock;
//Block declarations
public static Block Rock;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
//Item properties
smallRock = new Item() .setCreativeTab(rocksMod) .setUnlocalizedName("smallRock").setTextureName(modid + ":" + "smallRock").setMaxStackSize(16);
GameRegistry.registerItem(smallRock,"smallRock");
largeRock = new Item() .setCreativeTab(rocksMod) .setUnlocalizedName("largeRock").setTextureName(modid + ":" +"largeRock") .setMaxStackSize(16);
GameRegistry.registerItem(largeRock, "largeRock");
mediumRock = new Item() .setCreativeTab(rocksMod) .setUnlocalizedName("mediumRock").setTextureName(modid + ":" +"mediumRock").setMaxStackSize(16);
GameRegistry.registerItem(mediumRock, "mediumRock");
obsidRock = new Item() .setCreativeTab(rocksMod) .setUnlocalizedName("obsidRock").setTextureName(modid + ":" +"obsidRock").setMaxStackSize(16);
GameRegistry.registerItem(obsidRock, "obsidRock");
//Block properties
Rock = new Rock().setBlockName("Rock") .setCreativeTab(rocksMod).setBlockTextureName(modid + ":" + "Rock") ;
GameRegistry.registerBlock(Rock, "Rock");
//Recipes
GameRegistry.addShapelessRecipe(new ItemStack(mediumRock, 1), smallRock, smallRock);
GameRegistry.addShapelessRecipe(new ItemStack(smallRock, 2), mediumRock);
GameRegistry.addShapelessRecipe(new ItemStack(largeRock, 1), mediumRock, mediumRock);
GameRegistry.addShapelessRecipe(new ItemStack(mediumRock, 2), largeRock);
GameRegistry.addShapedRecipe (new ItemStack(obsidRock), "XXX", "X X", "XXX",
'X' , largeRock);
}
@EventHandler
public void init(FMLInitializationEvent event)
{
}
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
}
}
Error Log:
---- Minecraft Crash Report ----
// I'm sorry, Dave.
Time: 4/20/14 7:07 PM
Description: Initializing game
java.lang.NullPointerException: Initializing game
at therocksmod.rocksmod.preInit(rocksmod.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:500)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:202)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:520)
at net.minecraft.client.Minecraft.run(Minecraft.java:890)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at therocksmod.rocksmod.preInit(rocksmod.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:500)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:202)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:520)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:890)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_17, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 835731512 bytes (797 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.01-pre FML v7.2.156.1060 Minecraft Forge 10.12.1.1060 4 mods loaded, 4 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{7.2.156.1060} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized
Forge{10.12.1.1060} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized
therocksmod{1.0.0} [therocksmod] (bin) Unloaded->Constructed->Errored
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: AMD Radeon HD 7640G GL version 4.2.11476 Compatibility Profile Context, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
Anisotropic Filtering: Off (1)
I tried moving the declarations, but it just messed everything up. Here is the code for the Rock class:
package therocksmod;
import net.minecraft.block.Block;
public class Rock {
public Block setBlockName(String string) {
// TODO Auto-generated method stub
return null;
}
}
I tried moving the declarations, but it just messed everything up. Here is the code for the Rock class:
package therocksmod;
import net.minecraft.block.Block;
public class Rock {
public Block setBlockName(String string) {
// TODO Auto-generated method stub
return null;
}
}
Your "Rock" class needs to extend Block, and it needs a constructor (you can pass the constructor the id, like I do, if you like, or you can have it predefined). Your constructor will need to "super" an int and a Material (found in block).
Quick question:
can I put my "Item Properties" in their respective classes?
You're welcome! And the answer is yes, just in your constructor run those same methods with the same parameters. You can either run them raw (running them as if they were defined in the same class), or you can run them through "this.*method here*".
Source Code:
Error Log:
Thanks in advance, hope you guys can help!!!!
Your "Rock" class needs to extend Block, and it needs a constructor (you can pass the constructor the id, like I do, if you like, or you can have it predefined). Your constructor will need to "super" an int and a Material (found in block).
Quick question:
can I put my "Item Properties" in their respective classes?
You're welcome! And the answer is yes, just in your constructor run those same methods with the same parameters. You can either run them raw (running them as if they were defined in the same class), or you can run them through "this.*method here*".