001    
002    import java.util.ArrayList;
003    import java.util.HashSet;
004    import java.util.Iterator;
005    import java.util.List;
006    import java.util.Set;
007    import java.util.concurrent.DelayQueue;
008    import net.minecraft.server.MinecraftServer;
009    
010    public class im {
011    
012        private Set<io> a = new HashSet<io>();
013        private kh b = new kh();
014        private MinecraftServer c;
015        private int d;
016        // hMod: New fields to store the runnables in.
017        private static final DelayQueue<DelayedTask> delayQueue = new DelayQueue<DelayedTask>();
018    
019        public im(MinecraftServer paramMinecraftServer) {
020            c = paramMinecraftServer;
021            d = paramMinecraftServer.f.a();
022        }
023    
024        public void a(fe paramfe) {
025            fy localfy;
026            if ((paramfe instanceof fy)) {
027                a(paramfe, 512, 2);
028                localfy = (fy) paramfe;
029                for (io localio : a) {
030                    if (localio.a != localfy) {
031                        localio.b(localfy);
032                    }
033                }
034            } else if ((paramfe instanceof mq)) {
035                a(paramfe, 64, 5, true);
036            } else if ((paramfe instanceof fc)) {
037                a(paramfe, 64, 5, true);
038            } else if ((paramfe instanceof by)) {
039                a(paramfe, 64, 5, true);
040            } else if ((paramfe instanceof jb)) {
041                a(paramfe, 64, 5, true);
042            } else if ((paramfe instanceof ic)) {
043                a(paramfe, 64, 20, true);
044            } else if ((paramfe instanceof lw)) {
045                a(paramfe, 160, 5, true);
046            } else if ((paramfe instanceof gu)) {
047                a(paramfe, 160, 5, true);
048            } else if ((paramfe instanceof le)) {
049                a(paramfe, 160, 3, true);
050            } else if ((paramfe instanceof ap)) {
051                a(paramfe, 160, 3);
052            } else if ((paramfe instanceof dh)) {
053                a(paramfe, 160, 10, true);
054            } else if ((paramfe instanceof kd)) {
055                a(paramfe, 160, 20, true);
056            } else if ((paramfe instanceof dd)) {
057                a(paramfe, 160, 2147483647, false);
058            }
059        }
060    
061        public void a(fe paramfe, int paramInt1, int paramInt2) {
062            a(paramfe, paramInt1, paramInt2, false);
063        }
064    
065        public void a(fe paramfe, int paramInt1, int paramInt2, boolean paramBoolean) {
066            if (paramInt1 > d) {
067                paramInt1 = d;
068            }
069            if (b.b(paramfe.g)) {
070                throw new IllegalStateException("Entity is already tracked!");
071            }
072            io localio = new io(paramfe, paramInt1, paramInt2, paramBoolean);
073            a.add(localio);
074            b.a(paramfe.g, localio);
075            localio.b(c.e.d);
076        }
077    
078        public void b(fe paramfe) {
079            if ((paramfe instanceof fy)) {
080                fy localObject = (fy) paramfe;
081                for (io localio : a) {
082                    localio.a((fy) localObject);
083                }
084            }
085            Object localObject = (io) b.d(paramfe.g);
086            if (localObject != null) {
087                a.remove(localObject);
088                ((io) localObject).a();
089            }
090        }
091    
092        public void a() {
093            ArrayList localArrayList = new ArrayList();
094            for (Iterator localIterator1 = a.iterator(); localIterator1.hasNext();) {
095                io localObject = (io) localIterator1.next();
096                ((io) localObject).a(c.e.d);
097                if ((((io) localObject).m) && ((((io) localObject).a instanceof fy))) {
098                    localArrayList.add((fy) ((io) localObject).a);
099                }
100            }
101            Object localObject;
102            for (int i = 0; i < localArrayList.size(); i++) {
103                localObject = (fy) localArrayList.get(i);
104                for (io localio : a) {
105                    if (localio.a != localObject) {
106                        localio.b((fy) localObject);
107                    }
108                }
109            }
110            // hMod: Execute runnables contained in eventQueue.
111            for (DelayedTask task = delayQueue.poll(); task != null; task = delayQueue.poll()) {
112                // should we catch exceptions here?
113                task.run();
114            }
115        }
116    // hMod: Allow adding of tasks to the queue
117    
118        public static void add(Runnable task, long delayMillis) {
119            // j.u.concurent.* classes are thread safe
120            delayQueue.add(new DelayedTask(task, delayMillis));
121        }
122    
123        // hMod: deprecated. Use server.addToServerQueue().
124        @Deprecated
125        public synchronized static void add(Runnable r) {
126            add(r, 0L);
127        }
128    
129        public void a(fe paramfe, kx paramkx) {
130            io localio = (io) b.a(paramfe.g);
131            if (localio != null) {
132                localio.a(paramkx);
133            }
134        }
135    
136        public void b(fe paramfe, kx paramkx) {
137            io localio = (io) b.a(paramfe.g);
138            if (localio != null) {
139                localio.b(paramkx);
140            }
141        }
142    
143        public void a(fy paramfy) {
144            for (io localio : a) {
145                localio.c(paramfy);
146            }
147        }
148    }