Skip to content
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" //21
compileOnly(fg.deobf("curse.maven:quarkoddities-301051:3575623"))
compileOnly(fg.deobf("curse.maven:quark-243121:3919164"))
compileOnly(fg.deobf("curse.maven:kintsugi-908206:5229196"))
implementation(fg.deobf("curse.maven:cupboard-326652:4669193"))
annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
}
Expand Down
116 changes: 80 additions & 36 deletions src/main/java/com/cursery/config/CommonConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@

public class CommonConfiguration implements ICommonConfig
{
public List<String> excludedCurses = new ArrayList<>();
public boolean excludeTreasure = false;
public boolean debugTries = false;
public boolean showDesc = true;

public List<String> excludedCurses = new ArrayList<>();
public boolean excludeTreasure = false;

public boolean onlyUnEnchanted = false;
public boolean visualSuccess = true;
public boolean onlynotechanted = false;
public int basecursechance = 5;

public boolean curseChanceScales = true;
public int baseCurseChance = 5;
public int maxCurseChance = 75;

public int curseEveryXLevels = 0;


public CommonConfiguration()
{
Expand All @@ -35,59 +43,81 @@ public JsonObject serialize()
{
final JsonObject root = new JsonObject();

final JsonObject entry = new JsonObject();
entry.addProperty("desc:", "Should enchanted books show a hint for curse magic, default:true");
entry.addProperty("showDesc", showDesc);
root.add("showDesc", entry);
final JsonObject entry0 = new JsonObject();
entry0.addProperty("desc:", "Whether to log debug messages about curse chances being rolled. Default: false");
entry0.addProperty("debugTries", debugTries);
root.add("debugTries", entry0);

final JsonObject entry1 = new JsonObject();
entry1.addProperty("desc:", "Add a curse id here to exclude it from beeing applied. "
+ "To put multiple values seperate them by commas like this: [\"minecraft:curse\", \"mod:curse;\"] ");
entry1.addProperty("desc:", "Should enchanted books show a hint for curse magic. Default: true");
entry1.addProperty("showDesc", showDesc);
root.add("showDesc", entry1);

final JsonObject entry2 = new JsonObject();
entry2.addProperty("desc:", "Add a curse id here to exclude it from being applied. "
+ "To put multiple values separate them by commas like this: [\"minecraft:curse\", \"mod:curse;\"] ");
final JsonArray list1 = new JsonArray();
for (final String name : excludedCurses)
{
list1.add(name);
}
entry1.add("excludedCurses", list1);
root.add("excludedCurses", entry1);

final JsonObject entry2 = new JsonObject();
entry2.addProperty("desc:", "Should applying treasure enchants be excluded, default:false");
entry2.addProperty("excludeTreasure", excludeTreasure);
root.add("excludeTreasure", entry2);

final JsonObject entry7 = new JsonObject();
entry7.addProperty("desc:", "Should curses only be applied on enchanting unenchanted items, recommended to increase base chance when enabling, default:false");
entry7.addProperty("onlynotechanted", onlynotechanted);
root.add("onlynotechanted", entry7);
entry2.add("excludedCurses", list1);
root.add("excludedCurses", entry2);

final JsonObject entry3 = new JsonObject();
entry3.addProperty("desc:", "Base curse application chance, scales up the more enchants the item has. Default:5 %");
entry3.addProperty("basecursechance", basecursechance);
root.add("basecursechance", entry3);
entry3.addProperty("desc:", "Should applying treasure enchants be excluded. Default: false");
entry3.addProperty("excludeTreasure", excludeTreasure);
root.add("excludeTreasure", entry3);

final JsonObject entry4 = new JsonObject();
entry4.addProperty("desc:", "Whether to log debug messages about curse chances beeing rolled, default = false");
entry4.addProperty("debugTries", debugTries);
root.add("debugTries", entry4);
entry4.addProperty("desc:", "Should curses only be applied on enchanting unenchanted items, recommended to increase base chance when enabling. Default: false");
entry4.addProperty("onlyUnEnchanted", onlyUnEnchanted);
root.add("onlyUnEnchanted", entry4);

final JsonObject entry5 = new JsonObject();
entry5.addProperty("desc:", "Should enchanting success play a sound and show particles, default:true");
entry5.addProperty("desc:", "Should enchanting success play a sound and show particles. Default: true");
entry5.addProperty("visualSuccess", visualSuccess);
root.add("visualSuccess", entry5);

final JsonObject entry6 = new JsonObject();
entry6.addProperty("desc:", "Whether curse chance should scale the more enchantment levels an item has, "
+ "If FALSE, curseChance = baseCurseChance - item enchantability. Default: true");
entry6.addProperty("curseChanceScales", curseChanceScales);
root.add("curseChanceScales", entry6);

final JsonObject entry7 = new JsonObject();
entry7.addProperty("desc:", "Base curse application chance, varies with item enchantability "
+ "(minCurseChance = base - enchantability). Default: 5 %");
entry7.addProperty("baseCurseChance", baseCurseChance);
root.add("baseCurseChance", entry7);

final JsonObject entry8 = new JsonObject();
entry8.addProperty("desc:", "Maximum curse application chance, ignored if curseChanceScales is FALSE. Default: 75 %");
entry8.addProperty("maxCurseChance", maxCurseChance);
root.add("maxCurseChance", entry8);

final JsonObject entry9 = new JsonObject();
entry9.addProperty("desc:", "Applies a curse every X enchantment levels, "
+ "no other curses are applied by curseChance each time this occurs. Disabled if X = 0. Default: 0 ");
entry9.addProperty("curseEveryXLevels", curseEveryXLevels);
root.add("curseEveryXLevels", entry9);


return root;
}

public void deserialize(JsonObject data)
{
debugTries = data.get("debugTries").getAsJsonObject().get("debugTries").getAsBoolean();
showDesc = data.get("showDesc").getAsJsonObject().get("showDesc").getAsBoolean();
excludedCurses = new ArrayList<>();
excludeTreasure = data.get("excludeTreasure").getAsJsonObject().get("excludeTreasure").getAsBoolean();
debugTries = data.get("debugTries").getAsJsonObject().get("debugTries").getAsBoolean();
onlyUnEnchanted = data.get("onlyUnEnchanted").getAsJsonObject().get("onlyUnEnchanted").getAsBoolean();
visualSuccess = data.get("visualSuccess").getAsJsonObject().get("visualSuccess").getAsBoolean();
basecursechance = data.get("basecursechance").getAsJsonObject().get("basecursechance").getAsInt();
onlynotechanted = data.get("onlynotechanted").getAsJsonObject().get("onlynotechanted").getAsBoolean();
excludedCurses = new ArrayList<>();
curseChanceScales = data.get("curseChanceScales").getAsJsonObject().get("curseChanceScales").getAsBoolean();
baseCurseChance = data.get("baseCurseChance").getAsJsonObject().get("baseCurseChance").getAsInt();
maxCurseChance = data.get("maxCurseChance").getAsJsonObject().get("maxCurseChance").getAsInt();
curseEveryXLevels = data.get("curseEveryXLevels").getAsJsonObject().get("curseEveryXLevels").getAsInt();
for (final JsonElement element : data.get("excludedCurses").getAsJsonObject().get("excludedCurses").getAsJsonArray())
{
excludedCurses.add(element.getAsString());
Expand Down Expand Up @@ -131,15 +161,29 @@ public void parseConfig()
CurseEnchantmentHelper.curseWeightMap.put(enchantmentEntry.getValue(), weight);
}
else
{
Cursery.LOGGER.info("Excluding curse: " + ForgeRegistries.ENCHANTMENTS.getKey(enchantmentEntry.getValue()) + " as config disables it");
}
}
}

if (totalCurseWeight == 0)
{
Cursery.LOGGER.error("Unable to retrieve curses from registry");

if (baseCurseChance < 0 || baseCurseChance > 100)
{
Cursery.LOGGER.warn(String.format("BaseCurseChance was set to '%d' yet must be within the interval 0 <= X <= 100. Setting back to 5.", baseCurseChance));
baseCurseChance = 5;
}

if (maxCurseChance < 0 || maxCurseChance > 100)
{
Cursery.LOGGER.warn(String.format("MaxCurseChance was set to '%d' yet must be within the interval 0 <= X <= 100. Setting back to 75.", maxCurseChance));
maxCurseChance = 75;
}

if (curseEveryXLevels < 0)
{
Cursery.LOGGER.warn(String.format("CurseEveryXLevels was set to '%d' yet must be within interval X >= 0. Setting back to 0.", curseEveryXLevels));
curseEveryXLevels = 0;
}
}
}
Loading