Jump to content

Is it possible to use Arrays for new blocks


Grizzly101

Recommended Posts

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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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