diff --git a/src/generated/resources/assets/naturesaura/blockstates/aura_mushroom.json b/src/generated/resources/assets/naturesaura/blockstates/aura_mushroom.json new file mode 100644 index 00000000..4dcbb12b --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/aura_mushroom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/aura_mushroom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/blockstates/crimson_aura_mushroom.json b/src/generated/resources/assets/naturesaura/blockstates/crimson_aura_mushroom.json new file mode 100644 index 00000000..31e8aafb --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/crimson_aura_mushroom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/crimson_aura_mushroom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/blockstates/potted_aura_mushroom.json b/src/generated/resources/assets/naturesaura/blockstates/potted_aura_mushroom.json new file mode 100644 index 00000000..10b35e8a --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/potted_aura_mushroom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/potted_aura_mushroom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/blockstates/potted_crimson_aura_mushroom.json b/src/generated/resources/assets/naturesaura/blockstates/potted_crimson_aura_mushroom.json new file mode 100644 index 00000000..98f68462 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/potted_crimson_aura_mushroom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/potted_crimson_aura_mushroom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/blockstates/potted_warped_aura_mushroom.json b/src/generated/resources/assets/naturesaura/blockstates/potted_warped_aura_mushroom.json new file mode 100644 index 00000000..82bd39a2 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/potted_warped_aura_mushroom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/potted_warped_aura_mushroom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/blockstates/warped_aura_mushroom.json b/src/generated/resources/assets/naturesaura/blockstates/warped_aura_mushroom.json new file mode 100644 index 00000000..01b9412b --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/warped_aura_mushroom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/warped_aura_mushroom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/block/aura_mushroom.json new file mode 100644 index 00000000..d88cce07 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cross", + "textures": { + "cross": "naturesaura:block/aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/crimson_aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/block/crimson_aura_mushroom.json new file mode 100644 index 00000000..5fd332c3 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/crimson_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cross", + "textures": { + "cross": "naturesaura:block/crimson_aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/potted_aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/block/potted_aura_mushroom.json new file mode 100644 index 00000000..24212bcc --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/potted_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/flower_pot_cross", + "textures": { + "plant": "naturesaura:block/aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/potted_crimson_aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/block/potted_crimson_aura_mushroom.json new file mode 100644 index 00000000..006cce5f --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/potted_crimson_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/flower_pot_cross", + "textures": { + "plant": "naturesaura:block/crimson_aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/potted_warped_aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/block/potted_warped_aura_mushroom.json new file mode 100644 index 00000000..88f0dc81 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/potted_warped_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/flower_pot_cross", + "textures": { + "plant": "naturesaura:block/warped_aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/warped_aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/block/warped_aura_mushroom.json new file mode 100644 index 00000000..2f73def1 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/warped_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cross", + "textures": { + "cross": "naturesaura:block/warped_aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/item/aura_mushroom.json new file mode 100644 index 00000000..64997edd --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "naturesaura:block/aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/crimson_aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/item/crimson_aura_mushroom.json new file mode 100644 index 00000000..aa38a0b9 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/crimson_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "naturesaura:block/crimson_aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/warped_aura_mushroom.json b/src/generated/resources/assets/naturesaura/models/item/warped_aura_mushroom.json new file mode 100644 index 00000000..40cbee92 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/warped_aura_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "naturesaura:block/warped_aura_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_mushroom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_mushroom.json new file mode 100644 index 00000000..3aa4578f --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_mushroom.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:aura_mushroom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/crimson_aura_mushroom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/crimson_aura_mushroom.json new file mode 100644 index 00000000..984397c3 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/crimson_aura_mushroom.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:crimson_aura_mushroom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_mushroom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_mushroom.json new file mode 100644 index 00000000..97910340 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_mushroom.json @@ -0,0 +1,33 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:flower_pot" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:aura_mushroom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_crimson_aura_mushroom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_crimson_aura_mushroom.json new file mode 100644 index 00000000..b557f512 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_crimson_aura_mushroom.json @@ -0,0 +1,33 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:flower_pot" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:crimson_aura_mushroom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_warped_aura_mushroom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_warped_aura_mushroom.json new file mode 100644 index 00000000..133b4868 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_warped_aura_mushroom.json @@ -0,0 +1,33 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:flower_pot" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:warped_aura_mushroom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/warped_aura_mushroom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/warped_aura_mushroom.json new file mode 100644 index 00000000..bf66b7f0 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/warped_aura_mushroom.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:warped_aura_mushroom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java index e085e37b..57699383 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.blocks; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.reg.*; @@ -7,6 +8,8 @@ import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; import net.minecraft.entity.Entity; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ITag; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; @@ -18,27 +21,32 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.function.Predicate; import java.util.function.Supplier; public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType { protected static final VoxelShape SHAPE = Block.makeCuboidShape(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D); private final String baseName; - private final Supplier tileEntitySupplier; + private final Block[] allowedGround; - public BlockAuraBloom(String baseName, Supplier tileEntitySupplier) { + public BlockAuraBloom(String baseName, Block... allowedGround) { super(Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT)); this.baseName = baseName; - this.tileEntitySupplier = tileEntitySupplier; + this.allowedGround = allowedGround; ModRegistry.add(this); - ModRegistry.add(new ModTileType<>(this.tileEntitySupplier, this)); } @Override public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - if (this == ModBlocks.AURA_CACTUS) - return worldIn.getBlockState(pos.down()).getBlock() instanceof SandBlock; - return super.isValidPosition(state, worldIn, pos); + BlockPos down = pos.down(); + return this.isValidGround(worldIn.getBlockState(down), worldIn, down); + } + + @Override + protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos) { + return Arrays.stream(this.allowedGround).anyMatch(state::isIn); } @Override @@ -76,7 +84,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS @Nullable @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return this.tileEntitySupplier.get(); + return new TileEntityAuraBloom(); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 9b55f4fc..a0f86f63 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.NoFeatureConfig; @SuppressWarnings("FieldNamingConvention") public final class ModBlocks { @@ -72,4 +74,7 @@ public final class ModBlocks { public static Block AURA_TIMER; public static Block SLIME_SPLIT_GENERATOR; public static Block SPRING; + public static Block WARPED_AURA_MUSHROOM; + public static Block CRIMSON_AURA_MUSHROOM; + public static Block AURA_MUSHROOM; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java index 6593792a..3ff88e51 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java @@ -37,7 +37,6 @@ public final class ModTileEntities { public static TileEntityType SNOW_CREATOR; public static TileEntityType ITEM_DISTRIBUTOR; public static TileEntityType AURA_BLOOM; - public static TileEntityType AURA_CACTUS; public static TileEntityType CHORUS_GENERATOR; public static TileEntityType AURA_TIMER; public static TileEntityType SLIME_SPLIT_GENERATOR; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java index 219984d1..329df437 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java @@ -40,10 +40,4 @@ public class TileEntityAuraBloom extends TileEntityImpl implements ITickableTile if (type == SaveType.TILE) this.justGenerated = compound.getBoolean("just_generated"); } - - public static class TileEntityAuraCactus extends TileEntityAuraBloom { - public TileEntityAuraCactus() { - super(ModTileEntities.AURA_CACTUS); - } - } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index 1d34b9df..d4441b61 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -14,21 +14,19 @@ import de.ellpeck.naturesaura.commands.CommandAura; import de.ellpeck.naturesaura.gen.ModFeatures; import de.ellpeck.naturesaura.misc.WorldData; import de.ellpeck.naturesaura.packet.PacketHandler; -import de.ellpeck.naturesaura.recipes.ModRecipes; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.IFutureReloadListener; -import net.minecraft.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.GenerationStage.Decoration; import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.gen.placement.ConfiguredPlacement; import net.minecraft.world.gen.placement.IPlacementConfig; +import net.minecraft.world.gen.placement.NoPlacementConfig; import net.minecraft.world.gen.placement.Placement; import net.minecraft.world.server.ChunkHolder; import net.minecraft.world.server.ChunkManager; @@ -40,15 +38,12 @@ import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; public class CommonEvents { @@ -58,9 +53,20 @@ public class CommonEvents { @SubscribeEvent public void onBiomeLoad(BiomeLoadingEvent event) { if (ModConfig.instance.auraBlooms.get()) { - event.getGeneration().func_242513_a(GenerationStage.Decoration.VEGETAL_DECORATION, ModFeatures.AURA_BLOOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG))); - if (event.getCategory() == Biome.Category.DESERT) - event.getGeneration().func_242513_a(GenerationStage.Decoration.VEGETAL_DECORATION, ModFeatures.AURA_CACTUS.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG))); + ConfiguredPlacement placement = Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG); + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.AURA_BLOOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + switch (event.getCategory()) { + case DESERT: + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.AURA_CACTUS.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + break; + case NETHER: + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.CRIMSON_AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.WARPED_AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + break; + case MUSHROOM: + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + break; + } } } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index fb9a1049..3a306cc7 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -12,5 +12,8 @@ public final class ModFeatures { public static Feature NETHER_WART_MUSHROOM; public static Feature AURA_BLOOM; public static Feature AURA_CACTUS; + public static Feature WARPED_AURA_MUSHROOM; + public static Feature CRIMSON_AURA_MUSHROOM; + public static Feature AURA_MUSHROOM; } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java index 1d862ee1..af6f54c2 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java @@ -9,6 +9,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.ISeedReader; import net.minecraft.world.IWorld; +import net.minecraft.world.World; import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.Heightmap; import net.minecraft.world.gen.feature.Feature; @@ -20,34 +21,53 @@ import java.util.Random; public class WorldGenAuraBloom extends Feature { private final Block block; + private final int chance; + private final boolean nether; - public WorldGenAuraBloom(Block block) { + public WorldGenAuraBloom(Block block, int chance, boolean nether) { super(Codec.unit(IFeatureConfig.NO_FEATURE_CONFIG)); this.block = block; + this.chance = chance; + this.nether = nether; } @Override - public boolean func_241855_a(ISeedReader worldIn, ChunkGenerator gen, Random rand, BlockPos pos, NoFeatureConfig p_241855_5_) { - if (rand.nextInt(60) != 0) + public boolean func_241855_a(ISeedReader worldIn, ChunkGenerator gen, Random rand, BlockPos pos, NoFeatureConfig config) { + if (rand.nextInt(this.chance) != 0) return false; - int startX = pos.getX() + rand.nextInt(16); int startZ = pos.getZ() + rand.nextInt(16); boolean any = false; for (int i = MathHelper.nextInt(rand, 3, 8); i > 0; i--) { int offX = startX + MathHelper.nextInt(rand, -5, 5); int offZ = startZ + MathHelper.nextInt(rand, -5, 5); - BlockPos placePos = new BlockPos(offX, worldIn.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, offX, offZ), offZ); - BlockState state = this.block.getDefaultState(); - if (this.block.isValidPosition(state, worldIn, placePos)) { - worldIn.setBlockState(placePos, state, 3); - - TileEntity tile = worldIn.getTileEntity(placePos); - if (tile instanceof TileEntityAuraBloom) - ((TileEntityAuraBloom) tile).justGenerated = true; - any = true; + if (this.nether) { + int y = MathHelper.nextInt(rand, 0, 128); + for (int off = 0; off < 64; off++) { + // try to find a good location in both directions of the random pos + if (this.tryPlace(worldIn, new BlockPos(offX, y - off, offZ)) || this.tryPlace(worldIn, new BlockPos(offX, y + off, offZ))) { + any = true; + break; + } + } + } else { + BlockPos placePos = new BlockPos(offX, worldIn.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, offX, offZ), offZ); + if (this.tryPlace(worldIn, placePos)) + any = true; } } return any; } + + private boolean tryPlace(ISeedReader world, BlockPos pos) { + BlockState state = this.block.getDefaultState(); + if (this.block.isValidPosition(state, world, pos)) { + world.setBlockState(pos, state, 3); + TileEntity tile = world.getTileEntity(pos); + if (tile instanceof TileEntityAuraBloom) + ((TileEntityAuraBloom) tile).justGenerated = true; + return true; + } + return false; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 9dacf4f6..970442e7 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.api.misc.IWorldData; import de.ellpeck.naturesaura.blocks.*; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom.TileEntityAuraCactus; import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment; import de.ellpeck.naturesaura.enchant.ModEnchantments; @@ -127,9 +126,15 @@ public final class ModRegistry { new BlockAnimalContainer(), new BlockSnowCreator(), new BlockItemDistributor(), - temp = new BlockAuraBloom("aura_bloom", TileEntityAuraBloom::new), + temp = new BlockAuraBloom("aura_bloom", Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.PODZOL, Blocks.COARSE_DIRT, Blocks.FARMLAND), createFlowerPot(temp), - temp = new BlockAuraBloom("aura_cactus", TileEntityAuraCactus::new), + temp = new BlockAuraBloom("aura_cactus", Blocks.SAND, Blocks.RED_SAND), + createFlowerPot(temp), + temp = new BlockAuraBloom("warped_aura_mushroom", Blocks.WARPED_NYLIUM), + createFlowerPot(temp), + temp = new BlockAuraBloom("crimson_aura_mushroom", Blocks.CRIMSON_NYLIUM), + createFlowerPot(temp), + temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM), createFlowerPot(temp), new BlockImpl("tainted_gold_block", Block.Properties.create(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(3F)), new BlockNetherGrass(), @@ -225,6 +230,9 @@ public final class ModRegistry { @SubscribeEvent public static void registerTiles(RegistryEvent.Register> event) { + // add tile entities that support multiple blocks + add(new ModTileType<>(TileEntityAuraBloom::new, "aura_bloom", ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new))); + for (IModItem item : ALL_ITEMS) { if (item instanceof ModTileType) event.getRegistry().register(((ModTileType) item).type); @@ -303,8 +311,11 @@ public final class ModRegistry { @SubscribeEvent public static void registerFeatures(RegistryEvent.Register> event) { event.getRegistry().registerAll( - new WorldGenAuraBloom(ModBlocks.AURA_BLOOM).setRegistryName("aura_bloom"), - new WorldGenAuraBloom(ModBlocks.AURA_CACTUS).setRegistryName("aura_cactus"), + new WorldGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false).setRegistryName("aura_bloom"), + new WorldGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false).setRegistryName("aura_cactus"), + new WorldGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true).setRegistryName("warped_aura_mushroom"), + new WorldGenAuraBloom(ModBlocks.CRIMSON_AURA_MUSHROOM, 10, true).setRegistryName("crimson_aura_mushroom"), + new WorldGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false).setRegistryName("aura_mushroom"), new WorldGenAncientTree().setRegistryName("ancient_tree"), new WorldGenNetherWartMushroom().setRegistryName("nether_wart_mushroom") ); diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java b/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java index 814d145b..15f4a474 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java @@ -5,6 +5,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ForgeRegistryEntry; +import java.util.Arrays; import java.util.function.Supplier; public class ModTileType implements IModItem { @@ -12,9 +13,14 @@ public class ModTileType implements IModItem { public final TileEntityType type; public final String name; - public ModTileType(Supplier supplier, IModItem block) { - this.type = TileEntityType.Builder.create(supplier, (Block) block).build(null); - this.name = block.getBaseName(); + public ModTileType(Supplier supplier, IModItem item) { + this(supplier, item.getBaseName(), item); + } + + public ModTileType(Supplier supplier, String name, IModItem... items) { + this.name = name; + Block[] blocks = Arrays.stream(items).map(i -> (Block) i).toArray(Block[]::new); + this.type = TileEntityType.Builder.create(supplier, blocks).build(null); } @Override diff --git a/src/main/resources/assets/naturesaura/lang/en_us.json b/src/main/resources/assets/naturesaura/lang/en_us.json index c705eccb..211e8ca3 100644 --- a/src/main/resources/assets/naturesaura/lang/en_us.json +++ b/src/main/resources/assets/naturesaura/lang/en_us.json @@ -61,6 +61,9 @@ "block.naturesaura.item_distributor": "Item Distributor", "block.naturesaura.aura_bloom": "Aura Bloom", "block.naturesaura.aura_cactus": "Aura Cactus", + "block.naturesaura.aura_mushroom": "Aura Mushroom", + "block.naturesaura.warped_aura_mushroom": "Warped Aura Fungus", + "block.naturesaura.crimson_aura_mushroom": "Crimson Aura Fungus", "block.naturesaura.tainted_gold_block": "Tainted Gold Block", "block.naturesaura.nether_grass": "Grassy Netherrack", "block.naturesaura.chorus_generator": "Reaper of Ender Heights", diff --git a/src/main/resources/assets/naturesaura/textures/block/aura_mushroom.png b/src/main/resources/assets/naturesaura/textures/block/aura_mushroom.png new file mode 100644 index 00000000..04e126d7 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/block/aura_mushroom.png differ diff --git a/src/main/resources/assets/naturesaura/textures/block/crimson_aura_mushroom.png b/src/main/resources/assets/naturesaura/textures/block/crimson_aura_mushroom.png new file mode 100644 index 00000000..3a762fe8 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/block/crimson_aura_mushroom.png differ diff --git a/src/main/resources/assets/naturesaura/textures/block/warped_aura_mushroom.png b/src/main/resources/assets/naturesaura/textures/block/warped_aura_mushroom.png new file mode 100644 index 00000000..7a984d52 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/block/warped_aura_mushroom.png differ diff --git a/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/practices/aura_plants.json b/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/practices/aura_plants.json index 34183533..930b43e4 100644 --- a/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/practices/aura_plants.json +++ b/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/practices/aura_plants.json @@ -5,7 +5,7 @@ "pages": [ { "type": "text", - "text": "A natural occurence that helped the discovery of $(aura) are certain kinds of vegetation that appear almost everywhere in the world. These two plants, specifically $(item)Aura Blooms$() and $(item)Aura Cacti$() are known to cause the area around them to naturally contain a higher concentration of $(aura) when they first grow." + "text": "A natural occurence that helped the discovery of $(aura) are certain kinds of vegetation that appear almost everywhere in the world. These plants are known to cause the area around them to naturally contain a higher concentration of $(aura) when they first grow. Additionally, all of these plants fit perfectly into $(item)Flower Pots$(), serving as a nice decoration." }, { "type": "spotlight", @@ -17,7 +17,19 @@ "type": "spotlight", "item": "naturesaura:aura_cactus", "link_recipe": true, - "text": "The $(item)Aura Cactus$() grows in deserted areas of any color, as well as $(thing)mesa$() regions. Since these areas are usually fairly barren with not many plants to be found, these can be a good starting point as well as a nice decoration, since they, along with their bloom counterpart, fit perfectly inside $(item)Flower Pots$()." + "text": "The $(item)Aura Cactus$() grows in deserted areas of any color, as well as $(thing)mesa$() regions. Since these areas are usually fairly barren with not many plants to be found, these can be a good starting point." + }, + { + "type": "spotlight", + "item": "naturesaura:aura_mushroom", + "link_recipe": true, + "text": "The $(item)Aura Mushroom$() is found on mycelium-infested islands, where it appears alongside giant mushrooms and bright red cows. In these regions, it causes beautiful purple aura particles to rise from the ground." + }, + { + "type": "spotlight", + "item": "naturesaura:crimson_aura_mushroom", + "link_recipe": true, + "text": "The $(item)Crimson$() and $(item)Warped Aura Mushrooms$() can be found in the forested regions of $(thing)the nether$(), where they sprout alongside their aura-less counterparts. When starting out as a magical botanist in these hellish regions, they can prove especially beneficial." } ] } \ No newline at end of file