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

Hi all,

 

I am trying to make my first mod that uses swords with dynamic damage values. The formula for that works but I don't know how to give the damage value to the sword?

I already searched for anwsers but only found a few.

 

Here are my codes

sword code

 

 

package starglas.dsremake.common.items.swords;

 

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.ItemSword;

import starglas.dsremake.common.WeaponScaling;

 

public class Longsword extends ItemSword{

 

 

public static int upgradeLevel = 1;

public static float attackDMG;

public Longsword(int ID, EnumToolMaterial par2EnumToolMaterial, String Texture) {

super(ID, par2EnumToolMaterial);

this.setTextureName(Texture);

}

 

}

 

 

 

This is the material code

 

 

public static EnumToolMaterial DSRemake = EnumHelper.addToolMaterial("DSRemake", 0, 1000, -40.0F, 0, 0);

 

 

 

And the code with the formula

 

 

package starglas.dsremake.common;

 

public class WeaponScaling {

public static float totalAR;

private static float strScaling;

private static float dexScaling;

 

public static float WeaponScalingRaw(int weaponDamage, int strengthScaling, int dextScaling, int playerStrength, int playerDex){

switch(strengthScaling){

case 6:

strScaling = 0.3F;

break;

case 5:

strScaling = 0.7F;

break;

case 4:

strScaling = 1.1F;

break;

case 3:

strScaling = 1.5F;

break;

case 2:

strScaling = 1.9F;

break;

case 1:

strScaling = 2.5F;

break;

default:

strScaling = 0.0F;

break;

}

switch(dextScaling){

case 6:

dexScaling = 0.3F;

break;

case 5:

dexScaling = 0.7F;

break;

case 4:

dexScaling = 1.1F;

break;

case 3:

dexScaling = 1.5F;

break;

case 2:

dexScaling = 1.9F;

break;

case 1:

dexScaling = 2.5F;

break;

default:

dexScaling = 0.0F;

break;

}

if(strScaling != 0.0F && dexScaling !=0.0F){

totalAR = (float) Math.ceil( weaponDamage + (weaponDamage * ((strScaling * playerStrength)+(dexScaling * playerDex)/100)) );

}

if(strScaling != 0 && dexScaling == 0.0F){

totalAR = (float) Math.ceil( weaponDamage + (weaponDamage * ((strScaling * playerStrength)/100)) );

}

if(dexScaling != 0 && strScaling == 0.0F){

totalAR = (float) Math.ceil( weaponDamage + (weaponDamage * ((dexScaling * playerDex)/100)) );

}

return totalAR;

}

}

 

 

 

How can I change the damage of the sword that is being generated.

 

I'm quite sure you can set an int to be the damage then set it as your tool material:

 

int swordDamage = YourFormula;

public static EnumToolMaterial DSRemake = EnumHelper.addToolMaterial("DSRemake", 0, 1000, swordDamge, 0, 0);

 

Also, I suggest at least updating to 1.7 ESPECIALLY for your first mod. Considering 1.6 is no longer supported by forge and, the way everything is made has changed in 1.7; you'll be very confused when switching to 1.7. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

  • Author

I'm quite sure you can set an int to be the damage then set it as your tool material:

 

int swordDamage = YourFormula;

public static EnumToolMaterial DSRemake = EnumHelper.addToolMaterial("DSRemake", 0, 1000, swordDamge, 0, 0);

 

Also, I suggest at least updating to 1.7 ESPECIALLY for your first mod. Considering 1.6 is no longer supported by forge and, the way everything is made has changed in 1.7; you'll be very confused when switching to 1.7. :P

 

Well I kinda tested with the ItemSword code and now it works. I also looked to update to 1.7.10. The reason that I made it for 1.6.4 is because of a mod that my friend and I wanted to use and wasn't updated the last time we checked. I also forgot to say that this is one of the many swords that are gonna be made all with different damage values.

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.