package com.acethewildfire.acesbs;

import com.acethewildfire.acesbs.block.ModBlocks;
import com.acethewildfire.acesbs.block.entity.ModBlockEntities;
import com.acethewildfire.acesbs.component.ModDataComponentTypes;
import com.acethewildfire.acesbs.effect.ModEffects;
import com.acethewildfire.acesbs.enchantment.ModEnchantmentEffects;
import com.acethewildfire.acesbs.entity.ModEntities;
import com.acethewildfire.acesbs.entity.custom.FrenEntity;
import com.acethewildfire.acesbs.item.ModItemGroups;
import com.acethewildfire.acesbs.item.ModItems;
import com.acethewildfire.acesbs.potion.ModPotions;
import com.acethewildfire.acesbs.recipe.ModRecipies;
import com.acethewildfire.acesbs.screen.ModScreenHandlers;
import com.acethewildfire.acesbs.sounds.ModSounds;
import com.acethewildfire.acesbs.util.HammerUsageEvent;
import com.acethewildfire.acesbs.util.UpdateRecipies;
import com.acethewildfire.acesbs.util.YouMonsterEvent;
import com.acethewildfire.acesbs.world.gen.ModWorldGeneration;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FabricBrewingRecipeRegistryBuilder;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.item.Items;
import net.minecraft.potion.Potions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AcesBS implements ModInitializer {
	public static final String MOD_ID = "acesbs";

	// This logger is used to write text to the console and the log file.
	// It is considered best practice to use your mod id as the logger's name.
	// That way, it's clear which mod wrote info, warnings, and errors.
	public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

	@Override
	public void onInitialize() {
		// This code runs as soon as Minecraft is in a mod-load-ready state.
		// However, some things (like resources) may still be uninitialized.
		// Proceed with mild caution.

		LOGGER.info("You would not believe the kind of day I am having...");
		ModItemGroups.registerItemGroups();
		ModItems.registerModItems();
		ModBlocks.registerModBlocks();
		ModSounds.registerSounds();
		ModEffects.registerEffects();
		ModPotions.registerPotions();
		ModEnchantmentEffects.registerModEnchantments();
		ModWorldGeneration.generateModWorldGen();
		ModEntities.registerModEntities();
		ModBlockEntities.registerBlockEntities();
		ModScreenHandlers.registerScreenHandlers();
		ModRecipies.registerRecipes();

		ModDataComponentTypes.registerDataComponentsTypes();

		UpdateRecipies.updateVanilla();

		PlayerBlockBreakEvents.BEFORE.register(new HammerUsageEvent());
		AttackEntityCallback.EVENT.register(new YouMonsterEvent());

		FabricBrewingRecipeRegistryBuilder.BUILD.register(builder -> {
			builder.registerPotionRecipe(Potions.AWKWARD, ModItems.LEMON, ModPotions.LEMON);
			builder.registerPotionRecipe(Potions.AWKWARD, Items.SAND, ModPotions.BLINDNESS);
		});

//		CompostingChanceRegistry.INSTANCE.add(ModItems.TOBACCO);
		CompostingChanceRegistry.INSTANCE.add(ModItems.TOBACCO_SEEDS, 0.5f);

		StrippableBlockRegistry.register(ModBlocks.LEMONWOOD_LOG, ModBlocks.STRIPPED_LEMONWOOD_LOG);
		StrippableBlockRegistry.register(ModBlocks.LEMONWOOD_WOOD, ModBlocks.STRIPPED_LEMONWOOD_WOOD);

		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.LEMONWOOD_LOG, 5, 5);
		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.LEMONWOOD_WOOD, 5, 5);
		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.STRIPPED_LEMONWOOD_LOG, 5, 5);
		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.STRIPPED_LEMONWOOD_WOOD, 5, 5);

		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.LEMONWOOD_PLANKS, 5, 20);
		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.LEMONWOOD_SLAB, 5, 20);
		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.LEMONWOOD_STAIRS, 5, 20);

		FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.LEMONWOOD_LEAVES, 30, 60);

		FabricDefaultAttributeRegistry.register(ModEntities.FREN, FrenEntity.createAttributes());
	}
}