added decayed leaves

This commit is contained in:
Ellpeck 2018-10-14 16:12:33 +02:00
parent 9901eaa786
commit e068c48ca2
9 changed files with 92 additions and 11 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,14 @@
{
"forge_marker": 1,
"defaults": {
"model": "minecraft:leaves",
"textures": {
"all": "naturesaura:blocks/decayed_leaves"
},
"transform": "forge:default-block"
},
"variants": {
"normal": [{}],
"inventory": [{}]
}
}

View file

@ -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
tile.naturesaura.nature_altar.name=Natural Altar
tile.naturesaura.decayed_leaves.name=Decayed Leaves

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B