diff --git a/src/main/java/com/cstav/genshinstrument/Main.java b/src/main/java/com/cstav/genshinstrument/Main.java index a235e974..c4c0e772 100644 --- a/src/main/java/com/cstav/genshinstrument/Main.java +++ b/src/main/java/com/cstav/genshinstrument/Main.java @@ -5,9 +5,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig.Type; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod(Main.MODID) @@ -24,6 +22,5 @@ public Main() MinecraftForge.EVENT_BUS.register(this); - ModLoadingContext.get().registerConfig(Type.CLIENT, ModClientConfigs.CONFIGS, "instrument_configs.toml"); } } diff --git a/src/main/java/com/cstav/genshinstrument/ModClientConfigs.java b/src/main/java/com/cstav/genshinstrument/client/config/ModClientConfigs.java similarity index 61% rename from src/main/java/com/cstav/genshinstrument/ModClientConfigs.java rename to src/main/java/com/cstav/genshinstrument/client/config/ModClientConfigs.java index 056be35d..bce59c18 100644 --- a/src/main/java/com/cstav/genshinstrument/ModClientConfigs.java +++ b/src/main/java/com/cstav/genshinstrument/client/config/ModClientConfigs.java @@ -1,17 +1,28 @@ -package com.cstav.genshinstrument; +package com.cstav.genshinstrument.client.config; -import com.cstav.genshinstrument.client.gui.screens.instrument.drum.DrumNoteLabel; -import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteGridLabel; -import com.cstav.genshinstrument.client.gui.screens.options.instrument.InstrumentChannelType; -import com.cstav.genshinstrument.client.gui.screens.options.instrument.ZitherSoundType; +import com.cstav.genshinstrument.Main; +import com.cstav.genshinstrument.client.config.enumType.InstrumentChannelType; +import com.cstav.genshinstrument.client.config.enumType.ZitherSoundType; +import com.cstav.genshinstrument.client.config.enumType.label.DrumNoteLabel; +import com.cstav.genshinstrument.client.config.enumType.label.NoteGridLabel; import com.cstav.genshinstrument.sounds.NoteSound; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; import net.minecraftforge.common.ForgeConfigSpec.Builder; import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; import net.minecraftforge.common.ForgeConfigSpec.EnumValue; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.fml.config.ModConfig.Type; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; +@OnlyIn(Dist.CLIENT) +@EventBusSubscriber(bus = Bus.MOD, modid = Main.MODID, value = Dist.CLIENT) public class ModClientConfigs { public static final ForgeConfigSpec CONFIGS; @@ -48,4 +59,9 @@ private static double doubleMe(final float num) { return Double.valueOf(Float.toString(num)); } + + @SubscribeEvent + public static void registerConfigs(final FMLConstructModEvent event) { + ModLoadingContext.get().registerConfig(Type.CLIENT, ModClientConfigs.CONFIGS, "instrument_configs.toml"); + } } diff --git a/src/main/java/com/cstav/genshinstrument/client/config/enumType/InstrumentChannelType.java b/src/main/java/com/cstav/genshinstrument/client/config/enumType/InstrumentChannelType.java new file mode 100644 index 00000000..5ebbbf7d --- /dev/null +++ b/src/main/java/com/cstav/genshinstrument/client/config/enumType/InstrumentChannelType.java @@ -0,0 +1,9 @@ +package com.cstav.genshinstrument.client.config.enumType; + +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public enum InstrumentChannelType { + MONO, MIXED, STEREO +} diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/ZitherSoundType.java b/src/main/java/com/cstav/genshinstrument/client/config/enumType/ZitherSoundType.java similarity index 87% rename from src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/ZitherSoundType.java rename to src/main/java/com/cstav/genshinstrument/client/config/enumType/ZitherSoundType.java index 5ff60768..d5e46a57 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/ZitherSoundType.java +++ b/src/main/java/com/cstav/genshinstrument/client/config/enumType/ZitherSoundType.java @@ -1,4 +1,4 @@ -package com.cstav.genshinstrument.client.gui.screens.options.instrument; +package com.cstav.genshinstrument.client.config.enumType; import java.util.function.Supplier; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumNoteLabel.java b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/DrumNoteLabel.java similarity index 83% rename from src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumNoteLabel.java rename to src/main/java/com/cstav/genshinstrument/client/config/enumType/label/DrumNoteLabel.java index 9954cff7..383a8b1e 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumNoteLabel.java +++ b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/DrumNoteLabel.java @@ -1,14 +1,18 @@ -package com.cstav.genshinstrument.client.gui.screens.instrument.drum; +package com.cstav.genshinstrument.client.config.enumType.label; import static com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier.create; +import com.cstav.genshinstrument.client.gui.screens.instrument.drum.DrumNoteButton; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier; import com.cstav.genshinstrument.client.keyMaps.KeyMappings.DrumKeys; import net.minecraft.network.chat.Component; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +@OnlyIn(Dist.CLIENT) public enum DrumNoteLabel implements INoteLabel { DON_KA(create(() -> (note) -> Component.translatable(dn(note).btnType.getTransKey()) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/NoteGridLabel.java b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java similarity index 82% rename from src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/NoteGridLabel.java rename to src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java index fe1f6ab7..1cfbd082 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/NoteGridLabel.java +++ b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java @@ -1,9 +1,12 @@ -package com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label; +package com.cstav.genshinstrument.client.config.enumType.label; import static com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier.create; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteGridButton; +import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.AbsGridLabels; +import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; +import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier; import com.cstav.genshinstrument.client.keyMaps.KeyMappings; import net.minecraft.network.chat.Component; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumNoteButton.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumNoteButton.java index ff4ca701..09f57d9b 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumNoteButton.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumNoteButton.java @@ -1,6 +1,6 @@ package com.cstav.genshinstrument.client.gui.screens.instrument.drum; -import com.cstav.genshinstrument.ModClientConfigs; +import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import net.minecraftforge.api.distmarker.Dist; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumOptionsScren.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumOptionsScren.java index 79cc2757..10960abc 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumOptionsScren.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumOptionsScren.java @@ -1,9 +1,14 @@ package com.cstav.genshinstrument.client.gui.screens.instrument.drum; -import com.cstav.genshinstrument.ModClientConfigs; +import com.cstav.genshinstrument.client.config.ModClientConfigs; +import com.cstav.genshinstrument.client.config.enumType.label.DrumNoteLabel; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; import com.cstav.genshinstrument.client.gui.screens.options.instrument.AbstractInstrumentOptionsScreen; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) public class DrumOptionsScren extends AbstractInstrumentOptionsScreen { public DrumOptionsScren(AratakisGreatAndGloriousDrumScreen screen) { diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java index 8dc21a36..27938238 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java @@ -7,7 +7,10 @@ import com.cstav.genshinstrument.client.keyMaps.KeyMappings; import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +@OnlyIn(Dist.CLIENT) public abstract class AbstractGridInstrumentScreen extends AbstractInstrumentScreen { public static final int DEF_ROWS = 7, DEF_COLUMNS = 3; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java index c1023e3f..91c2d09a 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java @@ -2,14 +2,14 @@ import java.util.UUID; -import com.cstav.genshinstrument.ModClientConfigs; +import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier; import com.cstav.genshinstrument.networking.ModPacketHandler; import com.cstav.genshinstrument.networking.packets.instrument.InstrumentPacket; import com.cstav.genshinstrument.sounds.NoteSound; -import com.cstav.genshinstrument.util.RGBColor; import com.cstav.genshinstrument.util.CommonUtil; +import com.cstav.genshinstrument.util.RGBColor; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteGrid.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteGrid.java index 67f38f49..bb9dc188 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteGrid.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteGrid.java @@ -2,7 +2,7 @@ import java.util.Iterator; -import com.cstav.genshinstrument.ModClientConfigs; +import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractGridInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/AbsGridLabels.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/AbsGridLabels.java index 7a40abfb..9ec5acf3 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/AbsGridLabels.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/AbsGridLabels.java @@ -1,5 +1,9 @@ package com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) public abstract class AbsGridLabels { public static final String[] DO_RE_MI = { diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/NoteLabelSupplier.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/NoteLabelSupplier.java index 4bb6c415..4cd2c61e 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/NoteLabelSupplier.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/label/NoteLabelSupplier.java @@ -6,8 +6,10 @@ import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.loading.FMLEnvironment; +@OnlyIn(Dist.CLIENT) @FunctionalInterface public interface NoteLabelSupplier { public static final NoteLabelSupplier EMPTY = create(() -> (note) -> Component.empty()); diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java index e9058ebb..0fa8453f 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java @@ -4,10 +4,11 @@ import javax.annotation.Nullable; -import com.cstav.genshinstrument.ModClientConfigs; +import com.cstav.genshinstrument.client.config.ModClientConfigs; +import com.cstav.genshinstrument.client.config.enumType.InstrumentChannelType; +import com.cstav.genshinstrument.client.config.enumType.label.NoteGridLabel; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; -import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteGridLabel; import com.cstav.genshinstrument.client.gui.screens.options.widget.BetterSlider; import com.cstav.genshinstrument.sounds.NoteSound; import com.cstav.genshinstrument.util.RGBColor; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java index 39b3aa21..76e124b7 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java @@ -1,6 +1,7 @@ package com.cstav.genshinstrument.client.gui.screens.options.instrument; -import com.cstav.genshinstrument.ModClientConfigs; +import com.cstav.genshinstrument.client.config.ModClientConfigs; +import com.cstav.genshinstrument.client.config.enumType.ZitherSoundType; import com.cstav.genshinstrument.client.gui.screens.instrument.floralZither.FloralZitherScreen; import com.cstav.genshinstrument.util.RGBColor; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java index d28b3272..bb4f3383 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java @@ -3,9 +3,9 @@ import org.slf4j.Logger; import com.cstav.genshinstrument.Main; -import com.cstav.genshinstrument.ModClientConfigs; +import com.cstav.genshinstrument.client.config.ModClientConfigs; +import com.cstav.genshinstrument.client.config.enumType.label.NoteGridLabel; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractGridInstrumentScreen; -import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteGridLabel; import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; @@ -16,11 +16,13 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +@OnlyIn(Dist.CLIENT) @EventBusSubscriber(value = Dist.CLIENT, modid = Main.MODID, bus = Bus.FORGE) public class GridInstrumentOptionsScreen extends AbstractInstrumentOptionsScreen { private static final Logger LOGGER = LogUtils.getLogger(); diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/InstrumentChannelType.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/InstrumentChannelType.java deleted file mode 100644 index c46dddc7..00000000 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/InstrumentChannelType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.cstav.genshinstrument.client.gui.screens.options.instrument; - -public enum InstrumentChannelType { - MONO, MIXED, STEREO -} diff --git a/src/main/java/com/cstav/genshinstrument/sounds/NoteSound.java b/src/main/java/com/cstav/genshinstrument/sounds/NoteSound.java index 6f45647d..e198f5ca 100644 --- a/src/main/java/com/cstav/genshinstrument/sounds/NoteSound.java +++ b/src/main/java/com/cstav/genshinstrument/sounds/NoteSound.java @@ -2,8 +2,8 @@ import javax.annotation.Nullable; -import com.cstav.genshinstrument.ModClientConfigs; -import com.cstav.genshinstrument.client.gui.screens.options.instrument.InstrumentChannelType; +import com.cstav.genshinstrument.client.config.ModClientConfigs; +import com.cstav.genshinstrument.client.config.enumType.InstrumentChannelType; import com.cstav.genshinstrument.networking.packets.instrument.InstrumentPacket; import net.minecraft.client.Minecraft;