Skip to content

Commit

Permalink
Fixed client configs attempting to load on servers
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Apr 25, 2023
1 parent ae4a77f commit ff74ca9
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 28 deletions.
3 changes: 0 additions & 3 deletions src/main/java/com/cstav/genshinstrument/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -24,6 +22,5 @@ public Main()


MinecraftForge.EVENT_BUS.register(this);
ModLoadingContext.get().registerConfig(Type.CLIENT, ModClientConfigs.CONFIGS, "instrument_configs.toml");
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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())
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/com/cstav/genshinstrument/sounds/NoteSound.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ff74ca9

Please sign in to comment.