Compare commits

...

16 commits

Author SHA1 Message Date
Stephen Seo 0d79d88474 Change action runner for tags/releases 2024-03-21 16:16:18 +09:00
Stephen Seo 3f8a12a4ad Change action runner for tags/releases 2024-03-21 13:19:18 +09:00
Stephen Seo c0e70007f7 Fix "hover text" info for options in cli conf gui 2024-02-02 13:43:48 +09:00
Stephen Seo 6c2265f184 Update Changelog.md 2024-02-01 16:55:42 +09:00
Stephen Seo 3f7c922c5d Add cli opt for music vol affected by master vol 2024-02-01 16:54:34 +09:00
Stephen Seo 03ea6d3bc9 Update Changelog.md 2024-02-01 16:14:47 +09:00
Stephen Seo 6b21afdce9 Refactor ClientConfig GUI, reformat file
Also refactor how "minimum silly percentage" is handled (the minimum
percentage of "silly mobs" to play silly music in battle for).
2024-02-01 15:55:58 +09:00
Stephen Seo c8066e2550 Fix value formatting for sliders in client config 2024-02-01 14:19:27 +09:00
Stephen Seo b0a58384f3 Update README.md 2024-01-31 18:23:50 +09:00
Stephen Seo caa90f7fa6 Bump version to 1.26.0 2024-01-31 18:23:26 +09:00
Stephen Seo 7ba0b7b307 Update Changelog.md 2024-01-31 18:20:57 +09:00
Stephen Seo 83b7e99cee Impl. GUI to set client config, /tbm-client-edit 2024-01-31 18:18:55 +09:00
Stephen Seo c0fddb6955 Allow changing client config in settings
Client config is no longer stored in TBM_Config.toml.
2024-01-31 14:06:23 +09:00
Stephen Seo aac4f9b6aa Bump NeoForge version to 20.4.146-beta 2024-01-31 12:03:45 +09:00
Stephen Seo 18b4fac876 Version 1.25.3 2024-01-31 11:58:13 +09:00
Stephen Seo 86cbc5e7ba Fix volume handling of battle/silly music 2024-01-31 11:57:52 +09:00
11 changed files with 449 additions and 100 deletions

View file

@ -6,7 +6,7 @@ on:
jobs:
check-release-exists:
runs-on: any_archLinux
runs-on: highmem_self
outputs:
status: ${{ steps.release_exists_check.outputs.http_code }}
steps:
@ -19,7 +19,7 @@ jobs:
build-and-create-release:
needs: check-release-exists
if: ${{ needs.check-release-exists.outputs.status == '404' }}
runs-on: any_archLinux
runs-on: highmem_self
steps:
- run: git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod.git TurnBasedMinecraftMod
- run: cd TurnBasedMinecraftMod && git checkout ${GITHUB_REF_NAME}

View file

