Jump to content

[1.9.4] [SOLVED] Block not registering. Mentions hash code?


swordkorn

Recommended Posts

Hey guys. I'm currently working on an update of my mod to 1.9.4 and I'm trying to optimise my code a little. However; my registry fails and I get this crash log:

 

[13:44:03] [Client thread/ERROR] [FML]: Caught exception from mysticalcrops
java.lang.NullPointerException
at com.mysticalcrops.blocks.MysticalCropBlock.hashCode(MysticalCropBlock.java:191) ~[bin/:?]
at com.google.common.collect.HashBiMap.hash(HashBiMap.java:173) ~[guava-17.0.jar:?]
at com.google.common.collect.HashBiMap.access$300(HashBiMap.java:52) ~[guava-17.0.jar:?]
at com.google.common.collect.HashBiMap$Inverse.get(HashBiMap.java:508) ~[guava-17.0.jar:?]
at net.minecraft.util.registry.RegistryNamespaced.getNameForObject(RegistryNamespaced.java:44) ~[forgeSrc-1.9.4-12.17.0.1960.jar:?]
at net.minecraft.util.registry.RegistryNamespacedDefaultedByKey.getNameForObjectBypass(RegistryNamespacedDefaultedByKey.java:84) ~[forgeSrc-1.9.4-12.17.0.1960.jar:?]
at net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.getNameForObject(FMLControlledNamespacedRegistry.java:777) ~[forgeSrc-1.9.4-12.17.0.1960.jar:?]
at net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.getNameForObject(FMLControlledNamespacedRegistry.java:35) ~[forgeSrc-1.9.4-12.17.0.1960.jar:?]
at net.minecraft.block.state.BlockStateContainer.toString(BlockStateContainer.java:157) ~[forgeSrc-1.9.4-12.17.0.1960.jar:?]

 

Any help would be appreciated!

Link to comment
Share on other sites

Each Minecraft registry is backed by a

HashBiMap

, which uses

Object#hashCode

to hash its keys and values. Your override of this in

MysticalCropBlock

is throwing a

NullPointerException

.

 

To help you more, we'd need to see your code.

 

Why are you overriding this anyway? I can't think of any reason for two instances of

Block

to be considered the same value.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Hi Choonster and thank you for the reply.

 

This is where I create the HashMap I believe:

public class CropItems {
    public static Item[] MCSeeds;

    public static HashMap<MysticalCropBlock, Item> seedsMap = new HashMap<MysticalCropBlock, Item>();
    public static HashMap<MysticalCropBlock, Item> havestedItemMap = new HashMap<MysticalCropBlock, Item>();

And this is where I call on it:

    @Override
    public int hashCode() {
        return regName.hashCode();
    }

Link to comment
Share on other sites

That's not the issue here. The issue is in the override of the

Object#hashCode

method in

MysticalCropBlock

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.