Prevent meteorites from generating in the end or nether.
This commit is contained in:
@@ -637,8 +637,6 @@ final class Registration {
|
||||
// StorageWorldProvider.class );
|
||||
|
||||
registries.worldgen().disableWorldGenForDimension(type, DimensionType.THE_NETHER.getRegistryName());
|
||||
|
||||
registries.worldgen().disableWorldGenForDimension(type, DimensionType.THE_NETHER.getRegistryName());
|
||||
}
|
||||
|
||||
// whitelist from config
|
||||
@@ -648,37 +646,51 @@ final class Registration {
|
||||
}
|
||||
|
||||
ForgeRegistries.BIOMES.forEach(b -> {
|
||||
// b.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION,
|
||||
// new ConfiguredFeature<NoFeatureConfig, Feature<NoFeatureConfig>>(MeteoriteWorldGen.INSTANCE,
|
||||
// IFeatureConfig.NO_FEATURE_CONFIG));
|
||||
addMeteoriteWorldGen(b);
|
||||
addQuartzWorldGen(b);
|
||||
});
|
||||
|
||||
b.addStructure(MeteoriteStructure.INSTANCE.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
|
||||
b.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION,
|
||||
MeteoriteStructure.INSTANCE.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)
|
||||
.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
|
||||
}
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
BlockState quartzOre = AEApi.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE
|
||||
private static void addMeteoriteWorldGen(Biome b) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (b.getCategory() == Biome.Category.THEEND || b.getCategory() == Biome.Category.NETHER) {
|
||||
return;
|
||||
}
|
||||
|
||||
b.addStructure(MeteoriteStructure.INSTANCE.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
|
||||
b.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION,
|
||||
MeteoriteStructure.INSTANCE.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)
|
||||
.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
|
||||
}
|
||||
|
||||
private static void addQuartzWorldGen(Biome b) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState quartzOre = AEApi.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,
|
||||
Feature.ORE
|
||||
.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
|
||||
quartzOre, AEConfig.instance().getQuartzOresPerCluster()))
|
||||
.withPlacement(Placement.COUNT_RANGE.configure(
|
||||
new CountRangeConfig(AEConfig.instance().getQuartzOresClusterAmount(), 12, 12, 72))));
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
||||
|
||||
BlockState chargedQuartzOre = AEApi.instance().definitions().blocks().quartzOreCharged().block()
|
||||
.getDefaultState();
|
||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION,
|
||||
ChargedQuartzOreFeature.INSTANCE
|
||||
.withConfiguration(new ChargedQuartzOreConfig(quartzOre, chargedQuartzOre,
|
||||
AEConfig.instance().getSpawnChargedChance()))
|
||||
.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
BlockState chargedQuartzOre = AEApi.instance().definitions().blocks().quartzOreCharged().block()
|
||||
.getDefaultState();
|
||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION,
|
||||
ChargedQuartzOreFeature.INSTANCE
|
||||
.withConfiguration(new ChargedQuartzOreConfig(quartzOre, chargedQuartzOre,
|
||||
AEConfig.instance().getSpawnChargedChance()))
|
||||
.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void registerWorldGen(RegistryEvent.Register<Feature<?>> evt) {
|
||||
|
||||
@@ -46,8 +46,10 @@ public class MeteoriteSpawner {
|
||||
int minY = 10 + stepSize;
|
||||
BlockPos.Mutable mutablePos = new BlockPos.Mutable(startPos);
|
||||
|
||||
// Place the center on the first solid ground block
|
||||
int startY = world.getHeight(Heightmap.Type.WORLD_SURFACE_WG, startPos).getY();
|
||||
// Place the center on the first solid ground block, but move it down a little
|
||||
// to embed the meteorite more
|
||||
// in the ground
|
||||
int startY = world.getHeight(Heightmap.Type.WORLD_SURFACE_WG, startPos).getY() - stepSize / 2;
|
||||
mutablePos.setY(startY);
|
||||
|
||||
while (mutablePos.getY() > minY) {
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.MutableBoundingBox;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeManager;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.GenerationSettings;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.gen.EndChunkGenerator;
|
||||
import net.minecraft.world.gen.NetherChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.structure.*;
|
||||
import net.minecraft.world.gen.feature.structure.ScatteredStructure;
|
||||
import net.minecraft.world.gen.feature.structure.Structure;
|
||||
import net.minecraft.world.gen.feature.structure.StructureStart;
|
||||
import net.minecraft.world.gen.feature.template.TemplateManager;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class MeteoriteStructure extends ScatteredStructure<NoFeatureConfig> {
|
||||
@@ -36,12 +35,21 @@ public class MeteoriteStructure extends ScatteredStructure<NoFeatureConfig> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeGenerated(BiomeManager biomeManagerIn, ChunkGenerator<?> generatorIn, Random randIn, int chunkX,
|
||||
public boolean canBeGenerated(BiomeManager biomeManagerIn, ChunkGenerator<?> generator, Random randIn, int chunkX,
|
||||
int chunkZ, Biome biomeIn) {
|
||||
if (super.canBeGenerated(biomeManagerIn, generatorIn, randIn, chunkX, chunkZ, biomeIn)) {
|
||||
if (super.canBeGenerated(biomeManagerIn, generator, randIn, chunkX, chunkZ, biomeIn)) {
|
||||
// In case the biome blacklist fails, we still double-check here that we're not
|
||||
// generating chunks for
|
||||
// the nether or end.
|
||||
if (generator.getClass().equals(EndChunkGenerator.class)
|
||||
|| generator.getClass().equals(NetherChunkGenerator.class)) {
|
||||
AELog.warn("ignoring attempt to generate meteorite in nether/end.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int i = chunkX >> 4;
|
||||
int j = chunkZ >> 4;
|
||||
randIn.setSeed((long) (i ^ j << 4) ^ generatorIn.getSeed());
|
||||
randIn.setSeed((long) (i ^ j << 4) ^ generator.getSeed());
|
||||
randIn.nextInt();
|
||||
return randIn.nextBoolean();
|
||||
}
|
||||
@@ -75,8 +83,7 @@ public class MeteoriteStructure extends ScatteredStructure<NoFeatureConfig> {
|
||||
}
|
||||
|
||||
public void init(ChunkGenerator<?> generator, TemplateManager templateManagerIn, int chunkX, int chunkZ,
|
||||
Biome biomeIn) {
|
||||
|
||||
Biome biome) {
|
||||
float meteoriteSize = (this.rand.nextFloat() * 6.0f) + 2;
|
||||
|
||||
int centerX = chunkX * 16 + rand.nextInt(16);
|
||||
|
||||
Reference in New Issue
Block a user