package asm.mixins;

import com.mojang.serialization.MapCodec;
import dev.crucifixbeta.CrucifixBeta;
import dev.crucifixbeta.api.events.impl.BlockActivateEvent;
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.AbstractBlock.AbstractBlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.property.Property;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;

@Environment(EnvType.CLIENT)
@Mixin({BlockState.class})
public abstract class MixinBlockState extends AbstractBlockState {
   public MixinBlockState(Block block, Reference2ObjectArrayMap<Property<?>, Comparable<?>> propertyMap, MapCodec<BlockState> mapCodec) {
      super(block, propertyMap, mapCodec);
   }

   @Override
   public ActionResult onUse(World world, PlayerEntity player, BlockHitResult hit) {
      CrucifixBeta.EVENT_BUS.post(BlockActivateEvent.get(BlockState.class.cast(this)));
      return super.onUse(world, player, hit);
   }
}
