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;

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