Posted April 28, 20205 yr So basically i was creating some custom tools.Having been upgraded from 1.12.2 to 1.15.2;I can't really understand how to create your own tool material ,after some figuring out I got to know that it it IItemTier class that will create new tool material,but i cant really understand how that works,i also cannot find any hood tutorials or info on forge Documentation.Any help would be appreciated..
April 28, 20205 yr You need to create your own class (preferably enum, it’ll be easier) and let it implement IItemTier as an interface. You’ll need to override all the methods of IItemTier in your new class - look at what the vanilla one does, and just replicate its functionality. Then you can just use your MyModItemTier.SOME_MATERIAL in the constructor of your new tool Items.
April 28, 20205 yr Note that if you are just looking to create one IItemTier implementation then there is no point in using an enum. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
April 28, 20205 yr Author On 4/28/2020 at 12:08 PM, Fluorescent Flamingo said: You need to create your own class So isn't there any functionality like Enumhelper that would reduce the code. On 4/28/2020 at 12:21 PM, DavidM said: Note that if you are just looking to create one IItemTier implementation then there is no point in using an enum. So what should i do?
April 28, 20205 yr 19 minutes ago, Harry12OK said: So what should i do? Just pass an instance of IItemTier to your item. Edited April 28, 20205 yr by DavidM Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
April 28, 20205 yr Author On 4/28/2020 at 12:49 PM, DavidM said: Just pass an instance of IItemTier to your item. But IItemTier is an interface.It isn't a class.How am i supposed to pass an instance of it.I could only implement it. Sorry if i asked some foolish thing,i just have knowledge of basic core java. Edited April 28, 20205 yr by Harry12OK
April 28, 20205 yr 2 minutes ago, Harry12OK said: But IItemTier is an interface.It isn't a class.How am i supposed to pass an instance of it.I could only implement it. Sorry if i asked some foolish thing,i just have knowledge of basic core java. Basically the item tier is what used to be tool material in older versions. You create a class that implents IItemTier and then you pass that class to your item. (In simple words you "just copy" the vanilla ItemTier class and replace the values.)
April 28, 20205 yr 18 hours ago, Harry12OK said: But IItemTier is an interface.It isn't a class.How am i supposed to pass an instance of it.I could only implement it. Sorry if i asked some foolish thing,i just have knowledge of basic core java. An instance of a class implementing IItemTier is also an instance of IItemTier. In terms of class hierarchy as OOP concept, class and interface are treated the same way. Phrases such as “instance of” and “superclass of” apply to both classes and interfaces. Edited April 29, 20205 yr by DavidM Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
April 28, 20205 yr Have an example usage https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/item/ModItemTier.java Just be aware that the suppliers are absolutely required. 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.
April 28, 20205 yr Author thank You guys. I figured out and create my material. Bascially what i did was created a new class for my new material and implemented IItemTier and then did like the vanilla code. here is my code ===> public enum ToolMaterial implements IItemTier{ RUBY(3, 1000, 5.0f, 9.0f, 10, () -> { return Ingredient.fromItems(ModItems.RUBY.get()); }); private final int A; private final int B; private final float C; private final float D; private final int E; private final LazyValue<Ingredient> f; private ToolMaterial(int i, int j, float f, float g, int k, Supplier<Ingredient> object) { this.A = i; this.B = j; this.C = f; this.D = g; this.E = k; this.f = new LazyValue<>(object); } @Override public int getMaxUses() { return this.B; } @Override public float getEfficiency() { return this.C; } @Override public float getAttackDamage() { return this.D; } @Override public int getHarvestLevel() { return this.A; } @Override public int getEnchantability() { return this.E; } @Override public Ingredient getRepairMaterial() { return this.f.getValue(); } } Edited April 28, 20205 yr by Harry12OK
April 28, 20205 yr Author 11 minutes ago, diesieben07 said: Oh god why. Use proper variable names. I will fix it .Actually my brain was cooked up. I did it for testing because i thought it would not work. and i mistakenly reported your comment by seeing report post as reply to this post..
April 29, 20205 yr 3 minutes ago, Harry12OK said: Do i have right to close this topic? Threads on these forums don't close after the problem has been solved. Instead, you can prepend "[Solved]" to the title of this thread to notify other people that this problem has been solved. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
April 29, 20205 yr Author On 4/29/2020 at 9:50 AM, DavidM said: Threads on these forums don't close after the problem has been solved. Thank you.
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.