Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Implemented Boni's Todo list
Browse files Browse the repository at this point in the history
- Replaced "Multer" with a real word.
- Made a config option (true by default) to only make tool heads count
for XP.
- Fixed some spelling errors.
- Moved the material XP gain to a different part of the function: it
works for weapons now.
  • Loading branch information
talonos2 committed Dec 24, 2014
1 parent 03125b0 commit d68bb9a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
Expand Up @@ -249,7 +249,7 @@ else if (weapon && !(tool.getItem() instanceof Hammer))

base += ((float)baseMiningSpeed + (float)(miningSpeed-baseMiningSpeed)/5f)/divider;

// shovels need a bit more xp because their blocks berak much faster
// shovels need a bit more xp because their blocks break much faster

if(tool.getItem() instanceof Hammer) base *= 5.1f;
if(tool.getItem() instanceof Excavator) base *= 6.2f;
Expand All @@ -258,10 +258,6 @@ else if (weapon && !(tool.getItem() instanceof Hammer))
if(tool.getItem() instanceof Hatchet) base *= 0.66f; // not much wood to chop, but usable as weapon

base *= Config.xpRequiredToolsPercentage / 100f;

float xpMulter = getXPMulter(tool, tags);

base *= xpMulter;
}

if (miningBoost)
Expand All @@ -279,15 +275,29 @@ else if (weapon && !(tool.getItem() instanceof Hammer))
if (level >= 1) base *= Math.pow(Config.xpPerLevelMultiplier, level - 1);
if(tags.hasKey("HarvestLevel") && LevelingLogic.getHarvestLevel(tags) == 0)
base /= Config.xpPerLevelMultiplier * Config.xpPerLevelMultiplier;

//XP Multiplier applies to all tools, but not to "mining boost" XP.
float xpMultiplier = getXPMultiplier(tool, tags);

base *= xpMultiplier;
}

return Math.round(base);
}

private static float getXPMulter(ItemStack tool, NBTTagCompound tags)
private static float getXPMultiplier(ItemStack tool, NBTTagCompound tags)
{
boolean nonHeadsCount = !Config.onlyHeadsChangeXPRequirement;
ToolCore core = (ToolCore) tool.getItem();

boolean extraIsHead = (core instanceof Hammer);

boolean accessoryIsHead = (extraIsHead ||
core instanceof Excavator||
core instanceof Cleaver||
core instanceof LumberAxe||
core instanceof Mattock);

double numberOfParts = 0;
double xpModSoFar = 1;

Expand All @@ -298,29 +308,29 @@ private static float getXPMulter(ItemStack tool, NBTTagCompound tags)
String matName = TConstructRegistry.getMaterial(toolMaterialHead).name();
xpModSoFar *= XPAdjustmentMap.get(matName);
}
if(ReplacementLogic.getPart(core, HANDLE) != null)
if(ReplacementLogic.getPart(core, HANDLE) != null && nonHeadsCount)
{
numberOfParts++;
int toolMaterialHandle = ReplacementLogic.getToolPartMaterial(tags, HANDLE);
String matName = TConstructRegistry.getMaterial(toolMaterialHandle).name();
xpModSoFar *= XPAdjustmentMap.get(matName);
}
if(ReplacementLogic.getPart(core, ACCESSORY) != null)
if(ReplacementLogic.getPart(core, ACCESSORY) != null && (accessoryIsHead || nonHeadsCount))
{
numberOfParts++;
int toolMaterialAccessory = ReplacementLogic.getToolPartMaterial(tags, ACCESSORY);
String matName = TConstructRegistry.getMaterial(toolMaterialAccessory).name();
xpModSoFar *= XPAdjustmentMap.get(matName);
}
if(ReplacementLogic.getPart(core, EXTRA) != null)
if(ReplacementLogic.getPart(core, EXTRA) != null && (extraIsHead || nonHeadsCount))
{
numberOfParts++;
int toolMaterialExtra = ReplacementLogic.getToolPartMaterial(tags, EXTRA);
String matName = TConstructRegistry.getMaterial(toolMaterialExtra).name();
xpModSoFar *= XPAdjustmentMap.get(matName);
}

//Take the arithmatic mean
//Take the geometric mean
return (float)Math.pow(xpModSoFar,1.0/numberOfParts);
}
/**
Expand Down
Expand Up @@ -27,6 +27,7 @@ public class Config {
public static int[] randomBonusesAtlevels;
public static boolean randomBonusesAreUseful;
public static boolean randomBonusesAreRandom;
public static boolean onlyHeadsChangeXPRequirement;

// random bonuses deactivation
public static Set<RandomBonuses.Modifier> deactivatedModifiers = new HashSet<RandomBonuses.Modifier>();
Expand Down Expand Up @@ -120,6 +121,7 @@ public void sync()
xpRequiredToolsPercentage = configfile.getInt("xpRequiredToolsPercentage", CATEGORY_Leveling, 100, 1, 999, "Change the XP required to level up tools in % (higher = more xp needed)");
xpRequiredWeaponsPercentage = configfile.getInt("xpRequiredWeaponsPercentage", CATEGORY_Leveling, 100, 1, 999, "Change the XP required to level up weapons in % (higher = more xp needed)");
xpPerLevelMultiplier = configfile.getFloat("xpPerLevelMultiplier", CATEGORY_Leveling, 1.15f, 1.0f, 9.99f, "Exponential multiplier for required xp per level");
onlyHeadsChangeXPRequirement = configfile.getBoolean("onlyHeadsChangeXPRequirement", CATEGORY_Leveling, true, "If true, only the heads of tools are examined when determining how much XP it takes to level up. (This only matters if you manually specify that some material types level faster than others using the override module)");

// tooltip things
showTooltipXP = configfile.getBoolean("showTooltipXP", CATEGORY_Leveling, true, "Current XP is shown when hovering over a tool");
Expand Down Expand Up @@ -318,4 +320,5 @@ public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
"appliedenergistics2",
"MekanismTool"
};

}

0 comments on commit d68bb9a

Please sign in to comment.