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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • file:///C:/Users/Danie/Downloads/Capture.JPG I keep experiencing this error, does anyone know how to fix it here is the report: file:///C:/Users/Danie/AppData/Roaming/.minecraft/crash-reports/Bug_report1.txt
    • Hi, i am unable to join a multiplayer server my friend and i created. We started it with some mods then decided to add some others and this is when the error appeared. We are using Curseforge, the server is in 1.20.1 . The full error message is "Internal Exception: io.netty.handler.codec.DecoderException: java.lang.ArrayIndexOutOfBoundsException: Index 17196645 out of bounds for length 13" I am the only one with that issue, my friends can log in and out no problem. I have tried switching minecraft account but that doesn't help so i guess the bug is on my side. We use the same mod profile so i know the error doesn't come from there. Here is the latest.log file https://pastebin.com/X6J9Fnnf. If you need more informations to try and investigate, please let me know. Big thanks to anyone that will try to help
    • [00:02:07] [main/ERROR]: Missing or unsupported mandatory dependencies:     Mod ID: 'kotlinforforge', Requested by: 'flightlib', Expected range: '[4.3.0,)', Actual version: '[MISSING]'     Mod ID: 'terrablender', Requested by: 'biomesoplenty', Expected range: '[2.2.0.154,)', Actual version: '[MISSING]'     Mod ID: 'geckolib', Requested by: 'cakescosmetics', Expected range: '[4.4,)', Actual version: '[MISSING]'     Mod ID: 'balm', Requested by: 'waystones', Expected range: '[7.2.0,)', Actual version: '[MISSING]'     Mod ID: 'oculus', Requested by: 'irisflw', Expected range: '[1.6.15,)', Actual version: '[MISSING]'     Mod ID: 'cupboard', Requested by: 'betterfpsdist', Expected range: '[1.20.1-1.5,)', Actual version: '[MISSING]' [00:02:53] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.20.1-47.2.32\fmlcore-1.20.1-47.2.32.jar is missing mods.toml file [00:02:54] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.20.1-47.2.32\javafmllanguage-1.20.1-47.2.32.jar is missing mods.toml file [00:02:54] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.20.1-47.2.32\lowcodelanguage-1.20.1-47.2.32.jar is missing mods.toml file [00:02:54] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.20.1-47.2.32\mclanguage-1.20.1-47.2.32.jar is missing mods.toml file [00:02:65] [main/ERROR]: Skipping early mod setup due to previous error
    • Guns and more cool stuff
    • nvm i did it, turn out i just needed to install a drive or smth
  • Topics

×
×
  • Create New...

Important Information

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