Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

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.

  • Author

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();
    }

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.

  • Author

I'm trying to create a universal block class that I can call for multiple plant block types.

 

Previously I had multiple classes and it was a total mess, so I'm trying to optimise it all down into one class.

  • Author

Removed that and got a new problem. But this issue is solved so I'll mark it as so and make a new thread if necessary. Thanks guys!

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.