package me.km.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.fluid.FlowingFluid;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class ModFlowingFluidBlock extends FlowingFluidBlock {
    private final Effect effect;

    public ModFlowingFluidBlock(FlowingFluid fluid, Effect effect, Block.Properties builder) {
        super(fluid, builder);
        this.effect = effect;
    }

    @Override
    public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity ent) {
        if(ent instanceof LivingEntity) {
            ((LivingEntity) ent).addPotionEffect(new EffectInstance(effect, 60));
        }
    }
}
