-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from DancingSnow0517/cloth-config
新的配置文件系统
- Loading branch information
Showing
17 changed files
with
171 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 27 additions & 25 deletions
52
common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,46 @@ | ||
package dev.dubhe.anvilcraft.config; | ||
|
||
import dev.dubhe.anvilcraft.AnvilCraft; | ||
import dev.toma.configuration.Configuration; | ||
import dev.toma.configuration.config.Config; | ||
import dev.toma.configuration.config.Configurable; | ||
import dev.toma.configuration.config.format.ConfigFormats; | ||
import me.shedaniel.autoconfig.ConfigData; | ||
import me.shedaniel.autoconfig.annotation.Config; | ||
import me.shedaniel.autoconfig.annotation.ConfigEntry; | ||
import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment; | ||
|
||
@Config(id = AnvilCraft.MOD_ID) | ||
public class AnvilCraftConfig { | ||
|
||
public static AnvilCraftConfig INSTANCE; | ||
@Config(name = AnvilCraft.MOD_ID) | ||
public class AnvilCraftConfig implements ConfigData { | ||
|
||
public static void init() { | ||
INSTANCE = Configuration.registerConfig(AnvilCraftConfig.class, ConfigFormats.yaml()).getConfigInstance(); | ||
} | ||
|
||
@Configurable | ||
@Configurable.Comment("Maximum number of items processed by the anvil at the same time") | ||
@Comment("Maximum number of items processed by the anvil at the same time") | ||
@ConfigEntry.Gui.Tooltip | ||
@ConfigEntry.BoundedDiscrete(max = 64, min = 1) | ||
public int anvilEfficiency = 64; | ||
|
||
@Configurable | ||
@Configurable.Comment("Maximum depth a lightning strike can reach") | ||
@Comment("Maximum depth a lightning strike can reach") | ||
@ConfigEntry.Gui.Tooltip | ||
@ConfigEntry.BoundedDiscrete(max = 16, min = 1) | ||
public int lightningStrikeDepth = 2; | ||
|
||
@Configurable | ||
@Configurable.Comment("Maximum distance a magnet attracts") | ||
@Comment("Maximum distance a magnet attracts") | ||
@ConfigEntry.Gui.Tooltip | ||
@ConfigEntry.BoundedDiscrete(max = 16, min = 1) | ||
public int magnetAttractsDistance = 5; | ||
@Configurable | ||
@Configurable.Comment("Maximum radius a handheld magnet attracts") | ||
|
||
@Comment("Maximum radius a handheld magnet attracts") | ||
@ConfigEntry.Gui.Tooltip | ||
public double magnetItemAttractsRadius = 8; | ||
|
||
@Configurable | ||
@Configurable.Comment("Redstone EMP distance generated per block dropped by the anvil") | ||
@Comment("Redstone EMP distance generated per block dropped by the anvil") | ||
@ConfigEntry.Gui.Tooltip | ||
@ConfigEntry.BoundedDiscrete(max = 64, min = 1) | ||
public int redstoneEmpRadius = 6; | ||
|
||
@Configurable | ||
@Configurable.Comment("Maximum distance of redstone EMP") | ||
@Comment("Maximum distance of redstone EMP") | ||
@ConfigEntry.Gui.Tooltip | ||
@ConfigEntry.BoundedDiscrete(max = 64, min = 1) | ||
public int redstoneEmpMaxRadius = 24; | ||
|
||
@Configurable | ||
@Configurable.Comment("Maximum cooldown time of chute (in ticks)") | ||
@Comment("Maximum cooldown time of chute (in ticks)") | ||
@ConfigEntry.Gui.Tooltip | ||
@ConfigEntry.BoundedDiscrete(max = 64, min = 1) | ||
public int chuteMaxCooldown = 4; | ||
} |
35 changes: 35 additions & 0 deletions
35
common/src/main/java/dev/dubhe/anvilcraft/data/generator/lang/ConfigScreenLang.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package dev.dubhe.anvilcraft.data.generator.lang; | ||
|
||
import com.tterrag.registrate.providers.RegistrateLangProvider; | ||
import dev.dubhe.anvilcraft.AnvilCraft; | ||
|
||
|
||
public class ConfigScreenLang { | ||
private static final String OPTION_STRING = "text.autoconfig.%s.option.%s"; | ||
private static final String OPTION_TOOLTIP_STRING = "text.autoconfig.%s.option.%s.@Tooltip"; | ||
|
||
public static void init(RegistrateLangProvider provider) { | ||
provider.add("text.autoconfig.anvilcraft.title", "AnvilCraft Config"); | ||
|
||
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, "anvilEfficiency"), "Anvil Efficiency"); | ||
provider.add(OPTION_TOOLTIP_STRING.formatted(AnvilCraft.MOD_ID, "anvilEfficiency"), "Maximum number of items processed by the anvil at the same time"); | ||
|
||
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, "lightningStrikeDepth"), "Lightning Strike Depth"); | ||
provider.add(OPTION_TOOLTIP_STRING.formatted(AnvilCraft.MOD_ID, "lightningStrikeDepth"), "Maximum depth a lightning strike can reach"); | ||
|
||
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, "magnetAttractsDistance"), "Magnet Attracts Distance"); | ||
provider.add(OPTION_TOOLTIP_STRING.formatted(AnvilCraft.MOD_ID, "magnetAttractsDistance"), "Maximum radius a handheld magnet attracts"); | ||
|
||
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, "magnetItemAttractsRadius"), "Magnet Item Attracts Radius"); | ||
provider.add(OPTION_TOOLTIP_STRING.formatted(AnvilCraft.MOD_ID, "magnetItemAttractsRadius"), "Maximum radius a handheld magnet attracts"); | ||
|
||
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, "redstoneEmpRadius"), "Redstone EMP Radius"); | ||
provider.add(OPTION_TOOLTIP_STRING.formatted(AnvilCraft.MOD_ID, "redstoneEmpRadius"), "Redstone EMP distance generated per block dropped by the anvil"); | ||
|
||
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, "redstoneEmpMaxRadius"), "Redstone EMP Max Radius"); | ||
provider.add(OPTION_TOOLTIP_STRING.formatted(AnvilCraft.MOD_ID, "redstoneEmpMaxRadius"), "Maximum distance of redstone EMP"); | ||
|
||
provider.add(OPTION_STRING.formatted(AnvilCraft.MOD_ID, "chuteMaxCooldown"), "Chute Max Cooldown"); | ||
provider.add(OPTION_TOOLTIP_STRING.formatted(AnvilCraft.MOD_ID, "chuteMaxCooldown"), "Maximum distance of chute"); | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
common/src/main/java/dev/dubhe/anvilcraft/data/generator/lang/ConfigurationLang.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
fabric/src/main/java/dev/dubhe/anvilcraft/integration/AnvilCraftModMenuApiImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.dubhe.anvilcraft.integration; | ||
|
||
import com.terraformersmc.modmenu.api.ConfigScreenFactory; | ||
import com.terraformersmc.modmenu.api.ModMenuApi; | ||
import dev.dubhe.anvilcraft.config.AnvilCraftConfig; | ||
import me.shedaniel.autoconfig.AutoConfig; | ||
|
||
public class AnvilCraftModMenuApiImpl implements ModMenuApi { | ||
@Override | ||
public ConfigScreenFactory<?> getModConfigScreenFactory() { | ||
return screen -> AutoConfig.getConfigScreen(AnvilCraftConfig.class, screen).get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.