Jump to content

Recommended Posts

Posted

Hello Everyone, I am just wondering if it is possible to use Arrays for new Blocks.

 

This is the code for making my new blocks in my main java file:

[hide]

public static Block UnevenStoneStair_gray;

    public static Block UnevenStoneStair_blue; 

    public static Block UnevenStoneStair_brown;

    public static Block UnevenStoneStair_light;

    public static Block UnevenStoneStair_yellow;

    public static Block UnevenStoneStair_red;

    public static Block UnevenStoneStair_green;

    public static Block[] UnevenStoneStair= new Block[7];{

    UnevenStoneStair[0] = UnevenStoneStair_gray;

    UnevenStoneStair[1] = UnevenStoneStair_blue;

    UnevenStoneStair[2] = UnevenStoneStair_brown;

    UnevenStoneStair[3] = UnevenStoneStair_light;

    UnevenStoneStair[4] = UnevenStoneStair_yellow;

    UnevenStoneStair[5] = UnevenStoneStair_red;

    UnevenStoneStair[6] = UnevenStoneStair_green;}

[/hide]

 

There were no problems at first but when I wanted to make a recipe for it, minecraft crashed.

[hide]

GameRegistry.addRecipe(new ItemStack(NaughtyStoneCraft.UnevenStoneStair[0], 5, 1), new Object[]

                      {

                          "X", "XX", "XXX", 'X', (new ItemStack(NaughtyStoneCraft.UnevenStoneBrick, 1, 0))

                      });                 

[/hide]

 

Here is the crash report:

[hide]

java.lang.NullPointerException

at net.minecraft.src.ItemStack.<init>(ItemStack.java:42)

at grizzly101.common.NaughtyStoneCraft.load(NaughtyStoneCraft.java:203)

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:440)

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:69)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)

at com.google.common.eventbus.EventBus.post(EventBus.java:268)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:140)

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:69)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)

at com.google.common.eventbus.EventBus.post(EventBus.java:268)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:83)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:651)

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:196)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:465)

at net.minecraft.client.Minecraft.run(Minecraft.java:752)

at java.lang.Thread.run(Unknown Source)

[/hide]

 

Thanks in advance to those who would help :)

 

 

Posted

Hello,

I would think so, because an array is just storing objects with the same name using numbers to see the different objects. You wouldn't be able to use it possibly depending on how forge interprets the blocks (I may be wrong)

 

-Green0Yoshi

 

P.S. I can't see your hidden code while typing reply. :(

 

Edit: After post I can, but you should put it into code blocks and spoilers please. Also ignore my original post, I read it wrong and thought you couldn't make block arrays that worked.

 

Edit 2:  PLEASE READ YOUR ERROR REPORT. There is a reason people ask for it. Your problem is simple. NullPointerException. You are pointing towards the ARRAY, not the BLOCK. Put the square brackets and the zero please :). If you do this, you will not point towards the Null, which is pointed at somewhere in the array.

Thanks for your time... Hopefully I can reply soon after you reply, but I'm busy, anyways.

I can't wait to start working on my mod. I haven't worked on it in a while but it is on

Github. It needs much more organization and work, I have lots of plans. :)

Posted

Sorry About the hidden files Green0Yoshi. This is my first post. Thanks for telling me about using spoilers.

 

:)

 

I Thought people used the hide function. :P

 

I realized that I should register my block using my Array block if I going  to use those anyway. That was the cause for the null and now it is working as expected. :D

 

Thanks  :)

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I was trying to find a mod that added something specific, and was unable to find it with what limited memory I had of seeing it. I don't know why there isn't an option to include words in overviews of mods. I could see it being in the sort tab near filters on the app in my opinion. It might help someone trying to find something specific, only based off something from the overview tab, but idk
    • Please read the FAQ and post logs as described there.   Also, do not just add a post onto someone else's thread with your issue, create a new one please.
    • I am creating a server with mods but when i try tostart it it say in the logs:   [29Jan2025 20:36:50.715] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/fmlcore/1.20.1-47.3.27/fmlcore-1.20.1-47.3.27.jar is missing mods.toml file 159[29Jan2025 20:36:50.717] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/javafmllanguage/1.20.1-47.3.27/javafmllanguage-1.20.1-47.3.27.jar 160[29Jan2025 20:36:50.717] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/javafmllanguage/1.20.1-47.3.27/javafmllanguage-1.20.1-47.3.27.jar is missing mods.toml file 161[29Jan2025 20:36:50.718] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/lowcodelanguage/1.20.1-47.3.27/lowcodelanguage-1.20.1-47.3.27.jar 162[29Jan2025 20:36:50.718] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/lowcodelanguage/1.20.1-47.3.27/lowcodelanguage-1.20.1-47.3.27.jar is missing mods.toml file 163[29Jan2025 20:36:50.719] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/mclanguage/1.20.1-47.3.27/mclanguage-1.20.1-47.3.27.jar 164[29Jan2025 20:36:50.719] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/mclanguage/1.20.1-47.3.27/mclanguage-1.20.1-47.3.27.jar is missing mods.toml file
    • How do you configure the entity reach of a custom weapon? Asking for 1.21 Minecraft parchment
  • Topics

×
×
  • Create New...

Important Information

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