package com.leisuretimedock.blasttravelreborn.client;

import com.leisuretimedock.blasttravelreborn.BlastTravelReborn;
import com.leisuretimedock.blasttravelreborn.client.entity.CannonEntityRenderer;
import com.leisuretimedock.blasttravelreborn.client.particle.CannonBlastParticle;
import com.leisuretimedock.blasttravelreborn.client.screen.CannonScreen;
import com.leisuretimedock.blasttravelreborn.client.screen.overlay.CannonOverlay;
import com.leisuretimedock.blasttravelreborn.content.BTRParticleTypes;
import com.leisuretimedock.blasttravelreborn.content.entity.BTREntityTypes;
import com.leisuretimedock.blasttravelreborn.content.menu.BTRMenuTypes;
import com.leisuretimedock.jsonem.JsonEm;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(modid = BlastTravelReborn.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class BlastTravelClient {

	@SubscribeEvent
	public static void onFmlClientSetup(final FMLClientSetupEvent event) {
		event.enqueueWork(() -> MenuScreens.register(BTRMenuTypes.CANNON_CONTAINER_MENU.get(), CannonScreen::new));
	}
	@SubscribeEvent
	public static void onEntityRenderRegistry(final EntityRenderersEvent.RegisterRenderers event) {
		event.registerEntityRenderer(BTREntityTypes.CANNON_ENTITY.get(), CannonEntityRenderer::new);
	}
	@SubscribeEvent
	public static void onRegisterLayerDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event) {
		JsonEm.registerModelLayer(CannonEntityRenderer.MODEL);
	}
	@SubscribeEvent
	public static void onRegisterParticleProviders(RegisterParticleProvidersEvent event) {
		event.registerSpriteSet(BTRParticleTypes.CANNON_BLAST.get(), CannonBlastParticle.Provider::new);
	}

	@SubscribeEvent
	public static void onOverlayRegister(RegisterGuiOverlaysEvent event) {
		event.registerAbove(VanillaGuiOverlay.SPYGLASS.id(), "cannon",
			new CannonOverlay()
		);
	}
}