@ -1,5 +1,16 @@
# Upcoming changes
Fix volume handling of battle/silly music. (Previous implementation did not
properly reduce volume based on Minecraft's "music volume" setting.)
Move client-config to NeoForge's configuration.
Add GUI to edit client-config that can be opened with /tbm-client-edit command.
Add option in client-config to set battle/silly music volume, and an option for
whether or not battle/silly music volume is affected by global music volume
setting and whether or not it is affected by master volume setting.
# Version NeoForge-1.25.2
Fix invalid use of throwable potions. (Previously, the Player would "drink"

View file

@ -72,7 +72,7 @@ configured for them.)
Simply invoke `./gradlew build` in the mod directory and after some time the
finished jar will be saved at
`build/libs/TurnBasedMinecraft-NeoForge-1.25.2-all.jar`
`build/libs/TurnBasedMinecraft-NeoForge-1.26.0-all.jar`
# Reproducibility

View file

@ -15,7 +15,7 @@ minecraft_version=1.20.4
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.4,1.21)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=20.4.109-beta
neo_version=20.4.146-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[20.4,)
# The loader version range can only use the major version of FML as bounds
@ -31,7 +31,7 @@ mod_name=TurnBasedMinecraftMod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.25.2
mod_version=1.26.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -259,7 +259,7 @@ public class BattleMusic
// set volume
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(volume * 20.0f - 20.0f); // in decibels
gainControl.setValue(BattleMusic.percentageToDecibels(volume));
clip.loop(Clip.LOOP_CONTINUOUSLY);
clip.start();
@ -387,6 +387,17 @@ public class BattleMusic
return !sillyMusic.isEmpty();
}
/// Percentage must be between 0 and 1.
public static float percentageToDecibels(float percentage) {
if (percentage > 1.0F) {
return 0.0F;
} else if (percentage <= 0.0F) {
return Float.NEGATIVE_INFINITY;
} else {
return (float) (Math.log10(percentage) * 20.0);
}
}
private class MP3Streamer implements Runnable
{
private AtomicBoolean keepPlaying;
@ -438,7 +449,7 @@ public class BattleMusic
sdl.open(audioFormat);
{
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
volumeControl.setValue(BattleMusic.percentageToDecibels(volume));
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -536,7 +547,7 @@ public class BattleMusic
sdl.open(audioFormat);
{
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
volumeControl.setValue(BattleMusic.percentageToDecibels(volume));
}
AudioInputStream ais = reader.getAudioInputStream(oggVorbisFile);

View file

@ -0,0 +1,324 @@
package com.burnedkirby.TurnBasedMinecraft.client;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.*;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.common.ModConfigSpec;
import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList;
import java.util.List;
public class ClientConfig {
public static final ClientConfig CLIENT;
public static final ModConfigSpec CLIENT_SPEC;
static {
Pair<ClientConfig, ModConfigSpec> pair =
new ModConfigSpec.Builder().configure(ClientConfig::new);
CLIENT = pair.getKey();
CLIENT_SPEC = pair.getValue();
}
public final ModConfigSpec.ConfigValue<List<? extends String>> battleMusicList;
public final ModConfigSpec.ConfigValue<List<? extends String>> sillyMusicList;
public final ModConfigSpec.DoubleValue sillyMusicThreshold;
public final ModConfigSpec.BooleanValue volumeAffectedByMasterVolume;
public final ModConfigSpec.BooleanValue volumeAffectedByMusicVolume;
public final ModConfigSpec.DoubleValue musicVolume;
ClientConfig(ModConfigSpec.Builder builder) {
//builder.push("music");
List<String> battleMusicList = new ArrayList<String>(8);
battleMusicList.add("monster");
battleMusicList.add("animal");
battleMusicList.add("boss");
battleMusicList.add("player");
this.battleMusicList = builder.comment("What categories of mobs that play \"battle\" music")
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.battle_music_list")
.defineList("battleMusicList", battleMusicList, (v) -> v instanceof String);
List<String> sillyMusicList = new ArrayList<String>(4);
sillyMusicList.add("passive");
this.sillyMusicList = builder.comment("What categories of mobs that play \"silly\" music")
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.silly_music_list")
.defineList("sillyMusicList", sillyMusicList, (v) -> true);
this.sillyMusicThreshold =
builder.comment("Minimum percentage of silly entities in battle to use silly music")
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.silly_percentage")
.defineInRange("sillyMusicThreshold", 0.4, 0.0, 1.0);
this.volumeAffectedByMasterVolume = builder.comment(
"If \"true\", music volume will be affected by global Master volume setting")
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.volume_affected_by_master")
.define("volumeAffectedByMasterVolume", true);
this.volumeAffectedByMusicVolume = builder.comment(
"If \"true\", music volume will be affected by global Music volume setting")
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.volume_affected_by_volume")
.define("volumeAffectedByMusicVolume", true);
this.musicVolume =
builder.comment("Volume of battle/silly music as a percentage between 0.0 and 1.0")
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.music_volume")
.defineInRange("musicVolume", 0.7, 0.0, 1.0);
//builder.pop();
}
public static class CliConfGui extends Screen {
private final int widget_height = 20;
private boolean dirtyFlag;
private boolean accepted;
private EditBox battleListEditBox = null;
private EditBox sillyListEditBox = null;
private SliderPercentage sillyMusicThresholdSlider = null;
private Checkbox affectedByMasterVolCheckbox = null;
private Checkbox affectedByMusicVolCheckbox = null;
private SliderPercentage volumeSlider = null;
public CliConfGui() {
super(Component.literal("TurnBasedMC Client Config"));
dirtyFlag = true;
accepted = false;
}
public void onDirty() {
clearWidgets();
// Initialize GUI elements.
int widget_x_offset = 5;
int widget_width = this.width / 2 - widget_x_offset * 2;
int top_offset = 5;
addRenderableWidget(
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Battle Music Categories"),
font));
if (battleListEditBox == null) {
battleListEditBox =
new EditBox(font, this.width / 2 + widget_x_offset, top_offset, widget_width,
widget_height, Component.literal("Battle Music Categories Edit Box"));
} else {
battleListEditBox.setPosition(this.width / 2 + widget_x_offset, top_offset);
battleListEditBox.setSize(widget_width, widget_height);
}
String tempString = "";
for (String category : CLIENT.battleMusicList.get()) {
if (tempString.isEmpty()) {
tempString = category;
} else {
tempString += "," + category;
}
}
battleListEditBox.setMaxLength(128);
battleListEditBox.setValue(tempString);
addRenderableWidget(battleListEditBox);
top_offset += widget_height;
addRenderableWidget(
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Silly Music Categories"),
font));
if (sillyListEditBox == null) {
sillyListEditBox =
new EditBox(font, this.width / 2 + widget_x_offset, top_offset, widget_width,
widget_height, Component.literal("Silly Music Categories Edit Box"));
} else {
sillyListEditBox.setPosition(this.width / 2 + widget_x_offset, top_offset);
sillyListEditBox.setSize(widget_width, widget_height);
}
tempString = "";
for (String category : CLIENT.sillyMusicList.get()) {
if (tempString.isEmpty()) {
tempString = category;
} else {
tempString += "," + category;
}
}
sillyListEditBox.setMaxLength(128);
sillyListEditBox.setValue(tempString);
addRenderableWidget(sillyListEditBox);
top_offset += widget_height;
StringWidget stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Silly Music Threshold"), font);
stringWidget.setTooltip(Tooltip.create(
Component.literal("Ratio of minimum of silly mobs in battle to play silly music")));
addRenderableWidget(stringWidget);
if (sillyMusicThresholdSlider == null) {
sillyMusicThresholdSlider =
new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,
widget_height, Component.literal("Silly Music Threshold: " +
String.format("%.1f%%", CLIENT.sillyMusicThreshold.get() * 100.0)),
CLIENT.sillyMusicThreshold.get(), "Silly Music Threshold: ");
} else {
sillyMusicThresholdSlider.setPosition(this.width / 2 + widget_x_offset, top_offset);
sillyMusicThresholdSlider.setSize(widget_width, widget_height);
}
addRenderableWidget(sillyMusicThresholdSlider);
top_offset += widget_height;
stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Affected by Master Vol."),
font);
stringWidget.setTooltip(Tooltip.create(
Component.literal("If enabled, volume is affected by global master volume.")));
addRenderableWidget(stringWidget);
if (affectedByMasterVolCheckbox == null) {
affectedByMasterVolCheckbox = Checkbox.builder(Component.literal(""), font)
.pos(this.width / 2 + widget_x_offset, top_offset).build();
} else {
affectedByMasterVolCheckbox.setPosition(this.width / 2 + widget_x_offset,
top_offset);
}
if ((CLIENT.volumeAffectedByMasterVolume.get() &&
!affectedByMasterVolCheckbox.selected()) ||
(!CLIENT.volumeAffectedByMasterVolume.get() &&
affectedByMasterVolCheckbox.selected())) {
affectedByMasterVolCheckbox.onPress();
}
addRenderableWidget(affectedByMasterVolCheckbox);
top_offset += widget_height;
stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Affected by Music Vol."), font);
stringWidget.setTooltip(Tooltip.create(
Component.literal("If enabled, volume is affected by global music volume.")));
addRenderableWidget(stringWidget);
if (affectedByMusicVolCheckbox == null) {
affectedByMusicVolCheckbox = Checkbox.builder(Component.literal(""), font)
.pos(this.width / 2 + widget_x_offset, top_offset).build();
} else {
affectedByMusicVolCheckbox.setPosition(this.width / 2 + widget_x_offset,
top_offset);
}
if ((CLIENT.volumeAffectedByMusicVolume.get() &&
!affectedByMusicVolCheckbox.selected()) ||
(!CLIENT.volumeAffectedByMusicVolume.get() &&
affectedByMusicVolCheckbox.selected())) {
affectedByMusicVolCheckbox.onPress();
}
addRenderableWidget(affectedByMusicVolCheckbox);
top_offset += widget_height;
stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Music Volume"), font);
stringWidget.setTooltip(
Tooltip.create(Component.literal("Volume of battle/silly music")));
addRenderableWidget(stringWidget);
if (volumeSlider == null) {
volumeSlider =
new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,
widget_height, Component.literal(
"Volume: " + String.format("%.1f%%", CLIENT.musicVolume.get() * 100.0)),
CLIENT.musicVolume.get(), "Volume: ");
} else {
volumeSlider.setPosition(this.width / 2 + widget_x_offset, top_offset);
volumeSlider.setSize(widget_width, widget_height);
}
addRenderableWidget(volumeSlider);
addRenderableWidget(Button.builder(Component.literal("Cancel"),
(b) -> Minecraft.getInstance().setScreen(null))
.bounds(this.width / 2 - widget_width + widget_x_offset,
this.height - widget_height, widget_width, widget_height).build());
addRenderableWidget(Button.builder(Component.literal("Accept"), (b) -> {
accepted = true;
}).bounds(this.width / 2 + widget_x_offset, this.height - widget_height, widget_width,
widget_height).build());
dirtyFlag = false;
}
private void doAccepted() {
String temp = battleListEditBox.getValue();
{
List<String> battleList = new ArrayList<String>();
for (String category : temp.split(",")) {
battleList.add(category.strip());
}
CLIENT.battleMusicList.set(battleList);
}
temp = sillyListEditBox.getValue();
{
List<String> sillyList = new ArrayList<String>();
for (String category : temp.split(",")) {
sillyList.add(category.strip());
}
CLIENT.sillyMusicList.set(sillyList);
}
CLIENT.sillyMusicThreshold.set(sillyMusicThresholdSlider.percentage);
CLIENT.volumeAffectedByMasterVolume.set(affectedByMasterVolCheckbox.selected());
CLIENT.volumeAffectedByMusicVolume.set(affectedByMusicVolCheckbox.selected());
CLIENT.musicVolume.set(volumeSlider.percentage);
}
@Override
public boolean isPauseScreen() {
return true;
}
@Override
public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
if (accepted) {
doAccepted();
Minecraft.getInstance().setScreen(null);
return;
}
if (dirtyFlag) {
onDirty();
}
super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick);
}
@Override
public void resize(Minecraft pMinecraft, int pWidth, int pHeight) {
dirtyFlag = true;
super.resize(pMinecraft, pWidth, pHeight);
}
private static class SliderPercentage extends AbstractSliderButton {
private final String messagePrefix;
private double percentage;
public SliderPercentage(int x, int y, int width, int height, Component message, double percentage, String messagePrefix) {
super(x, y, width, height, message, percentage);
this.percentage = percentage;
this.messagePrefix = messagePrefix;
}
@Override
protected void updateMessage() {
setMessage(
Component.literal(messagePrefix + String.format("%.1f%%", percentage * 100.0)));
}
@Override
protected void applyValue() {
percentage = value;
}
}
}
}

