MSpace-Dev Posted November 17, 2017 Posted November 17, 2017 (edited) Hey everyone, So.. I have always wondered why, when you want to set something like, say, an item's rarity. You'd use the method getRarity() to SET the rarity of that item. Why are these methods named like this? Is it because when the code compiles, the code that puts it all together looks through everything and GETS the values from these methods, and that's why you override these GET methods? Just been a little curious about this. I did also notice a little inconsistency though. Like when you want to set a block's light level, the method you override is called setLightLevel()... are there any rules to know when to use the GET method to set something and the SET method to set something? Edited November 17, 2017 by MSpace-Dev Quote
MSpace-Dev Posted November 17, 2017 Author Posted November 17, 2017 Alright, then can you explain to me what calls GetRarity()? Cause everything you've said there I've already said above, but thanks for clarification on that part. Just need to know the missing piece of the puzzle, which is, what is calling these methods? Quote
MSpace-Dev Posted November 17, 2017 Author Posted November 17, 2017 I have tried to look, but I just get into a loop of going back and forth. I cannot find any other classes that use the method getRarity so, I cannot figure out what calls these methods, hence why I came here to ask the question. "Use your IDE." isn't super helpful. But I understand that you're trying to get people to figure things out for themselves, just... in this case, I never found what I was looking for. I also did find something called IForgeRegistryEntry so yeah... Quote
MSpace-Dev Posted November 17, 2017 Author Posted November 17, 2017 First off, I manage to find the super method public EnumRarity getRarity(ItemStack stack) { return stack.isItemEnchanted() ? EnumRarity.RARE : EnumRarity.COMMON; } Where do I go from there? (I'm ctrl+clicking things, btw) and I use IntelliJ IDE When I ctrl+click getRarity, it just takes me back to where I've overridden it, and not to where it gets called elsewhere, cause there is no 'elsewhere' Look at this picture: Quote
MSpace-Dev Posted November 17, 2017 Author Posted November 17, 2017 Look at the picture, that's exactly what I did. I clicked on Find Usages (Pressing Alt+F7) and that picture shows the results. A result of it only being used in my class. And when I say that I've found the super method, that method is the super method from MY derived class. What I'm saying is that I managed to get to the class where getRarity is declared. This takes me to the Item class where it's declared. Quote
MSpace-Dev Posted November 17, 2017 Author Posted November 17, 2017 Never realized I was in Project Files. Anyways, I have found it being decalred in ItemStack, and other classes. Except these aren't overriding anything, they're declaring new methods of it? I can't find what actually "calls" it. Perhaps if you tell me the answer, I'll be able to understand what's happening here better. Quote
Draco18s Posted November 17, 2017 Posted November 17, 2017 29 minutes ago, MSpace-Dev said: Never realized I was in Project Files. Anyways, I have found it being decalred in ItemStack, and other classes. Except these aren't overriding anything, they're declaring new methods of it? I can't find what actually "calls" it. Perhaps if you tell me the answer, I'll be able to understand what's happening here better. Sounds like you searched for references writing the hierarchy, rather than everywhere. 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.
MSpace-Dev Posted November 17, 2017 Author Posted November 17, 2017 Oh, I understand now. Yeah. I thought Item extended ItemStack or viceversa, which is why I was expecting to find an @Override above one of the methods. Yeah, this makes perfect sense. Quote
Draco18s Posted November 17, 2017 Posted November 17, 2017 30 minutes ago, MSpace-Dev said: Oh, I understand now. Yeah. I thought Item extended ItemStack or viceversa, That would never make sense. 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.
MSpace-Dev Posted November 17, 2017 Author Posted November 17, 2017 1 minute ago, Draco18s said: That would never make sense. I'm still grasping what each of these things do. Give me a break. Thanks for the help though guys! Quote
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.