Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Map;

import net.tfminecraft.advancedcrafting.objects.data.PermissionNamespace;
import net.tfminecraft.advancedcrafting.objects.ingredients.Ingredient;
import net.tfminecraft.advancedcrafting.objects.ingredients.IngredientType;

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

public static String brandingTool;

Expand All @@ -42,4 +45,9 @@ public static boolean canCombine(IngredientType base, IngredientType type){
if(!combinations.containsKey(base)) return true;
return combinations.get(base).contains(type);
}

public static double getAlloyForgeBaseBonus(Ingredient base) {
if(base == null) return 0.0;
return alloyForgeBaseBonus.getOrDefault(base.getId().toLowerCase(), 0.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public void load(File configFile) {
if (Cache.alloyForgeMaxSuccess < Cache.alloyForgeBaseSuccess) {
Cache.alloyForgeMaxSuccess = Cache.alloyForgeBaseSuccess;
}
Cache.alloyForgeBaseBonus.clear();
if (config.isConfigurationSection("alloy-forge.base-bonus-percent")) {
for (String ingredientId : config.getConfigurationSection("alloy-forge.base-bonus-percent").getKeys(false)) {
double bonus = clampPercent(config.getDouble("alloy-forge.base-bonus-percent." + ingredientId, 0.0));
if (bonus > 0.0) {
Cache.alloyForgeBaseBonus.put(ingredientId.toLowerCase(), bonus);
}
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public String getXP() {
private boolean isScrap() {
double chance = Math.min(
Cache.alloyForgeMaxSuccess,
Cache.alloyForgeBaseSuccess + Cache.alloyForgeBonusPerSqrtValue * Math.sqrt(value));
Cache.alloyForgeBaseSuccess + Cache.alloyForgeBonusPerSqrtValue * Math.sqrt(value)
+ Cache.getAlloyForgeBaseBonus(station.getBaseItem()));
return ThreadLocalRandom.current().nextDouble(100.0) >= chance;
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ crafting-station: v(ANVIL)
alloy-station: iaf(tfmc:alloy_forge)
ingredient-station: iaf(tfmc:ingredient_converter)

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

max-factor: 1.2

Expand Down