Skip to content

Commit

Permalink
Switch to native (Neo)Forge config system
Browse files Browse the repository at this point in the history
- Switched from MidnightLib to the native NeoForge and Forge config system
- Fixed description translation not applying for NeoForge
  • Loading branch information
Tschipcraft committed Jan 4, 2025
1 parent 39cb586 commit a8cc4c2
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"modmenu.summaryTranslation.make_bubbles_pop": "Arrr matey, this here makes yer bubbles pop!",
"modmenu.descriptionTranslation.make_bubbles_pop": "Arrr! This here client-side mod makes yer bubble particles pop an' lets them realistically rise to the water surface.\nIt also adds bubble particles to openin' chests, openin' barrels an' explosions underwater.\n",
"make_bubbles_pop.description": "Arrr matey! This here client-side mod makes yer bubble particles pop an' lets them realistically rise to the water surface.\nIt also adds bubble particles to openin' chests, openin' barrels an' explosions underwater.\n"
"fml.menu.mods.info.description.make_bubbles_pop": "Arrr matey! This here client-side mod makes yer bubble particles pop an' lets them realistically rise to the water surface.\n\nIt also adds bubble particles to openin' chests, openin' barrels an' explosions underwater.\n"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
"make_bubbles_pop.midnightconfig.additional_features": "Additional Features",

"make_bubbles_pop.midnightconfig.POP_PARTICLE_ENABLED": "Enable Bubble Pop Particles",
"make_bubbles_pop.midnightconfig.POP_PARTICLE_ENABLED.tooltip": "Default: §aYes§f \n§dℹ Note:§f Make sure to disable this or Particle Tweaks' implementation if Particle Tweaks is installed.",
"make_bubbles_pop.midnightconfig.POP_PARTICLE_ENABLED.tooltip": "Default: §aON§f \n§dℹ Note:§f Make sure to disable this or Particle Tweaks' implementation if Particle Tweaks is installed.",
"make_bubbles_pop.midnightconfig.BUBBLE_POP_VOLUME": " └ Bubble Pop Sound Volume",
"make_bubbles_pop.midnightconfig.BUBBLE_POP_VOLUME.tooltip": "Default: §b10%§f",
"make_bubbles_pop.midnightconfig.POPPED_BUBBLES_MAINTAIN_VELOCITY": " └ Maintain bubble velocity for bubble pop particles",
"make_bubbles_pop.midnightconfig.POPPED_BUBBLES_MAINTAIN_VELOCITY.tooltip": "Default: §cNo§f",
"make_bubbles_pop.midnightconfig.POPPED_BUBBLES_MAINTAIN_VELOCITY.tooltip": "Default: §cOFF§f",

