From a296a14cc00cde12796e5bc58b26c61567ee511d Mon Sep 17 00:00:00 2001 From: Sylv Date: Mon, 4 Nov 2024 17:31:15 -0500 Subject: [PATCH] feat(day 16): Witchery nature & "Super Secret Settings" --- gradle.properties | 2 +- .../sylv/legacy_landscape/ClientConfig.java | 27 ++++++++ .../gay/sylv/legacy_landscape/Config.java | 63 ------------------- .../legacy_landscape/LegacyLandscape.java | 8 ++- .../client/SuperSecretSetting.java | 6 ++ .../client/util/RenderUtil.java | 5 +- .../assets/legacy_landscape/lang/en_us.json | 7 ++- .../nature/ephemeral_fabric_of_reality.json | 11 ++++ .../nature/fabric_of_reality.json | 11 ++++ .../nature/flowing_reality.json | 11 ++++ .../nature/intertwined_reality.json | 11 ++++ .../nature/patched_fabric_of_reality.json | 11 ++++ .../block/ephemeral_fabric_of_reality.json | 6 ++ .../tags/block/fabric_of_reality.json | 6 ++ .../tags/block/flowing_reality.json | 6 ++ .../tags/block/intertwined_reality.json | 6 ++ .../tags/block/patched_fabric_of_reality.json | 6 ++ 17 files changed, 134 insertions(+), 69 deletions(-) create mode 100644 src/main/java/gay/sylv/legacy_landscape/ClientConfig.java delete mode 100644 src/main/java/gay/sylv/legacy_landscape/Config.java create mode 100644 src/main/java/gay/sylv/legacy_landscape/client/SuperSecretSetting.java create mode 100644 src/main/resources/data/legacy_landscape/nature/ephemeral_fabric_of_reality.json create mode 100644 src/main/resources/data/legacy_landscape/nature/fabric_of_reality.json create mode 100644 src/main/resources/data/legacy_landscape/nature/flowing_reality.json create mode 100644 src/main/resources/data/legacy_landscape/nature/intertwined_reality.json create mode 100644 src/main/resources/data/legacy_landscape/nature/patched_fabric_of_reality.json create mode 100644 src/main/resources/data/legacy_landscape/tags/block/ephemeral_fabric_of_reality.json create mode 100644 src/main/resources/data/legacy_landscape/tags/block/fabric_of_reality.json create mode 100644 src/main/resources/data/legacy_landscape/tags/block/flowing_reality.json create mode 100644 src/main/resources/data/legacy_landscape/tags/block/intertwined_reality.json create mode 100644 src/main/resources/data/legacy_landscape/tags/block/patched_fabric_of_reality.json diff --git a/gradle.properties b/gradle.properties index 7c501ba..ec5af1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ mod_name=Legacy Landscape # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=EUPL-1.2 # The mod version. See https://semver.org/ -mod_version=0.4.1+1.21.1 +mod_version=0.5.0+1.21.1 # 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 diff --git a/src/main/java/gay/sylv/legacy_landscape/ClientConfig.java b/src/main/java/gay/sylv/legacy_landscape/ClientConfig.java new file mode 100644 index 0000000..46c74fd --- /dev/null +++ b/src/main/java/gay/sylv/legacy_landscape/ClientConfig.java @@ -0,0 +1,27 @@ +package gay.sylv.legacy_landscape; + +import gay.sylv.legacy_landscape.client.SuperSecretSetting; +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; + +@EventBusSubscriber(modid = LegacyLandscape.MOD_ID, bus = EventBusSubscriber.Bus.MOD) +public class ClientConfig { + private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder(); + + private static final ModConfigSpec.IntValue SUPER_SECRET_SETTINGS = BUILDER + .comment("Super secret settings to enhance your experience.") + .comment("Do not use this setting if you have photosensitive epilepsy or are otherwise sensitive to flashing lights.") + .defineInRange("superSecretSettings", 0, 0, SuperSecretSetting.values().length - 1); + + static final ModConfigSpec SPEC = BUILDER.build(); + + public static SuperSecretSetting superSecretSettings; + + @SubscribeEvent + static void onLoad(final ModConfigEvent event) + { + superSecretSettings = SuperSecretSetting.values()[SUPER_SECRET_SETTINGS.get()]; + } +} diff --git a/src/main/java/gay/sylv/legacy_landscape/Config.java b/src/main/java/gay/sylv/legacy_landscape/Config.java deleted file mode 100644 index 750ea28..0000000 --- a/src/main/java/gay/sylv/legacy_landscape/Config.java +++ /dev/null @@ -1,63 +0,0 @@ -package gay.sylv.legacy_landscape; - -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -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 java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -// An example config class. This is not required, but it's a good idea to have one to keep your config organized. -// Demonstrates how to use Neo's config APIs -@EventBusSubscriber(modid = LegacyLandscape.MOD_ID, bus = EventBusSubscriber.Bus.MOD) -public class Config -{ - private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder(); - - private static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER - .comment("Whether to log the dirt block on common setup") - .define("logDirtBlock", true); - - private static final ModConfigSpec.IntValue MAGIC_NUMBER = BUILDER - .comment("A magic number") - .defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE); - - public static final ModConfigSpec.ConfigValue MAGIC_NUMBER_INTRODUCTION = BUILDER - .comment("What you want the introduction message to be for the magic number") - .define("magicNumberIntroduction", "The magic number is... "); - - // a list of strings that are treated as resource locations for items - private static final ModConfigSpec.ConfigValue> ITEM_STRINGS = BUILDER - .comment("A list of items to log on common setup.") - .defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName); - - static final ModConfigSpec SPEC = BUILDER.build(); - - public static boolean logDirtBlock; - public static int magicNumber; - public static String magicNumberIntroduction; - public static Set items; - - private static boolean validateItemName(final Object obj) - { - return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(ResourceLocation.parse(itemName)); - } - - @SubscribeEvent - static void onLoad(final ModConfigEvent event) - { - logDirtBlock = LOG_DIRT_BLOCK.get(); - magicNumber = MAGIC_NUMBER.get(); - magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get(); - - // convert the list of strings into a set of items - items = ITEM_STRINGS.get().stream() - .map(itemName -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(itemName))) - .collect(Collectors.toSet()); - } -} diff --git a/src/main/java/gay/sylv/legacy_landscape/LegacyLandscape.java b/src/main/java/gay/sylv/legacy_landscape/LegacyLandscape.java index 96a83e6..4e404a8 100644 --- a/src/main/java/gay/sylv/legacy_landscape/LegacyLandscape.java +++ b/src/main/java/gay/sylv/legacy_landscape/LegacyLandscape.java @@ -18,6 +18,8 @@ import net.neoforged.fml.common.Mod; import net.neoforged.fml.config.ModConfig; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.neoforge.client.gui.ConfigurationScreen; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -35,6 +37,9 @@ public final class LegacyLandscape { // The constructor for the mod class is the first code that is run when your mod is loaded. // FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically. public LegacyLandscape(IEventBus modBus, ModContainer modContainer) { + modContainer.registerConfig(ModConfig.Type.CLIENT, ClientConfig.SPEC); + modContainer.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new); + LegacySounds.SOUNDS.register(modBus); LegacyComponents.DATA_COMPONENTS.register(modBus); LegacyEffects.MOB_EFFECTS.register(modBus); @@ -47,9 +52,6 @@ public LegacyLandscape(IEventBus modBus, ModContainer modContainer) { LegacyRecipes.TYPES.register(modBus); LegacyRecipes.SERIALIZERS.register(modBus); modBus.addListener(this::commonSetup); - - // Register our mod's ModConfigSpec so that FML can create and load the config file for us - modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC); } public static ResourceLocation id(String path) { diff --git a/src/main/java/gay/sylv/legacy_landscape/client/SuperSecretSetting.java b/src/main/java/gay/sylv/legacy_landscape/client/SuperSecretSetting.java new file mode 100644 index 0000000..e3ca777 --- /dev/null +++ b/src/main/java/gay/sylv/legacy_landscape/client/SuperSecretSetting.java @@ -0,0 +1,6 @@ +package gay.sylv.legacy_landscape.client; + +public enum SuperSecretSetting { + NONE, + BLUR +} diff --git a/src/main/java/gay/sylv/legacy_landscape/client/util/RenderUtil.java b/src/main/java/gay/sylv/legacy_landscape/client/util/RenderUtil.java index 45ddad8..b3e3706 100644 --- a/src/main/java/gay/sylv/legacy_landscape/client/util/RenderUtil.java +++ b/src/main/java/gay/sylv/legacy_landscape/client/util/RenderUtil.java @@ -1,6 +1,8 @@ package gay.sylv.legacy_landscape.client.util; +import gay.sylv.legacy_landscape.ClientConfig; import gay.sylv.legacy_landscape.client.HackedRenderSystem; +import gay.sylv.legacy_landscape.client.SuperSecretSetting; import gay.sylv.legacy_landscape.mixin.client.Accessor_CompositeRenderType; import gay.sylv.legacy_landscape.mixin.client.Accessor_CompositeState; import gay.sylv.legacy_landscape.mixin.client.Accessor_TextureStateShard; @@ -54,7 +56,8 @@ public static void setLegacyTextures(RenderType renderType) { assert compositeState != null; Accessor_TextureStateShard textureState = (Accessor_TextureStateShard) (compositeState.getTextureState()); if (textureState.getTexture().isPresent()) { - HackedRenderSystem.setShaderTexture(0, textureState.getTexture().get(), textureState.isBlur(), textureState.isMipmap()); + boolean blurSetting = ClientConfig.superSecretSettings == SuperSecretSetting.BLUR; + HackedRenderSystem.setShaderTexture(0, textureState.getTexture().get(), textureState.isBlur() || blurSetting, textureState.isMipmap()); } } } diff --git a/src/main/resources/assets/legacy_landscape/lang/en_us.json b/src/main/resources/assets/legacy_landscape/lang/en_us.json index d2f9979..9b75268 100644 --- a/src/main/resources/assets/legacy_landscape/lang/en_us.json +++ b/src/main/resources/assets/legacy_landscape/lang/en_us.json @@ -32,5 +32,10 @@ "commands.legacy_landscape.vanish.cannot_be_applied": "Cannot apply Evanescence to entity.", "commands.legacy_landscape.vanish.cannot_be_removed": "Cannot remove Evanescence from entity.", "commands.legacy_landscape.vanish.applied": "vanish: Applied Evanescence effect to entity.", - "commands.legacy_landscape.vanish.removed": "vanish: Removed Evanescence effect from entity." + "commands.legacy_landscape.vanish.removed": "vanish: Removed Evanescence effect from entity.", + "legacy_landscape.configuration.superSecretSettings": "Super Secret Settings", + "legacy_landscape.configuration.section.legacy.landscape.client.toml": "legacy_landscape-client.toml", + "legacy_landscape.configuration.section.legacy.landscape.client.toml.title": "Legacy Landscape Client TOML", + "legacy_landscape.configuration.title": "Legacy Landscape", + "legacy_landscape.configuration.superSecretSettings.tooltip": "Super secret settings to enhance your experience.\nDo not use this setting if you have photosensitive epilepsy or are otherwise sensitive to flashing lights." } diff --git a/src/main/resources/data/legacy_landscape/nature/ephemeral_fabric_of_reality.json b/src/main/resources/data/legacy_landscape/nature/ephemeral_fabric_of_reality.json new file mode 100644 index 0000000..e1476d6 --- /dev/null +++ b/src/main/resources/data/legacy_landscape/nature/ephemeral_fabric_of_reality.json @@ -0,0 +1,11 @@ +{ + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "witchery" + } + ], + "block": "#legacy_landscape:ephemeral_fabric_of_reality", + "power": 1, + "limit": 800 +} diff --git a/src/main/resources/data/legacy_landscape/nature/fabric_of_reality.json b/src/main/resources/data/legacy_landscape/nature/fabric_of_reality.json new file mode 100644 index 0000000..b731503 --- /dev/null +++ b/src/main/resources/data/legacy_landscape/nature/fabric_of_reality.json @@ -0,0 +1,11 @@ +{ + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "witchery" + } + ], + "block": "#legacy_landscape:fabric_of_reality", + "power": 8, + "limit": 800 +} diff --git a/src/main/resources/data/legacy_landscape/nature/flowing_reality.json b/src/main/resources/data/legacy_landscape/nature/flowing_reality.json new file mode 100644 index 0000000..6b2c686 --- /dev/null +++ b/src/main/resources/data/legacy_landscape/nature/flowing_reality.json @@ -0,0 +1,11 @@ +{ + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "witchery" + } + ], + "block": "#legacy_landscape:flowing_reality", + "power": 32, + "limit": 800 +} diff --git a/src/main/resources/data/legacy_landscape/nature/intertwined_reality.json b/src/main/resources/data/legacy_landscape/nature/intertwined_reality.json new file mode 100644 index 0000000..a6622ac --- /dev/null +++ b/src/main/resources/data/legacy_landscape/nature/intertwined_reality.json @@ -0,0 +1,11 @@ +{ + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "witchery" + } + ], + "block": "#legacy_landscape:intertwined_reality", + "power": 12, + "limit": 800 +} diff --git a/src/main/resources/data/legacy_landscape/nature/patched_fabric_of_reality.json b/src/main/resources/data/legacy_landscape/nature/patched_fabric_of_reality.json new file mode 100644 index 0000000..6b49b55 --- /dev/null +++ b/src/main/resources/data/legacy_landscape/nature/patched_fabric_of_reality.json @@ -0,0 +1,11 @@ +{ + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "witchery" + } + ], + "block": "#legacy_landscape:patched_fabric_of_reality", + "power": 16, + "limit": 800 +} diff --git a/src/main/resources/data/legacy_landscape/tags/block/ephemeral_fabric_of_reality.json b/src/main/resources/data/legacy_landscape/tags/block/ephemeral_fabric_of_reality.json new file mode 100644 index 0000000..6b65821 --- /dev/null +++ b/src/main/resources/data/legacy_landscape/tags/block/ephemeral_fabric_of_reality.json @@ -0,0 +1,6 @@ +{ + "values": [ + "legacy_landscape:ephemeral_fabric_of_reality", + "legacy_landscape:inverted_ephemeral_fabric_of_reality" + ] +} diff --git a/src/main/resources/data/legacy_landscape/tags/block/fabric_of_reality.json b/src/main/resources/data/legacy_landscape/tags/block/fabric_of_reality.json new file mode 100644 index 0000000..ec6090d --- /dev/null +++ b/src/main/resources/data/legacy_landscape/tags/block/fabric_of_reality.json @@ -0,0 +1,6 @@ +{ + "values": [ + "legacy_landscape:fabric_of_reality", + "legacy_landscape:inverted_fabric_of_reality" + ] +} diff --git a/src/main/resources/data/legacy_landscape/tags/block/flowing_reality.json b/src/main/resources/data/legacy_landscape/tags/block/flowing_reality.json new file mode 100644 index 0000000..457b8a9 --- /dev/null +++ b/src/main/resources/data/legacy_landscape/tags/block/flowing_reality.json @@ -0,0 +1,6 @@ +{ + "values": [ + "legacy_landscape:flowing_reality", + "legacy_landscape:inverted_flowing_reality" + ] +} diff --git a/src/main/resources/data/legacy_landscape/tags/block/intertwined_reality.json b/src/main/resources/data/legacy_landscape/tags/block/intertwined_reality.json new file mode 100644 index 0000000..2585ec2 --- /dev/null +++ b/src/main/resources/data/legacy_landscape/tags/block/intertwined_reality.json @@ -0,0 +1,6 @@ +{ + "values": [ + "legacy_landscape:intertwined_reality", + "legacy_landscape:inverted_intertwined_reality" + ] +} diff --git a/src/main/resources/data/legacy_landscape/tags/block/patched_fabric_of_reality.json b/src/main/resources/data/legacy_landscape/tags/block/patched_fabric_of_reality.json new file mode 100644 index 0000000..465892c --- /dev/null +++ b/src/main/resources/data/legacy_landscape/tags/block/patched_fabric_of_reality.json @@ -0,0 +1,6 @@ +{ + "values": [ + "legacy_landscape:patched_fabric_of_reality", + "legacy_landscape:inverted_patched_fabric_of_reality" + ] +}