-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbd35ad
commit 21495ab
Showing
6 changed files
with
151 additions
and
1 deletion.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/generated/resources/data/vampirism/dimension/underworld.json
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,10 @@ | ||
{ | ||
"type": "vampirism:underworld", | ||
"generator": { | ||
"type": "minecraft:noise", | ||
"biome_source": { | ||
"type": "vampirism:underworld" | ||
}, | ||
"settings": "minecraft:end" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/generated/resources/data/vampirism/dimension_type/underworld.json
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,24 @@ | ||
{ | ||
"ambient_light": 0.0, | ||
"bed_works": false, | ||
"coordinate_scale": 1.0, | ||
"effects": "minecraft:the_end", | ||
"fixed_time": 6000, | ||
"has_ceiling": false, | ||
"has_raids": false, | ||
"has_skylight": false, | ||
"height": 256, | ||
"infiniburn": "#minecraft:infiniburn_end", | ||
"logical_height": 256, | ||
"min_y": 0, | ||
"monster_spawn_block_light_limit": 0, | ||
"monster_spawn_light_level": { | ||
"type": "minecraft:uniform", | ||
"max_inclusive": 7, | ||
"min_inclusive": 0 | ||
}, | ||
"natural": false, | ||
"piglin_safe": false, | ||
"respawn_anchor_works": false, | ||
"ultrawarm": false | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/de/teamlapen/vampirism/core/ModDimensions.java
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,46 @@ | ||
package de.teamlapen.vampirism.core; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import de.teamlapen.vampirism.REFERENCE; | ||
import de.teamlapen.vampirism.api.util.VResourceLocation; | ||
import de.teamlapen.vampirism.world.dimension.UnderworldBiomeSource; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.data.worldgen.BootstrapContext; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.tags.BlockTags; | ||
import net.minecraft.util.valueproviders.UniformInt; | ||
import net.minecraft.world.level.biome.BiomeSource; | ||
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 net.minecraft.world.level.levelgen.NoiseGeneratorSettings; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
|
||
import java.util.OptionalLong; | ||
|
||
public class ModDimensions { | ||
|
||
public static final ResourceKey<DimensionType> UNDERWORLD = ResourceKey.create(Registries.DIMENSION_TYPE, VResourceLocation.mod("underworld")); | ||
public static final ResourceKey<LevelStem> UNDERWORLD_STEM = ResourceKey.create(Registries.LEVEL_STEM, VResourceLocation.mod("underworld")); | ||
public static final DeferredRegister<MapCodec<? extends BiomeSource>> BIOME_SOURCES = DeferredRegister.create(Registries.BIOME_SOURCE, REFERENCE.MODID); | ||
|
||
public static final DeferredHolder<MapCodec<? extends BiomeSource>, MapCodec<? extends BiomeSource>> UNDERWORLD_BIOME_SOURCE = BIOME_SOURCES.register("underworld", () -> UnderworldBiomeSource.CODEC); | ||
|
||
static void register(IEventBus bus) { | ||
BIOME_SOURCES.register(bus); | ||
} | ||
static void bootstrapTypes(BootstrapContext<DimensionType> context) { | ||
context.register(UNDERWORLD, new DimensionType(OptionalLong.of(6000), false, false, false, false, 1.0, false, false, 0, 256, 256, BlockTags.INFINIBURN_END, BuiltinDimensionTypes.END_EFFECTS, 0f, new DimensionType.MonsterSettings(false, false, UniformInt.of(0,7), 0))); | ||
} | ||
|
||
static void bootstrapLevels(BootstrapContext<LevelStem> context) { | ||
var dimensionTypes = context.lookup(Registries.DIMENSION_TYPE); | ||
var noiseSettings = context.lookup(Registries.NOISE_SETTINGS); | ||
var biomes = context.lookup(Registries.BIOME); | ||
context.register(UNDERWORLD_STEM, new LevelStem(dimensionTypes.getOrThrow(UNDERWORLD), new NoiseBasedChunkGenerator(new UnderworldBiomeSource(biomes), noiseSettings.getOrThrow(NoiseGeneratorSettings.END)))); | ||
} | ||
|
||
} |
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
67 changes: 67 additions & 0 deletions
67
src/main/java/de/teamlapen/vampirism/world/dimension/UnderworldBiomeSource.java
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,67 @@ | ||
package de.teamlapen.vampirism.world.dimension; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import de.teamlapen.vampirism.core.ModBiomes; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.core.HolderGetter; | ||
import net.minecraft.core.QuartPos; | ||
import net.minecraft.core.SectionPos; | ||
import net.minecraft.resources.RegistryOps; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraft.world.level.biome.BiomeSource; | ||
import net.minecraft.world.level.biome.Climate; | ||
import net.minecraft.world.level.levelgen.DensityFunction; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class UnderworldBiomeSource extends BiomeSource { | ||
public static final MapCodec<UnderworldBiomeSource> CODEC = RecordCodecBuilder.mapCodec(inst -> { | ||
return inst.group( | ||
RegistryOps.retrieveElement(ModBiomes.VAMPIRE_FOREST)) | ||
.apply(inst, inst.stable(UnderworldBiomeSource::new)); | ||
}); | ||
|
||
private final Holder<Biome> biome; | ||
|
||
public UnderworldBiomeSource(HolderGetter<Biome> biomeGetter) { | ||
this.biome = biomeGetter.getOrThrow(ModBiomes.VAMPIRE_FOREST); | ||
} | ||
|
||
private UnderworldBiomeSource(Holder<Biome> biome) { | ||
this.biome = biome; | ||
} | ||
|
||
@Override | ||
protected MapCodec<? extends BiomeSource> codec() { | ||
return CODEC; | ||
} | ||
|
||
@Override | ||
protected Stream<Holder<Biome>> collectPossibleBiomes() { | ||
return Stream.of(this.biome); | ||
} | ||
|
||
@Override | ||
public Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) { | ||
int i = QuartPos.toBlock(x); | ||
int j = QuartPos.toBlock(y); | ||
int k = QuartPos.toBlock(z); | ||
int l = SectionPos.blockToSectionCoord(i); | ||
int i1 = SectionPos.blockToSectionCoord(k); | ||
if ((long)l * (long)l + (long)i1 * (long)i1 <= 4096L) { | ||
return this.biome; | ||
} else { | ||
int j1 = (SectionPos.blockToSectionCoord(i) * 2 + 1) * 8; | ||
int k1 = (SectionPos.blockToSectionCoord(k) * 2 + 1) * 8; | ||
double d0 = sampler.erosion().compute(new DensityFunction.SinglePointContext(j1, j, k1)); | ||
if (d0 > 0.25) { | ||
return this.biome; | ||
} else if (d0 >= -0.0625) { | ||
return this.biome; | ||
} else { | ||
return this.biome; | ||
} | ||
} | ||
} | ||
} |