"make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED": "Enable Bubble Physics",
"make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED.tooltip": "Enables overhauled bubble physics when colliding with blocks or entities. \nDefault: §aYes§f \n§dℹ Note:§f This does not currently work for bubbles from soul sand or magma blocks.",
"make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED.tooltip": "Enables overhauled bubble physics when colliding with blocks or entities. \nDefault: §aON§f \n§dℹ Note:§f This does not currently work for bubbles from soul sand or magma blocks.",
"make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER": " └ Average Bubble Particle Lifetime",
"make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER.tooltip": "The time it takes for a bubble to pop underwater. \nBy default, this is set longer than in vanilla to allow bubbles to reach the water surface. \nDefault: §b32.0§f §7(Vanilla: 8.0)§f",
"make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER.tooltip": "The time it takes for a bubble to pop underwater. \nBy default, this is set longer than in vanilla to allow bubbles to reach the water surface. \nDefault: §b32§f §7(Vanilla: 8)§f",
"make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED": "Enable Biome Dependent Bubble Colors",
"make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED.tooltip": "Tints all bubble types depending on the water color. \nDefault: §aYes§f",
"make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED.tooltip": "Tints all bubble types depending on the water color. \nDefault: §aON§f",
"make_bubbles_pop.midnightconfig.BIOME_COLOR_INTENSITY": " └ Bubble Biome Color Intensity",
"make_bubbles_pop.midnightconfig.BIOME_COLOR_INTENSITY.tooltip": "Default: §b65%§f",
"make_bubbles_pop.midnightconfig.CHEST_BUBBLES_ENABLED": "Enable Chest Bubbles",
"make_bubbles_pop.midnightconfig.CHEST_BUBBLES_ENABLED.tooltip": "Default: §aYes§f \n§dℹ Note:§f Make sure to disable this or Effective's implementation if Effective is installed.",
"make_bubbles_pop.midnightconfig.CHEST_BUBBLES_ENABLED.tooltip": "Default: §aON§f \n§dℹ Note:§f Make sure to disable this or Effective's implementation if Effective is installed.",
"make_bubbles_pop.midnightconfig.BARREL_BUBBLES_ENABLED": "Enable Barrel Bubbles",
"make_bubbles_pop.midnightconfig.BARREL_BUBBLES_ENABLED.tooltip": "Default: §aYes§f",
"make_bubbles_pop.midnightconfig.BARREL_BUBBLES_ENABLED.tooltip": "Default: §aON§f",
"make_bubbles_pop.midnightconfig.CONTAINER_SOUND_ENABLED": " └ Enable sound when opening chests or barrels underwater",
"make_bubbles_pop.midnightconfig.CONTAINER_SOUND_ENABLED.tooltip": "Default: §aYes§f",
"make_bubbles_pop.midnightconfig.CONTAINER_SOUND_ENABLED.tooltip": "Default: §aON§f",
"make_bubbles_pop.midnightconfig.EXPLOSION_BUBBLES_ENABLED": "Enable Explosion Bubbles",
"make_bubbles_pop.midnightconfig.EXPLOSION_BUBBLES_ENABLED.tooltip": "Default: §aYes§f \n§dℹ Note:§f Make sure to disable this or Explosive Enhancement's implementation if Explosive Enhancement is installed."
"make_bubbles_pop.midnightconfig.EXPLOSION_BUBBLES_ENABLED.tooltip": "Default: §aON§f \n§dℹ Note:§f Make sure to disable this or Explosive Enhancement's implementation if Explosive Enhancement is installed."
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED": "버블 물리학 활성화",
"make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED.tooltip": "블록이나 엔티티와 충돌할 때 개선된 버블 물리학을 활성화합니다. \n기본값: §a예§f \n§dℹ 주의:§f 이 설정은 소울 샌드나 마그마 블록에서 생성된 버블에는 현재 작동하지 않습니다.",
"make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER": " └ 평균 버블 입자 수명",
"make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER.tooltip": "버블이 물속에서 터지는데 걸리는 시간. \n기본값은 버블이 물 표면에 도달할 수 있도록 바닐라보다 길게 설정되어 있습니다. \n기본값: §b32.0§f §7(바닐라: 8.0)§f",
"make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER.tooltip": "버블이 물속에서 터지는데 걸리는 시간. \n기본값은 버블이 물 표면에 도달할 수 있도록 바닐라보다 길게 설정되어 있습니다. \n기본값: §b32§f §7(바닐라: 8)§f",
"make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED": "생물군계에 따른 버블 색상 활성화",
"make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED.tooltip": "물 색상에 따라 모든 버블 종류에 색조를 입힙니다. \n기본값: §a예§f",
"make_bubbles_pop.midnightconfig.BIOME_COLOR_INTENSITY": " └ 버블 생물군계 색상 강도",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.tschipcraft.make_bubbles_pop.MakeBubblesPop;
Expand All @@ -13,7 +15,6 @@
@Mod(MakeBubblesPop.MOD_ID)
public class MakeBubblesPopForge {

// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger();

public static final boolean MIDNIGHTLIB_INSTALLED = ModList.get().isLoaded("midnightlib");
Expand All @@ -27,6 +28,9 @@ public MakeBubblesPopForge() {

// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);

// Register config
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, MakeBubblesPopForgeConfig.SPEC);
}