View file

@ -94,13 +94,27 @@ public class ClientProxy extends CommonProxy {
@Override
public void playBattleMusic() {
Options gs = Minecraft.getInstance().options;
battleMusic.playBattle(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
float volume = ClientConfig.CLIENT.musicVolume.get().floatValue();
if (ClientConfig.CLIENT.volumeAffectedByMasterVolume.get()) {
volume *= gs.getSoundSourceVolume(SoundSource.MASTER);
}
if (ClientConfig.CLIENT.volumeAffectedByMusicVolume.get()) {
volume *= gs.getSoundSourceVolume(SoundSource.MUSIC);
}
battleMusic.playBattle(volume);
}
@Override
public void playSillyMusic() {
Options gs = Minecraft.getInstance().options;
battleMusic.playSilly(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
float volume = ClientConfig.CLIENT.musicVolume.get().floatValue();
if (ClientConfig.CLIENT.volumeAffectedByMasterVolume.get()) {
volume *= gs.getSoundSourceVolume(SoundSource.MASTER);
}
if (ClientConfig.CLIENT.volumeAffectedByMusicVolume.get()) {
volume *= gs.getSoundSourceVolume(SoundSource.MUSIC);
}
battleMusic.playSilly(volume);
}
@Override
@ -116,9 +130,9 @@ public class ClientProxy extends CommonProxy {
if (localBattle == null) {
return;
}
if (type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
if (type == null || type.isEmpty() || ClientConfig.CLIENT.battleMusicList.get().contains(type)) {
++battleMusicCount;
} else if (getConfig().isSillyMusicType(type)) {
} else if (ClientConfig.CLIENT.sillyMusicList.get().contains(type)) {
++sillyMusicCount;
} else {
++battleMusicCount;
@ -132,9 +146,9 @@ public class ClientProxy extends CommonProxy {
battleMusicCount = 0;
sillyMusicCount = 0;
return;
} else if (type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
} else if (type == null || type.isEmpty() || ClientConfig.CLIENT.battleMusicList.get().contains(type)) {
--battleMusicCount;
} else if (getConfig().isSillyMusicType(type)) {
} else if (ClientConfig.CLIENT.sillyMusicList.get().contains(type)) {
--sillyMusicCount;
} else {
--battleMusicCount;
@ -176,16 +190,16 @@ public class ClientProxy extends CommonProxy {
return;
}
float percentage = 0.0f;
double percentage = 0.0;
if (sillyMusicCount == 0 && battleMusicCount == 0) {
percentage = 0.0f;
percentage = 0.0;
} else if (battleMusicCount == 0) {
percentage = 100.0f;
percentage = 1.0;
} else {
percentage = 100.0f * (float) sillyMusicCount / (float) (sillyMusicCount + battleMusicCount);
percentage = (double) sillyMusicCount / (double) (sillyMusicCount + battleMusicCount);
}
if (percentage >= (float) getConfig().getSillyMusicThreshold()) {
if (percentage >= ClientConfig.CLIENT.sillyMusicThreshold.get()) {
if (battleMusic.isPlaying()) {
if (!battleMusic.isPlayingSilly() && battleMusic.hasSillyMusic()) {
stopMusic(false);

View file

@ -37,10 +37,7 @@ public class Config
private int fleeBadProbability = 35;
private int minimumHitPercentage = 4;
private int maxInBattle = 8;
private Set<String> musicBattleTypes;
private Set<String> musicSillyTypes;
private boolean freezeCombatantsInBattle = false;
private int sillyMusicThreshold = 40;
private int configVersion = 0;
private Set<Integer> battleIgnoringPlayers = null;
private boolean onlyOPsSelfDisableTB = true;
@ -63,8 +60,6 @@ public class Config
customEntityInfoMap = new HashMap<String, EntityInfo>();
ignoreBattleTypes = new HashSet<String>();
this.logger = logger;
musicBattleTypes = new HashSet<String>();
musicSillyTypes = new HashSet<String>();
battleIgnoringPlayers = new HashSet<Integer>();
possibleIgnoreHurtDamageSources = new HashSet<String>();
ignoreHurtDamageSources = new HashSet<String>();
@ -156,56 +151,6 @@ public class Config
{
CommentedFileConfig conf = getConfigObj(configFile);
// client config
try {
Collection<String> battle_music_categories = conf.get("client_config.battle_music");
if (battle_music_categories != null) {
for (String category : battle_music_categories) {
musicBattleTypes.add(category);
}
} else {
musicBattleTypes.add("monster");
musicBattleTypes.add("animal");
musicBattleTypes.add("boss");
musicBattleTypes.add("player");
logNotFound("client_config.battle_music");
}
} catch (ClassCastException e) {
musicBattleTypes.add("monster");
musicBattleTypes.add("animal");
musicBattleTypes.add("boss");
musicBattleTypes.add("player");
logTOMLInvalidValue("client_config.battle_music");
}
try {
Collection<String> silly_music_categories = conf.get("client_config.silly_music");
if (silly_music_categories != null) {
for (String category : silly_music_categories) {
musicSillyTypes.add(category);
}
} else {
musicSillyTypes.add("passive");
logNotFound("client_config.silly_music");
}
} catch (ClassCastException e) {
musicSillyTypes.add("passive");
logTOMLInvalidValue("client_config.silly_music");
}
try {
OptionalInt silly_music_threshold = conf.getOptionalInt("client_config.silly_music_threshold");
if(silly_music_threshold.isPresent()) {
this.sillyMusicThreshold = silly_music_threshold.getAsInt();
} else {
this.sillyMusicThreshold = 40;
logNotFound("client_config.silly_music_threshold", "40");
}
} catch (ClassCastException e) {
this.sillyMusicThreshold = 40;
logTOMLInvalidValue("client_config.silly_music_threshold", "40");
}
// server_config
try {
OptionalInt leave_battle_cooldown = conf.getOptionalInt("server_config.leave_battle_cooldown");
@ -1328,16 +1273,6 @@ public class Config
this.maxInBattle = maxInBattle;
}
public boolean isBattleMusicType(String type)
{
return musicBattleTypes.contains(type.toLowerCase());
}
public boolean isSillyMusicType(String type)
{
return musicSillyTypes.contains(type.toLowerCase());
}
public boolean isFreezeCombatantsEnabled()
{
return freezeCombatantsInBattle;
@ -1347,11 +1282,6 @@ public class Config
freezeCombatantsInBattle = enabled;
}
public int getSillyMusicThreshold()
{
return sillyMusicThreshold;
}
public int getConfigVersion()
{
return configVersion;

View file

@ -1,6 +1,6 @@
package com.burnedkirby.TurnBasedMinecraft.common;
import ca.weblite.objc.Client;
import com.burnedkirby.TurnBasedMinecraft.client.ClientConfig;
import com.burnedkirby.TurnBasedMinecraft.client.ClientProxy;
import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
import com.mojang.brigadier.LiteralMessage;
@ -21,6 +21,8 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
@ -40,7 +42,7 @@ import org.apache.logging.log4j.Logger;
public class TurnBasedMinecraftMod {
public static final String MODID = "com_burnedkirby_turnbasedminecraft";
public static final String NAME = "Turn Based Minecraft Mod";
public static final String VERSION = "1.25.2";
public static final String VERSION = "1.26.0";
public static final String CONFIG_FILENAME = "TBM_Config.toml";
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
@ -67,6 +69,7 @@ public class TurnBasedMinecraftMod {
eventBus.addListener(this::secondInitServer);
eventBus.addListener(this::registerNetwork);
NeoForge.EVENT_BUS.register(this);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ClientConfig.CLIENT_SPEC);
}
private void registerNetwork(final RegisterPayloadHandlerEvent event) {
@ -90,6 +93,9 @@ public class TurnBasedMinecraftMod {
registrar.play(PacketGeneralMessage.ID, PacketGeneralMessage::new, handler -> handler
.client(PacketGeneralMessage.PayloadHandler.getInstance()::handleData));
registrar.play(PacketClientGUI.ID, PacketClientGUI::new, handler -> handler
.client(PacketClientGUI.PayloadHandler.getInstance()::handleData));
logger.debug("Register packets com_burnedkirby_turnbasedminecraft");
}
@ -1671,6 +1677,15 @@ public class TurnBasedMinecraftMod {
return 1;
})))
);
// tbm-client-edit
event.getDispatcher().register(
Commands.literal("tbm-client-edit").executes(c -> {
ServerPlayer player = c.getSource().getPlayerOrException();
PacketDistributor.PLAYER.with(player).send(new PacketClientGUI());
return 1;
})
);
}
@SubscribeEvent

View file

@ -0,0 +1,52 @@
package com.burnedkirby.TurnBasedMinecraft.common.networking;
import com.burnedkirby.TurnBasedMinecraft.client.ClientConfig;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
public class PacketClientGUI implements CustomPacketPayload {
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetclientgui");
int reserved;
public PacketClientGUI() {
reserved = 0;
}
public PacketClientGUI(FriendlyByteBuf buf) {
reserved = buf.readInt();
}
@Override
public void write(FriendlyByteBuf buf) {
buf.writeInt(0);
}
@Override
public ResourceLocation id() {
return ID;
}
public static class PayloadHandler {
private static final PayloadHandler INSTANCE = new PayloadHandler();
public static PayloadHandler getInstance() { return INSTANCE; }
public void handleData(final PacketClientGUI pkt, final PlayPayloadContext ctx) {
ctx.workHandler().submitAsync(() -> {
if (FMLEnvironment.dist.isClient()) {
Minecraft.getInstance().setScreen(new ClientConfig.CliConfGui());
}
}).exceptionally(e -> {
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketClientGUI! " + e.getMessage()));
return null;
});
}
}
}

View file

@ -6,16 +6,8 @@ version = 10
# "false"!
do_not_overwrite = false
[client_config]
# What categories play this type of music (battle_music). Unknown categories will default to this type.
battle_music = ["monster", "animal", "boss", "player"]
# What categories play this type of music (silly_music).
silly_music = ["passive"]
# Minimum percentage of silly entities in battle to use silly music.
silly_music_threshold = 40
# Note that client config is no longer stored here but rather in the settings.
[server_config]