diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java index efff176f..ace21da4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java @@ -135,13 +135,18 @@ public class BlockAncientLeaves extends BlockLeaves implements public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { super.randomDisplayTick(stateIn, worldIn, pos, rand); if (rand.nextFloat() >= 0.9F && !worldIn.getBlockState(pos.down()).isFullBlock()) { - NaturesAura.proxy.spawnMagicParticle(worldIn, - pos.getX() + rand.nextDouble(), pos.getY(), pos.getZ() + rand.nextDouble(), - 0F, 0F, 0F, 0xc46df9, - rand.nextFloat() * 2F + 0.5F, - rand.nextInt(100) + 150, - rand.nextFloat() * 0.05F + 0.005F, true, true); + TileEntity tile = worldIn.getTileEntity(pos); + if (tile instanceof TileEntityAncientLeaves) { + if (((TileEntityAncientLeaves) tile).container().getStoredAura() > 0) { + NaturesAura.proxy.spawnMagicParticle(worldIn, + pos.getX() + rand.nextDouble(), pos.getY(), pos.getZ() + rand.nextDouble(), + 0F, 0F, 0F, 0xc46df9, + rand.nextFloat() * 2F + 0.5F, + rand.nextInt(100) + 150, + rand.nextFloat() * 0.05F + 0.005F, true, true); + } + } } } @@ -149,4 +154,17 @@ public class BlockAncientLeaves extends BlockLeaves implements public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(ModBlocks.ANCIENT_SAPLING); } + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + super.updateTick(worldIn, pos, state, rand); + if (!worldIn.isRemote) { + TileEntity tile = worldIn.getTileEntity(pos); + if (tile instanceof TileEntityAncientLeaves) { + if (((TileEntityAncientLeaves) tile).container().getStoredAura() <= 0) { + worldIn.setBlockState(pos, ModBlocks.DECAYED_LEAVES.getDefaultState()); + } + } + } + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java new file mode 100644 index 00000000..5a91467d --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java @@ -0,0 +1,39 @@ +package de.ellpeck.naturesaura.blocks; + +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.Random; + +public class BlockDecayedLeaves extends BlockImpl { + + public BlockDecayedLeaves() { + super("decayed_leaves", Material.LEAVES); + this.setTickRandomly(true); + this.setHardness(0.2F); + this.setLightOpacity(1); + this.setSoundType(SoundType.PLANT); + } + + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @SideOnly(Side.CLIENT) + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; + } + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random random) { + if (!worldIn.isRemote) { + worldIn.setBlockToAir(pos); + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index a2bc38f6..bf6a5379 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -11,4 +11,5 @@ public final class ModBlocks { public static final Block ANCIENT_LEAVES = new BlockAncientLeaves(); public static final Block ANCIENT_SAPLING = new BlockAncientSapling(); public static final Block NATURE_ALTAR = new BlockNatureAltar(); + public static final Block DECAYED_LEAVES = new BlockDecayedLeaves(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java index 57b6a67c..59d822aa 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java @@ -7,11 +7,20 @@ import net.minecraft.nbt.NBTTagCompound; public class TileEntityAncientLeaves extends TileEntityImpl implements IAuraContainerProvider { - private final FiniteAuraContainer container = new FiniteAuraContainer(50) { + private final FiniteAuraContainer container = new FiniteAuraContainer(20) { @Override public int getAuraColor() { return 0xc46df9; } + + @Override + public int drainAura(int amountToDrain, boolean simulate) { + int amount = super.drainAura(amountToDrain, simulate); + if (amount > 0 && !simulate) { + TileEntityAncientLeaves.this.sendToClients(); + } + return amount; + } }; @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java index b2b22915..ff183c1b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -65,9 +65,7 @@ public class TileEntityImpl extends TileEntity { WorldServer world = (WorldServer) this.getWorld(); PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(this.getPos().getX() >> 4, this.getPos().getZ() >> 4); if (entry != null) { - for (EntityPlayerMP player : entry.getWatchingPlayers()) { - player.connection.sendPacket(this.getUpdatePacket()); - } + entry.sendPacket(this.getUpdatePacket()); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index 3e592ce3..2d6b8a52 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -167,6 +167,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, this.pos.getX() + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() + 4F + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(200) + 100, -0.025F, true, true); } + } } } diff --git a/src/main/resources/assets/naturesaura/blockstates/decayed_leaves.json b/src/main/resources/assets/naturesaura/blockstates/decayed_leaves.json new file mode 100644 index 00000000..574e89eb --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/decayed_leaves.json @@ -0,0 +1,14 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:leaves", + "textures": { + "all": "naturesaura:blocks/decayed_leaves" + }, + "transform": "forge:default-block" + }, + "variants": { + "normal": [{}], + "inventory": [{}] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index aa2ac970..f4011779 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -4,4 +4,5 @@ tile.naturesaura.ancient_log.name=Ancient Log tile.naturesaura.ancient_bark.name=Ancient Bark tile.naturesaura.ancient_leaves.name=Ancient Leaves tile.naturesaura.ancient_sapling.name=Ancient Sapling -tile.naturesaura.nature_altar.name=Natural Altar \ No newline at end of file +tile.naturesaura.nature_altar.name=Natural Altar +tile.naturesaura.decayed_leaves.name=Decayed Leaves \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/decayed_leaves.png b/src/main/resources/assets/naturesaura/textures/blocks/decayed_leaves.png new file mode 100644 index 00000000..989e0b49 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/decayed_leaves.png differ