Skip to content

Commit

Permalink
feat: stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Jun 1, 2024
1 parent e12947a commit ae9e16d
Show file tree
Hide file tree
Showing 15 changed files with 343 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aether_version=1.20.4-1.4.1-neoforge
nitrogen_version=1.20.4-1.1.4-neoforge
cumulus_version=1.20.4-1.0.1-neoforge
curios_version=7.3.4
zenith_version=1.0.35
zenith_version=1.0.36
aeroblender_version=5271794
terrablender_version=1.20.4-3.3.0.12
terrablender_version_minimum=1.20.4-3.3.0.0
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/net/zepalesque/redux/Redux.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
import net.zepalesque.redux.data.gen.ReduxLootGen;
import net.zepalesque.redux.data.gen.ReduxRecipeGen;
import net.zepalesque.redux.data.gen.ReduxRegistrySets;
import net.zepalesque.redux.data.gen.tags.ReduxBiomeTagsGen;
import net.zepalesque.redux.data.gen.tags.ReduxBlockTagsGen;
import net.zepalesque.redux.data.gen.tags.ReduxItemTagsGen;
import net.zepalesque.redux.entity.ReduxEntities;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.tile.ReduxTiles;
import net.zepalesque.redux.world.biome.tint.ReduxBiomeTints;
import net.zepalesque.redux.world.feature.gen.ReduxFeatures;
import net.zepalesque.zenith.api.biometint.BiomeTints;
import net.zepalesque.zenith.api.blockset.AbstractStoneSet;
import net.zepalesque.zenith.api.blockset.AbstractWoodSet;
Expand Down Expand Up @@ -95,11 +97,12 @@ public Redux(IEventBus bus, Dist dist) {
ReduxEntities.ENTITIES.register(bus);
ReduxTiles.TILES.register(bus);
ReduxBiomeTints.TINTS.register(bus);
ReduxFeatures.FEATURES.register(bus);

ReduxConfigHandler.setup(bus);

ConfigCondition.registerSerializer("redux_server", new ConfigSerializer(ReduxConfig.SERVER::serialize, ReduxConfig.SERVER::deserialize));
ConfigCondition.registerSerializer("redux_common", new ConfigSerializer(ReduxConfig.COMMON::serialize, ReduxConfig.COMMON::deserialize));
ConfigCondition.registerSerializer(ReduxConfig.SERVER.serializerID(), new ConfigSerializer(ReduxConfig.SERVER::serialize, ReduxConfig.SERVER::deserialize));
ConfigCondition.registerSerializer(ReduxConfig.COMMON.serializerID(), new ConfigSerializer(ReduxConfig.COMMON::serialize, ReduxConfig.COMMON::deserialize));
}

