Add back worldgen

This commit is contained in:
Mrbysco 2023-07-25 21:34:39 +02:00
parent 16820698c8
commit 6192523202
18 changed files with 130 additions and 36 deletions

View file

@ -0,0 +1,4 @@
{
"type": "naturesaura:ancient_tree",
"config": {}
}

View file

@ -0,0 +1,4 @@
{
"type": "naturesaura:aura_bloom",
"config": {}
}

View file

@ -0,0 +1,4 @@
{
"type": "naturesaura:aura_cactus",
"config": {}
}

View file

@ -0,0 +1,4 @@
{
"type": "naturesaura:aura_mushroom",
"config": {}
}

View file

@ -0,0 +1,4 @@
{
"type": "naturesaura:crimson_aura_mushroom",
"config": {}
}

View file

@ -0,0 +1,4 @@
{
"type": "naturesaura:nether_wart_mushroom",
"config": {}
}

View file

@ -0,0 +1,4 @@
{
"type": "naturesaura:warped_aura_mushroom",
"config": {}
}

View file

@ -0,0 +1,4 @@
{
"feature": "naturesaura:aura_bloom",
"placement": []
}

View file

@ -0,0 +1,4 @@
{
"feature": "naturesaura:aura_cactus",
"placement": []
}

View file

@ -0,0 +1,4 @@
{
"feature": "naturesaura:aura_mushroom",
"placement": []
}

View file

@ -0,0 +1,4 @@
{
"feature": "naturesaura:crimson_aura_mushroom",
"placement": []
}

View file

@ -0,0 +1,4 @@
{
"feature": "naturesaura:warped_aura_mushroom",
"placement": []
}

View file

@ -11,7 +11,6 @@ import de.ellpeck.naturesaura.proxy.ClientProxy;
import de.ellpeck.naturesaura.proxy.IProxy;
import de.ellpeck.naturesaura.proxy.ServerProxy;
import de.ellpeck.naturesaura.recipes.ModRecipes;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor;
@ -63,7 +62,6 @@ public final class NaturesAura {
event.enqueueWork(ModConfig.instance::apply);
ModRecipes.init();
ModRegistry.init();
DrainSpotEffects.init();
NaturesAura.proxy.init(event);

View file

@ -8,6 +8,8 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockGetter;
@ -16,6 +18,7 @@ import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.event.ForgeEventFactory;
@ -72,7 +75,8 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock,
if (state.getValue(SaplingBlock.STAGE) == 0) {
level.setBlock(pos, state.cycle(SaplingBlock.STAGE), 4);
} else if (!ForgeEventFactory.blockGrowFeature(level, rand, pos, null).getResult().equals(Event.Result.DENY)) {
ModFeatures.Configured.ANCIENT_TREE.value().place(level, level.getChunkSource().getGenerator(), rand, pos);
Registry<ConfiguredFeature<?, ?>> registry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
registry.getHolderOrThrow(ModFeatures.Configured.ANCIENT_TREE).value().place(level, level.getChunkSource().getGenerator(), rand, pos);
}
}

View file

@ -1,13 +1,24 @@
package de.ellpeck.naturesaura.data;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.gen.ModFeatures;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.data.registries.VanillaRegistries;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public final class ModData {
@ -25,5 +36,20 @@ public final class ModData {
gen.addProvider(event.includeServer(), new LootTableProvider(out, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLootProvider::new, LootContextParamSets.BLOCK))));
gen.addProvider(event.includeServer(), new BlockStateGenerator(out, existing));
gen.addProvider(event.includeServer(), new ItemModelGenerator(out, existing));
gen.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(out, CompletableFuture.supplyAsync(ModData::getProvider), Set.of(NaturesAura.MOD_ID)));
}
private static HolderLookup.Provider getProvider() {
final RegistrySetBuilder registryBuilder = new RegistrySetBuilder();
registryBuilder.add(Registries.CONFIGURED_FEATURE, ModFeatures.Configured::bootstrap);
registryBuilder.add(Registries.PLACED_FEATURE, ModFeatures.Placed::bootstrap);
registryBuilder.add(ForgeRegistries.Keys.BIOME_MODIFIERS, context -> {
});
// We need the BIOME registry to be present, so we can use a biome tag, doesn't matter that it's empty
registryBuilder.add(Registries.BIOME, context -> {
});
RegistryAccess.Frozen regAccess = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY);
return registryBuilder.buildPatch(regAccess, VanillaRegistries.createLookup());
}
}

View file

@ -1,6 +1,12 @@
package de.ellpeck.naturesaura.gen;
import net.minecraft.core.Holder;
import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.data.worldgen.features.FeatureUtils;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -20,23 +26,44 @@ public final class ModFeatures {
public static final class Configured {
public static Holder<ConfiguredFeature<TreeConfiguration, ?>> ANCIENT_TREE;
public static Holder<ConfiguredFeature<NoneFeatureConfiguration, ?>> NETHER_WART_MUSHROOM;
public static Holder<ConfiguredFeature<NoneFeatureConfiguration, ?>> AURA_BLOOM;
public static Holder<ConfiguredFeature<NoneFeatureConfiguration, ?>> AURA_CACTUS;
public static Holder<ConfiguredFeature<NoneFeatureConfiguration, ?>> WARPED_AURA_MUSHROOM;
public static Holder<ConfiguredFeature<NoneFeatureConfiguration, ?>> CRIMSON_AURA_MUSHROOM;
public static Holder<ConfiguredFeature<NoneFeatureConfiguration, ?>> AURA_MUSHROOM;
public static ResourceKey<ConfiguredFeature<?, ?>> ANCIENT_TREE = FeatureUtils.createKey(NaturesAura.MOD_ID + ":ancient_tree");
public static ResourceKey<ConfiguredFeature<?, ?>> NETHER_WART_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":nether_wart_mushroom");
public static ResourceKey<ConfiguredFeature<?, ?>> AURA_BLOOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom");
public static ResourceKey<ConfiguredFeature<?, ?>> AURA_CACTUS = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus");
public static ResourceKey<ConfiguredFeature<?, ?>> WARPED_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom");
public static ResourceKey<ConfiguredFeature<?, ?>> CRIMSON_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom");
public static ResourceKey<ConfiguredFeature<?, ?>> AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom");
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
FeatureUtils.register(context, ModFeatures.Configured.AURA_BLOOM, ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE);
FeatureUtils.register(context, ModFeatures.Configured.AURA_CACTUS, ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE);
FeatureUtils.register(context, ModFeatures.Configured.WARPED_AURA_MUSHROOM, ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
FeatureUtils.register(context, ModFeatures.Configured.CRIMSON_AURA_MUSHROOM, ModFeatures.CRIMSON_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
FeatureUtils.register(context, ModFeatures.Configured.AURA_MUSHROOM, ModFeatures.AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
FeatureUtils.register(context, ModFeatures.Configured.ANCIENT_TREE, ModFeatures.ANCIENT_TREE, new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build());
FeatureUtils.register(context, ModFeatures.Configured.NETHER_WART_MUSHROOM, ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
}
}
public static final class Placed {
public static Holder<PlacedFeature> AURA_BLOOM;
public static Holder<PlacedFeature> AURA_CACTUS;
public static Holder<PlacedFeature> WARPED_AURA_MUSHROOM;
public static Holder<PlacedFeature> CRIMSON_AURA_MUSHROOM;
public static Holder<PlacedFeature> AURA_MUSHROOM;
public static ResourceKey<PlacedFeature> AURA_BLOOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom");
public static ResourceKey<PlacedFeature> AURA_CACTUS = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus");
public static ResourceKey<PlacedFeature> WARPED_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom");
public static ResourceKey<PlacedFeature> CRIMSON_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom");
public static ResourceKey<PlacedFeature> AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom");
public static void bootstrap(BootstapContext<PlacedFeature> context) {
HolderGetter<ConfiguredFeature<?, ?>> holdergetter = context.lookup(Registries.CONFIGURED_FEATURE);
PlacementUtils.register(context, AURA_BLOOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_BLOOM));
PlacementUtils.register(context, AURA_CACTUS, holdergetter.getOrThrow(ModFeatures.Configured.AURA_CACTUS));
PlacementUtils.register(context, WARPED_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.WARPED_AURA_MUSHROOM));
PlacementUtils.register(context, CRIMSON_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.CRIMSON_AURA_MUSHROOM));
PlacementUtils.register(context, AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_MUSHROOM));
}
}
}

