mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-16 23:11:40 +01:00
Merge branch '0.2' of https://github.com/simibubi/Create into 0.2
This commit is contained in:
commit
1d96f50b9a
2 changed files with 104 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.simibubi.create;
|
package com.simibubi.create;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.world.OreGeneration;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ public class Create {
|
||||||
|
|
||||||
modEventBus.addListener(Create::createConfigs);
|
modEventBus.addListener(Create::createConfigs);
|
||||||
CreateClient.addListeners(modEventBus);
|
CreateClient.addListeners(modEventBus);
|
||||||
|
OreGeneration.setupOreGeneration();
|
||||||
|
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, CreateConfig.specification);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, CreateConfig.specification);
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CreateClientConfig.specification);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CreateClientConfig.specification);
|
||||||
|
@ -85,7 +87,6 @@ public class Create {
|
||||||
LogisticianHandler.registerVillagerProfessions(event);
|
LogisticianHandler.registerVillagerProfessions(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerPointsOfInterest(RegistryEvent.Register<PointOfInterestType> event) {
|
public static void registerPointsOfInterest(RegistryEvent.Register<PointOfInterestType> event) {
|
||||||
LogisticianHandler.registerPointsOfInterest(event);
|
LogisticianHandler.registerPointsOfInterest(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
package com.simibubi.create.foundation.world;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.biome.Biomes;
|
||||||
|
import net.minecraft.world.gen.GenerationStage;
|
||||||
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
|
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||||
|
import net.minecraft.world.gen.placement.CountRangeConfig;
|
||||||
|
import net.minecraft.world.gen.placement.Placement;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum OreGeneration {
|
||||||
|
|
||||||
|
TEST_BLOB_1(new BasicOreGenConfig(Blocks.EMERALD_BLOCK, 25, 2, 128)),
|
||||||
|
TEST_BLOB_2(new BasicOreGenConfig(Blocks.QUARTZ_BLOCK, 41, 3, 25)),
|
||||||
|
TEST_BLOB_3(new OnlyInBiomes(new BasicOreGenConfig(Blocks.BLUE_GLAZED_TERRACOTTA, 5, 10, 30), Biome.Category.OCEAN)),
|
||||||
|
TEST_BLOB_4(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.GABBRO.get(), 31, 2, 128), Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS)),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
IOreGenConfig config;
|
||||||
|
|
||||||
|
OreGeneration(IOreGenConfig oreGenConfig) {
|
||||||
|
this.config = oreGenConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupOreGeneration() {
|
||||||
|
|
||||||
|
for (Biome biome :
|
||||||
|
ForgeRegistries.BIOMES) {
|
||||||
|
|
||||||
|
Arrays.stream(values()).forEach(oreGen -> oreGen.config.addFeature(biome));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BasicOreGenConfig implements IOreGenConfig {
|
||||||
|
|
||||||
|
Block block;
|
||||||
|
//im not 100% certain that these names are accurate but at least they seem that way
|
||||||
|
int clusterSize, clusterCount/*per chunk*/, maxHeight;
|
||||||
|
|
||||||
|
private BasicOreGenConfig(Block block, int clusterSize, int clusterCount, int maxHeight) {
|
||||||
|
this.block = block;
|
||||||
|
this.clusterSize = clusterSize;
|
||||||
|
this.clusterCount = clusterCount;
|
||||||
|
this.maxHeight = maxHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFeature(Biome biome) {
|
||||||
|
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,
|
||||||
|
Biome.createDecoratedFeature(Feature.ORE,
|
||||||
|
new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
|
||||||
|
block.getDefaultState(), clusterSize),
|
||||||
|
Placement.COUNT_RANGE, new CountRangeConfig(clusterCount, 0, 0, maxHeight)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class OnlyInBiomes implements IOreGenConfig {
|
||||||
|
|
||||||
|
//not sure if this is really needed but w/e
|
||||||
|
|
||||||
|
IOreGenConfig config;
|
||||||
|
List<Biome> biomes;
|
||||||
|
|
||||||
|
private OnlyInBiomes(IOreGenConfig config, Biome... biomes) {
|
||||||
|
this.config = config;
|
||||||
|
this.biomes = Arrays.asList(biomes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnlyInBiomes(IOreGenConfig config, Biome.Category category){
|
||||||
|
this.config = config;
|
||||||
|
this.biomes = new LinkedList<>();
|
||||||
|
for (Biome biome:
|
||||||
|
ForgeRegistries.BIOMES) {
|
||||||
|
if (biome.getCategory() == category)
|
||||||
|
biomes.add(biome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFeature(Biome biome) {
|
||||||
|
if (biomes.contains(biome)) {
|
||||||
|
config.addFeature(biome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface IOreGenConfig {
|
||||||
|
|
||||||
|
void addFeature(Biome biome);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue