package net.kyau.darkmatter.proxy;

import java.util.Random;
import java.util.logging.Level;
import java.util.logging.LogManager;

import net.kyau.darkmatter.client.gui.GuiHUD;
import net.kyau.darkmatter.client.gui.GuiVoidJournal;
import net.kyau.darkmatter.client.renderer.EntityParticleFXQuantum;
import net.kyau.darkmatter.references.ModInfo;
import net.kyau.darkmatter.registry.ModBlocks;
import net.kyau.darkmatter.registry.ModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

public class ClientProxy extends CommonProxy {
  
  private static Minecraft minecraft = Minecraft.getMinecraft();
  
  @Override
  public ClientProxy getClientProxy() {
    return this;
  }

  @Override
  public void registerEventHandlers() {
    super.registerEventHandlers();
    MinecraftForge.EVENT_BUS.register(new GuiHUD(minecraft));
    //LogManager.getLogger(ModInfo.MOD_ID).log(Level.INFO, "ClientProxy: registerEventHandlers() SUCCESS!");
  }

  @Override
  public void registerClientEventHandlers() {
    // NOOP
  }

  @Override
  public void registerKeybindings() {
    // NOOP
  }

  @Override
  public void initRenderingAndTextures() {
    ModItems.registerRenders();
    ModBlocks.registerRenders();
  }

  @Override
  public boolean isSinglePlayer() {
    return Minecraft.getMinecraft().isSingleplayer();
  }

  @Override
  public void openJournal() {
    Minecraft.getMinecraft().displayGuiScreen(new GuiVoidJournal());
  }

  @Override
  public void generateQuantumParticles(World world, BlockPos pos, Random rand) {
    float motionX = (float) (rand.nextGaussian() * 0.02F);
    float motionY = (float) (rand.nextGaussian() * 0.02F);
    float motionZ = (float) (rand.nextGaussian() * 0.02F);
    // for (int i = 0; i < 2; i++) {
    Particle particleMysterious = new EntityParticleFXQuantum(world, pos.getX() + rand.nextFloat() * 0.7F + 0.2F, pos.getY() + 0.1F, pos.getZ() + rand.nextFloat() * 0.8F + 0.2F, motionX, motionY, motionZ);
    Minecraft.getMinecraft().effectRenderer.addEffect(particleMysterious);
    // }
  }

  @Override
  public long getVoidPearlLastUse() {
    // return lastUseVoidPearl;
    return 0;
  }

  @Override
  public void setVoidPearlLastUse(long lastUse) {
    // this.lastUseVoidPearl = cooldown;
  }

  @Override
  public void registerTileEntities() {
    // TODO Auto-generated method stub
    
  }
}