View file

@ -1,12 +1,15 @@
package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.gen.ModFeatures;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.NetherWartBlock;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
public class ItemCrimsonMeal extends ItemImpl {
@ -24,7 +27,8 @@ public class ItemCrimsonMeal extends ItemImpl {
if (level.random.nextInt(5) == 0) {
int age = state.getValue(NetherWartBlock.AGE);
if (age >= 3) {
ModFeatures.Configured.NETHER_WART_MUSHROOM.value().place((ServerLevel) level, ((ServerLevel) level).getChunkSource().getGenerator(), level.random, pos);
Registry<ConfiguredFeature<?, ?>> registry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
registry.getHolderOrThrow(ModFeatures.Configured.NETHER_WART_MUSHROOM).value().place((ServerLevel) level, ((ServerLevel) level).getChunkSource().getGenerator(), level.random, pos);
} else {
level.setBlockAndUpdate(pos, state.setValue(NetherWartBlock.AGE, age + 1));
}

View file

@ -11,6 +11,10 @@ import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment;
import de.ellpeck.naturesaura.enchant.ModEnchantments;
import de.ellpeck.naturesaura.entities.*;
import de.ellpeck.naturesaura.gen.LevelGenAncientTree;
import de.ellpeck.naturesaura.gen.LevelGenAuraBloom;
import de.ellpeck.naturesaura.gen.LevelGenNetherWartMushroom;
import de.ellpeck.naturesaura.gen.ModFeatures;
import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers;
import de.ellpeck.naturesaura.items.*;
@ -276,7 +280,7 @@ public final class ModRegistry {
Helper.populateObjectHolders(ModEntities.class, event.getForgeRegistry());
});
/*
event.register(ForgeRegistries.Keys.FEATURES, h -> {
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false));
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false));
@ -287,7 +291,7 @@ public final class ModRegistry {
h.register(new ResourceLocation(NaturesAura.MOD_ID, "nether_wart_mushroom"), new LevelGenNetherWartMushroom());
Helper.populateObjectHolders(ModFeatures.class, event.getForgeRegistry());
});
*/
event.register(ForgeRegistries.Keys.RECIPE_TYPES, h -> {
h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_TYPE);
@ -324,23 +328,6 @@ public final class ModRegistry {
});
}
public static void init() {
// TODO fucking features changed again
/*ModFeatures.Configured.AURA_BLOOM = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_bloom", ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE);
ModFeatures.Configured.AURA_CACTUS = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_cactus", ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE);
ModFeatures.Configured.WARPED_AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":warped_aura_mushroom", ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
ModFeatures.Configured.CRIMSON_AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":crimson_aura_mushroom", ModFeatures.CRIMSON_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
ModFeatures.Configured.AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_mushroom", ModFeatures.AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
ModFeatures.Configured.ANCIENT_TREE = FeatureUtils.register(NaturesAura.MOD_ID + ":ancient_tree", ModFeatures.ANCIENT_TREE, new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build());
ModFeatures.Configured.NETHER_WART_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":nether_wart_mushroom", ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
ModFeatures.Placed.AURA_BLOOM = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_bloom", ModFeatures.Configured.AURA_BLOOM);
ModFeatures.Placed.AURA_CACTUS = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_cactus", ModFeatures.Configured.AURA_CACTUS);
ModFeatures.Placed.WARPED_AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":warped_aura_mushroom", ModFeatures.Configured.WARPED_AURA_MUSHROOM);
ModFeatures.Placed.CRIMSON_AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":crimson_aura_mushroom", ModFeatures.Configured.CRIMSON_AURA_MUSHROOM);
ModFeatures.Placed.AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_mushroom", ModFeatures.Configured.AURA_MUSHROOM);*/
}
public static Block createFlowerPot(Block block) {
var props = Block.Properties.of().strength(0F);
Block potted = new BlockFlowerPot(() -> (FlowerPotBlock) Blocks.FLOWER_POT, () -> block, props);