added aura bloom

This commit is contained in:
Ellpeck 2020-02-25 15:14:56 +01:00
parent 2505975c32
commit a4f0f509e8
23 changed files with 352 additions and 6 deletions

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "naturesaura:block/aura_bloom"
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "naturesaura:block/potted_aura_bloom"
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "naturesaura:block/aura_bloom"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/flower_pot_cross",
"textures": {
"plant": "naturesaura:block/aura_bloom"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:block/aura_bloom"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "naturesaura:block/potted_aura_bloom"
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:aura_bloom"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -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"
}
]
}
]
}

View file

@ -38,6 +38,7 @@ public final class ModConfig {
public ForgeConfigSpec.ConfigValue<Boolean> breathlessEffect;
public ForgeConfigSpec.ConfigValue<Boolean> animalEffect;
public ForgeConfigSpec.ConfigValue<Boolean> oreEffect;
public ForgeConfigSpec.ConfigValue<Boolean> auraBlooms;
public ForgeConfigSpec.ConfigValue<Double> particleAmount;
public ForgeConfigSpec.ConfigValue<Boolean> 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");

View file

@ -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);
}
}

View file

@ -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<RenderType> 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;
}
}

View file

@ -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<FlowerPotBlock> emptyPot, Supplier<? extends Block> 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<RenderType> getRenderType() {
return RenderType::cutout;
}
}

View file

@ -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);

View file

@ -36,4 +36,5 @@ public final class ModTileEntities {
public static TileEntityType<TileEntityAnimalContainer> ANIMAL_CONTAINER;
public static TileEntityType<TileEntitySnowCreator> SNOW_CREATOR;
public static TileEntityType<TileEntityItemDistributor> ITEM_DISTRIBUTOR;
public static TileEntityType<TileEntityAuraBloom> AURA_BLOOM;
}

View file

@ -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");
}
}

View file

@ -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> T survivesExplosion(Block block, ILootConditionConsumer<T> then) {
return withSurvivesExplosion(block, then);
}

View file

@ -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<NoFeatureConfig> AURA_BLOOM;
public static Feature<TreeFeatureConfig> ANCIENT_TREE;
public static Feature<NoFeatureConfig> NETHER_WART_MUSHROOM;
}

View file

@ -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<NoFeatureConfig> {
public WorldGenAuraBloom() {
super(d -> IFeatureConfig.NO_FEATURE_CONFIG);
}
@Override
public boolean place(IWorld worldIn, ChunkGenerator<? extends GenerationSettings> 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;
}
}

View file

@ -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));
}

View file

@ -0,0 +1,4 @@
package de.ellpeck.naturesaura.reg;
public interface INoItemBlock {
}

View file

@ -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<Block> 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<Item> 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<Feature<?>> 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;
}
}

View file

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B