Changed overrides into operations. Added priority and isLast values to operations.
This commit is contained in:
@ -9,6 +9,7 @@ import net.minecraftforge.fml.event.config.ModConfigEvent;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = XpTools.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(modid = XpTools.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
@ -50,30 +51,31 @@ public final class Config {
|
|||||||
|
|
||||||
public static class Server {
|
public static class Server {
|
||||||
public static ForgeConfigSpec.BooleanValue blockBreakDefaultNoXp;
|
public static ForgeConfigSpec.BooleanValue blockBreakDefaultNoXp;
|
||||||
private static ForgeConfigSpec.ConfigValue<List<? extends String>> blockBreakOverridesRaw;
|
private static ForgeConfigSpec.ConfigValue<List<? extends String>> blockBreakOperationsRaw;
|
||||||
public static List<OverrideItem> blockBreakOverrideItems;
|
public static List<OperationItem> blockBreakOperationItems;
|
||||||
|
|
||||||
Server(ForgeConfigSpec.Builder builder) {
|
Server(ForgeConfigSpec.Builder builder) {
|
||||||
builder.comment("Settings for block breaking").push("block_breaking");
|
builder.comment("Settings for block breaking").push("block_breaking");
|
||||||
blockBreakDefaultNoXp = builder
|
blockBreakDefaultNoXp = builder
|
||||||
.comment("Should all blocks drop 0 XP by default?")
|
.comment("Should all blocks drop 0 XP by default?")
|
||||||
.comment("(This makes multipliers not have any effect)")
|
.comment("(This makes multipliers not have any effect)")
|
||||||
.define("blockBreakXpDisabled", false);
|
.define("blockBreakDefaultNoXp", false);
|
||||||
blockBreakOverridesRaw = builder
|
blockBreakOperationsRaw = builder
|
||||||
.comment("List of all overrides. Format: '[block_id/tag],[multi/val],[min],[max]'")
|
.comment("List of all overrides. Format: '[block_id/tag],[operation],[min],[max],[priority],[is_last]'")
|
||||||
|
.comment("Available operations: " + Arrays.toString(OperationType.values()))
|
||||||
.comment("Examples:")
|
.comment("Examples:")
|
||||||
.comment("'minecraft:dirt,val,2,2' - Makes minecraft's dirt blocks drop 2 XP")
|
.comment("'minecraft:dirt,set,2,2,0,true' - Sets the xp drop of the dirt block to 2, takes highest priority and stops any additional operations.")
|
||||||
.comment("'#forge:ores,multi,1,2' - Applies an XP multiplier between 1-2 to all blocks tagged forge:ores")
|
.comment("'#forge:ores,multiply,1,2,1,false' - Multiplies xp drop of all blocks tagged forge:ores by 1-2, allows additional operations.")
|
||||||
.define("blockBreakOverrides", new ArrayList<>());
|
.define("blockBreakOperations", new ArrayList<>());
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerConfigReload(ModConfigEvent event) {
|
public static void onServerConfigReload(ModConfigEvent event) {
|
||||||
if (event.getConfig().getSpec() == SERVER_SPEC) {
|
if (event.getConfig().getSpec() == SERVER_SPEC) {
|
||||||
blockBreakOverrideItems = new ArrayList<>();
|
blockBreakOperationItems = new ArrayList<>();
|
||||||
for (String s : blockBreakOverridesRaw.get()) {
|
for (String s : blockBreakOperationsRaw.get()) {
|
||||||
blockBreakOverrideItems.add(new OverrideItem(s));
|
blockBreakOperationItems.add(new OperationItem(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
src/main/java/dev/micle/xptools/config/OperationItem.java
Normal file
57
src/main/java/dev/micle/xptools/config/OperationItem.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package dev.micle.xptools.config;
|
||||||
|
|
||||||
|
public class OperationItem {
|
||||||
|
private boolean isTag;
|
||||||
|
private String id;
|
||||||
|
private OperationType type;
|
||||||
|
private float min;
|
||||||
|
private float max;
|
||||||
|
private int priority;
|
||||||
|
private boolean isLast;
|
||||||
|
|
||||||
|
public OperationItem(String configString) {
|
||||||
|
String[] splitString = configString.split(",");
|
||||||
|
|
||||||
|
if (splitString.length == 6) {
|
||||||
|
isTag = splitString[0].startsWith("#");
|
||||||
|
id = isTag ? splitString[0].substring(1) : splitString[0];
|
||||||
|
|
||||||
|
type = OperationType.valueOf(splitString[1]);
|
||||||
|
|
||||||
|
min = Float.parseFloat(splitString[2]);
|
||||||
|
max = Float.parseFloat(splitString[3]);
|
||||||
|
|
||||||
|
priority = Integer.parseInt(splitString[4]);
|
||||||
|
|
||||||
|
isLast = Boolean.parseBoolean(splitString[5]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTag() {
|
||||||
|
return isTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLast() {
|
||||||
|
return isLast;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package dev.micle.xptools.config;
|
||||||
|
|
||||||
|
public enum OperationType {
|
||||||
|
SET,
|
||||||
|
ADD,
|
||||||
|
SUBTRACT,
|
||||||
|
MULTIPLY,
|
||||||
|
DIVIDE
|
||||||
|
}
|
@ -1,43 +0,0 @@
|
|||||||
package dev.micle.xptools.config;
|
|
||||||
|
|
||||||
public class OverrideItem {
|
|
||||||
private boolean isTag = false;
|
|
||||||
private String id = "";
|
|
||||||
private OverrideType type = OverrideType.MULTIPLIER;
|
|
||||||
private float min = 1;
|
|
||||||
private float max = 1;
|
|
||||||
|
|
||||||
public OverrideItem(String configString) {
|
|
||||||
String[] splitString = configString.split(",");
|
|
||||||
|
|
||||||
if (splitString.length == 4) {
|
|
||||||
isTag = splitString[0].startsWith("#");
|
|
||||||
id = isTag ? splitString[0].substring(1) : splitString[0];
|
|
||||||
|
|
||||||
type = OverrideType.valueOf(splitString[1]);
|
|
||||||
|
|
||||||
min = Float.parseFloat(splitString[2]);
|
|
||||||
max = Float.parseFloat(splitString[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTag() {
|
|
||||||
return isTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OverrideType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getMin() {
|
|
||||||
return min;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getMax() {
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package dev.micle.xptools.config;
|
|
||||||
|
|
||||||
public enum OverrideType {
|
|
||||||
VALUE("val"),
|
|
||||||
MULTIPLIER("multi");
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
OverrideType(String s) {
|
|
||||||
name = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user