diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json new file mode 100644 index 00000000..dba422d1 --- /dev/null +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -0,0 +1,15 @@ +{ + "values": [ + "naturesaura:ancient_bark", + "naturesaura:ancient_log", + "naturesaura:ancient_planks", + "naturesaura:ancient_slab", + "naturesaura:ancient_stairs", + "naturesaura:auto_crafter", + "naturesaura:flower_generator", + "naturesaura:nether_wart_mushroom", + "naturesaura:oak_generator", + "naturesaura:offering_table", + "naturesaura:wood_stand" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json new file mode 100644 index 00000000..347917f8 --- /dev/null +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -0,0 +1,49 @@ +{ + "values": [ + "naturesaura:animal_container", + "naturesaura:animal_generator", + "naturesaura:animal_spawner", + "naturesaura:aura_detector", + "naturesaura:aura_timer", + "naturesaura:blast_furnace_booster", + "naturesaura:chorus_generator", + "naturesaura:chunk_loader", + "naturesaura:conversion_catalyst", + "naturesaura:crushing_catalyst", + "naturesaura:depth_ingot_block", + "naturesaura:ender_crate", + "naturesaura:field_creator", + "naturesaura:firework_generator", + "naturesaura:furnace_heater", + "naturesaura:generator_limit_remover", + "naturesaura:gold_brick", + "naturesaura:gold_nether_brick", + "naturesaura:grated_chute", + "naturesaura:hopper_upgrade", + "naturesaura:infused_brick", + "naturesaura:infused_brick_slab", + "naturesaura:infused_brick_stairs", + "naturesaura:infused_iron_block", + "naturesaura:infused_slab", + "naturesaura:infused_stairs", + "naturesaura:infused_stone", + "naturesaura:item_distributor", + "naturesaura:lower_limiter", + "naturesaura:moss_generator", + "naturesaura:nature_altar", + "naturesaura:nether_grass", + "naturesaura:pickup_stopper", + "naturesaura:placer", + "naturesaura:potion_generator", + "naturesaura:powder_placer", + "naturesaura:projectile_generator", + "naturesaura:rf_converter", + "naturesaura:sky_ingot_block", + "naturesaura:snow_creator", + "naturesaura:spawn_lamp", + "naturesaura:spring", + "naturesaura:tainted_gold_block", + "naturesaura:time_changer", + "naturesaura:weather_changer" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_bloom.json b/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_bloom.json new file mode 100644 index 00000000..5b2133ae --- /dev/null +++ b/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_bloom.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#minecraft:is_overworld", + "features": "naturesaura:aura_bloom", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_cactus.json b/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_cactus.json new file mode 100644 index 00000000..7a8b4048 --- /dev/null +++ b/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_cactus.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#forge:is_sandy", + "features": "naturesaura:aura_cactus", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_mushroom.json b/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_mushroom.json new file mode 100644 index 00000000..b2ac9789 --- /dev/null +++ b/src/generated/resources/data/naturesaura/forge/biome_modifier/aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#forge:is_mushroom", + "features": "naturesaura:aura_mushroom", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/forge/biome_modifier/crimson_aura_mushroom.json b/src/generated/resources/data/naturesaura/forge/biome_modifier/crimson_aura_mushroom.json new file mode 100644 index 00000000..e3a0f533 --- /dev/null +++ b/src/generated/resources/data/naturesaura/forge/biome_modifier/crimson_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#minecraft:is_nether", + "features": "naturesaura:crimson_aura_mushroom", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/forge/biome_modifier/warped_aura_mushroom.json b/src/generated/resources/data/naturesaura/forge/biome_modifier/warped_aura_mushroom.json new file mode 100644 index 00000000..b3aad564 --- /dev/null +++ b/src/generated/resources/data/naturesaura/forge/biome_modifier/warped_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#minecraft:is_nether", + "features": "naturesaura:warped_aura_mushroom", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/configured_feature/ancient_tree.json b/src/generated/resources/data/naturesaura/worldgen/configured_feature/ancient_tree.json new file mode 100644 index 00000000..244e3522 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/configured_feature/ancient_tree.json @@ -0,0 +1,4 @@ +{ + "type": "naturesaura:ancient_tree", + "config": {} +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_bloom.json b/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_bloom.json new file mode 100644 index 00000000..4263180d --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_bloom.json @@ -0,0 +1,4 @@ +{ + "type": "naturesaura:aura_bloom", + "config": {} +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_cactus.json b/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_cactus.json new file mode 100644 index 00000000..7c576b08 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_cactus.json @@ -0,0 +1,4 @@ +{ + "type": "naturesaura:aura_cactus", + "config": {} +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_mushroom.json b/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_mushroom.json new file mode 100644 index 00000000..0f7c2c24 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/configured_feature/aura_mushroom.json @@ -0,0 +1,4 @@ +{ + "type": "naturesaura:aura_mushroom", + "config": {} +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/configured_feature/crimson_aura_mushroom.json b/src/generated/resources/data/naturesaura/worldgen/configured_feature/crimson_aura_mushroom.json new file mode 100644 index 00000000..e60a20f2 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/configured_feature/crimson_aura_mushroom.json @@ -0,0 +1,4 @@ +{ + "type": "naturesaura:crimson_aura_mushroom", + "config": {} +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/configured_feature/nether_wart_mushroom.json b/src/generated/resources/data/naturesaura/worldgen/configured_feature/nether_wart_mushroom.json new file mode 100644 index 00000000..394f197f --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/configured_feature/nether_wart_mushroom.json @@ -0,0 +1,4 @@ +{ + "type": "naturesaura:nether_wart_mushroom", + "config": {} +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/configured_feature/warped_aura_mushroom.json b/src/generated/resources/data/naturesaura/worldgen/configured_feature/warped_aura_mushroom.json new file mode 100644 index 00000000..89c28223 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/configured_feature/warped_aura_mushroom.json @@ -0,0 +1,4 @@ +{ + "type": "naturesaura:warped_aura_mushroom", + "config": {} +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_bloom.json b/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_bloom.json new file mode 100644 index 00000000..4892a560 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_bloom.json @@ -0,0 +1,4 @@ +{ + "feature": "naturesaura:aura_bloom", + "placement": [] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_cactus.json b/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_cactus.json new file mode 100644 index 00000000..c4bcaed3 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_cactus.json @@ -0,0 +1,4 @@ +{ + "feature": "naturesaura:aura_cactus", + "placement": [] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_mushroom.json b/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_mushroom.json new file mode 100644 index 00000000..a8c7168b --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/placed_feature/aura_mushroom.json @@ -0,0 +1,4 @@ +{ + "feature": "naturesaura:aura_mushroom", + "placement": [] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/placed_feature/crimson_aura_mushroom.json b/src/generated/resources/data/naturesaura/worldgen/placed_feature/crimson_aura_mushroom.json new file mode 100644 index 00000000..2fe5c073 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/placed_feature/crimson_aura_mushroom.json @@ -0,0 +1,4 @@ +{ + "feature": "naturesaura:crimson_aura_mushroom", + "placement": [] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/worldgen/placed_feature/warped_aura_mushroom.json b/src/generated/resources/data/naturesaura/worldgen/placed_feature/warped_aura_mushroom.json new file mode 100644 index 00000000..3d898042 --- /dev/null +++ b/src/generated/resources/data/naturesaura/worldgen/placed_feature/warped_aura_mushroom.json @@ -0,0 +1,4 @@ +{ + "feature": "naturesaura:warped_aura_mushroom", + "placement": [] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 0989a280..91ea3760 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -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); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index 319c15c1..e06dfd4e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -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> registry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE); + registry.getHolderOrThrow(ModFeatures.Configured.ANCIENT_TREE).value().place(level, level.getChunkSource().getGenerator(), rand, pos); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java index bd071bd7..52589924 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java @@ -10,6 +10,7 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.data.worldgen.features.TreeFeatures; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.SoundType; @@ -38,11 +39,11 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab Helper.getBlockEntitiesInArea(level, pos, 10, tile -> { if (!(tile instanceof BlockEntityOakGenerator oak)) return false; - /* var replacement = BlockOakGenerator.getReplacement(event.getFeature()); + var replacement = BlockOakGenerator.getReplacement(event.getFeature()); if (replacement != null) { oak.scheduledBigTrees.add(pos); event.setFeature(replacement); - }*/ + } return true; }); } @@ -68,8 +69,11 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab generator.modLoc("block/" + this.getBaseName() + "_top"))); } - // TODO oak gen replacements - /*private static Holder> getReplacement(Holder> feature) { + private static ResourceKey> getReplacement(Holder> holder) { + if(holder == null || !holder.unwrapKey().isPresent()) + return null; + + ResourceKey> feature = holder.unwrapKey().get(); if (feature == TreeFeatures.FANCY_OAK || feature == TreeFeatures.FANCY_OAK_BEES) { return TreeFeatures.OAK; } else if (feature == TreeFeatures.FANCY_OAK_BEES_002) { @@ -81,5 +85,5 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab } else { return null; } - }*/ + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 615c1352..218165a1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -28,6 +28,7 @@ public final class ModBlocks { public static Block AURA_DETECTOR; public static Block CONVERSION_CATALYST; public static Block CRUSHING_CATALYST; + public static Block DEPTH_INGOT_BLOCK; public static Block FLOWER_GENERATOR; public static Block PLACER; public static Block HOPPER_UPGRADE; @@ -45,6 +46,7 @@ public final class ModBlocks { public static Block GOLD_BRICK; public static Block GOLD_NETHER_BRICK; public static Block RF_CONVERTER; + public static Block SKY_INGOT_BLOCK; public static Block MOSS_GENERATOR; public static Block TIME_CHANGER; public static Block GENERATOR_LIMIT_REMOVER; diff --git a/src/main/java/de/ellpeck/naturesaura/data/BiomeModifiers.java b/src/main/java/de/ellpeck/naturesaura/data/BiomeModifiers.java new file mode 100644 index 00000000..8b0deff4 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/data/BiomeModifiers.java @@ -0,0 +1,60 @@ +package de.ellpeck.naturesaura.data; + +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.gen.ModFeatures; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BiomeTags; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; +import net.minecraftforge.common.Tags; +import net.minecraftforge.common.world.BiomeModifier; +import net.minecraftforge.common.world.ForgeBiomeModifiers; +import net.minecraftforge.registries.ForgeRegistries; + +public class BiomeModifiers { + public static ResourceKey AURA_BLOOM = createKey("aura_bloom"); + public static ResourceKey AURA_CACTUS = createKey("aura_cactus"); + public static ResourceKey WARPED_AURA_MUSHROOM = createKey("warped_aura_mushroom"); + public static ResourceKey CRIMSON_AURA_MUSHROOM = createKey("crimson_aura_mushroom"); + public static ResourceKey AURA_MUSHROOM = createKey("aura_mushroom"); + + private static ResourceKey createKey(String id) { + return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(NaturesAura.MOD_ID, id)); + } + + public static void bootstrap(BootstapContext context) { + HolderGetter biomeGetter = context.lookup(Registries.BIOME); + HolderGetter placedGetter = context.lookup(Registries.PLACED_FEATURE); + + context.register(AURA_BLOOM, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( + biomeGetter.getOrThrow(BiomeTags.IS_OVERWORLD), + HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_BLOOM)), + GenerationStep.Decoration.VEGETAL_DECORATION)); + + context.register(AURA_CACTUS, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( + biomeGetter.getOrThrow(Tags.Biomes.IS_SANDY), + HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_CACTUS)), + GenerationStep.Decoration.VEGETAL_DECORATION)); + + context.register(AURA_MUSHROOM, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( + biomeGetter.getOrThrow(Tags.Biomes.IS_MUSHROOM), + HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_MUSHROOM)), + GenerationStep.Decoration.VEGETAL_DECORATION)); + + context.register(CRIMSON_AURA_MUSHROOM, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( + biomeGetter.getOrThrow(BiomeTags.IS_NETHER), + HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.CRIMSON_AURA_MUSHROOM)), + GenerationStep.Decoration.VEGETAL_DECORATION)); + + context.register(WARPED_AURA_MUSHROOM, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( + biomeGetter.getOrThrow(BiomeTags.IS_NETHER), + HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.WARPED_AURA_MUSHROOM)), + GenerationStep.Decoration.VEGETAL_DECORATION)); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java index 12e77f4d..04eeb321 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java @@ -44,15 +44,22 @@ public class BlockTagProvider extends BlockTagsProvider { this.tag(BlockTagProvider.ALTAR_GOLD_BRICK).add(ModBlocks.GOLD_BRICK, ModBlocks.GOLD_NETHER_BRICK); this.tag(BlockTagProvider.ALTAR_FANCY_BRICK).add(Blocks.RED_NETHER_BRICKS, Blocks.CHISELED_STONE_BRICKS); - // sort these so that they don't change the json every time we run data (because it's a set) - ModRegistry.ALL_ITEMS.stream().sorted(Comparator.comparing(IModItem::getBaseName)).filter(i -> i instanceof Block).map(i -> (Block) i).forEach(b -> { - // TODO figure out what to do about materials for mineability - /*var material = b.defaultBlockState().getMaterial(); - if (material == Material.STONE || material == Material.METAL) { - this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(b); - } else if (material == Material.WOOD) { - this.tag(BlockTags.MINEABLE_WITH_AXE).add(b); - }*/ - }); + this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(ModBlocks.ANIMAL_CONTAINER, ModBlocks.ANIMAL_GENERATOR, + ModBlocks.ANIMAL_SPAWNER, ModBlocks.AURA_DETECTOR, ModBlocks.AURA_TIMER, ModBlocks.BLAST_FURNACE_BOOSTER, + ModBlocks.CHORUS_GENERATOR, ModBlocks.CHUNK_LOADER, ModBlocks.CONVERSION_CATALYST, ModBlocks.CRUSHING_CATALYST, + ModBlocks.DEPTH_INGOT_BLOCK, ModBlocks.ENDER_CRATE, ModBlocks.FIELD_CREATOR, ModBlocks.FIREWORK_GENERATOR, + ModBlocks.FURNACE_HEATER, ModBlocks.GENERATOR_LIMIT_REMOVER, ModBlocks.GOLD_BRICK, ModBlocks.GOLD_NETHER_BRICK, + ModBlocks.GRATED_CHUTE, ModBlocks.HOPPER_UPGRADE, ModBlocks.INFUSED_BRICK, ModBlocks.INFUSED_BRICK_SLAB, + ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_IRON_BLOCK, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_STAIRS, + ModBlocks.INFUSED_STONE, ModBlocks.ITEM_DISTRIBUTOR, ModBlocks.LOWER_LIMITER, ModBlocks.MOSS_GENERATOR, + ModBlocks.NATURE_ALTAR, ModBlocks.NETHER_GRASS, ModBlocks.PICKUP_STOPPER, ModBlocks.PLACER, ModBlocks.POTION_GENERATOR, + ModBlocks.POWDER_PLACER, ModBlocks.PROJECTILE_GENERATOR, ModBlocks.RF_CONVERTER, ModBlocks.SKY_INGOT_BLOCK, + ModBlocks.SNOW_CREATOR, ModBlocks.SPAWN_LAMP, ModBlocks.SPRING, ModBlocks.TAINTED_GOLD_BLOCK, + ModBlocks.TIME_CHANGER, ModBlocks.WEATHER_CHANGER); + + this.tag(BlockTags.MINEABLE_WITH_AXE).add(ModBlocks.ANCIENT_BARK, ModBlocks.ANCIENT_LOG, + ModBlocks.ANCIENT_PLANKS, ModBlocks.ANCIENT_SLAB, ModBlocks.ANCIENT_STAIRS, + ModBlocks.AUTO_CRAFTER, ModBlocks.FLOWER_GENERATOR, ModBlocks.NETHER_WART_MUSHROOM, + ModBlocks.OAK_GENERATOR, ModBlocks.OFFERING_TABLE, ModBlocks.WOOD_STAND); } } diff --git a/src/main/java/de/ellpeck/naturesaura/data/ModData.java b/src/main/java/de/ellpeck/naturesaura/data/ModData.java index 9840fc2e..bfe94347 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/ModData.java +++ b/src/main/java/de/ellpeck/naturesaura/data/ModData.java @@ -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,18 @@ 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, BiomeModifiers::bootstrap); + // 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()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index 82b85bee..6644366b 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -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> ANCIENT_TREE; - public static Holder> NETHER_WART_MUSHROOM; - public static Holder> AURA_BLOOM; - public static Holder> AURA_CACTUS; - public static Holder> WARPED_AURA_MUSHROOM; - public static Holder> CRIMSON_AURA_MUSHROOM; - public static Holder> AURA_MUSHROOM; + public static ResourceKey> ANCIENT_TREE = FeatureUtils.createKey(NaturesAura.MOD_ID + ":ancient_tree"); + public static ResourceKey> NETHER_WART_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":nether_wart_mushroom"); + public static ResourceKey> AURA_BLOOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom"); + public static ResourceKey> AURA_CACTUS = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus"); + public static ResourceKey> WARPED_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom"); + public static ResourceKey> CRIMSON_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom"); + public static ResourceKey> AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom"); + + public static void bootstrap(BootstapContext> 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 AURA_BLOOM; - public static Holder AURA_CACTUS; - public static Holder WARPED_AURA_MUSHROOM; - public static Holder CRIMSON_AURA_MUSHROOM; - public static Holder AURA_MUSHROOM; + public static ResourceKey AURA_BLOOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom"); + public static ResourceKey AURA_CACTUS = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus"); + public static ResourceKey WARPED_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom"); + public static ResourceKey CRIMSON_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom"); + public static ResourceKey AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom"); + public static void bootstrap(BootstapContext context) { + HolderGetter> 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)); + + } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java index 001e2dca..a8693be9 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java @@ -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> 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)); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java index 9617ed54..d33a3d44 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java @@ -50,8 +50,7 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel { // this is just a modified copy of Player.attack's sweeping damage code var damage = (float) player.getAttributeValue(Attributes.ATTACK_DAMAGE) * 0.75F; for (var other : player.level().getEntitiesOfClass(LivingEntity.class, stack.getSweepHitBox(player, target))) { - // TODO we removed canHit here, is that okay? - if (other != player && other != target && !player.isAlliedTo(other) && (!(other instanceof ArmorStand stand) || !stand.isMarker())) { + if (other != player && other != target && !player.isAlliedTo(other) && (!(other instanceof ArmorStand stand) || !stand.isMarker()) && player.distanceToSqr(other) < Mth.square(player.getEntityReach())) { other.knockback(0.4F, Mth.sin(player.getYRot() * (Mth.PI / 180)), -Mth.cos(player.getYRot() * (Mth.PI / 180))); other.hurt(other.damageSources().playerAttack(player), damage); } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 57b2ee58..1f09e105 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -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); diff --git a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_bloom.json b/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_bloom.json deleted file mode 100644 index a290296f..00000000 --- a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_bloom.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "forge:add_features", - "biomes": "#forge:is_overworld", - "features": "naturesaura:aura_bloom", - "step": "vegetal_decoration" -} \ No newline at end of file diff --git a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_cactus.json b/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_cactus.json deleted file mode 100644 index 951d92ac..00000000 --- a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_cactus.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "forge:add_features", - "biomes": "#forge:is_sandy", - "features": "naturesaura:aura_cactus", - "step": "vegetal_decoration" -} \ No newline at end of file diff --git a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_mushroom.json b/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_mushroom.json deleted file mode 100644 index 15f85f32..00000000 --- a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/aura_mushroom.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "forge:add_features", - "biomes": "#forge:is_mushroom", - "features": "naturesaura:aura_mushroom", - "step": "vegetal_decoration" -} \ No newline at end of file diff --git a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/crimson_aura_mushroom.json b/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/crimson_aura_mushroom.json deleted file mode 100644 index 60e81816..00000000 --- a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/crimson_aura_mushroom.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "forge:add_features", - "biomes": "#minecraft:is_nether", - "features": "naturesaura:crimson_aura_mushroom", - "step": "vegetal_decoration" -} \ No newline at end of file diff --git a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/warped_aura_mushroom.json b/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/warped_aura_mushroom.json deleted file mode 100644 index 94ecf74f..00000000 --- a/src/main/resources/data/naturesaura/forge/biome_modifier_fixme/warped_aura_mushroom.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "forge:add_features", - "biomes": "#minecraft:is_nether", - "features": "naturesaura:warped_aura_mushroom", - "step": "vegetal_decoration" -} \ No newline at end of file