Skip to content

Commit

Permalink
Add YACL support
Browse files Browse the repository at this point in the history
- Switched from MidnightLib to the Yet Another Config Lib config API for Fabric&Quilt
- Added support for YACL config screen rendering for NeoForge
  • Loading branch information
Tschipcraft committed Jan 4, 2025
1 parent a8cc4c2 commit b5305a8
Show file tree
Hide file tree
Showing 16 changed files with 353 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/archloom' }}
add-job-summary: 'always' # maybe change to error only?
- name: Make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
Expand Down
38 changes: 6 additions & 32 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
- **Support for Minecraft 1.21** ⚔️ (closes [#13](https://github.com/Tschipcraft/make_bubbles_pop/issues/13), [#14](https://github.com/Tschipcraft/make_bubbles_pop/issues/14), [#15](https://github.com/Tschipcraft/make_bubbles_pop/issues/15))
- **Added config file and settings menu when installed alongside [MidnightLib](https://modrinth.com/mod/midnightlib)** (closes [#4](https://github.com/Tschipcraft/make_bubbles_pop/issues/4))
<details>
<summary>🔎 In game screenshot</summary>
<img src="demo/settings.png" alt="Ingame screenshot of the settings menu">
</details>
- **Added entity interaction physics to bubbles** (configurable)
<details>
<summary>🔎 In game demo</summary>
<video src="demo/bubble_entity_interactions.mp4" autoplay loop muted>Your browser does not support the video tag or the video doesn't exist anymore.</video>
</details>
- **Added biome dependent tint to all bubble types** (configurable)
<details>
<summary>🔎 In game screenshot</summary>
<img src="demo/bubble_tints.png" alt="Ingame screenshot of the bubble tints">
</details>
- **Fixed barrels opened by other players on servers not emitting bubbles** (closes [#11](https://github.com/Tschipcraft/make_bubbles_pop/issues/11)) (Thanks @AViewFromTheTop)
- Adjusted current down bubbles to pop on top of magma blocks rather than inside them (closes [#9](https://github.com/Tschipcraft/make_bubbles_pop/issues/9))
<details>
<summary>🔎 In game demo</summary>
<video src="demo/overhauled_magma_block_bubbles-v0.3.0.mp4" autoplay loop muted>Your browser does not support the video tag or the video doesn't exist anymore.</video>
</details>
- Added varied pitch and volume to bubble pop and bubble swirl sounds (closes [#8](https://github.com/Tschipcraft/make_bubbles_pop/issues/8)) (Thanks @AViewFromTheTop)
- Barrel bubbling is now reliable on the client and will no longer bubble when a chunk with an already opened Barrel is loaded (Thanks @AViewFromTheTop)
- Fixed checking incorrect side of barrels for bubble particles
- Changed the default behavior to not maintain bubble particle velocity when popping (configurable) (Thanks @AViewFromTheTop)
- Tweaked explosion bubbles and used better variable names
- Restructured bubble particle logic and used better variable types
- Adjusted barrel bubble spawn locations
- Moved bubble pop logic to a separate utility class to reduce code duplication
- Simplified water checks to use the already provided helper function in world or level
- Fixed literal new line in fabric.mod.json after building (closes [#12](https://github.com/Tschipcraft/make_bubbles_pop/issues/12))
- **Native NeoForge support** 🦊
- Switched from using MidnightLib to Yet Another Config Library for configuration
- Added support for the native NeoForge&Forge config system
- Switched to Architectury Loom in favor of a combined codebase and native NeoForge support
- Lowered mixin defaultRequire to 0 to avoid crashes even when mixins fail to apply
- Added South Korean language support (Thanks @Merhaf)
16 changes: 15 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ subprojects {
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
name "modrinth"
name "Modrinth Maven"
url "https://api.modrinth.com/maven"
}
maven {
name 'Xander Maven'
url 'https://maven.isxander.dev/releases'
}
maven {
name = "Terraformers Maven"
url = "https://maven.terraformersmc.com/"
}
}

dependencies {
Expand All @@ -41,6 +49,12 @@ subprojects {
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
}

// YACL
modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}"

// Mod Menu
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public final class MakeBubblesPop {

public static final String MOD_ID = "make_bubbles_pop";

public static final boolean MIDNIGHTLIB_INSTALLED = false;
public static final boolean MIDNIGHTLIB_INSTALLED = true;

public static void init() {
// Write common init code here.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package net.tschipcraft.make_bubbles_pop;

/**
* Main value holder config class for Make Bubbles Pop. Actual values are set in the respective platform-specific config classes.
*/
public class MakeBubblesPopConfig {

private MakeBubblesPopConfig() {
throw new IllegalStateException("Config class cannot be instantiated");
throw new IllegalStateException("Main value holder config class cannot be instantiated");
}

public static boolean POP_PARTICLE_ENABLED = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package net.tschipcraft.make_bubbles_pop.config;

import dev.isxander.yacl3.api.YetAnotherConfigLib;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.DoubleSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
import dev.isxander.yacl3.api.controller.ValueFormatter;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
import net.tschipcraft.make_bubbles_pop.MakeBubblesPopConfig;

public class ConfigScreen {

/**
* Create the config screen for Make Bubbles Pop using Yet Another Config Lib.
*
* @param parent The parent screen
* @param config The config handler (Can be either a new PlatformConfig or a direct MakeBubblesPopConfig implementing PlatformConfig)
* @return The config screen
*/
public static Screen getScreen(Screen parent, PlatformConfig config) {
// Reload config from file before opening the screen
config.load();

// Create options
var POP_PARTICLE_ENABLED = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.POP_PARTICLE_ENABLED"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.POP_PARTICLE_ENABLED.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(true, () -> MakeBubblesPopConfig.POP_PARTICLE_ENABLED, newVal -> MakeBubblesPopConfig.POP_PARTICLE_ENABLED = newVal)
.build();

var BUBBLE_POP_VOLUME = Option.<Float>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.BUBBLE_POP_VOLUME"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.BUBBLE_POP_VOLUME.tooltip")))
.customController(opt -> FloatSliderControllerBuilder.create(opt).range(0F, 1.0F).step(0.01F).formatValue(new ValueFormatter<Float>() {
@Override
public Text format(Float aFloat) {
// Format as percentage
return Text.of(String.format("%.0f%%", aFloat * 100));
}
}).build())
.binding(0.1F, () -> MakeBubblesPopConfig.BUBBLE_POP_VOLUME, newVal -> MakeBubblesPopConfig.BUBBLE_POP_VOLUME = newVal)
.build();

var POPPED_BUBBLES_MAINTAIN_VELOCITY = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.POPPED_BUBBLES_MAINTAIN_VELOCITY"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.POPPED_BUBBLES_MAINTAIN_VELOCITY.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(false, () -> MakeBubblesPopConfig.POPPED_BUBBLES_MAINTAIN_VELOCITY, newVal -> MakeBubblesPopConfig.POPPED_BUBBLES_MAINTAIN_VELOCITY = newVal)
.build();

var BUBBLE_PHYSICS_ENABLED = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.BUBBLE_PHYSICS_ENABLED.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(true, () -> MakeBubblesPopConfig.BUBBLE_PHYSICS_ENABLED, newVal -> MakeBubblesPopConfig.BUBBLE_PHYSICS_ENABLED = newVal)
.build();

var BUBBLE_LIFETIME_MULTIPLIER = Option.<Double>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.BUBBLE_LIFETIME_MULTIPLIER.tooltip")))
.customController(opt -> DoubleSliderControllerBuilder.create(opt).range(1D, 100D).step(0.5D).build())
.binding(32D, () -> MakeBubblesPopConfig.BUBBLE_LIFETIME_MULTIPLIER, newVal -> MakeBubblesPopConfig.BUBBLE_LIFETIME_MULTIPLIER = newVal)
.build();

var BIOME_COLORS_ENABLED = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.BIOME_COLORS_ENABLED.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(true, () -> MakeBubblesPopConfig.BIOME_COLORS_ENABLED, newVal -> MakeBubblesPopConfig.BIOME_COLORS_ENABLED = newVal)
.build();

var BIOME_COLOR_INTENSITY = Option.<Float>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.BIOME_COLOR_INTENSITY"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.BIOME_COLOR_INTENSITY.tooltip")))
.customController(opt -> FloatSliderControllerBuilder.create(opt).range(0F, 1.0F).step(0.01F).formatValue(new ValueFormatter<Float>() {
@Override
public Text format(Float aFloat) {
// Format as percentage
return Text.of(String.format("%.0f%%", aFloat * 100));
}
}).build())
.binding(0.65F, () -> MakeBubblesPopConfig.BIOME_COLOR_INTENSITY, newVal -> MakeBubblesPopConfig.BIOME_COLOR_INTENSITY = newVal)
.build();

var CHEST_BUBBLES_ENABLED = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.CHEST_BUBBLES_ENABLED"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.CHEST_BUBBLES_ENABLED.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(true, () -> MakeBubblesPopConfig.CHEST_BUBBLES_ENABLED, newVal -> MakeBubblesPopConfig.CHEST_BUBBLES_ENABLED = newVal)
.build();

var BARREL_BUBBLES_ENABLED = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.BARREL_BUBBLES_ENABLED"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.BARREL_BUBBLES_ENABLED.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(true, () -> MakeBubblesPopConfig.BARREL_BUBBLES_ENABLED, newVal -> MakeBubblesPopConfig.BARREL_BUBBLES_ENABLED = newVal)
.build();

var CONTAINER_SOUND_ENABLED = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.CONTAINER_SOUND_ENABLED"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.CONTAINER_SOUND_ENABLED.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(true, () -> MakeBubblesPopConfig.CONTAINER_SOUND_ENABLED, newVal -> MakeBubblesPopConfig.CONTAINER_SOUND_ENABLED = newVal)
.build();

var EXPLOSION_BUBBLES_ENABLED = Option.<Boolean>createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.EXPLOSION_BUBBLES_ENABLED"))
.description(OptionDescription.of(Text.translatable("make_bubbles_pop.midnightconfig.EXPLOSION_BUBBLES_ENABLED.tooltip")))
.controller(TickBoxControllerBuilder::create)
.binding(true, () -> MakeBubblesPopConfig.EXPLOSION_BUBBLES_ENABLED, newVal -> MakeBubblesPopConfig.EXPLOSION_BUBBLES_ENABLED = newVal)
.build();

// Build screen
return YetAnotherConfigLib.createBuilder()
.title(Text.translatable("make_bubbles_pop.midnightconfig.title"))
.category(ConfigCategory.createBuilder()
.name(Text.translatable("make_bubbles_pop.midnightconfig.title"))
// Add options
.option(POP_PARTICLE_ENABLED)
.option(BUBBLE_POP_VOLUME)
.option(POPPED_BUBBLES_MAINTAIN_VELOCITY)
.option(BUBBLE_PHYSICS_ENABLED)
.option(BUBBLE_LIFETIME_MULTIPLIER)
.option(BIOME_COLORS_ENABLED)
.option(BIOME_COLOR_INTENSITY)
.option(CHEST_BUBBLES_ENABLED)
.option(BARREL_BUBBLES_ENABLED)
.option(CONTAINER_SOUND_ENABLED)
.option(EXPLOSION_BUBBLES_ENABLED)
.build())
.save(config::save) // Link save button to config save method
.build()
.generateScreen(parent);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.tschipcraft.make_bubbles_pop.config;

/**
* Interface used for passing platform-specific config classes to ConfigScreen.getScreen().
*/
public interface PlatformConfig {

void load();

void save();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"modmenu.summaryTranslation.make_bubbles_pop": "Makes bubble particles pop and lets them rise to the water surface.",
"make_bubbles_pop.yacl.missing": "Yet Another Config Lib is not installed!",
"make_bubbles_pop.yacl.missing.description": "Make Bubbles Pop for Fabric&Quilt requires Yet Another Config Lib to be installed for configuration. Would you like to download it now?",

"make_bubbles_pop.midnightconfig.title": "Make Bubbles Pop Configuration",
"make_bubbles_pop.midnightconfig.empty": "",
"make_bubbles_pop.midnightconfig.additional_features": "Additional Features",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.tschipcraft.make_bubbles_pop.MakeBubblesPop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MakeBubblesPopFabric implements ModInitializer {

public static final Logger LOGGER = LoggerFactory.getLogger("make_bubbles_pop");
public static final Logger LOGGER = LoggerFactory.getLogger(MakeBubblesPop.MOD_ID);

public static final boolean MIDNIGHTLIB_INSTALLED = FabricLoader.getInstance().isModLoaded("midnightlib");
public static final boolean YACL_INSTALLED = FabricLoader.getInstance().isModLoaded("yet_another_config_lib_v3");

@Override
public void onInitialize() {
if (MIDNIGHTLIB_INSTALLED) {
// Use MidnightLib features
LOGGER.info("MidnightLib detected!");
//MakeBubblesPopConfig.init(LOGGER.getName(), MakeBubblesPopConfig.class);
if (YACL_INSTALLED) {
LOGGER.info("Yet Another Config Lib detected! Using YACL config system.");
MakeBubblesPopFabricConfig.HANDLER.instance().load();
}

LOGGER.info("Make Bubbles Pop by Tschipcraft initialized!");
net.tschipcraft.make_bubbles_pop.MakeBubblesPop.init();
MakeBubblesPop.init();
}

}
Loading

0 comments on commit b5305a8

Please sign in to comment.