From a4f0f509e84f5cbedc6a17951600ec75627b2927 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 25 Feb 2020 15:14:56 +0100 Subject: [PATCH] added aura bloom --- .../naturesaura/blockstates/aura_bloom.json | 7 ++ .../blockstates/potted_aura_bloom.json | 7 ++ .../naturesaura/models/block/aura_bloom.json | 6 ++ .../models/block/potted_aura_bloom.json | 6 ++ .../naturesaura/models/item/aura_bloom.json | 6 ++ .../models/item/potted_aura_bloom.json | 3 + .../loot_tables/blocks/aura_bloom.json | 19 +++++ .../loot_tables/blocks/potted_aura_bloom.json | 33 +++++++++ .../de/ellpeck/naturesaura/ModConfig.java | 5 ++ .../blocks/BlockAncientSapling.java | 3 +- .../naturesaura/blocks/BlockAuraBloom.java | 69 ++++++++++++++++++ .../naturesaura/blocks/BlockFlowerPot.java | 33 +++++++++ .../ellpeck/naturesaura/blocks/ModBlocks.java | 1 + .../blocks/tiles/ModTileEntities.java | 1 + .../blocks/tiles/TileEntityAuraBloom.java | 38 ++++++++++ .../naturesaura/data/BlockLootProvider.java | 8 ++ .../ellpeck/naturesaura/gen/ModFeatures.java | 14 ++++ .../naturesaura/gen/WorldGenAuraBloom.java | 48 ++++++++++++ .../naturesaura/items/ItemCrimsonMeal.java | 4 +- .../ellpeck/naturesaura/reg/INoItemBlock.java | 4 + .../ellpeck/naturesaura/reg/ModRegistry.java | 42 ++++++++++- .../assets/naturesaura/lang/en_us.json | 1 + .../naturesaura/textures/block/aura_bloom.png | Bin 0 -> 331 bytes 23 files changed, 352 insertions(+), 6 deletions(-) create mode 100644 src/generated/resources/assets/naturesaura/blockstates/aura_bloom.json create mode 100644 src/generated/resources/assets/naturesaura/blockstates/potted_aura_bloom.json create mode 100644 src/generated/resources/assets/naturesaura/models/block/aura_bloom.json create mode 100644 src/generated/resources/assets/naturesaura/models/block/potted_aura_bloom.json create mode 100644 src/generated/resources/assets/naturesaura/models/item/aura_bloom.json create mode 100644 src/generated/resources/assets/naturesaura/models/item/potted_aura_bloom.json create mode 100644 src/generated/resources/data/naturesaura/loot_tables/blocks/aura_bloom.json create mode 100644 src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_bloom.json create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java create mode 100644 src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java create mode 100644 src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java create mode 100644 src/main/java/de/ellpeck/naturesaura/reg/INoItemBlock.java create mode 100644 src/main/resources/assets/naturesaura/textures/block/aura_bloom.png diff --git a/src/generated/resources/assets/naturesaura/blockstates/aura_bloom.json b/src/generated/resources/assets/naturesaura/blockstates/aura_bloom.json new file mode 100644 index 00000000..047cbe80 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/aura_bloom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/aura_bloom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/blockstates/potted_aura_bloom.json b/src/generated/resources/assets/naturesaura/blockstates/potted_aura_bloom.json new file mode 100644 index 00000000..c233f6ab --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/potted_aura_bloom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/potted_aura_bloom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/aura_bloom.json b/src/generated/resources/assets/naturesaura/models/block/aura_bloom.json new file mode 100644 index 00000000..0214762c --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/aura_bloom.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cross", + "textures": { + "cross": "naturesaura:block/aura_bloom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/potted_aura_bloom.json b/src/generated/resources/assets/naturesaura/models/block/potted_aura_bloom.json new file mode 100644 index 00000000..f4ead497 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/potted_aura_bloom.json @@ -0,0 +1,6 @@ +{ + "parent": "block/flower_pot_cross", + "textures": { + "plant": "naturesaura:block/aura_bloom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/aura_bloom.json b/src/generated/resources/assets/naturesaura/models/item/aura_bloom.json new file mode 100644 index 00000000..eba23390 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/aura_bloom.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:block/aura_bloom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/potted_aura_bloom.json b/src/generated/resources/assets/naturesaura/models/item/potted_aura_bloom.json new file mode 100644 index 00000000..0290f89f --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/potted_aura_bloom.json @@ -0,0 +1,3 @@ +{ + "parent": "naturesaura:block/potted_aura_bloom" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_bloom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_bloom.json new file mode 100644 index 00000000..bb7d8264 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_bloom.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:aura_bloom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_bloom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_bloom.json new file mode 100644 index 00000000..374bbc4f --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_bloom.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_bloom" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index aa5e2d68..6bfaa078 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -38,6 +38,7 @@ public final class ModConfig { public ForgeConfigSpec.ConfigValue breathlessEffect; public ForgeConfigSpec.ConfigValue animalEffect; public ForgeConfigSpec.ConfigValue oreEffect; + public ForgeConfigSpec.ConfigValue auraBlooms; public ForgeConfigSpec.ConfigValue particleAmount; public ForgeConfigSpec.ConfigValue respectVanillaParticleSettings; @@ -119,6 +120,10 @@ public final class ModConfig { .comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur") .translation("config." + NaturesAura.MOD_ID + ".oreEffect") .define("oreEffect", true); + this.auraBlooms = builder + .comment("If Aura Blooms should generate in the world") + .translation("config." + NaturesAura.MOD_ID + ".auraBlooms") + .define("auraBlooms", true); builder.pop(); builder.push("client"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index d854b817..a841d6dc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator; +import de.ellpeck.naturesaura.gen.ModFeatures; import de.ellpeck.naturesaura.gen.WorldGenAncientTree; import de.ellpeck.naturesaura.reg.*; import net.minecraft.block.*; @@ -68,7 +69,7 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte if (state.get(SaplingBlock.STAGE) == 0) { world.setBlockState(pos, state.cycle(SaplingBlock.STAGE), 4); } else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) { - new WorldGenAncientTree().place(world, world.getChunkProvider().getChunkGenerator(), rand, pos, WorldGenAncientTree.CONFIG); + ModFeatures.ANCIENT_TREE.place(world, world.getChunkProvider().getChunkGenerator(), rand, pos, WorldGenAncientTree.CONFIG); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java new file mode 100644 index 00000000..df25acf1 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java @@ -0,0 +1,69 @@ +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.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.BushBlock; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; + +import javax.annotation.Nullable; +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); + + public BlockAuraBloom() { + super(ModBlocks.prop(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT)); + ModRegistry.add(this); + ModRegistry.add(new ModTileType<>(TileEntityAuraBloom::new, this)); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + Vec3d vec3d = state.getOffset(worldIn, pos); + return SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z); + } + + @Override + public void generateCustomBlockState(BlockStateGenerator generator) { + generator.simpleBlock(this, generator.models().cross(this.getBaseName(), generator.modLoc("block/" + this.getBaseName()))); + } + + @Override + public void generateCustomItemModel(ItemModelGenerator generator) { + generator.withExistingParent(this.getBaseName(), "item/generated").texture("layer0", "block/" + this.getBaseName()); + } + + @Override + public Supplier getRenderType() { + return RenderType::cutout; + } + + @Override + public String getBaseName() { + return "aura_bloom"; + } + + @Nullable + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return new TileEntityAuraBloom(); + } + + @Override + public boolean hasTileEntity(BlockState state) { + return true; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java new file mode 100644 index 00000000..8419d374 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java @@ -0,0 +1,33 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.data.BlockStateGenerator; +import de.ellpeck.naturesaura.reg.*; +import net.minecraft.block.Block; +import net.minecraft.block.FlowerPotBlock; +import net.minecraft.client.renderer.RenderType; + +import java.util.function.Supplier; + +public class BlockFlowerPot extends FlowerPotBlock implements ICustomBlockState, IModItem, INoItemBlock, ICustomRenderType { + public BlockFlowerPot(Supplier emptyPot, Supplier block, Properties props) { + super(emptyPot, block, props); + ModRegistry.add(this); + } + + @Override + public void generateCustomBlockState(BlockStateGenerator generator) { + generator.simpleBlock(this, generator.models() + .withExistingParent(this.getBaseName(), "block/flower_pot_cross") + .texture("plant", "block/" + this.func_220276_d().getRegistryName().getPath())); + } + + @Override + public String getBaseName() { + return "potted_" + this.func_220276_d().getRegistryName().getPath(); + } + + @Override + public Supplier getRenderType() { + return RenderType::cutout; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 589bd66b..55b640cf 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -62,6 +62,7 @@ public final class ModBlocks { public static Block ANIMAL_CONTAINER; public static Block SNOW_CREATOR; public static Block ITEM_DISTRIBUTOR; + public static Block AURA_BLOOM; public static Block.Properties prop(Material material, MaterialColor color) { return Block.Properties.create(material, color); 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 2c1de0be..21fb4451 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java @@ -36,4 +36,5 @@ public final class ModTileEntities { public static TileEntityType ANIMAL_CONTAINER; public static TileEntityType SNOW_CREATOR; public static TileEntityType ITEM_DISTRIBUTOR; + public static TileEntityType AURA_BLOOM; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java new file mode 100644 index 00000000..01f984bd --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java @@ -0,0 +1,38 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.ITickableTileEntity; + +public class TileEntityAuraBloom extends TileEntityImpl implements ITickableTileEntity { + + public boolean justGenerated; + + public TileEntityAuraBloom() { + super(ModTileEntities.AURA_BLOOM); + } + + // Doing this in validate() creates a loading deadlock for some reason... + @Override + public void tick() { + if (this.world.isRemote || !this.justGenerated) + return; + IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, this.pos); + chunk.storeAura(this.pos, 200000); + this.justGenerated = false; + } + + @Override + public void writeNBT(CompoundNBT compound, SaveType type) { + super.writeNBT(compound, type); + if (type == SaveType.TILE) + compound.putBoolean("just_generated", this.justGenerated); + } + + @Override + public void readNBT(CompoundNBT compound, SaveType type) { + super.readNBT(compound, type); + if (type == SaveType.TILE) + this.justGenerated = compound.getBoolean("just_generated"); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java index e8985d34..0022857b 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.data; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import de.ellpeck.naturesaura.blocks.BlockFlowerPot; import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.Slab; @@ -10,6 +11,7 @@ import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.advancements.criterion.StatePropertiesPredicate; import net.minecraft.block.Block; +import net.minecraft.block.FlowerPotBlock; import net.minecraft.data.DataGenerator; import net.minecraft.data.DirectoryCache; import net.minecraft.data.IDataProvider; @@ -42,6 +44,8 @@ public class BlockLootProvider implements IDataProvider { Block block = (Block) item; if (block instanceof Slab) { this.lootFunctions.put(block, LootTableHooks::genSlab); + } else if (block instanceof BlockFlowerPot) { + this.lootFunctions.put(block, LootTableHooks::genFlowerPot); } else { this.lootFunctions.put(block, LootTableHooks::genRegular); } @@ -96,6 +100,10 @@ public class BlockLootProvider implements IDataProvider { return droppingWithSilkTouch(block, builder); } + public static LootTable.Builder genFlowerPot(Block block) { + return droppingAndFlowerPot(((FlowerPotBlock) block).func_220276_d()); + } + public static T survivesExplosion(Block block, ILootConditionConsumer then) { return withSurvivesExplosion(block, then); } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java new file mode 100644 index 00000000..30843c8a --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -0,0 +1,14 @@ +package de.ellpeck.naturesaura.gen; + +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.feature.TreeFeatureConfig; + +@SuppressWarnings("FieldNamingConvention") +public final class ModFeatures { + + public static Feature AURA_BLOOM; + public static Feature ANCIENT_TREE; + public static Feature NETHER_WART_MUSHROOM; + +} diff --git a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java new file mode 100644 index 00000000..d8ee3295 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java @@ -0,0 +1,48 @@ +package de.ellpeck.naturesaura.gen; + +import de.ellpeck.naturesaura.blocks.ModBlocks; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom; +import net.minecraft.block.BlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.IWorld; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.gen.feature.NoFeatureConfig; + +import java.util.Random; + +public class WorldGenAuraBloom extends Feature { + public WorldGenAuraBloom() { + super(d -> IFeatureConfig.NO_FEATURE_CONFIG); + } + + @Override + public boolean place(IWorld worldIn, ChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) { + if (rand.nextInt(60) != 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 = ModBlocks.AURA_BLOOM.getDefaultState(); + if (ModBlocks.AURA_BLOOM.isValidPosition(state, worldIn, placePos)) { + worldIn.setBlockState(placePos, state, 3); + + TileEntity tile = worldIn.getTileEntity(placePos); + if (tile instanceof TileEntityAuraBloom) + ((TileEntityAuraBloom) tile).justGenerated = true; + any = true; + } + } + return any; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java index ed5908ce..74b6ccb3 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.items; -import de.ellpeck.naturesaura.gen.WorldGenNetherWartMushroom; +import de.ellpeck.naturesaura.gen.ModFeatures; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.NetherWartBlock; @@ -27,7 +27,7 @@ public class ItemCrimsonMeal extends ItemImpl { if (world.rand.nextInt(5) == 0) { int age = state.get(NetherWartBlock.AGE); if (age >= 3) { - new WorldGenNetherWartMushroom().place(world, ((ServerWorld) world).getChunkProvider().getChunkGenerator(), world.rand, pos, IFeatureConfig.NO_FEATURE_CONFIG); + ModFeatures.NETHER_WART_MUSHROOM.place(world, ((ServerWorld) world).getChunkProvider().getChunkGenerator(), world.rand, pos, IFeatureConfig.NO_FEATURE_CONFIG); } else { world.setBlockState(pos, state.with(NetherWartBlock.AGE, age + 1)); } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/INoItemBlock.java b/src/main/java/de/ellpeck/naturesaura/reg/INoItemBlock.java new file mode 100644 index 00000000..8ba461c1 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/reg/INoItemBlock.java @@ -0,0 +1,4 @@ +package de.ellpeck.naturesaura.reg; + +public interface INoItemBlock { +} diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 5dcc7418..7f97860b 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -14,6 +14,10 @@ import de.ellpeck.naturesaura.entities.EntityMoverMinecart; import de.ellpeck.naturesaura.entities.ModEntities; import de.ellpeck.naturesaura.entities.render.RenderEffectInhibitor; import de.ellpeck.naturesaura.entities.render.RenderMoverMinecart; +import de.ellpeck.naturesaura.gen.ModFeatures; +import de.ellpeck.naturesaura.gen.WorldGenAncientTree; +import de.ellpeck.naturesaura.gen.WorldGenAuraBloom; +import de.ellpeck.naturesaura.gen.WorldGenNetherWartMushroom; import de.ellpeck.naturesaura.gui.ContainerEnderCrate; import de.ellpeck.naturesaura.gui.ModContainers; import de.ellpeck.naturesaura.items.*; @@ -22,6 +26,7 @@ import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.potion.PotionBreathless; import net.minecraft.block.Block; import net.minecraft.block.Blocks; +import net.minecraft.block.FlowerPotBlock; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.enchantment.Enchantment; @@ -34,12 +39,19 @@ import net.minecraft.item.Item; import net.minecraft.potion.Effect; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.biome.Biome; import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.gen.placement.IPlacementConfig; +import net.minecraft.world.gen.placement.Placement; import net.minecraftforge.common.extensions.IForgeContainerType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.registries.ForgeRegistries; import java.util.HashSet; import java.util.Set; @@ -56,7 +68,7 @@ public final class ModRegistry { @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { - BlockImpl temp; + Block temp; event.getRegistry().registerAll( new BlockAncientLog("ancient_log"), new BlockAncientLog("ancient_bark"), @@ -110,7 +122,9 @@ public final class ModRegistry { new BlockImpl("nether_wart_mushroom", ModBlocks.prop(Blocks.RED_MUSHROOM_BLOCK)), new BlockAnimalContainer(), new BlockSnowCreator(), - new BlockItemDistributor() + new BlockItemDistributor(), + temp = new BlockAuraBloom(), + createFlowerPot(temp) ); if (ModConfig.instance.rfConverter.get()) @@ -124,7 +138,7 @@ public final class ModRegistry { @SubscribeEvent public static void registerItems(RegistryEvent.Register event) { for (IModItem block : ALL_ITEMS) { - if (block instanceof Block) { + if (block instanceof Block && !(block instanceof INoItemBlock)) { BlockItem item = new BlockItem((Block) block, new Item.Properties().group(NaturesAura.CREATIVE_TAB)); item.setRegistryName(block.getBaseName()); event.getRegistry().register(item); @@ -239,6 +253,16 @@ public final class ModRegistry { NaturesAura.proxy.registerEntityRenderer(ModEntities.EFFECT_INHIBITOR, () -> RenderEffectInhibitor::new); } + @SubscribeEvent + public static void registerFeatures(RegistryEvent.Register> event) { + event.getRegistry().registerAll( + new WorldGenAuraBloom().setRegistryName("aura_bloom"), + new WorldGenAncientTree().setRegistryName("ancient_tree"), + new WorldGenNetherWartMushroom().setRegistryName("nether_wart_mushroom") + ); + Helper.populateObjectHolders(ModFeatures.class, event.getRegistry()); + } + public static void init() { for (IModItem item : ALL_ITEMS) { if (item instanceof IColorProvidingBlock) @@ -248,5 +272,17 @@ public final class ModRegistry { if (item instanceof ITESRProvider) NaturesAura.proxy.registerTESR((ITESRProvider) item); } + + for (Biome biome : ForgeRegistries.BIOMES) { + if (ModConfig.instance.auraBlooms.get()) + biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, ModFeatures.AURA_BLOOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).func_227228_a_(Placement.NOPE.func_227446_a_(IPlacementConfig.NO_PLACEMENT_CONFIG))); + } + } + + public static Block createFlowerPot(Block block) { + Block.Properties props = Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0F); + Block potted = new BlockFlowerPot(() -> (FlowerPotBlock) Blocks.FLOWER_POT, block::getBlock, props); + ((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(block.getRegistryName(), () -> potted); + return potted; } } diff --git a/src/main/resources/assets/naturesaura/lang/en_us.json b/src/main/resources/assets/naturesaura/lang/en_us.json index bd7226a5..31902ef6 100644 --- a/src/main/resources/assets/naturesaura/lang/en_us.json +++ b/src/main/resources/assets/naturesaura/lang/en_us.json @@ -58,6 +58,7 @@ "block.naturesaura.animal_container": "Corporeal Eye", "block.naturesaura.snow_creator": "Winter's Calling", "block.naturesaura.item_distributor": "Item Distributor", + "block.naturesaura.aura_bloom": "Aura Bloom", "item.naturesaura.eye": "Environmental Eye", "item.naturesaura.eye_improved": "Environmental Ocular", "item.naturesaura.gold_fiber": "Brilliant Fiber", diff --git a/src/main/resources/assets/naturesaura/textures/block/aura_bloom.png b/src/main/resources/assets/naturesaura/textures/block/aura_bloom.png new file mode 100644 index 0000000000000000000000000000000000000000..2a1574f18d92e8c0af02797392e1e2917982f951 GIT binary patch literal 331 zcmV-R0kr;!P)d|yYJxaAI})!?APzHJAx6L z;Q2LL|KGoR&#+2Zmm%!!Wro-9|1*S_zrd;%s~`gdBphx&V#TW&s~2FP;Ikyd>-YZ| z7P1L2gs#>lJ`j?tk$b7UI*v#uCy0GZ|$VHkOFO zHLGT<`=BXBmBi2h$