added the aura cactus

This commit is contained in:
Ellpeck 2020-02-25 15:56:46 +01:00
parent a4f0f509e8
commit 29b291eb15
18 changed files with 151 additions and 20 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:aura_cactus"
}
],
"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_cactus"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

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

View file

@ -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<TileEntity> tileEntitySupplier;
public BlockAuraBloom() {
public BlockAuraBloom(String baseName, Supplier<TileEntity> 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

View file

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

View file

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

View file

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

View file

@ -7,8 +7,9 @@ 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;
public static Feature<NoFeatureConfig> AURA_BLOOM;
public static Feature<NoFeatureConfig> AURA_CACTUS;
}

View file

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

View file

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

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B