package com.zivilon.cinder_loe.command;

import com.zivilon.cinder_loe.world.sounds.MobileSoundHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatComponentText;

public class CommandMobileSound extends CommandBase {

    private boolean active = false;

    @Override
    public String getCommandName() {
        return "movesound";
    }

    @Override
    public String getCommandUsage(ICommandSender sender) {
        return "/movesound - turns you into a walking jukebox (toggle command)";
    }

    @Override
    public void processCommand(ICommandSender sender, String[] args) {
        EntityPlayer player = getCommandSenderAsPlayer(sender);

        if (!player.worldObj.isRemote) {
            return;
        }
        if (!active) {
            Minecraft.getMinecraft().getSoundHandler().playSound(new MobileSoundHandler(player, "soundname"));
            active = true;
            player.addChatMessage(new ChatComponentText("You are a walking jukebox"));
        } else {
            active = false;
            player.addChatMessage(new ChatComponentText("You are no longer a walking jukebox"));
        }

    }

}
