Skip to content

Commit

Permalink
Implement TCon damage cutoff tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jchung01 committed Dec 22, 2023
1 parent f689f2b commit f50f67e
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,61 @@ public static class TinkersConstructCategory
@Config.Name("Duplication Fixes")
@Config.Comment("Fixes various duplication exploits")
public boolean utDuplicationFixesToggle = true;

@Config.RequiresMcRestart
@Config.Name("Tool Customization")
@Config.Comment("Enables usage of tweaks in below category to customize Tinkers' tools stats")
public boolean utTConToolCustomizationToggle = true;

@Config.LangKey("cfg.universaltweaks.modintegration.tcon.toolcustomization")
@Config.Name("Tool Customization")
public final TinkersConstructCategory.ToolCustomizationCategory TOOL_CUSTOMIZATION = new TinkersConstructCategory.ToolCustomizationCategory();

public static class ToolCustomizationCategory
{
@Config.Name("General Attack Damage Cutoff")
@Config.Comment
({
"Sets the attack damage cutoff at which diminishing returns start for any Tinkers' tool not listed here",
"Default value: 15.0"
})
public float utTConToolGeneralDamageCutoff = 15.0f;

@Config.Name("Cleaver Attack Damage Cutoff")
@Config.Comment
({
"Sets the attack damage cutoff at which diminishing returns start for the cleaver",
"Default value: 25.0"
})
public float utTConToolCleaverDamageCutoff = 25.0f;

@Config.Name("Longsword Attack Damage Cutoff")
@Config.Comment
({
"Sets the attack damage cutoff at which diminishing returns start for the longsword",
"Default value: 18.0"
})
public float utTConToolLongswordDamageCutoff = 18.0f;

@Config.Name("Rapier Attack Damage Cutoff")
@Config.Comment
({
"Sets the attack damage cutoff at which diminishing returns start for the rapier",
"Default value: 13.0"
})
public float utTConToolRapierDamageCutoff = 13.0f;

@Config.Name("Attack Damage Decay Rate")
@Config.Comment
({
"Sets the rate at which a tool's attack damage incrementally decays depending on its damage cutoff",
"Default value: 0.9",
"Range: 0.0 - 1.0",
"Note: A rate of 1.0 means there is no damage decay",
"Note: The damage curve will cap the maximum value to (tool's damage cutoff)/(1 - decay rate)"
})
public String utTConToolDamageDecayRate = "0.9";
}
}

public static class TinyProgressionsCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public List<String> getMixinConfigs()
"mixins.mods.spiceoflife.dupes.json",
"mixins.mods.storagedrawers.client.json",
"mixins.mods.tconstruct.json",
"mixins.mods.tconstruct.toolcustomization.json",
"mixins.mods.tconstruct.oredictcache.json",
"mixins.mods.techreborn.json",
"mixins.mods.thaumcraft.dupes.json",
Expand Down Expand Up @@ -189,6 +190,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return Loader.isModLoaded("thermalexpansion") && UTConfigMods.THERMAL_EXPANSION.utDuplicationFixesToggle;
case "mixins.mods.tconstruct.json":
return Loader.isModLoaded("tconstruct");
case "mixins.mods.tconstruct.toolcustomization.json":
return Loader.isModLoaded("tconstruct") && UTConfigMods.TINKERS_CONSTRUCT.utTConToolCustomizationToggle;
case "mixins.mods.tconstruct.oredictcache.json":
return Loader.isModLoaded("tconstruct") && UTConfigMods.TINKERS_CONSTRUCT.utTConOreDictCacheToggle;
case "mixins.mods.tinyprogressions.dupes.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mod.acgaming.universaltweaks.mods.tconstruct.toolcustomization.mixin;

import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import slimeknights.tconstruct.tools.melee.item.Cleaver;

@Mixin(value = Cleaver.class, remap = false)
public class UTCleaverMixin
{
@Inject(method = "damageCutoff", at = @At(value = "RETURN"), cancellable = true)
private void utModifyDamageCutoff(CallbackInfoReturnable<Float> cir)
{
cir.setReturnValue(UTConfigMods.TINKERS_CONSTRUCT.TOOL_CUSTOMIZATION.utTConToolCleaverDamageCutoff);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mod.acgaming.universaltweaks.mods.tconstruct.toolcustomization.mixin;

import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import slimeknights.tconstruct.tools.melee.item.LongSword;

@Mixin(value = LongSword.class, remap = false)
public class UTLongswordMixin
{
@Inject(method = "damageCutoff", at = @At(value = "RETURN"), cancellable = true)
private void utModifyDamageCutoff(CallbackInfoReturnable<Float> cir)
{
cir.setReturnValue(UTConfigMods.TINKERS_CONSTRUCT.TOOL_CUSTOMIZATION.utTConToolLongswordDamageCutoff);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mod.acgaming.universaltweaks.mods.tconstruct.toolcustomization.mixin;

import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import slimeknights.tconstruct.tools.melee.item.Rapier;

@Mixin(value = Rapier.class, remap = false)
public class UTRapierMixin
{
@Inject(method = "damageCutoff", at = @At(value = "RETURN"), cancellable = true)
private void utModifyDamageCutoff(CallbackInfoReturnable<Float> cir)
{
cir.setReturnValue(UTConfigMods.TINKERS_CONSTRUCT.TOOL_CUSTOMIZATION.utTConToolRapierDamageCutoff);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mod.acgaming.universaltweaks.mods.tconstruct.toolcustomization.mixin;

import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import slimeknights.tconstruct.library.tools.ToolCore;

@Mixin(value = ToolCore.class, remap = false)
public class UTToolCoreMixin
{
@Inject(method = "damageCutoff", at = @At(value = "RETURN"), cancellable = true)
private void utModifyDamageCutoff(CallbackInfoReturnable<Float> cir)
{
cir.setReturnValue(UTConfigMods.TINKERS_CONSTRUCT.TOOL_CUSTOMIZATION.utTConToolGeneralDamageCutoff);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package mod.acgaming.universaltweaks.mods.tconstruct.toolcustomization.mixin;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import slimeknights.tconstruct.library.utils.ToolHelper;

@Mixin(value = ToolHelper.class, remap = false)
public class UTToolHelperMixin
{
@ModifyConstant(method = "calcCutoffDamage", constant = @Constant(floatValue = 0.9f))
private static float utModifyDecayRate(float original)
{
try
{
float newDecayRate = Float.parseFloat(UTConfigMods.TINKERS_CONSTRUCT.TOOL_CUSTOMIZATION.utTConToolDamageDecayRate);
if (newDecayRate < 0.0f || newDecayRate > 1.0f)
{
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.info("UTToolHelperMixin ::: Config's 'Attack Damage Decay Rate' is not in the valid range, must be a value from 0.0 to 1.0. Falling back to default value.");
return original;
}
return newDecayRate;
}
catch (NumberFormatException e)
{
UniversalTweaks.LOGGER.error("UTToolHelperMixin ::: Could not parse a float from config's 'Attack Damage Decay Rate', must be a value from 0.0 to 1.0. Falling back to default value.");
return original;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.tconstruct.toolcustomization.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTCleaverMixin", "UTLongswordMixin", "UTRapierMixin", "UTToolCoreMixin", "UTToolHelperMixin"]
}

0 comments on commit f50f67e

Please sign in to comment.