wehttam664 Posted May 2, 2016 Posted May 2, 2016 Now, I'm not really sure why, but for some reason PropertyEnum.create(String, Class<T>) is returning null. This is what I have: final PropertyEnum<FrameType> frameTypeProperty = PropertyEnum.create("type", FrameType.class); // ... @Override protected BlockStateContainer createBlockState() { System.out.println(frameTypeProperty); return new BlockStateContainer(this, frameTypeProperty); } The console has null printed to it then the game crashes on an NPE in BlockStateContainer:99. Why is it null? Quote
wehttam664 Posted May 2, 2016 Author Posted May 2, 2016 Upon playing around a bit, I found that PropertyEnum.create(String, Class<T>) will work fine when called inside createBlockState() or in a static context, but not in object context. Basically: final static PropertyEnum<FrameType> frameTypeProperty = PropertyEnum.create("type", FrameType.class); // Works final PropertyEnum<FrameType> frameTypeProperty = PropertyEnum.create("type", FrameType.class); // Doesn't work. Any thoughts, or should I go bug report this? Quote
coolAlias Posted May 2, 2016 Posted May 2, 2016 You should be declaring your Block properties as static - that's how every vanilla class does it, as well as every non-vanilla example that I have seen. Why it works that way, I couldn't tell you, but that's how it is so I wouldn't sweat it. Quote http://i.imgur.com/NdrFdld.png[/img]
Draco18s Posted May 2, 2016 Posted May 2, 2016 And this, kids, is why you don't define your variables where they're declared and use the constructor method for what it's for. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
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.