Skip to content

Commit

Permalink
Heliolith and Levita worldgen
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Mar 30, 2024
1 parent 24ba2fc commit 1ea04c6
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,11 @@ private static Map<GenerationStep.Feature, List<RegistryEntry<PlacedFeature>>> g
SURTRUM_METEORITE
),
GenerationStep.Feature.UNDERGROUND_ORES, List.of(
HELIOLITH_BLOB,
LEVITA_BLOB,
ORE_CHERINE,
ORE_OLVITE
ORE_OLVITE,
ORE_LEVITA
),
GenerationStep.Feature.VEGETAL_DECORATION, List.of(
PATCH_BROWN_SPORECAP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ParadiseLostFeatures {
public static final PillarFeature PILLAR_FEATURE = register("pillar_feature", new PillarFeature(LongFeatureConfig.CODEC));
public static final FallenPillarFeature FALLEN_PILLAR_FEATURE = register("fallen_pillar_feature", new FallenPillarFeature(LongFeatureConfig.CODEC));

public static final JaggedOreFeature JAGGED_ORE = register("jagged_ore_feature", new JaggedOreFeature(JaggedOreConfig.CODEC));
public static final SurtrumMeteoriteFeature SURTRUM_METEORITE_FEATURE = register("surtrum_meteorite_feature", new SurtrumMeteoriteFeature(DefaultFeatureConfig.CODEC));

private static <C extends FeatureConfig, F extends Feature<C>> F register(String id, F feature) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.id.paradiselost.world.feature.configs;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.math.intprovider.IntProvider;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.stateprovider.BlockStateProvider;

public record JaggedOreConfig(BlockStateProvider block, IntProvider height, IntProvider width, IntProvider length, IntProvider lengthOffset) implements FeatureConfig {
public static final Codec<JaggedOreConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
BlockStateProvider.TYPE_CODEC.fieldOf("block").forGetter(JaggedOreConfig::block),
IntProvider.VALUE_CODEC.fieldOf("height").forGetter(JaggedOreConfig::height),
IntProvider.VALUE_CODEC.fieldOf("width").forGetter(JaggedOreConfig::width),
IntProvider.VALUE_CODEC.fieldOf("length").forGetter(JaggedOreConfig::length),
IntProvider.VALUE_CODEC.fieldOf("lengthOffset").forGetter(JaggedOreConfig::lengthOffset)
).apply(instance, JaggedOreConfig::new));
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package net.id.paradiselost.world.feature.configured_features;

import net.id.paradiselost.blocks.ParadiseLostBlocks;
import net.id.paradiselost.world.feature.ParadiseLostFeatures;
import net.id.paradiselost.world.feature.configs.BoulderFeatureConfig;
import net.id.paradiselost.world.feature.configs.GroundcoverFeatureConfig;
import net.id.paradiselost.world.feature.configs.JaggedOreConfig;
import net.id.paradiselost.world.feature.placed_features.ParadiseLostPlacedFeatures;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand Down Expand Up @@ -39,8 +41,11 @@ public class ParadiseLostMiscConfiguredFeatures extends ParadiseLostConfiguredFe
public static final RegistryEntry<ConfiguredFeature<BoulderFeatureConfig, ?>> THICKET_BOULDER = register("thicket_boulder", ParadiseLostFeatures.BOULDER, Configs.THICKET_BOULDER_CONFIG);
public static final RegistryEntry<ConfiguredFeature<BoulderFeatureConfig, ?>> GOLDEN_BOULDER = register("golden_boulder", ParadiseLostFeatures.BOULDER, Configs.GOLDEN_BOULDER_CONFIG);

public static final RegistryEntry<ConfiguredFeature<JaggedOreConfig, ?>> HELIOLITH_BLOB = register("heliolith_blob", ParadiseLostFeatures.JAGGED_ORE, Configs.HELIOLITH_BLOB_CONFIG);
public static final RegistryEntry<ConfiguredFeature<JaggedOreConfig, ?>> LEVITA_BLOB = register("levita_blob", ParadiseLostFeatures.JAGGED_ORE, Configs.LEVITA_BLOB_CONFIG);
public static final RegistryEntry<ConfiguredFeature<OreFeatureConfig, ?>> ORE_CHERINE = register("ore_cherine", Feature.ORE, Configs.ore(CHERINE_ORE, 14));
public static final RegistryEntry<ConfiguredFeature<OreFeatureConfig, ?>> ORE_OLVITE = register("ore_olvite", Feature.ORE, Configs.ore(OLVITE_ORE, 9));
public static final RegistryEntry<ConfiguredFeature<OreFeatureConfig, ?>> ORE_LEVITA = register("ore_levita", Feature.ORE, Configs.ore(LEVITA_ORE, 3));
public static final RegistryEntry<ConfiguredFeature<DefaultFeatureConfig, ?>> SURTRUM_METEORITE = register("surtrum_meteorite", ParadiseLostFeatures.SURTRUM_METEORITE_FEATURE, new DefaultFeatureConfig());
// Plato
// Shield
Expand Down Expand Up @@ -79,6 +84,15 @@ private static BoulderFeatureConfig boulder(Block block, int tries, IntProvider
return boulder(BlockStateProvider.of(block), tries, size);
}

private static final JaggedOreConfig HELIOLITH_BLOB_CONFIG =
new JaggedOreConfig(BlockStateProvider.of(HELIOLITH), UniformIntProvider.create(4, 7), UniformIntProvider.create(7, 11), UniformIntProvider.create(5, 11), UniformIntProvider.create(1, 4));
private static final JaggedOreConfig LEVITA_BLOB_CONFIG =
new JaggedOreConfig(new WeightedBlockStateProvider(
DataPool.<BlockState>builder()
.add(LEVITA.getDefaultState(), 200)
.add(LEVITA_ORE.getDefaultState(), 1)
), UniformIntProvider.create(3, 5), UniformIntProvider.create(6, 10), UniformIntProvider.create(4, 10), UniformIntProvider.create(3, 6));

private static final BoulderFeatureConfig GENERIC_BOULDER_CONFIG = boulder(new WeightedBlockStateProvider(
DataPool.<BlockState>builder()
.add(MOSSY_FLOESTONE.getDefaultState(), 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.id.paradiselost.world.feature.features;

import com.mojang.serialization.Codec;
import net.id.paradiselost.blocks.FloatingBlock;
import net.id.paradiselost.blocks.ParadiseLostBlocks;
import net.id.paradiselost.tag.ParadiseLostBlockTags;
import net.id.paradiselost.world.feature.configs.JaggedOreConfig;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.util.FeatureContext;

public class JaggedOreFeature extends Feature<JaggedOreConfig> {
public JaggedOreFeature(Codec<JaggedOreConfig> configCodec) {
super(configCodec);
}

@Override
public boolean generate(FeatureContext<JaggedOreConfig> context) {
JaggedOreConfig config = context.getConfig();
BlockPos center = context.getOrigin();
StructureWorldAccess world = context.getWorld();
Random rand = context.getRandom();

int height = center.getY() + config.height().get(rand);
for (int y = center.getY(); y < height; y++) {
int sizex = config.width().get(rand);
int xOffset = rand.nextBetween(0, 2);
int sizez = config.length().get(rand);
for (int x = 0; x < sizex; x++) {
int zOffset = config.lengthOffset().get(rand);
for (int z = zOffset; z < sizez + zOffset; z++) {
BlockPos iPos = new BlockPos(center.getX() + x + xOffset, y, center.getZ() + z);
if (world.getBlockState(iPos).isIn(ParadiseLostBlockTags.BASE_PARADISE_LOST_STONE)) {
BlockState block = config.block().getBlockState(rand, center);
if (!(block.getBlock() instanceof FloatingBlock && !world.getBlockState(iPos.up()).isOpaque()))
world.setBlockState(iPos, config.block().getBlockState(rand, iPos), Block.NOTIFY_LISTENERS);
}
}
}
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public class ParadiseLostMiscPlacedFeatures extends ParadiseLostPlacedFeatures {

public static final RegistryEntry<PlacedFeature> WATER_SPRING = register("water_spring", ParadiseLostMiscConfiguredFeatures.WATER_SPRING);

public static final RegistryEntry<PlacedFeature> HELIOLITH_BLOB = register("heliolith_blob", ParadiseLostMiscConfiguredFeatures.HELIOLITH_BLOB, CountPlacementModifier.of(3), SquarePlacementModifier.of(), HeightRangePlacementModifier.uniform(YOffset.aboveBottom(0), YOffset.aboveBottom(320)), BiomePlacementModifier.of());
public static final RegistryEntry<PlacedFeature> LEVITA_BLOB = register("levita_blob", ParadiseLostMiscConfiguredFeatures.LEVITA_BLOB, CountPlacementModifier.of(1), SquarePlacementModifier.of(), HeightRangePlacementModifier.uniform(YOffset.aboveBottom(0), YOffset.aboveBottom(320)), BiomePlacementModifier.of());

public static final RegistryEntry<PlacedFeature> ORE_CHERINE = register("ore_cherine", ParadiseLostMiscConfiguredFeatures.ORE_CHERINE, CountPlacementModifier.of(20), SquarePlacementModifier.of(), HeightRangePlacementModifier.trapezoid(YOffset.aboveBottom(0), YOffset.aboveBottom(320)), BiomePlacementModifier.of());
public static final RegistryEntry<PlacedFeature> ORE_OLVITE = register("ore_olvite", ParadiseLostMiscConfiguredFeatures.ORE_OLVITE, CountPlacementModifier.of(16), SquarePlacementModifier.of(), HeightRangePlacementModifier.trapezoid(YOffset.aboveBottom(0), YOffset.aboveBottom(384)), BiomePlacementModifier.of());
public static final RegistryEntry<PlacedFeature> ORE_LEVITA = register("ore_levita", ParadiseLostMiscConfiguredFeatures.ORE_LEVITA, CountPlacementModifier.of(6), SquarePlacementModifier.of(), HeightRangePlacementModifier.trapezoid(YOffset.aboveBottom(0), YOffset.aboveBottom(384)), BiomePlacementModifier.of());
public static final RegistryEntry<PlacedFeature> SURTRUM_METEORITE = register("surtrum_meteorite", ParadiseLostMiscConfiguredFeatures.SURTRUM_METEORITE, SquarePlacementModifier.of(), HeightRangePlacementModifier.uniform(YOffset.fixed(65), YOffset.fixed(85)), ChancePlacementModifier.of(255));
// Plato
// Shield
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/paradise_lost/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"block.paradise_lost.dirt": "Paradise Dirt",
"block.paradise_lost.coarse_dirt": "Coarse Paradise Dirt",
"block.paradise_lost.permafrost": "Permafrost",
"block.paradise_lost.levita": "Levita Precipitate",
"block.paradise_lost.levita": "Levita",
"block.paradise_lost.farmland": "Paradise Farmland",
"block.paradise_lost.grass_path": "Paradise Grass Path",
"block.paradise_lost.packed_swedroot": "Packed Swedroot",
Expand Down Expand Up @@ -245,7 +245,7 @@
"block.paradise_lost.olvite_block": "Block of Olvite",
"block.paradise_lost.refined_surtrum_block": "Block of Refined Surtrum",

"block.paradise_lost.levitator": "Surtrum Levitator",
"block.paradise_lost.levitator": "Redstone Levitator",
"block.paradise_lost.olvite_chain": "Olvite Chain",
"block.paradise_lost.cherine_lantern": "Cherine Lantern",
"block.paradise_lost.blue_portal": "Paradise Portal",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"gred",
"swatgred",
"groot",
"malk",
"mert",
"cokmert"
]
Expand Down

0 comments on commit 1ea04c6

Please sign in to comment.