Skip to content

Commit

Permalink
Config screen
Browse files Browse the repository at this point in the history
  • Loading branch information
legobmw99 committed Jul 20, 2024
1 parent aaf6d8a commit bba1d30
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Allomancy 5.1.0

This mod adds the basics of [Allomancy](http://coppermind.net/wiki/Allomancy) from Brandon Sanderson's book series *Mistborn*.

This mod is currently updated for `Minecraft 1.21` and `NeoForge 21.0.40-beta`
This mod is currently updated for `Minecraft 1.21` and `NeoForge 21.0.110-beta`

Please verify and report any issues!

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.151'
id 'net.neoforged.gradle.mixin' version '7.0.151'
id 'net.neoforged.gradle.userdev' version '7.0.155'
id 'net.neoforged.gradle.mixin' version '7.0.155'
}

tasks.named('wrapper', Wrapper).configure {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ minecraft_version=1.21
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21,1.22)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.0.40-beta
neo_version=21.0.113-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[21.0.40-beta,)
neo_version_range=[21.0.110-beta,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[4,)
# read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
neogradle.subsystems.parchment.minecraftVersion=1.21
neogradle.subsystems.parchment.mappingsVersion=2024.06.23
neogradle.subsystems.parchment.mappingsVersion=2024.07.07
# https://www.curseforge.com/minecraft/mc-mods/jade/files/all
jade_id=5444008
jade_api=5427895
Expand Down
11 changes: 10 additions & 1 deletion src/generated/resources/assets/allomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@
"allomancy.chromium.red": "Red Chromium Symbol",
"allomancy.chromium.white": "White Chromium Symbol",
"allomancy.chromium.yellow": "Yellow Chromium Symbol",
"allomancy.configuration.animate_selection": "Animate Metal Selection Wheel",
"allomancy.configuration.gameplay": "Allomancy Gameplay Settings",
"allomancy.configuration.graphics": "Allomancy Graphics Settings",
"allomancy.configuration.max_metal_distance": "Maximum Steelsight Distance",
"allomancy.configuration.overlay_enabled": "Vial HUD Enabled",
"allomancy.configuration.overlay_position": "Vial HUD Position",
"allomancy.configuration.random_mistings": "Randomly Assign Mistings",
"allomancy.configuration.respect_player_UUID": "Misting from UUID",
"allomancy.configuration.whitelist": "Metal Whitelist",
"allomancy.copper.black": "Black Copper Symbol",
"allomancy.copper.blue": "Blue Copper Symbol",
"allomancy.copper.brown": "Brown Copper Symbol",
Expand Down Expand Up @@ -425,7 +434,7 @@
"item.allomancy.zinc_pattern.desc": "Zinc Symbol",
"key.burn": "Burn Metals",
"key.categories.allomancy": "Allomancy",
"key.hud": "Show HUD",
"key.hud": "Show Vial HUD",
"key.metals.aluminum": "Toggle Aluminum",
"key.metals.bendalloy": "Toggle Bendalloy",
"key.metals.brass": "Toggle Brass",
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/legobmw99/allomancy/Allomancy.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.common.NeoForge;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -64,5 +66,7 @@ public Allomancy(IEventBus bus, ModContainer container, Dist dist) {
bus.addListener(AllomancyConfig::onLoad);
bus.addListener(AllomancyConfig::onReload);

container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);

}
}
13 changes: 12 additions & 1 deletion src/main/java/com/legobmw99/allomancy/datagen/Languages.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected void addTranslations() {

add("key.categories.allomancy", "Allomancy");
add("key.burn", "Burn Metals");
add("key.hud", "Show HUD");
add("key.hud", "Show Vial HUD");
add("allomancy.gui", "Select Metal");

add("commands.allomancy.getpowers", "%s currently has Allomantic powers: %s");
Expand All @@ -144,5 +144,16 @@ protected void addTranslations() {
add("allomancy.networking.failed", "Allomancy packet failed to play: %s");
add("allomancy.networking.kicked", "Requested illegal action: %s");

add("allomancy.configuration.gameplay", "Allomancy Gameplay Settings");
add("allomancy.configuration.whitelist", "Metal Whitelist");
add("allomancy.configuration.random_mistings", "Randomly Assign Mistings");
add("allomancy.configuration.respect_player_UUID", "Misting from UUID");

add("allomancy.configuration.graphics", "Allomancy Graphics Settings");
add("allomancy.configuration.overlay_enabled", "Vial HUD Enabled");
add("allomancy.configuration.overlay_position", "Vial HUD Position");
add("allomancy.configuration.animate_selection", "Animate Metal Selection Wheel");
add("allomancy.configuration.max_metal_distance", "Maximum Steelsight Distance");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.legobmw99.allomancy.modules.powers.client.gui.MetalOverlay;
import com.legobmw99.allomancy.modules.powers.util.Physical;
import com.legobmw99.allomancy.util.AllomancyConfig;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.config.ModConfigEvent;
import net.neoforged.neoforge.common.ModConfigSpec;
Expand Down Expand Up @@ -38,17 +39,22 @@ public static void init(ModConfigSpec.Builder server_builder,
server_builder.comment("Settings for the gameplay elements of the mod").push("gameplay");
cfg_whitelist = server_builder
.comment("List of registry names of items and blocks that are counted as 'metal'")
.defineListAllowEmpty("whitelist", Physical::default_whitelist, o -> o instanceof String);
.defineListAllowEmpty("whitelist", Physical::default_whitelist, String::new, o -> {
if (o instanceof String s) {
return ResourceLocation.tryParse(s) != null;
}
return false;
});
server_builder.pop();

client_builder.push("graphics");
max_metal_detection = client_builder
.comment("Maximum iron/steel sight distance. Can have an impact on performance")
.defineInRange("max_metal_distance", 15, 3, 30);
animate_selection = client_builder.comment("Animate the selection wheel").define("animate_selection", true);
enable_overlay = client_builder.comment("Enable the screen overlay").define("overlay_enabled", true);
enable_overlay = client_builder.comment("Enable the metal vial HUD").define("overlay_enabled", true);
overlay_position = client_builder
.comment("Screen Overlay Position")
.comment("Metal vial HUD position")
.defineEnum("overlay_position", MetalOverlay.SCREEN_LOC.TOP_LEFT);
client_builder.pop();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,16 @@ private static Vec3 cutoff(Vec3 value, double e) {
return new Vec3(mag.x < e ? 0 : value.x, mag.y < e ? 0 : value.y, mag.z < e ? 0 : value.z);
}

private static HashSet<String> defaultList;

private static HashSet<String> defaultSet;
private static List<String> defaultList = null;

// TODO? this could be a Tag one day
public static List<String> default_whitelist() {
defaultList = new HashSet<>();
if (defaultList != null) {
return defaultList;
}

defaultSet = new HashSet<>();

add(Items.BUCKET);
add(Items.LAVA_BUCKET);
Expand Down Expand Up @@ -265,15 +269,15 @@ public static List<String> default_whitelist() {
.forEach(Physical::add);


List<String> list = new ArrayList<>(defaultList);
list.sort(String::compareTo);
return list;
defaultList = new ArrayList<>(defaultSet);
defaultList.sort(String::compareTo);
return defaultList;

}

private static void add(String s) {
Allomancy.LOGGER.info("Adding {} to the default whitelist!", s);
defaultList.add(s);
defaultSet.add(s);
}

private static void add(ResourceLocation r) {
Expand Down

0 comments on commit bba1d30

Please sign in to comment.