private void commonSetup(final FMLCommonSetupEvent event) {
Expand Down Expand Up @@ -135,6 +138,7 @@ private void dataSetup(GatherDataEvent event) {
ReduxBlockTagsGen blockTags = new ReduxBlockTagsGen(packOutput, lookupProvider, fileHelper);
generator.addProvider(event.includeServer(), blockTags);
generator.addProvider(event.includeServer(), new ReduxItemTagsGen(packOutput, lookupProvider, blockTags.contentsGetter(), fileHelper));
generator.addProvider(event.includeServer(), new ReduxBiomeTagsGen(packOutput, lookupProvider, fileHelper));

// pack.mcmeta
generator.addProvider(true, new PackMetadataGenerator(packOutput).add(PackMetadataSection.TYPE, new PackMetadataSection(
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/net/zepalesque/redux/client/audio/ReduxMusic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.zepalesque.redux.client.audio;

import com.aetherteam.aether.client.AetherSoundEvents;
import net.minecraft.sounds.Music;

public class ReduxMusic {
public static final Music DEFAULT_AETHER_MUSIC = new Music(AetherSoundEvents.MUSIC_AETHER.getHolder().orElseThrow(), 12000, 24000, true);
// public static final Music REDUX_MENU = new Music(ReduxSoundEvents.REDUX_MENU.getHolder().orElseThrow(), 0, 0, true);

public static final int MUSIC_MIN = 1200;
public static final int MUSIC_MAX = 3600;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
public class DataSerializableConfig {

protected final ModConfigSpec spec;
protected final String id;

public DataSerializableConfig(ModConfigSpec spec) {
public DataSerializableConfig(ModConfigSpec spec, String id) {
this.spec = spec;
this.id = id;
}

public String serialize(ModConfigSpec.ConfigValue<Boolean> config) {
Expand All @@ -31,4 +33,8 @@ public ModConfigSpec.ConfigValue<Boolean> deserialize(String string) {
public ModConfigSpec spec() {
return spec;
}

public String serializerID() {
return this.id;
}
}
12 changes: 6 additions & 6 deletions src/main/java/net/zepalesque/redux/config/ReduxConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ public class ReduxConfig {

public static class Server extends DataSerializableConfig {

public final ModConfigSpec.ConfigValue<Boolean> placeholder;
public final ModConfigSpec.ConfigValue<Boolean> redux_sky_colors;

public Server(ModConfigSpec.Builder builder) {
super(SERVER_SPEC);
super(SERVER_SPEC, "redux_server");
builder.push("TODO");
placeholder = builder
.comment("Temporary placeholder config, used")
.define("Placeholder Config", true);
redux_sky_colors = builder
.comment("Use Redux's alternative sky colors for the Aether")
.define("Redux Sky Colors", true);
builder.pop();
}
}
Expand All @@ -24,7 +24,7 @@ public static class Common extends DataSerializableConfig {
public final ModConfigSpec.ConfigValue<Boolean> placeholder;

public Common(ModConfigSpec.Builder builder) {
super(COMMON_SPEC);
super(COMMON_SPEC, "redux_common");
builder.push("TODO");
placeholder = builder
.comment("Temporary placeholder config, used")
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/net/zepalesque/redux/data/ReduxTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ private static TagKey<EntityType<?>> tag(String name) {
}

public static class Biomes {


public static final TagKey<Biome> MODIFY_MUSIC = tag("should_modify_music");
// TODO: Biome-dependent skies
public static final TagKey<Biome> MODIFY_SKY_COLOR = tag("should_modify_sky_color");

public static final TagKey<Biome> HAS_SENTRITE = tag("has_sentrite");
public static final TagKey<Biome> HAS_CLOUDBED = tag("has_cloudbed");

private static TagKey<Biome> tag(String name) {
return TagKey.create(Registries.BIOME, Redux.loc(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.data.resource.ReduxBiomeModifiers;
import net.zepalesque.redux.data.resource.ReduxConditions;
import net.zepalesque.redux.data.resource.ReduxDensityFunctions;
import net.zepalesque.redux.data.resource.ReduxFeatureConfig;
import net.zepalesque.redux.data.resource.ReduxPlacements;
import net.zepalesque.zenith.Zenith;
Expand All @@ -25,6 +27,9 @@
public class ReduxRegistrySets extends DatapackBuiltinEntriesProvider {
public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.CONFIGURED_FEATURE, ReduxFeatureConfig::bootstrap)
.add(Registries.PLACED_FEATURE, ReduxPlacements::bootstrap)
.add(Registries.DENSITY_FUNCTION, ReduxDensityFunctions::bootstrap)
.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ReduxBiomeModifiers::bootstrap)
.add(Zenith.Keys.CONDITION, ReduxConditions::bootstrap);

public ReduxRegistrySets(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, String modid, String... otherIds) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.zepalesque.redux.data.gen.tags;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.BiomeTagsProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.zepalesque.redux.Redux;

import javax.annotation.Nullable;
import java.util.concurrent.CompletableFuture;

public class ReduxBiomeTagsGen extends BiomeTagsProvider {

public ReduxBiomeTagsGen(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, @Nullable ExistingFileHelper helper) {
super(output, registries, Redux.MODID, helper);
}

@SuppressWarnings("unchecked")
@Override
public void addTags(HolderLookup.Provider provider) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package net.zepalesque.redux.data.resource;

import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.neoforged.neoforge.common.world.BiomeModifier;
import net.neoforged.neoforge.common.world.BiomeModifiers;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.client.audio.ReduxMusic;
import net.zepalesque.redux.data.ReduxTags;
import net.zepalesque.zenith.Zenith;
import net.zepalesque.zenith.api.condition.Condition;
import net.zepalesque.zenith.util.codec.CodecPredicates;
import net.zepalesque.zenith.world.biome.modifier.MusicModifier;
import net.zepalesque.zenith.world.biome.modifier.SkyModifier;

import java.util.Optional;

public class ReduxBiomeModifiers {
public static final ResourceKey<BiomeModifier> ADD_CLOUDBED = createKey("add_cloudbed");
public static final ResourceKey<BiomeModifier> SKY_COLOR_AETHER = createKey("modify_sky_color");
public static final ResourceKey<BiomeModifier> MUSIC_MODIFY = createKey("modify_music");

private static ResourceKey<BiomeModifier> createKey(String name) {
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, Redux.loc(name));
}

public static void bootstrap(BootstapContext<BiomeModifier> context) {
HolderGetter<Biome> biomes = context.lookup(Registries.BIOME);
HolderGetter<ConfiguredWorldCarver<?>> carvers = context.lookup(Registries.CONFIGURED_CARVER);
HolderGetter<PlacedFeature> features = context.lookup(Registries.PLACED_FEATURE);
HolderGetter<Condition<?>> conditions = context.lookup(Zenith.Keys.CONDITION);

context.register(ADD_CLOUDBED, new BiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(ReduxTags.Biomes.HAS_CLOUDBED), HolderSet.direct(features.getOrThrow(ReduxPlacements.CLOUDBED)),
GenerationStep.Decoration.RAW_GENERATION));

context.register(SKY_COLOR_AETHER, new SkyModifier(biomes.getOrThrow(ReduxTags.Biomes.MODIFY_SKY_COLOR),
CodecPredicates.DualInt.of(12632319, 9671612), 0x9FA4DD, 0xBEC4E5, Optional.of(conditions.get(ReduxConditions.SKY_COLORS).orElseThrow())));

// TODO: MusicPredicate, with optional fields for each field of the Music class
context.register(MUSIC_MODIFY, new MusicModifier(biomes.getOrThrow(ReduxTags.Biomes.MODIFY_MUSIC),
Optional.empty(), Optional.of(CodecPredicates.DualInt.of(ReduxMusic.MUSIC_MIN, ReduxMusic.MUSIC_MAX)), Optional.of(false), Optional.empty(), Optional.empty(), Optional.empty()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.zepalesque.redux.config.ReduxConfig;
import net.zepalesque.zenith.Zenith;
import net.zepalesque.zenith.api.condition.Condition;
import net.zepalesque.zenith.api.condition.ConfigCondition;
import net.zepalesque.zenith.api.condition.ModLoadedCondition;

public class ReduxConditions {
Expand All @@ -13,11 +15,14 @@ public class ReduxConditions {
public static final ResourceKey<Condition<?>> LOST = createKey("lost_content");
public static final ResourceKey<Condition<?>> ANCIENT = createKey("ancient_aether");

public static final ResourceKey<Condition<?>> SKY_COLORS = createKey("sky_colors");

public static void bootstrap(BootstapContext<Condition<?>> context) {
context.register(DEEP, new ModLoadedCondition("deep_aether"));
context.register(GENESIS, new ModLoadedCondition("aether_genesis"));
context.register(LOST, new ModLoadedCondition("lost_aether_content"));
context.register(ANCIENT, new ModLoadedCondition("ancient_aether"));
context.register(SKY_COLORS, new ConfigCondition(ReduxConfig.SERVER.serializerID(), ReduxConfig.SERVER.redux_sky_colors));
}

private static ResourceKey<Condition<?>> createKey(String name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package net.zepalesque.redux.data.resource;

import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.levelgen.DensityFunction;
import net.minecraft.world.level.levelgen.DensityFunctions;
import net.minecraft.world.level.levelgen.synth.BlendedNoise;
import net.minecraft.world.level.levelgen.synth.NormalNoise;
import net.zepalesque.redux.Redux;
import net.zepalesque.zenith.world.density.PerlinNoiseFunction;

import java.util.Optional;

public class ReduxDensityFunctions {

public static final ResourceKey<DensityFunction> CLOUDBED_NOISE = createKey("cloudbed_noise");
public static final ResourceKey<DensityFunction> CLOUDBED_Y_OFFSET = createKey("cloudbed_y_offset");

public static void bootstrap(BootstapContext<DensityFunction> context) {
context.register(CLOUDBED_NOISE, DensityFunctions.mul(new PerlinNoiseFunction(new NormalNoise.NoiseParameters(0, 1, 1, 1, 1, 1, 1), 0.01D, 0.0D, 42), DensityFunctions.constant(1.5D)));

context.register(CLOUDBED_Y_OFFSET, DensityFunctions.mul(new PerlinNoiseFunction(new NormalNoise.NoiseParameters(0, 1, 1), 0.005D, 0.0D, 95), DensityFunctions.constant(1.5D)));

}

private static ResourceKey<DensityFunction> createKey(String name) {
return ResourceKey.create(Registries.DENSITY_FUNCTION, new ResourceLocation(Redux.MODID, name));
}

public static DensityFunction get(HolderGetter<DensityFunction> densityFunctions, ResourceKey<DensityFunction> key) {
return new DensityFunctions.HolderHolder(densityFunctions.getOrThrow(key));
}

public static DensityFunction get(RegistryAccess access, ResourceKey<DensityFunction> key) {
Optional<HolderLookup.RegistryLookup<DensityFunction>> optional = access.lookup(Registries.DENSITY_FUNCTION);
if (optional.isPresent()) {
HolderLookup.RegistryLookup<DensityFunction> lookup = optional.get();
return lookup.getOrThrow(key).value();

} else {
throw new NullPointerException("Optional value is not present!");
}
}

public static DensityFunction get(Level level, ResourceKey<DensityFunction> key) {
return level.registryAccess().registryOrThrow(Registries.DENSITY_FUNCTION).getOrThrow(key);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.random.SimpleWeightedRandomList;
import net.minecraft.util.valueproviders.ConstantInt;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.DensityFunction;
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
Expand All @@ -21,30 +24,47 @@
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.block.state.ReduxStates;
import net.zepalesque.redux.blockset.wood.ReduxWoodSets;
import net.zepalesque.redux.world.feature.gen.CloudbedFeature;
import net.zepalesque.redux.world.feature.gen.ReduxFeatures;

import java.util.function.Supplier;

public class ReduxFeatureConfig {

public static final ResourceKey<ConfiguredFeature<?, ?>> CRYSTAL_TREE_OVERRIDE = AetherConfiguredFeatures.CRYSTAL_TREE_CONFIGURATION;

public static final ResourceKey<ConfiguredFeature<?, ?>> CLOUDBED = createKey("cloudbed");

public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
HolderGetter<ConfiguredFeature<?, ?>> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE);
HolderGetter<ConfiguredFeature<?, ?>> configs = context.lookup(Registries.CONFIGURED_FEATURE);
HolderGetter<DensityFunction> functions = context.lookup(Registries.DENSITY_FUNCTION);
register(context, CRYSTAL_TREE_OVERRIDE, Feature.TREE,
new TreeConfiguration.TreeConfigurationBuilder(
prov(ReduxWoodSets.CRYSTAL.log()),
new CrystalTreeTrunkPlacer(7, 0, 0),
new WeightedStateProvider(new SimpleWeightedRandomList.Builder<BlockState>().add(AetherFeatureStates.CRYSTAL_LEAVES, 4).add(AetherFeatureStates.CRYSTAL_FRUIT_LEAVES, 1).build()),
new CrystalFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0), ConstantInt.of(6)),
new TwoLayersFeatureSize(1, 0, 1)).ignoreVines().build());

register(context, CLOUDBED, ReduxFeatures.CLOUDBED.get(),
new CloudbedFeature.Config(
prov(AetherFeatureStates.COLD_AERCLOUD),
BlockPredicate.ONLY_IN_AIR_PREDICATE,
16, ReduxDensityFunctions.get(functions, ReduxDensityFunctions.CLOUDBED_NOISE),
10, ReduxDensityFunctions.get(functions, ReduxDensityFunctions.CLOUDBED_Y_OFFSET), 10));
}

private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstapContext<ConfiguredFeature<?, ?>> context, ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) {
context.register(key, new ConfiguredFeature<>(feature, configuration));
}

private static ResourceKey<ConfiguredFeature<?, ?>> createKey(String name) {
return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(Redux.MODID, name));
}

private static String name(DeferredHolder<?, ?> reg) {
return reg.getId().getPath();
}
Expand Down
Loading

0 comments on commit ae9e16d

Please sign in to comment.