package com.bioxx.tfc2.blocks.terrain; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import com.bioxx.tfc2.Core; import com.bioxx.tfc2.api.types.StoneType; import com.bioxx.tfc2.blocks.BlockGravity; import com.bioxx.tfc2.core.TFC_Sounds; import com.bioxx.tfc2.entity.EntityFallingBlockTFC; public class BlockGravel extends BlockGravity { public static PropertyEnum META_PROPERTY = PropertyEnum.create("stone", StoneType.class); public BlockGravel() { super(Material.GROUND, META_PROPERTY); this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS); setSoundType(SoundType.GROUND); } /******************************************************************************* * 1. Content *******************************************************************************/ @Override public void onStartFalling(EntityFallingBlockTFC fallingEntity) { Core.playSoundAtEntity(fallingEntity, TFC_Sounds.FALLININGDIRTSHORT, 0.7f, 0.8f); } @Override public int getSlideHeight() { return 1; } @Override public float getSlideChance() { return 0.9f; } @Override protected void checkFallable(World worldIn, BlockPos pos, IBlockState state) { BlockPos slidePos = slideScan(worldIn, pos); if(slidePos != null && (slidePos.getY() >= 0)) { worldIn.setBlockToAir(pos); fall(worldIn, slidePos, state); } } /******************************************************************************* * 2. Rendering *******************************************************************************/ /******************************************************************************* * 3. Blockstate *******************************************************************************/ @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[]{META_PROPERTY}); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(META_PROPERTY, StoneType.getStoneTypeFromMeta(meta)); } @Override public int getMetaFromState(IBlockState state) { return ((StoneType)state.getValue(META_PROPERTY)).getMeta(); } }