From 1cef48a667e13e5902032a072ae15fcab9eef9a2 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 31 Jul 2014 12:35:16 +0200 Subject: [PATCH] Add a config option and logic to penalize part-replacement with an xp-penality --- .../reference/Config.java | 9 +++++++++ .../replacing/ReplacementLogic.java | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java index 90326de..dd98d0f 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java @@ -39,6 +39,10 @@ public class Config { public static int durabilityPercentage; public static int miningSpeedPercentage; + // part replacement + public static int partReplacementXpPenality; + public static int partReplacementBoostXpPenality; + // heads public static int baseHeadDropChance; public static int beheadingHeadDropChance; @@ -72,6 +76,7 @@ public class Config { final String CATEGORY_Leveling = "ToolLeveling"; final String CATEGORY_PickLeveling = "PickLeveling"; final String CATEGORY_HarvestLevels = "HarvestLevelTweaks"; + final String CATEGORY_PartReplacement = "PartReplacement"; final String CATEGORY_Heads = "MobHeads"; final String CATEGORY_Tweaks = "Tweaks"; final String CATEGORY_Debug = "Debug"; @@ -117,6 +122,10 @@ public class Config { durabilityPercentage = configfile.getInt("durabilityPercentage", CATEGORY_HarvestLevels, 80, 1, 999, "Change durability of all tool materials (in percent)"); miningSpeedPercentage = configfile.getInt("miningSpeedPercentage", CATEGORY_HarvestLevels, 100, 1, 999, "Change mining speed of all tool materials (in percent)"); + /** PartReplacement Module **/ + partReplacementXpPenality = configfile.getInt("XpPenality", CATEGORY_PartReplacement, 0, 0, 100, "How much of the current XP% shall be removed when replacing parts (So if you had 50%, and penality is 10% it'll remove 5% xp, resulting in 45%). Does not remove Skill Levels."); + partReplacementBoostXpPenality = configfile.getInt("PickBoostXpPenality", CATEGORY_PartReplacement, 5, 0, 100, "How much of the current XP% to the next mining level shall be removed when replacing parts. Useful to remove the mining level boost on part replacement."); + /** MobHeads **/ // todo: implement configfile.setCategoryComment(CATEGORY_Heads, "Mob Head Module: Adds additional Mob heads and drops"); diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/replacing/ReplacementLogic.java b/src/main/java/iguanaman/iguanatweakstconstruct/replacing/ReplacementLogic.java index 803dd6d..483c293 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/replacing/ReplacementLogic.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/replacing/ReplacementLogic.java @@ -2,6 +2,7 @@ package iguanaman.iguanatweakstconstruct.replacing; import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic; import iguanaman.iguanatweakstconstruct.leveling.modifiers.ModXpAwareRedstone; +import iguanaman.iguanatweakstconstruct.reference.Config; import iguanaman.iguanatweakstconstruct.util.Log; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -158,6 +159,12 @@ public abstract class ReplacementLogic { // apply transition xp *= newRequiredXp / (float) oldRequiredXp; + // xp penality? + if(Config.partReplacementXpPenality > 0) + { + xp *= (100.0f-Config.partReplacementXpPenality)/100.0f; + } + tags.setInteger(LevelingLogic.TAG_EXP, Math.round(xp)); } @@ -172,6 +179,17 @@ public abstract class ReplacementLogic { // apply transition xp *= newRequiredBoostXp / (float) oldRequiredBoostXp; + // xp penality? + if(Config.partReplacementBoostXpPenality > 0) + { + if(LevelingLogic.isBoosted(tags)) { + tags.setBoolean(LevelingLogic.TAG_IS_BOOSTED, false); + xp = newRequiredBoostXp; + } + + xp *= (100.0f-Config.partReplacementBoostXpPenality)/100.0f; + } + tags.setInteger(LevelingLogic.TAG_BOOST_EXP, Math.round(xp)); // already full xp?