private void setup(final FMLCommonSetupEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package net.tschipcraft.forge;

import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import net.tschipcraft.make_bubbles_pop.MakeBubblesPop;
import net.tschipcraft.make_bubbles_pop.MakeBubblesPopConfig;

@Mod.EventBusSubscriber(modid = MakeBubblesPop.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class MakeBubblesPopForgeConfig extends MakeBubblesPopConfig {

private MakeBubblesPopForgeConfig() {
throw new IllegalStateException("Config class cannot be instantiated");
}

private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();

private static final ForgeConfigSpec.BooleanValue POP_PARTICLE_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.POP_PARTICLE_ENABLED")
.comment("Default: true")
.define("POP_PARTICLE_ENABLED", true);

private static final ForgeConfigSpec.IntValue BUBBLE_POP_VOLUME_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BUBBLE_POP_VOLUME")
.comment("Default: 10")
.defineInRange("BUBBLE_POP_VOLUME", 10, 0, 100);

private static final ForgeConfigSpec.BooleanValue POPPED_BUBBLES_MAINTAIN_VELOCITY_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.POPPED_BUBBLES_MAINTAIN_VELOCITY")
.comment("If enabled, popped bubbles will maintain their velocity. Default: false")
.define("POPPED_BUBBLES_MAINTAIN_VELOCITY", false);

private static final ForgeConfigSpec.BooleanValue BUBBLE_PHYSICS_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED")
.comment("If enabled, bubbles will be affected by physics when colliding with blocks or entities. Default: true")
.define("BUBBLE_PHYSICS_ENABLED", true);

private static final ForgeConfigSpec.IntValue BUBBLE_LIFETIME_MULTIPLIER_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER")
.comment("The time it takes for a bubble to pop underwater. By default, this is set longer than in vanilla to allow bubbles to reach the water surface. Default: 32 (Vanilla: 8)")
.defineInRange("BUBBLE_LIFETIME_MULTIPLIER", 32, 1, 100);

private static final ForgeConfigSpec.BooleanValue BIOME_COLORS_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED")
.comment("If enabled, bubbles will have a color based on the biome they are in. Default: true")
.define("BIOME_COLORS_ENABLED", true);

private static final ForgeConfigSpec.IntValue BIOME_COLOR_INTENSITY_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BIOME_COLOR_INTENSITY")
.comment("Default: 65")
.defineInRange("BIOME_COLOR_INTENSITY", 65, 0, 100);

private static final ForgeConfigSpec.BooleanValue CHEST_BUBBLES_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.CHEST_BUBBLES_ENABLED")
.comment("If enabled, bubbles will appear when opening chests underwater. Default: true")
.define("CHEST_BUBBLES_ENABLED", true);

private static final ForgeConfigSpec.BooleanValue BARREL_BUBBLES_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BARREL_BUBBLES_ENABLED")
.comment("If enabled, bubbles will appear when opening barrels underwater. Default: true")
.define("BARREL_BUBBLES_ENABLED", true);

private static final ForgeConfigSpec.BooleanValue CONTAINER_SOUND_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.CONTAINER_SOUND_ENABLED")
.comment("If enabled, a sound will play when opening chests or barrels underwater. Default: true")
.define("CONTAINER_SOUND_ENABLED", true);

private static final ForgeConfigSpec.BooleanValue EXPLOSION_BUBBLES_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.EXPLOSION_BUBBLES_ENABLED")
.comment("If enabled, bubbles will appear when an explosion occurs underwater. Default: true")
.define("EXPLOSION_BUBBLES_ENABLED", true);

public static final ForgeConfigSpec SPEC = BUILDER.build();

@SubscribeEvent
static void onLoad(final ModConfigEvent event) {
MakeBubblesPopConfig.POP_PARTICLE_ENABLED = POP_PARTICLE_ENABLED_CONF.get();
MakeBubblesPopConfig.BUBBLE_POP_VOLUME = BUBBLE_POP_VOLUME_CONF.get() / 100.0F;
MakeBubblesPopConfig.POPPED_BUBBLES_MAINTAIN_VELOCITY = POPPED_BUBBLES_MAINTAIN_VELOCITY_CONF.get();
MakeBubblesPopConfig.BUBBLE_PHYSICS_ENABLED = BUBBLE_PHYSICS_ENABLED_CONF.get();
MakeBubblesPopConfig.BUBBLE_LIFETIME_MULTIPLIER = BUBBLE_LIFETIME_MULTIPLIER_CONF.get().doubleValue();
MakeBubblesPopConfig.BIOME_COLORS_ENABLED = BIOME_COLORS_ENABLED_CONF.get();
MakeBubblesPopConfig.BIOME_COLOR_INTENSITY = BIOME_COLOR_INTENSITY_CONF.get() / 100.0F;
MakeBubblesPopConfig.CHEST_BUBBLES_ENABLED = CHEST_BUBBLES_ENABLED_CONF.get();
MakeBubblesPopConfig.BARREL_BUBBLES_ENABLED = BARREL_BUBBLES_ENABLED_CONF.get();
MakeBubblesPopConfig.CONTAINER_SOUND_ENABLED = CONTAINER_SOUND_ENABLED_CONF.get();
MakeBubblesPopConfig.EXPLOSION_BUBBLES_ENABLED = EXPLOSION_BUBBLES_ENABLED_CONF.get();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package net.tschipcraft.neoforge;

import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import org.slf4j.Logger;

import com.mojang.logging.LogUtils;
Expand All @@ -19,6 +22,10 @@ public MakeBubblesPopNeoForge(IEventBus modEventBus, ModContainer modContainer)
// Call common setup
MakeBubblesPop.init();

// Register config
modContainer.registerConfig(ModConfig.Type.CLIENT, MakeBubblesPopNeoForgeConfig.SPEC);
modContainer.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);

LOGGER.info("Make Bubbles Pop by Tschipcraft initialized!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package net.tschipcraft.neoforge;

import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.event.config.ModConfigEvent;
import net.neoforged.neoforge.common.ModConfigSpec;
import net.tschipcraft.make_bubbles_pop.MakeBubblesPop;
import net.tschipcraft.make_bubbles_pop.MakeBubblesPopConfig;

@EventBusSubscriber(modid = MakeBubblesPop.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
public class MakeBubblesPopNeoForgeConfig {

private MakeBubblesPopNeoForgeConfig() {
throw new IllegalStateException("Config class cannot be instantiated");
}

private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();

private static final ModConfigSpec.BooleanValue POP_PARTICLE_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.POP_PARTICLE_ENABLED")
.comment("Default: true")
.define("POP_PARTICLE_ENABLED", true);

private static final ModConfigSpec.IntValue BUBBLE_POP_VOLUME_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BUBBLE_POP_VOLUME")
.comment("Default: 10")
.defineInRange("BUBBLE_POP_VOLUME", 10, 0, 100);

private static final ModConfigSpec.BooleanValue POPPED_BUBBLES_MAINTAIN_VELOCITY_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.POPPED_BUBBLES_MAINTAIN_VELOCITY")
.comment("If enabled, popped bubbles will maintain their velocity. Default: false")
.define("POPPED_BUBBLES_MAINTAIN_VELOCITY", false);

private static final ModConfigSpec.BooleanValue BUBBLE_PHYSICS_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED")
.comment("If enabled, bubbles will be affected by physics when colliding with blocks or entities. Default: true")
.define("BUBBLE_PHYSICS_ENABLED", true);

private static final ModConfigSpec.IntValue BUBBLE_LIFETIME_MULTIPLIER_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER")
.comment("The time it takes for a bubble to pop underwater. By default, this is set longer than in vanilla to allow bubbles to reach the water surface. Default: 32 (Vanilla: 8)")
.defineInRange("BUBBLE_LIFETIME_MULTIPLIER", 32, 1, 100);

private static final ModConfigSpec.BooleanValue BIOME_COLORS_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED")
.comment("If enabled, bubbles will have a color based on the biome they are in. Default: true")
.define("BIOME_COLORS_ENABLED", true);

private static final ModConfigSpec.IntValue BIOME_COLOR_INTENSITY_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BIOME_COLOR_INTENSITY")
.comment("Default: 65")
.defineInRange("BIOME_COLOR_INTENSITY", 65, 0, 100);

private static final ModConfigSpec.BooleanValue CHEST_BUBBLES_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.CHEST_BUBBLES_ENABLED")
.comment("If enabled, bubbles will appear when opening chests underwater. Default: true")
.define("CHEST_BUBBLES_ENABLED", true);

private static final ModConfigSpec.BooleanValue BARREL_BUBBLES_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.BARREL_BUBBLES_ENABLED")
.comment("If enabled, bubbles will appear when opening barrels underwater. Default: true")
.define("BARREL_BUBBLES_ENABLED", true);

private static final ModConfigSpec.BooleanValue CONTAINER_SOUND_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.CONTAINER_SOUND_ENABLED")
.comment("If enabled, a sound will play when opening chests or barrels underwater. Default: true")
.define("CONTAINER_SOUND_ENABLED", true);

private static final ModConfigSpec.BooleanValue EXPLOSION_BUBBLES_ENABLED_CONF = BUILDER
.translation("make_bubbles_pop.midnightconfig.EXPLOSION_BUBBLES_ENABLED")
.comment("If enabled, bubbles will appear when an explosion occurs underwater. Default: true")
.define("EXPLOSION_BUBBLES_ENABLED", true);

public static final ModConfigSpec SPEC = BUILDER.build();

@SubscribeEvent
static void onLoad(final ModConfigEvent event) {
MakeBubblesPopConfig.POP_PARTICLE_ENABLED = POP_PARTICLE_ENABLED_CONF.get();
MakeBubblesPopConfig.BUBBLE_POP_VOLUME = BUBBLE_POP_VOLUME_CONF.get() / 100.0F;
MakeBubblesPopConfig.POPPED_BUBBLES_MAINTAIN_VELOCITY = POPPED_BUBBLES_MAINTAIN_VELOCITY_CONF.get();
MakeBubblesPopConfig.BUBBLE_PHYSICS_ENABLED = BUBBLE_PHYSICS_ENABLED_CONF.get();
MakeBubblesPopConfig.BUBBLE_LIFETIME_MULTIPLIER = BUBBLE_LIFETIME_MULTIPLIER_CONF.get().doubleValue();
MakeBubblesPopConfig.BIOME_COLORS_ENABLED = BIOME_COLORS_ENABLED_CONF.get();
MakeBubblesPopConfig.BIOME_COLOR_INTENSITY = BIOME_COLOR_INTENSITY_CONF.get() / 100.0F;
MakeBubblesPopConfig.CHEST_BUBBLES_ENABLED = CHEST_BUBBLES_ENABLED_CONF.get();
MakeBubblesPopConfig.BARREL_BUBBLES_ENABLED = BARREL_BUBBLES_ENABLED_CONF.get();
MakeBubblesPopConfig.CONTAINER_SOUND_ENABLED = CONTAINER_SOUND_ENABLED_CONF.get();
MakeBubblesPopConfig.EXPLOSION_BUBBLES_ENABLED = EXPLOSION_BUBBLES_ENABLED_CONF.get();
}

}

0 comments on commit a8cc4c2

Please sign in to comment.