Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.)

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.

  • 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);
			}
	}

}

 

  • 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.

  • 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.

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 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.