Jump to content

[1.8] Crash when registering a block


Gwafu

Recommended Posts

Crash Log:

net.minecraftforge.fml.common.LoaderException: java.lang.ArrayIndexOutOfBoundsException: -1
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:225)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:182)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:171)
at growthcraft.GrowthcraftBlocks.setup(GrowthcraftBlocks.java:21)

 

This is GrowthcraftBlocks.setup, which is called during pre-init:

public static void setup() 
{
	appleSapling = new BlockAppleSapling("apple_sapling");
	GameRegistry.registerBlock(appleSapling, "apple_sapling");

	appleBlock = new BlockApple("apple_block");
	GameRegistry.registerBlock(appleBlock, "apple_block");

	appleLeaves = new BlockAppleLeaves("apple_leaves");
	GameRegistry.registerBlock(appleLeaves, "apple_leaves");

}

 

The crash happens before the Mojang splash screen even appears (black Minecraft window).

 

"at growthcraft.GrowthcraftBlocks.setup(GrowthcraftBlocks.java:21)" points to "GameRegistry.registerBlock(appleBlock, "apple_block")", the second block to be registered.

 

I don't really know what causes the crash (the other two registers just fine). I already checked the three blocks multiple times and their constructors all look pretty much the same (only differing in creative tabs, sound types, etc.)

 

Here's a bit of BlockApple:

public class BlockApple extends Block implements IGrowable
{
public BlockApple(String name)
{
	super(Material.plants);

	this.setUnlocalizedName(Growthcraft.MODID + "." + name);
	this.setDefaultState(...);
}
}

 

Using the latest version of 1.8 Forge: 11.14.1.1402

 

Any help is really appreciated!

Link to comment
Share on other sites

put the GameRegistry.registerBlock() inside the constructor of your BlockApple, so it would be:

 

public BlockApple(String name)

{

super(Material.plants);

 

this.setUnlocalizedName(Growthcraft.MODID + "." + name);

this.setDefaultState(...);

                GameRegistry.registerBlock(this, "apple_block");

}

 

It would probably also be better practice to use the variable passed into the constructor called 'name' instead of "apple_block".

- Just because things are the way they are doesn't mean they can't be the way you want them to be. Unless they're aspen trees. You can tell they're aspens 'cause the way they are.

Link to comment
Share on other sites

Always, always, always, post the full crash.

 

Sorry, here's the complete crash log:

 

 

---- Minecraft Crash Report ----
// But it works on my machine.

Time: 5/8/15 11:35 AM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderException: java.lang.ArrayIndexOutOfBoundsException: -1
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:225)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:182)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:171)
at growthcraft.GrowthcraftBlocks.setup(GrowthcraftBlocks.java:21)
at growthcraft.proxy.CommonProxy.preInit(CommonProxy.java:11)
at growthcraft.proxy.ClientProxy.preInit(ClientProxy.java:10)
at growthcraft.Growthcraft.preInit(Growthcraft.java:26)
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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:536)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
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:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.set(Unknown Source)
at net.minecraft.util.ObjectIntIdentityMap.put(ObjectIntIdentityMap.java:25)
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:839)
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:801)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:214)
... 45 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 703732016 bytes (671 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.10 FML v8.0.76.1402 Minecraft Forge 11.14.1.1402 5 mods loaded, 5 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{8.0.76.1402} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1402.jar) Unloaded->Constructed->Pre-initialized
Forge{11.14.1.1402} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1402.jar) Unloaded->Constructed->Pre-initialized
examplemod{1.0} [Example Mod] (bin) Unloaded->Constructed->Pre-initialized
growthcraft{3.0} [Growthcraft] (bin) Unloaded->Constructed->Errored
Loaded coremods (and transformers): 

 

 

put the GameRegistry.registerBlock() inside the constructor of your BlockApple, so it would be:

 

public BlockApple(String name)

{

super(Material.plants);

 

this.setUnlocalizedName(Growthcraft.MODID + "." + name);

this.setDefaultState(...);

                GameRegistry.registerBlock(this, "apple_block");

}

 

It would probably also be better practice to use the variable passed into the constructor called 'name' instead of "apple_block".

 

This still crashes. And also, I prefer instantiating and registering my stuff in one place.

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