-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a new working version of the code
- Loading branch information
1 parent
0e76516
commit bf282cd
Showing
8 changed files
with
406 additions
and
592 deletions.
There are no files selected for viewing
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
100 changes: 55 additions & 45 deletions
100
src/main/java/fr/alasdiablo/janoeo/world/OreGenUtils.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 |
---|---|---|
@@ -1,58 +1,68 @@ | ||
package fr.alasdiablo.janoeo.world; | ||
|
||
import fr.alasdiablo.janoeo.world.gen.feature.CustomFillerBlockType; | ||
import fr.alasdiablo.janoeo.world.gen.feature.CustomOreFeature; | ||
import fr.alasdiablo.janoeo.world.gen.feature.CustomOreFeatureConfig; | ||
import com.google.common.collect.Lists; | ||
import fr.alasdiablo.janoeo.world.gen.*; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.util.RegistryKey; | ||
import net.minecraft.util.registry.Registry; | ||
import net.minecraft.util.registry.WorldGenRegistries; | ||
import net.minecraft.world.biome.Biome; | ||
import net.minecraft.world.biome.BiomeGenerationSettings; | ||
import net.minecraft.world.gen.GenerationStage; | ||
import net.minecraft.world.gen.feature.Feature; | ||
import net.minecraft.world.gen.feature.ReplaceBlockConfig; | ||
import net.minecraft.world.gen.placement.CountRangeConfig; | ||
import net.minecraft.world.gen.feature.*; | ||
import net.minecraft.world.gen.feature.template.RuleTest; | ||
import net.minecraft.world.gen.placement.Placement; | ||
import net.minecraft.world.gen.placement.TopSolidRangeConfig; | ||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Some part of this code is inspire by Applied Energistics 2 | ||
*/ | ||
public class OreGenUtils { | ||
|
||
public static void addOreGenOnBiome(Biome biome, CustomFillerBlockType blockType, BlockState oreBlock, int size, int count, int bottom, int top) { | ||
biome.addFeature( | ||
GenerationStage.Decoration.UNDERGROUND_ORES, | ||
CustomOreFeature.INSTANCE.withConfiguration( | ||
new CustomOreFeatureConfig( | ||
blockType, | ||
oreBlock, | ||
size | ||
) | ||
).withPlacement( | ||
Placement.COUNT_RANGE.configure( | ||
new CountRangeConfig( | ||
count, | ||
bottom, | ||
0, | ||
top | ||
) | ||
) | ||
) | ||
); | ||
private static final IWorldGenerator OVERWORLD_GENERATOR = new OverworldOreGenerator(); | ||
private static final IWorldGenerator NETHER_GENERATOR = new NetherOreGenerator(); | ||
private static final IWorldGenerator END_GENERATOR = new EndOreGenerator(); | ||
private static final IWorldGenerator GRAVEL_GENERATOR = new GravelOreGenerator(); | ||
private static final IWorldGenerator BASALT_GENERATOR = new BasaltOreGenerator(); | ||
|
||
public static void setupOres() { | ||
|
||
for (Biome biome : ForgeRegistries.BIOMES) { | ||
if (!biome.getCategory().equals(Biome.Category.NETHER) && !biome.getCategory().equals(Biome.Category.THEEND)) { | ||
OVERWORLD_GENERATOR.startWorldGeneration(biome); | ||
GRAVEL_GENERATOR.startWorldGeneration(biome); | ||
} | ||
if (biome.getCategory().equals(Biome.Category.NETHER)) { | ||
GRAVEL_GENERATOR.startWorldGeneration(biome); | ||
NETHER_GENERATOR.startWorldGeneration(biome); | ||
BASALT_GENERATOR.startWorldGeneration(biome); | ||
} | ||
if (biome.getCategory().equals(Biome.Category.THEEND)) { | ||
END_GENERATOR.startWorldGeneration(biome); | ||
} | ||
} | ||
} | ||
|
||
public static void addBlockGenOnBiome(Biome biome, BlockState replamentBlock, BlockState oreBlock, int count, int bottom, int top) { | ||
biome.addFeature( | ||
GenerationStage.Decoration.UNDERGROUND_ORES, | ||
Feature.EMERALD_ORE.withConfiguration( | ||
new ReplaceBlockConfig( | ||
replamentBlock, | ||
oreBlock | ||
) | ||
).withPlacement( | ||
Placement.COUNT_RANGE.configure( | ||
new CountRangeConfig( | ||
count, | ||
bottom, | ||
0, | ||
top | ||
) | ||
) | ||
) | ||
); | ||
public static void addFeatureToBiome(Biome biome, ConfiguredFeature<?, ?> configuredFeature) { | ||
System.out.println("Feature added ! " + configuredFeature.feature.getRegistryName().toString()); | ||
|
||
GenerationStage.Decoration decoration = GenerationStage.Decoration.UNDERGROUND_ORES; | ||
|
||
List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = new ArrayList<>(biome.func_242440_e().func_242498_c()); | ||
while (biomeFeatures.size() <= decoration.ordinal()) { | ||
biomeFeatures.add(Lists.newArrayList()); | ||
} | ||
List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(biomeFeatures.get(decoration.ordinal())); | ||
features.add(() -> configuredFeature); | ||
biomeFeatures.set(decoration.ordinal(), features); | ||
|
||
ObfuscationReflectionHelper.setPrivateValue(BiomeGenerationSettings.class, biome.func_242440_e(), biomeFeatures, "field_242484_f"); | ||
} | ||
} |
9 changes: 1 addition & 8 deletions
9
src/main/java/fr/alasdiablo/janoeo/world/gen/BasaltOreGenerator.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
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
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
Oops, something went wrong.