Posted June 18, 20169 yr 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!
June 18, 20169 yr 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.
June 18, 20169 yr 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(); }
June 18, 20169 yr 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.
June 18, 20169 yr 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.
June 18, 20169 yr Author http://pastebin.com/ExBf80RQ That's the entirety of my class EDIT: Are you saying diesieben that I don't need to be overriding that method?
June 18, 20169 yr 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.