Posted November 20, 20177 yr So, I'd like to set my custom weapons to do a random amount of damage between X and Y. What should I do with the original code in order to make this work? By default, the code only seems to accept a fixed value of damage. public static final ToolMaterial WEAPON_DRAGON = EnumHelper.addToolMaterial("weapon_dragon", 8, -1, 3.0F, 5.0F, 0); (Also, not entirely necessary, but I'm still trying to get into all this coding business, so if you wouldn't mind explaining what your code suggestion does, it would help me a lot.)
November 20, 20177 yr Well...you'd need a custom sword class, you can't do this with just the tool material enum. 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.
November 20, 20177 yr Author I tried that, but I think I made a mistake with the code somewhere. package orescape.mod.objects.tools; import net.minecraft.item.Item; import net.minecraft.item.ItemSword; public class DragonLong extends ItemSword { public DragonLong(Item.ToolMaterial material) { super(material); @Override this.attackDamage = randomWithRange(1, 20); { float range = Math.abs(max - min) + 1; return (float)(Math.random() * range) + (min <= max ? min : max); } } }
November 20, 20177 yr Author Any tips on where to do that? I'm not really looking to spend a year+ just to learn something that someone else could easily do or help me with.
November 20, 20177 yr Author I didn't say I wasn't willing to learn, but I've yet to find a guide that's specific in the stuff I actually want to learn, I guess. Or I have no idea what I'm talking about. But if you've got any resources I could look at, that would be really helpful.
November 22, 20177 yr The reason we're saying to learn Java is that you literally wrote nonsense. You need more help than telling you how to change the damage, you need to learn where to put the @Override and braces and how to invoke a method from another class. I personally recommend learning Java from a book because video tutorials will tempt you to skip the important basics like the fundamental structure of the code blocks. But you don't need a big "Java for Dummies" book. Instead I recommend "Java In Easy Steps" https://www.amazon.com/Java-easy-steps-Covers/dp/1840787538 That book is very inexpensive, is not very thick, and gets to all the important parts quickly without being overly boring. Edited November 22, 20177 yr by jabelar Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.