Compare commits

..

No commits in common. "7ba0b7b307ac203ef01b350cdbfa033edae57906" and "bba99d4e6a38bf88c9b737918a7bf429715b4ee7" have entirely different histories.

10 changed files with 94 additions and 367 deletions

View file

@ -1,12 +1,5 @@
# 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.
# 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.3-all.jar`
`build/libs/TurnBasedMinecraft-NeoForge-1.25.2-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.146-beta
neo_version=20.4.109-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.3
mod_version=1.25.2
# 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(BattleMusic.percentageToDecibels(volume));
gainControl.setValue(volume * 20.0f - 20.0f); // in decibels
clip.loop(Clip.LOOP_CONTINUOUSLY);
clip.start();
@ -387,17 +387,6 @@ 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;
@ -449,7 +438,7 @@ public class BattleMusic
sdl.open(audioFormat);
{
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
volumeControl.setValue(BattleMusic.percentageToDecibels(volume));
volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -547,7 +536,7 @@ public class BattleMusic
sdl.open(audioFormat);
{
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
volumeControl.setValue(BattleMusic.percentageToDecibels(volume));
volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
}
AudioInputStream ais = reader.getAudioInputStream(oggVorbisFile);

View file

@ -1,258 +0,0 @@
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.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
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.IntValue sillyMusicThreshold;
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", 40, 0, 100);
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 Slider100 sillyMusicThresholdSlider = null;
private Checkbox affectedByMusicVolCheckbox = null;
private SliderDouble 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;
addRenderableWidget(new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset, widget_width, widget_height, Component.literal("Silly Music Threshold").setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0XFFFFFFFF)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("0-100 percentage minimum count of silly mobs to play silly music")))), font));
if (sillyMusicThresholdSlider == null) {
sillyMusicThresholdSlider = new Slider100(this.width / 2 + widget_x_offset, top_offset, widget_width, widget_height, Component.literal("Silly Music Threshold: " + CLIENT.sillyMusicThreshold.get()), 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;
addRenderableWidget(new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset, widget_width, widget_height, Component.literal("Affected by Music Vol.").setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0XFFFFFFFF)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("If enabled, volume is affected by global music volume.")))), font));
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;
addRenderableWidget(new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset, widget_width, widget_height, Component.literal("Music Volume").setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0XFFFFFFFF)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Volume of battle/silly music")))), font));
if (volumeSlider == null) {
volumeSlider = new SliderDouble(this.width / 2 + widget_x_offset, top_offset, widget_width, widget_height, Component.literal("Volume: " + String.format("%.2f", CLIENT.musicVolume.get())), 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.percentageInt);
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 Slider100 extends AbstractSliderButton {
private int percentageInt;
private String messagePrefix;
public Slider100(int x, int y, int width, int height, Component message, int percentage, String messagePrefix) {
super(x, y, width, height, message, percentage / 100.0);
this.percentageInt = percentage;
this.messagePrefix = messagePrefix;
}
@Override
protected void updateMessage() {
setMessage(Component.literal(messagePrefix + (int) (value * 100.0)));
}
@Override
protected void applyValue() {
percentageInt = (int) (value * 100.0);
}
}
private static class SliderDouble extends AbstractSliderButton {
private final String messagePrefix;
private double percentage;
public SliderDouble(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("%.2f", percentage)));
}
@Override
protected void applyValue() {
percentage = value;
}
}
}
}

View file

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

View file

@ -37,7 +37,10 @@ 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;
@ -60,6 +63,8 @@ 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>();
@ -151,6 +156,56 @@ 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");
@ -1273,6 +1328,16 @@ 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;
@ -1282,6 +1347,11 @@ 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 com.burnedkirby.TurnBasedMinecraft.client.ClientConfig;
import ca.weblite.objc.Client;
import com.burnedkirby.TurnBasedMinecraft.client.ClientProxy;
import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
import com.mojang.brigadier.LiteralMessage;
@ -21,8 +21,6 @@ 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;
@ -42,7 +40,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.3";
public static final String VERSION = "1.25.2";
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/";
@ -69,7 +67,6 @@ 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) {
@ -93,9 +90,6 @@ 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");
}
@ -1677,15 +1671,6 @@ 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

@ -1,52 +0,0 @@
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,8 +6,16 @@ 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]