Ported to 1.16.2-pre
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package appeng.worldgen;
|
||||
|
||||
import appeng.mixins.BiomeAccessor;
|
||||
import appeng.mixins.GenerationSettingsAccessor;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class BiomeModifier {
|
||||
|
||||
private final BiomeAccessor biomeAccessor;
|
||||
|
||||
private final GenerationSettingsAccessor generationSettingsAccessor;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public BiomeModifier(Biome biome) {
|
||||
this.biomeAccessor = (BiomeAccessor) (Object) biome;
|
||||
this.generationSettingsAccessor = (GenerationSettingsAccessor) biome.getGenerationSettings();
|
||||
}
|
||||
|
||||
public void addFeature(GenerationStep.Feature step, ConfiguredFeature<?, ?> feature) {
|
||||
|
||||
int stepIndex = step.ordinal();
|
||||
List<List<Supplier<ConfiguredFeature<?, ?>>>> featuresByStep = new ArrayList<>(generationSettingsAccessor.getFeatures());
|
||||
|
||||
while (featuresByStep.size() <= stepIndex) {
|
||||
featuresByStep.add(Lists.newArrayList());
|
||||
}
|
||||
|
||||
List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(featuresByStep.get(stepIndex));
|
||||
features.add(() -> feature);
|
||||
featuresByStep.set(stepIndex, features);
|
||||
|
||||
generationSettingsAccessor.setFeatures(featuresByStep);
|
||||
|
||||
}
|
||||
|
||||
public void addStructureFeature(ConfiguredStructureFeature<?, ?> structure) {
|
||||
List<Supplier<ConfiguredStructureFeature<?, ?>>> features = new ArrayList<>(generationSettingsAccessor.getStructureFeatures());
|
||||
features.add(() -> structure);
|
||||
generationSettingsAccessor.setStructureFeatures(features);
|
||||
|
||||
// Add it to the structures that will generate pieces within this biome,
|
||||
// this is only half-correct since a structure can start in an adjacent biome
|
||||
// and extend into biomes that would usually not start the structure
|
||||
Map<Integer, List<StructureFeature<?>>> structuresByStage = biomeAccessor.getField_26634();
|
||||
int step = structure.feature.getGenerationStep().ordinal();
|
||||
if (!structuresByStage.containsKey(step)) {
|
||||
structuresByStage.put(step, new ArrayList<>());
|
||||
}
|
||||
structuresByStage.get(step).add(structure.feature);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class ChargedQuartzOreConfig implements FeatureConfig {
|
||||
public static final Codec<ChargedQuartzOreConfig> CODEC = RecordCodecBuilder.create((instance) -> instance
|
||||
.group(BlockState.CODEC.fieldOf("target").forGetter((config) -> config.target),
|
||||
BlockState.CODEC.fieldOf("state").forGetter((config) -> config.state),
|
||||
Codec.FLOAT.fieldOf("chance").withDefault(0f).forGetter((config) -> config.chance))
|
||||
Codec.FLOAT.fieldOf("chance").orElse(0f).forGetter((config) -> config.chance))
|
||||
.apply(instance, ChargedQuartzOreConfig::new));
|
||||
|
||||
public final BlockState target;
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
@@ -28,8 +25,7 @@ public class ChargedQuartzOreFeature extends Feature<ChargedQuartzOreConfig> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ServerWorldAccess worldIn, net.minecraft.world.gen.StructureAccessor structureAccessor,
|
||||
ChunkGenerator generator, Random rand, BlockPos pos, ChargedQuartzOreConfig config) {
|
||||
public boolean generate(StructureWorldAccess worldIn, ChunkGenerator generator, Random rand, BlockPos pos, ChargedQuartzOreConfig config) {
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
|
||||
BlockPos.Mutable bpos = new BlockPos.Mutable();
|
||||
|
||||
@@ -193,7 +193,7 @@ public final class MeteoritePlacer {
|
||||
}
|
||||
}
|
||||
|
||||
for (final Object o : world.getEntities(ItemEntity.class,
|
||||
for (final Object o : world.getEntitiesByClass(ItemEntity.class,
|
||||
new Box(minX(x - 30), y - 5, minZ(z - 30), maxX(x + 30), y + 30, maxZ(z + 30)), null)) {
|
||||
final Entity e = (Entity) o;
|
||||
e.remove();
|
||||
|
||||
@@ -26,7 +26,7 @@ import net.minecraft.structure.StructurePieceType;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class MeteoriteStructurePiece extends StructurePiece {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ServerWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator,
|
||||
public boolean generate(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator,
|
||||
Random random, BlockBox bounds, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
MeteoritePlacer placer = new MeteoritePlacer(world, settings, bounds);
|
||||
placer.place();
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@@ -26,9 +27,9 @@ import appeng.worldgen.meteorite.fallout.FalloutMode;
|
||||
|
||||
public class MeteoriteStructureStart extends StructureStart<DefaultFeatureConfig> {
|
||||
|
||||
private final Tag<Block> sandTag = BlockTags.getContainer().getOrCreate(new Identifier("minecraft:sand"));
|
||||
private final Tag<Block> terracottaTag = BlockTags.getContainer()
|
||||
.getOrCreate(new Identifier("c:terracotta_blocks"));
|
||||
private final Tag<Block> sandTag = BlockTags.getTagGroup().getTagOrEmpty(new Identifier("minecraft:sand"));
|
||||
private final Tag<Block> terracottaTag = BlockTags.getTagGroup()
|
||||
.getTagOrEmpty(new Identifier("c:terracotta_blocks"));
|
||||
|
||||
public MeteoriteStructureStart(StructureFeature<DefaultFeatureConfig> feature, int chunkX, int chunkZ, BlockBox box,
|
||||
int references, long seed) {
|
||||
@@ -36,8 +37,7 @@ public class MeteoriteStructureStart extends StructureStart<DefaultFeatureConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ChunkGenerator generator, StructureManager templateManagerIn, int chunkX, int chunkZ, Biome biome,
|
||||
DefaultFeatureConfig config) {
|
||||
public void init(DynamicRegistryManager dynamicRegistryManager, ChunkGenerator generator, StructureManager structureManager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig featureConfig) {
|
||||
final int centerX = chunkX * 16 + this.random.nextInt(16);
|
||||
final int centerZ = chunkZ * 16 + this.random.nextInt(16);
|
||||
final float meteoriteRadius = (this.random.nextFloat() * 6.0f) + 2;
|
||||
@@ -75,7 +75,7 @@ public class MeteoriteStructureStart extends StructureStart<DefaultFeatureConfig
|
||||
boolean craterLake = this.locateWaterAroundTheCrater(generator, actualPos, meteoriteRadius);
|
||||
CraterType craterType = this.determineCraterType(spawnBiome);
|
||||
boolean pureCrater = this.random.nextFloat() > .9f;
|
||||
FalloutMode fallout = getFalloutFromBaseBlock(spawnBiome.getSurfaceConfig().getTopMaterial());
|
||||
FalloutMode fallout = getFalloutFromBaseBlock(spawnBiome.getGenerationSettings().getSurfaceConfig().getTopMaterial());
|
||||
|
||||
children.add(
|
||||
new MeteoriteStructurePiece(actualPos, meteoriteRadius, craterType, fallout, pureCrater, craterLake));
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FalloutCopy extends Fallout {
|
||||
final BlockState skyStone) {
|
||||
super(putter, skyStone);
|
||||
this.putter = putter;
|
||||
this.block = w.getBiome(pos).getSurfaceConfig().getTopMaterial();
|
||||
this.block = w.getBiome(pos).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user