package net.minecraft.world.level.block;

import net.minecraft.world.phys.Vec3;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class SlimeBlock extends HalfTransparentBlock {
    public SlimeBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public void fallOn(final Level bqb, final BlockPos fu, final Entity aom, final float float4) {
        if (aom.isSuppressingBounce()) {
            super.fallOn(bqb, fu, aom, float4);
        }
        else {
            aom.causeFallDamage(float4, 0.0f);
        }
    }
    
    @Override
    public void updateEntityAfterFallOn(final BlockGetter bpg, final Entity aom) {
        if (aom.isSuppressingBounce()) {
            super.updateEntityAfterFallOn(bpg, aom);
        }
        else {
            this.bounceUp(aom);
        }
    }
    
    private void bounceUp(final Entity aom) {
        final Vec3 dem3 = aom.getDeltaMovement();
        if (dem3.y < 0.0) {
            final double double4 = (aom instanceof LivingEntity) ? 1.0 : 0.8;
            aom.setDeltaMovement(dem3.x, -dem3.y * double4, dem3.z);
        }
    }
    
    @Override
    public void stepOn(final Level bqb, final BlockPos fu, final Entity aom) {
        final double double5 = Math.abs(aom.getDeltaMovement().y);
        if (double5 < 0.1 && !aom.isSteppingCarefully()) {
            final double double6 = 0.4 + double5 * 0.2;
            aom.setDeltaMovement(aom.getDeltaMovement().multiply(double6, 1.0, double6));
        }
        super.stepOn(bqb, fu, aom);
    }
}
