Ether Grove prototype
This commit is contained in:
parent
46450a1bc8
commit
0fffaad9f0
12 changed files with 173 additions and 22 deletions
|
@ -18,6 +18,14 @@ public class Integrations {
|
|||
});
|
||||
}
|
||||
|
||||
public static void addBiomes() {
|
||||
INTEGRATIONS.forEach((integration) -> {
|
||||
if (integration.modIsInstalled()) {
|
||||
integration.addBiomes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static ModIntegration register(ModIntegration integration) {
|
||||
INTEGRATIONS.add(integration);
|
||||
return integration;
|
||||
|
|
|
@ -18,6 +18,8 @@ public abstract class ModIntegration {
|
|||
|
||||
public abstract void register();
|
||||
|
||||
public abstract void addBiomes();
|
||||
|
||||
public ModIntegration(String modID) {
|
||||
this.modID = modID;
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package ru.betterend.integration.byg;
|
||||
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
import ru.betterend.world.generator.BiomeType;
|
||||
|
||||
public class BYGBiomes {
|
||||
// Original Biomes
|
||||
public static final EndBiome BULBIS_GARDENS = EndBiomes.registerBiome(Integrations.BYG.getKey("bulbis_gardens"), BiomeType.LAND, 1F);
|
||||
|
||||
// New Biomes
|
||||
public static final EndBiome OLD_BULBIS_GARDENS = EndBiomes.registerSubBiome(new OldBulbisGardens(), BULBIS_GARDENS);
|
||||
|
||||
public static void register() {}
|
||||
}
|
|
@ -2,6 +2,8 @@ package ru.betterend.integration.byg;
|
|||
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.ModIntegration;
|
||||
import ru.betterend.integration.byg.biomes.BYGBiomes;
|
||||
import ru.betterend.integration.byg.features.BYGFeatures;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.TagHelper;
|
||||
|
||||
|
@ -17,4 +19,9 @@ public class BYGIntegration extends ModIntegration {
|
|||
BYGFeatures.register();
|
||||
BYGBiomes.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomes() {
|
||||
BYGBiomes.addBiomes();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package ru.betterend.integration.byg.biomes;
|
||||
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class BYGBiomes {
|
||||
// New Biomes
|
||||
public static final EndBiome OLD_BULBIS_GARDENS = EndBiomes.registerSubBiomeIntegration(new OldBulbisGardens());
|
||||
public static final EndBiome ETHERIAL_GROVE = EndBiomes.registerSubBiomeIntegration(new EterialGrove());
|
||||
|
||||
public static void register() {}
|
||||
|
||||
public static void addBiomes() {
|
||||
EndBiomes.addSubBiomeIntegration(OLD_BULBIS_GARDENS, Integrations.BYG.getID("bulbis_gardens"));
|
||||
EndBiomes.addSubBiomeIntegration(ETHERIAL_GROVE, Integrations.BYG.getID("ethereal_islands"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package ru.betterend.integration.byg.biomes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.byg.features.BYGFeatures;
|
||||
import ru.betterend.world.biome.BiomeDefinition;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class EterialGrove extends EndBiome {
|
||||
public EterialGrove() {
|
||||
super(makeDef());
|
||||
}
|
||||
|
||||
private static BiomeDefinition makeDef() {
|
||||
Biome biome = Integrations.BYG.getBiome("ethereal_islands");
|
||||
BiomeEffects effects = biome.getEffects();
|
||||
|
||||
BiomeDefinition def = new BiomeDefinition("eterial_grove")
|
||||
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get())
|
||||
.addFeature(BYGFeatures.BIG_ETHER_TREE);
|
||||
|
||||
if (BetterEnd.isClient()) {
|
||||
SoundEvent loop = effects.getLoopSound().get();
|
||||
SoundEvent music = effects.getMusic().get().getSound();
|
||||
SoundEvent additions = effects.getAdditionsSound().get().getSound();
|
||||
SoundEvent mood = effects.getMoodSound().get().getSound();
|
||||
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
|
||||
}
|
||||
|
||||
for (SpawnGroup group: SpawnGroup.values()) {
|
||||
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
|
||||
list.forEach((entry) -> {
|
||||
def.addMobSpawn(entry);
|
||||
});
|
||||
}
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ru.betterend.integration.byg;
|
||||
package ru.betterend.integration.byg.biomes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -11,6 +11,7 @@ import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
|
|||
import net.minecraft.world.gen.GenerationStep.Feature;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.byg.features.BYGFeatures;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.world.biome.BiomeDefinition;
|
||||
import ru.betterend.world.biome.EndBiome;
|
|
@ -1,7 +1,8 @@
|
|||
package ru.betterend.integration.byg;
|
||||
package ru.betterend.integration.byg.features;
|
||||
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.byg.BYGBlocks;
|
||||
import ru.betterend.world.features.EndFeature;
|
||||
import ru.betterend.world.features.SinglePlantFeature;
|
||||
import ru.betterend.world.features.VineFeature;
|
||||
|
@ -17,6 +18,8 @@ public class BYGFeatures {
|
|||
public static final EndFeature BULBIS_ODDITY = new EndFeature("bulbis_oddity", new SinglePlantFeature(Integrations.BYG.getBlock("bulbis_oddity"), 4, 4), 5);
|
||||
public static final EndFeature PURPLE_BULBIS_ODDITY = new EndFeature("purple_bulbis_oddity", new SinglePlantFeature(Integrations.BYG.getBlock("purple_bulbis_oddity"), 4, 4), 5);
|
||||
|
||||
public static final EndFeature BIG_ETHER_TREE = new EndFeature("big_ether_tree", new BigEtherTreeFeature(), 1);
|
||||
|
||||
public static final ConfiguredFeature<?,?> BULBIS_TREES = Integrations.BYG.getConfiguredFeature("rs_sparse_bulbis_tree");
|
||||
public static final ConfiguredFeature<?,?> PURPLE_BULBIS_TREES = Integrations.BYG.getConfiguredFeature("rs_sparse_purple_bulbis_tree");
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package ru.betterend.integration.byg.features;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.SplineHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class BigEtherTreeFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
BlockState log = Integrations.BYG.getDefaultState("ether_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("ether_wood");
|
||||
BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves");
|
||||
|
||||
int height = MHelper.randRange(20, 30, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 2);
|
||||
SplineHelper.offsetParts(trunk, random, 0.5F, 0, 0.5F);
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, (bpos) -> { return log;});
|
||||
sdf.setReplaceFunction((state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||
}).fillRecursive(world, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos, BlockState leaves, Function<BlockState, Boolean> ignore) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ru.betterend.integration.byg;
|
||||
package ru.betterend.integration.byg.features;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
|
@ -28,6 +28,7 @@ import net.minecraft.world.biome.BiomeKeys;
|
|||
import net.minecraft.world.biome.layer.util.LayerRandomnessSource;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.util.JsonFactory;
|
||||
import ru.betterend.world.biome.BiomeAmberLand;
|
||||
import ru.betterend.world.biome.BiomeBlossomingSpires;
|
||||
|
@ -134,6 +135,7 @@ public class EndBiomes {
|
|||
}
|
||||
}
|
||||
});
|
||||
Integrations.addBiomes();
|
||||
Configs.BIOME_CONFIG.saveChanges();
|
||||
|
||||
LAND_BIOMES.rebuild();
|
||||
|
@ -266,7 +268,7 @@ public class EndBiomes {
|
|||
* @return registered {@link EndBiome}
|
||||
*/
|
||||
public static EndBiome registerSubBiome(EndBiome biome, EndBiome parent) {
|
||||
registerBiomeDirect(biome);
|
||||
registerBiomeDirectly(biome);
|
||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||
parent.addSubBiome(biome);
|
||||
SUBBIOMES.add(biome);
|
||||
|
@ -284,7 +286,7 @@ public class EndBiomes {
|
|||
* @return registered {@link EndBiome}
|
||||
*/
|
||||
public static EndBiome registerBiome(EndBiome biome, BiomeType type) {
|
||||
registerBiomeDirect(biome);
|
||||
registerBiomeDirectly(biome);
|
||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||
addToPicker(biome, type);
|
||||
ID_MAP.put(biome.getID(), biome);
|
||||
|
@ -298,6 +300,37 @@ public class EndBiomes {
|
|||
return biome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put integration sub-biome {@link EndBiome} into subbiomes list and registers it.
|
||||
* @param biome - {@link EndBiome} instance
|
||||
* @return registered {@link EndBiome}
|
||||
*/
|
||||
public static EndBiome registerSubBiomeIntegration(EndBiome biome) {
|
||||
registerBiomeDirectly(biome);
|
||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||
SUBBIOMES.add(biome);
|
||||
SUBBIOMES_UNMUTABLES.add(biome.getID());
|
||||
ID_MAP.put(biome.getID(), biome);
|
||||
addLandBiomeToFabricApi(biome);
|
||||
}
|
||||
return biome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Link integration sub-biome with parent.
|
||||
* @param biome - {@link EndBiome} instance
|
||||
* @param parent - {@link Identifier} parent id
|
||||
*/
|
||||
public static void addSubBiomeIntegration(EndBiome biome, Identifier parent) {
|
||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||
EndBiome parentBiome = ID_MAP.get(parent);
|
||||
System.out.println(parentBiome);
|
||||
if (parentBiome != null && !parentBiome.containsSubBiome(biome)) {
|
||||
parentBiome.addSubBiome(biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static EndBiome registerBiome(RegistryKey<Biome> key, BiomeType type, float genChance) {
|
||||
return registerBiome(BuiltinRegistries.BIOME.get(key), type, genChance);
|
||||
}
|
||||
|
@ -313,7 +346,7 @@ public class EndBiomes {
|
|||
VOID_BIOMES.addBiome(biome);
|
||||
}
|
||||
|
||||
private static void registerBiomeDirect(EndBiome biome) {
|
||||
private static void registerBiomeDirectly(EndBiome biome) {
|
||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||
Registry.register(BuiltinRegistries.BIOME, biome.getID(), biome.getBiome());
|
||||
}
|
||||
|
|
|
@ -77,6 +77,10 @@ public class EndBiome {
|
|||
biome.biomeParent = this;
|
||||
subbiomes.add(biome);
|
||||
}
|
||||
|
||||
public boolean containsSubBiome(EndBiome biome) {
|
||||
return subbiomes.contains(biome);
|
||||
}
|
||||
|
||||
public EndBiome getSubBiome(Random random) {
|
||||
float chance = random.nextFloat() * maxSubBiomeChance;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue