diff --git a/src/generated/resources/assets/naturesaura/blockstates/aura_cactus.json b/src/generated/resources/assets/naturesaura/blockstates/aura_cactus.json new file mode 100644 index 00000000..d3e67523 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/aura_cactus.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/aura_cactus" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/blockstates/potted_aura_cactus.json b/src/generated/resources/assets/naturesaura/blockstates/potted_aura_cactus.json new file mode 100644 index 00000000..44b4c7fc --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/potted_aura_cactus.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/potted_aura_cactus" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/aura_cactus.json b/src/generated/resources/assets/naturesaura/models/block/aura_cactus.json new file mode 100644 index 00000000..aff259a0 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/aura_cactus.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cross", + "textures": { + "cross": "naturesaura:block/aura_cactus" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/potted_aura_cactus.json b/src/generated/resources/assets/naturesaura/models/block/potted_aura_cactus.json new file mode 100644 index 00000000..9d6eabcb --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/potted_aura_cactus.json @@ -0,0 +1,6 @@ +{ + "parent": "block/flower_pot_cross", + "textures": { + "plant": "naturesaura:block/aura_cactus" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/aura_cactus.json b/src/generated/resources/assets/naturesaura/models/item/aura_cactus.json new file mode 100644 index 00000000..b76a3ac9 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/aura_cactus.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:block/aura_cactus" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/potted_aura_cactus.json b/src/generated/resources/assets/naturesaura/models/item/potted_aura_cactus.json new file mode 100644 index 00000000..86e7aceb --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/potted_aura_cactus.json @@ -0,0 +1,3 @@ +{ + "parent": "naturesaura:block/potted_aura_cactus" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_cactus.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_cactus.json new file mode 100644 index 00000000..2a27093e --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/aura_cactus.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:aura_cactus" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_cactus.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_cactus.json new file mode 100644 index 00000000..6b3339b9 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/potted_aura_cactus.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_cactus" + } + ], + "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 6bfaa078..3eadcda6 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -121,7 +121,7 @@ public final class ModConfig { .translation("config." + NaturesAura.MOD_ID + ".oreEffect") .define("oreEffect", true); this.auraBlooms = builder - .comment("If Aura Blooms should generate in the world") + .comment("If Aura Blooms and Aura Cacti should generate in the world") .translation("config." + NaturesAura.MOD_ID + ".auraBlooms") .define("auraBlooms", true); builder.pop(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java index df25acf1..dafb8c7b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java @@ -1,21 +1,21 @@ 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.*; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; +import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.DamageSource; 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 net.minecraft.world.IWorldReader; +import net.minecraft.world.World; import javax.annotation.Nullable; import java.util.function.Supplier; @@ -23,11 +23,28 @@ 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; - public BlockAuraBloom() { + public BlockAuraBloom(String baseName, Supplier tileEntitySupplier) { super(ModBlocks.prop(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT)); + this.baseName = baseName; + this.tileEntitySupplier = tileEntitySupplier; ModRegistry.add(this); - ModRegistry.add(new ModTileType<>(TileEntityAuraBloom::new, 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); + } + + @Override + public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + if (this == ModBlocks.AURA_CACTUS) + entityIn.attackEntityFrom(DamageSource.CACTUS, 1); } @Override @@ -53,13 +70,13 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS @Override public String getBaseName() { - return "aura_bloom"; + return this.baseName; } @Nullable @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return new TileEntityAuraBloom(); + return this.tileEntitySupplier.get(); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 55b640cf..caf9ee6d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -63,6 +63,7 @@ public final class ModBlocks { public static Block SNOW_CREATOR; public static Block ITEM_DISTRIBUTOR; public static Block AURA_BLOOM; + public static Block AURA_CACTUS; 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 21fb4451..9f6b6249 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java @@ -37,4 +37,5 @@ public final class ModTileEntities { public static TileEntityType SNOW_CREATOR; public static TileEntityType ITEM_DISTRIBUTOR; public static TileEntityType AURA_BLOOM; + public static TileEntityType AURA_CACTUS; } 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 01f984bd..219984d1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java @@ -3,13 +3,18 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.TileEntityType; public class TileEntityAuraBloom extends TileEntityImpl implements ITickableTileEntity { public boolean justGenerated; public TileEntityAuraBloom() { - super(ModTileEntities.AURA_BLOOM); + this(ModTileEntities.AURA_BLOOM); + } + + protected TileEntityAuraBloom(TileEntityType type) { + super(type); } // Doing this in validate() creates a loading deadlock for some reason... @@ -18,7 +23,7 @@ public class TileEntityAuraBloom extends TileEntityImpl implements ITickableTile if (this.world.isRemote || !this.justGenerated) return; IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, this.pos); - chunk.storeAura(this.pos, 200000); + chunk.storeAura(this.pos, 150000); this.justGenerated = false; } @@ -35,4 +40,10 @@ 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/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index 30843c8a..ce2fd77b 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -7,8 +7,9 @@ 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; + public static Feature AURA_BLOOM; + public static Feature AURA_CACTUS; } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java index d8ee3295..2ddc4aa1 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.gen; -import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; @@ -17,8 +17,12 @@ import net.minecraft.world.gen.feature.NoFeatureConfig; import java.util.Random; public class WorldGenAuraBloom extends Feature { - public WorldGenAuraBloom() { + + private final Block block; + + public WorldGenAuraBloom(Block block) { super(d -> IFeatureConfig.NO_FEATURE_CONFIG); + this.block = block; } @Override @@ -33,8 +37,8 @@ public class WorldGenAuraBloom extends Feature { 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)) { + BlockState state = this.block.getDefaultState(); + if (this.block.isValidPosition(state, worldIn, placePos)) { worldIn.setBlockState(placePos, state, 3); TileEntity tile = worldIn.getTileEntity(placePos); diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 7f97860b..57a49327 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -6,6 +6,8 @@ import de.ellpeck.naturesaura.NaturesAura; 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; @@ -123,7 +125,9 @@ public final class ModRegistry { new BlockAnimalContainer(), new BlockSnowCreator(), new BlockItemDistributor(), - temp = new BlockAuraBloom(), + temp = new BlockAuraBloom("aura_bloom", TileEntityAuraBloom::new), + createFlowerPot(temp), + temp = new BlockAuraBloom("aura_cactus", TileEntityAuraCactus::new), createFlowerPot(temp) ); @@ -256,7 +260,8 @@ public final class ModRegistry { @SubscribeEvent public static void registerFeatures(RegistryEvent.Register> event) { event.getRegistry().registerAll( - new WorldGenAuraBloom().setRegistryName("aura_bloom"), + new WorldGenAuraBloom(ModBlocks.AURA_BLOOM).setRegistryName("aura_bloom"), + new WorldGenAuraBloom(ModBlocks.AURA_CACTUS).setRegistryName("aura_cactus"), new WorldGenAncientTree().setRegistryName("ancient_tree"), new WorldGenNetherWartMushroom().setRegistryName("nether_wart_mushroom") ); @@ -274,8 +279,11 @@ public final class ModRegistry { } for (Biome biome : ForgeRegistries.BIOMES) { - if (ModConfig.instance.auraBlooms.get()) + 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))); + if (biome.getCategory() == Biome.Category.DESERT) + biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, ModFeatures.AURA_CACTUS.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).func_227228_a_(Placement.NOPE.func_227446_a_(IPlacementConfig.NO_PLACEMENT_CONFIG))); + } } } diff --git a/src/main/resources/assets/naturesaura/lang/en_us.json b/src/main/resources/assets/naturesaura/lang/en_us.json index 31902ef6..13f3b561 100644 --- a/src/main/resources/assets/naturesaura/lang/en_us.json +++ b/src/main/resources/assets/naturesaura/lang/en_us.json @@ -59,6 +59,7 @@ "block.naturesaura.snow_creator": "Winter's Calling", "block.naturesaura.item_distributor": "Item Distributor", "block.naturesaura.aura_bloom": "Aura Bloom", + "block.naturesaura.aura_cactus": "Aura Cactus", "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_cactus.png b/src/main/resources/assets/naturesaura/textures/block/aura_cactus.png new file mode 100644 index 00000000..de5b884c Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/block/aura_cactus.png differ