-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dimensions basis (PROBABLY VERY BUGGY)
- Loading branch information
1 parent
2191e6a
commit 8040ba9
Showing
10 changed files
with
192 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package breadmod.datagen.dimension | ||
|
||
import breadmod.BreadMod | ||
import net.minecraft.core.particles.ParticleTypes | ||
import net.minecraft.core.registries.Registries | ||
import net.minecraft.resources.ResourceKey | ||
import net.minecraft.resources.ResourceLocation | ||
import net.minecraft.sounds.SoundEvents | ||
import net.minecraft.world.level.biome.* | ||
import java.awt.Color | ||
|
||
object ModBiomes { | ||
private val entries = mutableListOf<Pair<ResourceKey<Biome>, Biome>>() | ||
|
||
fun register( | ||
name: String, biomeBuilder: (id: ResourceLocation) -> Biome | ||
) = BreadMod.modLocation(name).let { | ||
val pair = ResourceKey.create(Registries.BIOME, it) to biomeBuilder(it) | ||
entries.add(pair) | ||
return@let pair | ||
} | ||
|
||
val BREAD = register("bread") { _ -> | ||
Biome.BiomeBuilder() | ||
.hasPrecipitation(false) | ||
.temperatureAdjustment(Biome.TemperatureModifier.NONE) | ||
.specialEffects( | ||
BiomeSpecialEffects.Builder() | ||
.fogColor(Color(0, 150,120).rgb) | ||
.skyColor(Color(0, 255,192).rgb) | ||
.waterColor(Color(200,100,0).rgb) | ||
.waterFogColor(Color(200, 75, 0).rgb) | ||
.ambientParticle(AmbientParticleSettings(ParticleTypes.SMOKE, 0.1F)) | ||
.ambientLoopSound(SoundEvents.AMBIENT_BASALT_DELTAS_LOOP) | ||
.build() | ||
) | ||
.generationSettings(BiomeGenerationSettings.EMPTY) | ||
.mobSpawnSettings(MobSpawnSettings.EMPTY) | ||
.temperature(1.0F) | ||
.downfall(0.0F) | ||
.build() | ||
} | ||
|
||
fun bootstrapBiomes(ctx: BootstrapContext<Biome>) = entries.forEach { ctx.register(it.first, it.second) } | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/breadmod/datagen/dimension/ModDimensionEntry.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package breadmod.datagen.dimension | ||
|
||
import net.minecraft.core.Holder | ||
import net.minecraft.core.HolderGetter | ||
import net.minecraft.resources.ResourceKey | ||
import net.minecraft.resources.ResourceLocation | ||
import net.minecraft.world.level.biome.Biome | ||
import net.minecraft.world.level.biome.Climate | ||
import net.minecraft.world.level.dimension.DimensionType | ||
import net.minecraft.world.level.dimension.LevelStem | ||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings | ||
|
||
typealias ClimateParameterListBuilder = ((HolderGetter<Biome>) -> Climate.ParameterList<Holder<Biome>>) | ||
|
||
data class ModDimensionEntry( | ||
val effectLocation: ResourceLocation, | ||
val dimensionType: Pair<ResourceKey<DimensionType>, DimensionType>, | ||
val levelStemKey: ResourceKey<LevelStem>, | ||
|
||
val climateParameterListBuilder: ClimateParameterListBuilder? = null, | ||
val noiseSettings: ResourceKey<NoiseGeneratorSettings> = NoiseGeneratorSettings.OVERWORLD | ||
) { | ||
companion object { | ||
internal val entries = mutableListOf<ModDimensionEntry>() | ||
internal var frozen = false | ||
} | ||
|
||
init { | ||
if(frozen) throw IllegalStateException("Dimension registered after entry list froze") | ||
entries.add(this) | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
src/main/kotlin/breadmod/datagen/dimension/ModDimensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package breadmod.datagen.dimension | ||
|
||
import breadmod.BreadMod.modLocation | ||
import com.mojang.datafixers.util.Pair | ||
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.tags.BlockTags | ||
import net.minecraft.util.valueproviders.ConstantInt | ||
import net.minecraft.world.level.biome.* | ||
import net.minecraft.world.level.biome.Climate.ParameterList | ||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes | ||
import net.minecraft.world.level.dimension.DimensionType | ||
import net.minecraft.world.level.dimension.LevelStem | ||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator | ||
import java.util.* | ||
|
||
typealias BootstrapContext<T> = BootstapContext<T> | ||
|
||
object ModDimensions { | ||
fun register( | ||
name: String, | ||
dimensionType: (key: ResourceKey<DimensionType>, location: ResourceLocation) -> DimensionType, | ||
climateParameterListBuilder: ClimateParameterListBuilder, | ||
) = modLocation(name).let { | ||
ModDimensionEntry( | ||
it, | ||
ResourceKey.create(Registries.DIMENSION_TYPE, it).let { typeKey -> typeKey to dimensionType.invoke(typeKey, it) }, | ||
ResourceKey.create(Registries.LEVEL_STEM, it), | ||
climateParameterListBuilder | ||
) | ||
} | ||
|
||
@Suppress("unused") | ||
val BREAD = register("bread", { _, _ -> | ||
DimensionType( | ||
OptionalLong.empty(), | ||
true, | ||
false, | ||
false, | ||
true, | ||
4.0, | ||
true, | ||
false, | ||
-64, // minY TODO, | ||
2048, // maxY TODO | ||
2048, | ||
BlockTags.INFINIBURN_OVERWORLD, | ||
BuiltinDimensionTypes.NETHER_EFFECTS, | ||
8F, | ||
DimensionType.MonsterSettings( | ||
false, | ||
false, | ||
ConstantInt.of(0), | ||
0 | ||
) | ||
) | ||
}, { holderGetter -> | ||
ParameterList( | ||
listOf( | ||
Pair.of( | ||
Climate.parameters( | ||
0.9F, | ||
0.0f, | ||
0.0F, | ||
0.0f, | ||
0.0f, | ||
1.0F, | ||
0.175F | ||
), holderGetter.getOrThrow(ModBiomes.BREAD.first) | ||
) | ||
) | ||
) | ||
}) | ||
|
||
fun bootstrapDimensionTypes(ctx: BootstrapContext<DimensionType>) = | ||
ModDimensionEntry.entries.forEach { ctx.register(it.dimensionType.first, it.dimensionType.second) } | ||
fun bootstrapLevelStems(ctx: BootstrapContext<LevelStem>) { | ||
val noiseSettings = ctx.lookup(Registries.NOISE_SETTINGS) | ||
val mnbspList = ctx.lookup(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST) | ||
val holderGetter = ctx.lookup(Registries.DIMENSION_TYPE) | ||
|
||
val biomeGetter = ctx.lookup(Registries.BIOME) | ||
|
||
ModDimensionEntry.entries.forEach { | ||
ctx.register(it.levelStemKey, LevelStem( | ||
holderGetter.getOrThrow(it.dimensionType.first), | ||
NoiseBasedChunkGenerator( | ||
it.climateParameterListBuilder.let { builder -> | ||
if(builder != null) MultiNoiseBiomeSource.createFromList(builder(biomeGetter)) | ||
else MultiNoiseBiomeSource.createFromPreset(mnbspList.getOrThrow(MultiNoiseBiomeSourceParameterLists.OVERWORLD)) | ||
}, | ||
noiseSettings.getOrThrow(it.noiseSettings) | ||
) | ||
)) | ||
} | ||
} | ||
|
||
init { ModDimensionEntry.frozen = true } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 0 additions & 72 deletions
72
src/main/kotlin/breadmod/registry/dimension/ModDimensions.kt
This file was deleted.
Oops, something went wrong.
Empty file.