Files
Mohammad-Ali Minaie b86dedad2f base mod created
2018-10-08 09:07:47 -04:00

79 lines
2.2 KiB
Java

package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
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;
public class BlockSlime extends BlockBreakable
{
public BlockSlime()
{
super(Material.CLAY, false, MapColor.GRASS);
this.setCreativeTab(CreativeTabs.DECORATIONS);
this.slipperiness = 0.8F;
}
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.TRANSLUCENT;
}
/**
* Block's chance to react to a living entity falling on it.
*/
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
{
if (entityIn.isSneaking())
{
super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
}
else
{
entityIn.fall(fallDistance, 0.0F);
}
}
/**
* Called when an Entity lands on this Block. This method *must* update motionY because the entity will not do that
* on its own
*/
public void onLanded(World worldIn, Entity entityIn)
{
if (entityIn.isSneaking())
{
super.onLanded(worldIn, entityIn);
}
else if (entityIn.motionY < 0.0D)
{
entityIn.motionY = -entityIn.motionY;
if (!(entityIn instanceof EntityLivingBase))
{
entityIn.motionY *= 0.8D;
}
}
}
/**
* Called when the given entity walks on this Block
*/
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
{
if (Math.abs(entityIn.motionY) < 0.1D && !entityIn.isSneaking())
{
double d0 = 0.4D + Math.abs(entityIn.motionY) * 0.2D;
entityIn.motionX *= d0;
entityIn.motionZ *= d0;
}
super.onEntityWalk(worldIn, pos, entityIn);
}
}