Jump to content

Recommended Posts

Posted

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!

Posted

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.

Posted
  On 5/7/2015 at 4:30 PM, diesieben07 said:

Always, always, always, post the full crash.

 

Sorry, here's the complete crash log:

 

 

  Reveal hidden contents

 

 

  Quote

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.

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.