package net.minecraft.client;// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: fullnames deadcode fieldsfirst safe 
// Source File Name:   SourceFile

import java.awt.Color;
import java.io.File;
import java.util.LinkedList;

public class ad extends java.awt.Canvas
    implements java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.lang.Runnable
{

    private int a;
    private int b;
    private boolean c;
    private cn d;
    private java.io.File e;
    private boolean f;
    private java.util.List g;
    private jj h[][];
    private int i;
    private int j;
    private int k;
    private int l;

    public java.io.File a()
    {
        if(e == null)
            e = a("minecraft");
        return e;
    }

    public java.io.File a(java.lang.String s)
    {
        java.lang.String s1 = java.lang.System.getProperty("user.home", ".");
        java.io.File file;
        switch(ln.a[ad.e().ordinal()])
        {
        case 1: // '\001'
        case 2: // '\002'
            file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString());
            break;

        case 3: // '\003'
            java.lang.String s2 = java.lang.System.getenv("APPDATA");
            if(s2 != null)
                file = new File(s2, (new StringBuilder()).append(".").append(s).append('/').toString());
            else
                file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString());
            break;

        case 4: // '\004'
            file = new File(s1, (new StringBuilder()).append("Library/Application Support/").append(s).toString());
            break;

        default:
            file = new File(s1, (new StringBuilder()).append(s).append('/').toString());
            break;
        }
        if(!file.exists() && !file.mkdirs())
            throw new RuntimeException((new StringBuilder()).append("The working directory could not be created: ").append(((java.lang.Object) (file))).toString());
        else
            return file;
    }

    private static fa e()
    {
        java.lang.String s = java.lang.System.getProperty("os.name").toLowerCase();
        if(s.contains("win"))
            return fa.c;
        if(s.contains("mac"))
            return fa.d;
        if(s.contains("solaris"))
            return fa.b;
        if(s.contains("sunos"))
            return fa.b;
        if(s.contains("linux"))
            return fa.a;
        if(s.contains("unix"))
            return fa.a;
        else
            return fa.e;
    }

    public ad()
    {
        a = 0;
        b = 2;
        c = true;
        f = true;
        g = java.util.Collections.synchronizedList(((java.util.List) (new LinkedList())));
        h = new jj[64][64];
        e = a();
        for(int i1 = 0; i1 < 64; i1++)
        {
            for(int j1 = 0; j1 < 64; j1++)
                h[i1][j1] = new jj(((cn) (null)), i1, j1);

        }

        addMouseListener(((java.awt.event.MouseListener) (this)));
        addMouseMotionListener(((java.awt.event.MouseMotionListener) (this)));
        addKeyListener(((java.awt.event.KeyListener) (this)));
        setFocusable(true);
        requestFocus();
        setBackground(java.awt.Color.red);
    }

    public void b(java.lang.String s)
    {
        i = j = 0;
        d = ((cn) (new lk(this, new File(e, "saves"), s)));
        d.e = 0;
        synchronized(g)
        {
            g.clear();
            for(int i1 = 0; i1 < 64; i1++)
            {
                for(int j1 = 0; j1 < 64; j1++)
                    h[i1][j1].a(d, i1, j1);

            }

        }
    }

    private void a(int i1)
    {
        synchronized(g)
        {
            d.e = i1;
            g.clear();
            for(int j1 = 0; j1 < 64; j1++)
            {
                for(int k1 = 0; k1 < 64; k1++)
                    h[j1][k1].a(d, j1, k1);

            }

        }
    }

    public void b()
    {
        (new lh(this)).start();
        for(int i1 = 0; i1 < 8; i1++)
            (new Thread(((java.lang.Runnable) (this)))).start();

    }

    public void c()
    {
        f = false;
    }

    private jj a(int i1, int j1)
    {
        int k1 = i1 & 0x3f;
        int l1 = j1 & 0x3f;
        jj jj1 = h[k1][l1];
        if(jj1.c == i1 && jj1.d == j1)
            return jj1;
        synchronized(g)
        {
            g.remove(((java.lang.Object) (jj1)));
        }
        jj1.a(i1, j1);
        return jj1;
    }

    public void run()
    {
        lt lt1 = new lt();
        while(f) 
        {
            jj jj1 = null;
            synchronized(g)
            {
                if(g.size() > 0)
                    jj1 = (jj)g.remove(0);
            }
            if(jj1 != null)
                if(a - jj1.g < 2)
                {
                    lt1.a(jj1);
                    repaint();
                } else
                {
                    jj1.h = false;
                }
            try
            {
                java.lang.Thread.sleep(2L);
            }
            catch(java.lang.InterruptedException interruptedexception)
            {
                interruptedexception.printStackTrace();
            }
        }
    }

    public void update(java.awt.Graphics g1)
    {
    }

    public void paint(java.awt.Graphics g1)
    {
    }

    public void d()
    {
        java.awt.image.BufferStrategy bufferstrategy = getBufferStrategy();
        if(bufferstrategy == null)
        {
            createBufferStrategy(2);
            return;
        } else
        {
            a((java.awt.Graphics2D)bufferstrategy.getDrawGraphics());
            bufferstrategy.show();
            return;
        }
    }

    public void a(java.awt.Graphics2D graphics2d)
    {
        a++;
        java.awt.geom.AffineTransform affinetransform = graphics2d.getTransform();
        graphics2d.setClip(0, 0, getWidth(), getHeight());
        graphics2d.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION, java.awt.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
        graphics2d.translate(getWidth() / 2, getHeight() / 2);
        graphics2d.scale(b, b);
        graphics2d.translate(i, j);
        if(d != null)
            graphics2d.translate(-(d.o + d.q), -(-d.o + d.q) + 64);
        java.awt.Rectangle rectangle = graphics2d.getClipBounds();
        graphics2d.setColor(new Color(0xff101020));
        graphics2d.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
        byte byte0 = 16;
        byte byte1 = 3;
        int i1 = rectangle.x / byte0 / 2 - 2 - byte1;
        int j1 = (rectangle.x + rectangle.width) / byte0 / 2 + 1 + byte1;
        int k1 = rectangle.y / byte0 - 1 - byte1 * 2;
        int l1 = (rectangle.y + rectangle.height + 16 + 128) / byte0 + 1 + byte1 * 2;
        for(int i2 = k1; i2 <= l1; i2++)
        {
            for(int k2 = i1; k2 <= j1; k2++)
            {
                int l2 = k2 - (i2 >> 1);
                int i3 = k2 + (i2 + 1 >> 1);
                jj jj1 = a(l2, i3);
                jj1.g = a;
                if(!jj1.e)
                {
                    if(!jj1.h)
                    {
                        jj1.h = true;
                        g.add(((java.lang.Object) (jj1)));
                    }
                    continue;
                }
                jj1.h = false;
                if(!jj1.f)
                {
                    int j3 = k2 * byte0 * 2 + (i2 & 1) * byte0;
                    int k3 = i2 * byte0 - 128 - 16;
                    graphics2d.drawImage(((java.awt.Image) (jj1.a)), j3, k3, ((java.awt.image.ImageObserver) (null)));
                }
            }

        }

        if(c)
        {
            graphics2d.setTransform(affinetransform);
            int j2 = getHeight() - 32 - 4;
            graphics2d.setColor(new Color(0x80000000, true));
            graphics2d.fillRect(4, getHeight() - 32 - 4, getWidth() - 8, 32);
            graphics2d.setColor(java.awt.Color.WHITE);
            java.lang.String s = "F1 - F5: load levels   |   0-9: Set time of day   |   Space: return to spawn   |   Double click: zoom   |   Escape: hide this text";
            graphics2d.drawString(s, getWidth() / 2 - graphics2d.getFontMetrics().stringWidth(s) / 2, j2 + 20);
        }
        graphics2d.dispose();
    }

    public void mouseDragged(java.awt.event.MouseEvent mouseevent)
    {
        int i1 = mouseevent.getX() / b;
        int j1 = mouseevent.getY() / b;
        i += i1 - k;
        j += j1 - l;
        k = i1;
        l = j1;
        repaint();
    }

    public void mouseMoved(java.awt.event.MouseEvent mouseevent)
    {
    }

    public void mouseClicked(java.awt.event.MouseEvent mouseevent)
    {
        if(mouseevent.getClickCount() == 2)
        {
            b = 3 - b;
            repaint();
        }
    }

    public void mouseEntered(java.awt.event.MouseEvent mouseevent)
    {
    }

    public void mouseExited(java.awt.event.MouseEvent mouseevent)
    {
    }

    public void mousePressed(java.awt.event.MouseEvent mouseevent)
    {
        int i1 = mouseevent.getX() / b;
        int j1 = mouseevent.getY() / b;
        k = i1;
        l = j1;
    }

    public void mouseReleased(java.awt.event.MouseEvent mouseevent)
    {
    }

    public void keyPressed(java.awt.event.KeyEvent keyevent)
    {
        if(keyevent.getKeyCode() == 48)
            a(11);
        if(keyevent.getKeyCode() == 49)
            a(10);
        if(keyevent.getKeyCode() == 50)
            a(9);
        if(keyevent.getKeyCode() == 51)
            a(7);
        if(keyevent.getKeyCode() == 52)
            a(6);
        if(keyevent.getKeyCode() == 53)
            a(5);
        if(keyevent.getKeyCode() == 54)
            a(3);
        if(keyevent.getKeyCode() == 55)
            a(2);
        if(keyevent.getKeyCode() == 56)
            a(1);
        if(keyevent.getKeyCode() == 57)
            a(0);
        if(keyevent.getKeyCode() == 112)
            b("World1");
        if(keyevent.getKeyCode() == 113)
            b("World2");
        if(keyevent.getKeyCode() == 114)
            b("World3");
        if(keyevent.getKeyCode() == 115)
            b("World4");
        if(keyevent.getKeyCode() == 116)
            b("World5");
        if(keyevent.getKeyCode() == 32)
            i = j = 0;
        if(keyevent.getKeyCode() == 27)
            c = !c;
        repaint();
    }

    public void keyReleased(java.awt.event.KeyEvent keyevent)
    {
    }

    public void keyTyped(java.awt.event.KeyEvent keyevent)
    {
    }

    static boolean a(ad ad1)
    {
        return ad1.f;
    }
}
