Skip to content

Commit 2efc4f0

Browse files
XxFran10xXclaude
andauthored
feat: add per-base success bonus to the alloy forge scrap roll (#23)
Higher-tier base ingots now lower the scrap chance of a new alloy discovery through a flat, configurable bonus (alloy-forge.base-bonus-percent). It only applies to the base, so ingots used as catalysts gain nothing, and it does not touch ingredient values, which also drive stat rolls, revisions and Thievery totals. Co-authored-by: XxFran10xX <318299142+XxFran10xX@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 0b781d0 commit 2efc4f0

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎src/main/java/net/tfminecraft/advancedcrafting/cache/Cache.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Map;
66

77
import net.tfminecraft.advancedcrafting.objects.data.PermissionNamespace;
8+
import net.tfminecraft.advancedcrafting.objects.ingredients.Ingredient;
89
import net.tfminecraft.advancedcrafting.objects.ingredients.IngredientType;
910

1011
public class Cache {
@@ -17,6 +18,8 @@ public class Cache {
1718
public static double alloyForgeBaseSuccess = 2.0;
1819
public static double alloyForgeBonusPerSqrtValue = 4.0;
1920
public static double alloyForgeMaxSuccess = 85.0;
21+
/** Flat success% added when the ingredient (lowercase id) is the alloy base. Catalysts never get it. */
22+
public static Map<String, Double> alloyForgeBaseBonus = new HashMap<>();
2023

2124
public static String brandingTool;
2225

@@ -42,4 +45,9 @@ public static boolean canCombine(IngredientType base, IngredientType type){
4245
if(!combinations.containsKey(base)) return true;
4346
return combinations.get(base).contains(type);
4447
}
48+
49+
public static double getAlloyForgeBaseBonus(Ingredient base) {
50+
if(base == null) return 0.0;
51+
return alloyForgeBaseBonus.getOrDefault(base.getId().toLowerCase(), 0.0);
52+
}
4553
}

‎src/main/java/net/tfminecraft/advancedcrafting/loaders/ConfigLoader.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ public void load(File configFile) {
4040
if (Cache.alloyForgeMaxSuccess < Cache.alloyForgeBaseSuccess) {
4141
Cache.alloyForgeMaxSuccess = Cache.alloyForgeBaseSuccess;
4242
}
43+
Cache.alloyForgeBaseBonus.clear();
44+
if (config.isConfigurationSection("alloy-forge.base-bonus-percent")) {
45+
for (String ingredientId : config.getConfigurationSection("alloy-forge.base-bonus-percent").getKeys(false)) {
46+
double bonus = clampPercent(config.getDouble("alloy-forge.base-bonus-percent." + ingredientId, 0.0));
47+
if (bonus > 0.0) {
48+
Cache.alloyForgeBaseBonus.put(ingredientId.toLowerCase(), bonus);
49+
}
50+
}
51+
}
4352

4453
Cache.brandingTool = config.getString("branding-tool", null);
4554

‎src/main/java/net/tfminecraft/advancedcrafting/objects/alloys/AlloyForger.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ public String getXP() {
132132
private boolean isScrap() {
133133
double chance = Math.min(
134134
Cache.alloyForgeMaxSuccess,
135-
Cache.alloyForgeBaseSuccess + Cache.alloyForgeBonusPerSqrtValue * Math.sqrt(value));
135+
Cache.alloyForgeBaseSuccess + Cache.alloyForgeBonusPerSqrtValue * Math.sqrt(value)
136+
+ Cache.getAlloyForgeBaseBonus(station.getBaseItem()));
136137
return ThreadLocalRandom.current().nextDouble(100.0) >= chance;
137138
}
138139

‎src/main/resources/config.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ crafting-station: v(ANVIL)
66
alloy-station: iaf(tfmc:alloy_forge)
77
ingredient-station: iaf(tfmc:ingredient_converter)
88

9-
# New alloy discovery roll: success% = min(max, base + sqrt(totalValue) * bonus). totalValue = sum of ingredient value fields (base + catalysts).
9+
# New alloy discovery roll: success% = min(max, base + sqrt(totalValue) * bonus + base-bonus). totalValue = sum of ingredient value fields (base + catalysts).
1010
alloy-forge:
1111
base-success-percent: 2.0
1212
success-bonus-per-sqrt-value: 4.0
1313
max-success-percent: 85.0
14+
# Flat success% added when this ingredient is the base. Catalysts never get it; unlisted ingredients get 0.
15+
base-bonus-percent:
16+
steel_ingot: 10.0
17+
bronze_ingot: 15.0
18+
abyssalite_ingot: 20.0
19+
mythril_ingot: 25.0
1420

1521
max-factor: 1.2
1622

0 commit comments

Comments
 (0)