    001    package net.minecraft.src;
    002
    003    public class MapInfo
    004    {
    005        /** Reference for EntityPlayer object in MapInfo */
    006        public final EntityPlayer entityplayerObj;
    007        public int[] field_76209_b;
    008        public int[] field_76210_c;
    009
    010        /**
    011         * updated by x = mod(x*11,128) +1  x-1 is used to index field_76209_b and field_76210_c
    012         */
    013        private int currentRandomNumber;
    014        private int ticksUntilPlayerLocationMapUpdate;
    015
    016        /**
    017         * a cache of the result from getPlayersOnMap so that it is not resent when nothing changes
    018         */
    019        private byte[] lastPlayerLocationOnMap;
    020
    021        /** reference in MapInfo to MapData object */
    022        final MapData mapDataObj;
    023
    024        public MapInfo(MapData par1MapData, EntityPlayer par2EntityPlayer)
    025        {
    026            this.mapDataObj = par1MapData;
    027            this.field_76209_b = new int[128];
    028            this.field_76210_c = new int[128];
    029            this.currentRandomNumber = 0;
    030            this.ticksUntilPlayerLocationMapUpdate = 0;
    031            this.entityplayerObj = par2EntityPlayer;
    032
    033            for (int var3 = 0; var3 < this.field_76209_b.length; ++var3)
    034            {
    035                this.field_76209_b[var3] = 0;
    036                this.field_76210_c[var3] = 127;
    037            }
    038        }
    039
    040        /**
    041         * returns a 1+players*3 array, of x,y, and color . the name of this function may be partially wrong, as there is a
    042         * second branch to the code here
    043         */
    044        public byte[] getPlayersOnMap(ItemStack par1ItemStack)
    045        {
    046            int var3;
    047            int var10;
    048
    049            if (--this.ticksUntilPlayerLocationMapUpdate < 0)
    050            {
    051                this.ticksUntilPlayerLocationMapUpdate = 4;
    052                byte[] var2 = new byte[this.mapDataObj.playersVisibleOnMap.size() * 3 + 1];
    053                var2[0] = 1;
    054
    055                for (var3 = 0; var3 < this.mapDataObj.playersVisibleOnMap.size(); ++var3)
    056                {
    057                    MapCoord var4 = (MapCoord)this.mapDataObj.playersVisibleOnMap.get(var3);
    058                    var2[var3 * 3 + 1] = (byte)(var4.iconSize + (var4.iconRotation & 15) * 16);
    059                    var2[var3 * 3 + 2] = var4.centerX;
    060                    var2[var3 * 3 + 3] = var4.centerZ;
    061                }
    062
    063                boolean var9 = true;
    064
    065                if (this.lastPlayerLocationOnMap != null && this.lastPlayerLocationOnMap.length == var2.length)
    066                {
    067                    for (var10 = 0; var10 < var2.length; ++var10)
    068                    {
    069                        if (var2[var10] != this.lastPlayerLocationOnMap[var10])
    070                        {
    071                            var9 = false;
    072                            break;
    073                        }
    074                    }
    075                }
    076                else
    077                {
    078                    var9 = false;
    079                }
    080
    081                if (!var9)
    082                {
    083                    this.lastPlayerLocationOnMap = var2;
    084                    return var2;
    085                }
    086            }
    087
    088            for (int var8 = 0; var8 < 10; ++var8)
    089            {
    090                var3 = this.currentRandomNumber * 11 % 128;
    091                ++this.currentRandomNumber;
    092
    093                if (this.field_76209_b[var3] >= 0)
    094                {
    095                    var10 = this.field_76210_c[var3] - this.field_76209_b[var3] + 1;
    096                    int var5 = this.field_76209_b[var3];
    097                    byte[] var6 = new byte[var10 + 3];
    098                    var6[0] = 0;
    099                    var6[1] = (byte)var3;
    100                    var6[2] = (byte)var5;
    101
    102                    for (int var7 = 0; var7 < var6.length - 3; ++var7)
    103                    {
    104                        var6[var7 + 3] = this.mapDataObj.colors[(var7 + var5) * 128 + var3];
    105                    }
    106
    107                    this.field_76210_c[var3] = -1;
    108                    this.field_76209_b[var3] = -1;
    109                    return var6;
    110                }
    111            }
    112
    113            return null;
    114        }
    115    }