mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
'Fix' chunkgenerator and worldtype
This commit is contained in:
1 parent
5484cfc815
commit
cf7ef9a96f
3 files changed
+62
-37
No files matched your search
@@ -8,28 +8,66 @@
|
||||
*/
|
||||
package vazkii.botania.common.world;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.Blockreader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.biome.BiomeManager;
|
||||
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.gen.*;
|
||||
import net.minecraft.world.gen.feature.structure.StructureManager;
|
||||
import net.minecraft.world.gen.settings.DimensionStructuresSettings;
|
||||
|
||||
public class SkyblockChunkGenerator extends OverworldChunkGenerator {
|
||||
public static final ChunkGeneratorType<OverworldGenSettings, SkyblockChunkGenerator> TYPE = new ChunkGeneratorType<>(SkyblockChunkGenerator::new, false, OverworldGenSettings::new);
|
||||
public class SkyblockChunkGenerator extends ChunkGenerator {
|
||||
private static final Codec<SkyblockChunkGenerator> CODEC = RecordCodecBuilder.create(
|
||||
instance -> instance.group(
|
||||
BiomeProvider.field_235202_a_.fieldOf("biome_source").forGetter(scg -> scg.biomeProvider),
|
||||
DimensionStructuresSettings.field_236190_a_.fieldOf("structures").forGetter(ChunkGenerator::func_235957_b_)
|
||||
).apply(instance, instance.stable(SkyblockChunkGenerator::new)));
|
||||
|
||||
private SkyblockChunkGenerator(IWorld worldIn, BiomeProvider provider, OverworldGenSettings settingsIn) {
|
||||
super(worldIn, provider, settingsIn);
|
||||
public SkyblockChunkGenerator(BiomeProvider provider, DimensionStructuresSettings settings) {
|
||||
super(provider, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeBase(IWorld worldIn, IChunk chunkIn) {}
|
||||
protected Codec<? extends ChunkGenerator> func_230347_a_() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateSurface(WorldGenRegion region, IChunk chunkIn) {}
|
||||
public ChunkGenerator func_230349_a_(long newSeed) {
|
||||
return new SkyblockChunkGenerator(this.biomeProvider.func_230320_a_(newSeed), func_235957_b_());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(WorldGenRegion region) {}
|
||||
public void func_230352_b_(IWorld world, StructureManager structureManager, IChunk chunk) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_225550_a_(BiomeManager biomeManager, IChunk chunkIn, GenerationStage.Carving carvingSettings) {}
|
||||
public void generateSurface(WorldGenRegion region, IChunk chunk) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_230350_a_(long seed, BiomeManager biomes, IChunk chunk, GenerationStage.Carving stage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_230351_a_(WorldGenRegion region, StructureManager structureManager) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int func_222529_a(int x, int z, Heightmap.Type heightmapType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockReader func_230348_a_(int p_230348_1_, int p_230348_2_) {
|
||||
return new Blockreader(new BlockState[0]);
|
||||
}
|
||||
}
|
||||
@@ -8,52 +8,32 @@
|
||||
*/
|
||||
package vazkii.botania.common.world;
|
||||
|
||||
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.provider.BiomeProviderType;
|
||||
import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.biome.provider.OverworldBiomeProvider;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.OverworldGenSettings;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraft.world.gen.DimensionSettings;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class WorldTypeSkyblock extends WorldType {
|
||||
public class WorldTypeSkyblock extends BiomeGeneratorTypeScreens {
|
||||
|
||||
public WorldTypeSkyblock() {
|
||||
super("botania-skyblock");
|
||||
|
||||
}
|
||||
|
||||
public static boolean isWorldSkyblock(World world) {
|
||||
return world.getWorldInfo().getGenerator() instanceof WorldTypeSkyblock;
|
||||
return world.getChunkProvider() instanceof ServerChunkProvider
|
||||
&& ((ServerChunkProvider) world.getChunkProvider()).getChunkGenerator() instanceof SkyblockChunkGenerator;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public boolean hasInfoNotice() {
|
||||
return true;
|
||||
}
|
||||
/* todo 1.16 impossible now?
|
||||
|
||||
@Override
|
||||
public float getCloudHeight() {
|
||||
return 260f;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ChunkGenerator<?> createChunkGenerator(@Nonnull World world) {
|
||||
if (world.dimension.getType() == DimensionType.OVERWORLD) {
|
||||
OverworldGenSettings genSettings = SkyblockChunkGenerator.TYPE.createSettings();
|
||||
OverworldBiomeProviderSettings biomeSettings = BiomeProviderType.VANILLA_LAYERED.createSettings(world.getWorldInfo()).setGeneratorSettings(genSettings);
|
||||
return SkyblockChunkGenerator.TYPE.create(world, BiomeProviderType.VANILLA_LAYERED.create(biomeSettings), genSettings);
|
||||
}
|
||||
return super.createChunkGenerator(world);
|
||||
}
|
||||
|
||||
/* In skyblock worlds, do not darken the sky until player hits y=0 */
|
||||
// In skyblock worlds, do not darken the sky until player hits y=0
|
||||
@Override
|
||||
public double getHorizon(World world) {
|
||||
return 0.0D;
|
||||
@@ -63,5 +43,10 @@ public class WorldTypeSkyblock extends WorldType {
|
||||
public double voidFadeMagnitude() {
|
||||
return 1.0D;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected ChunkGenerator func_230484_a_(long seed) {
|
||||
return new SkyblockChunkGenerator(new OverworldBiomeProvider(seed, false, false), DimensionSettings.Preset.field_236122_b_.func_236137_b_().func_236108_a_());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user