package mapped;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSWorldMapRegion;

@ObfuscatedName("jl")
public class WorldMapRegion implements RSWorldMapRegion {
   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "Lls;"
   )
   public static DemotingHashTable WorldMapRegion_cachedSprites;
   @ObfuscatedName("au")
   @ObfuscatedGetter(
      intValue = -584179489
   )
   int regionX;
   @ObfuscatedName("aa")
   @ObfuscatedGetter(
      intValue = -523067815
   )
   int regionY;
   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "Lii;"
   )
   WorldMapData_0 worldMapData_0;
   @ObfuscatedName("al")
   LinkedList worldMapData1List;
   @ObfuscatedName("az")
   @ObfuscatedGetter(
      intValue = -278802829
   )
   int backgroundColor;
   @ObfuscatedName("ap")
   @ObfuscatedGetter(
      intValue = 2115657887
   )
   int pixelsPerTile;
   @ObfuscatedName("av")
   List icon0List;
   @ObfuscatedName("ax")
   HashMap iconMap;
   @ObfuscatedName("as")
   final HashMap fonts;

   static {
      WorldMapRegion_cachedSprites = new DemotingHashTable(37748736, 256);
   }

   WorldMapRegion(int var1, int var2, int var3, HashMap var4) {
      this.regionX = var1;
      this.regionY = var2;
      this.worldMapData1List = new LinkedList();
      this.icon0List = new LinkedList();
      this.iconMap = new HashMap();
      this.backgroundColor = var3 | -16777216;
      this.fonts = var4;
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(IIII)V",
      garbageValue = "-1077363567"
   )
   void method4625_base(int var1, int var2, int var3) {
      SpritePixels var4 = class130.method3096(this.regionX, this.regionY, this.pixelsPerTile);
      if(var4 != null) {
         if(var3 == this.pixelsPerTile * 64) {
            var4.drawAt_base(var1, var2);
         } else {
            var4.drawScaledWorldmap_base(var1, var2, var3, var3);
         }

      }
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(Lii;Ljava/util/List;I)V",
      garbageValue = "1079022526"
   )
   void method4671(WorldMapData_0 var1, List var2) {
      this.iconMap.clear();
      this.worldMapData_0 = var1;
      this.addAllToIconList_base(var2);
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(Ljava/util/HashSet;Ljava/util/List;S)V",
      garbageValue = "363"
   )
   void initWorldMapData1_base(HashSet var1, List var2) {
      this.iconMap.clear();
      Iterator var3 = var1.iterator();

      while(var3.hasNext()) {
         WorldMapData_1 var4 = (WorldMapData_1)var3.next();
         if(var4.getRegionX_base() == this.regionX && var4.getRegionY_base() == this.regionY) {
            this.worldMapData1List.add(var4);
         }
      }

      this.addAllToIconList_base(var2);
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(IIIILjm;I)V",
      garbageValue = "-1882994474"
   )
   void method4627(int var1, int var2, int var3, int var4, AbstractWorldMapData var5) {
      for(int var6 = var1; var6 < var3 + var1; ++var6) {
         label50:
         for(int var7 = var2; var7 < var2 + var4; ++var7) {
            for(int var8 = 0; var8 < var5.planes; ++var8) {
               WorldMapDecoration[] var9 = var5.decorations[var8][var6][var7];
               if(var9 != null && var9.length != 0) {
                  WorldMapDecoration[] var10 = var9;

                  for(int var11 = 0; var11 < var10.length; ++var11) {
                     WorldMapDecoration var12 = var10[var11];
                     ObjectComposition var13 = WorldMapSection2.method4515(var12.objectDefinitionId);
                     if(class351.method6854(var13)) {
                        this.method4628(var13, var8, var6, var7, var5);
                        continue label50;
                     }
                  }
               }
            }
         }
      }

   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(Lhs;IIILjm;B)V",
      garbageValue = "-49"
   )
   void method4628(ObjectComposition var1, int var2, int var3, int var4, AbstractWorldMapData var5) {
      Coord var6 = new Coord(var2, var3 + this.regionX * 64, this.regionY * 64 + var4);
      Coord var7 = null;
      if(this.worldMapData_0 != null) {
         var7 = new Coord(this.worldMapData_0.minPlane + var2, var3 + this.worldMapData_0.regionXLow * 64, var4 + this.worldMapData_0.regionYLow * 64);
      } else {
         WorldMapData_1 var8 = (WorldMapData_1)var5;
         var7 = new Coord(var2 + var8.minPlane, var3 + var8.regionXLow * 64 + var8.getChunkXLow_base() * 8, var8.regionYLow * 64 + var4 + var8.getChunkYLow_base() * 8);
      }

      WorldMapElement var9;
      Object var10;
      if(var1.transforms != null) {
         var10 = new WorldMapIcon_1(var7, var6, var1.id, this);
      } else {
         var9 = class141.method3209(var1.mapIconId);
         var10 = new WorldMapIcon_0(var7, var6, var9.objectId, this.method4638(var9));
      }

      var9 = class141.method3209(((AbstractWorldMapIcon)var10).getElement_base());
      if(var9.field1825) {
         this.iconMap.put(new Coord(0, var3, var4), var10);
      }

   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "1468543514"
   )
   void initWorldMapIcon1s_base() {
      Iterator var1 = this.iconMap.values().iterator();

      while(var1.hasNext()) {
         AbstractWorldMapIcon var2 = (AbstractWorldMapIcon)var1.next();
         if(var2 instanceof WorldMapIcon_1) {
            ((WorldMapIcon_1)var2).init_base();
         }
      }

   }

   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "(Ljava/util/List;I)V",
      garbageValue = "-1918438816"
   )
   void addAllToIconList_base(List var1) {
      Iterator var2 = var1.iterator();

      while(var2.hasNext()) {
         WorldMapIcon_0 var3 = (WorldMapIcon_0)var2.next();
         if(class141.method3209(var3.element).field1825 && var3.coord2.x >> 6 == this.regionX && var3.coord2.y >> 6 == this.regionY) {
            WorldMapIcon_0 var4 = new WorldMapIcon_0(var3.coord2, var3.coord2, var3.element, this.method4653(var3.element));
            this.icon0List.add(var4);
         }
      }

   }

   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "(B)V",
      garbageValue = "-70"
   )
   void method4624_base() {
      if(this.worldMapData_0 != null) {
         this.worldMapData_0.reset_base();
      } else {
         Iterator var1 = this.worldMapData1List.iterator();

         while(var1.hasNext()) {
            WorldMapData_1 var2 = (WorldMapData_1)var1.next();
            var2.reset_base();
         }
      }

   }

   @ObfuscatedName("az")
   @ObfuscatedSignature(
      descriptor = "(Lol;I)Z",
      garbageValue = "-207493702"
   )
   boolean method4730(AbstractArchive var1) {
      this.iconMap.clear();
      if(this.worldMapData_0 != null) {
         this.worldMapData_0.method4894(var1);
         if(this.worldMapData_0.isFullyLoaded_base()) {
            this.method4627(0, 0, 64, 64, this.worldMapData_0);
            return true;
         } else {
            return false;
         }
      } else {
         boolean var2 = true;

         Iterator var3;
         WorldMapData_1 var4;
         for(var3 = this.worldMapData1List.iterator(); var3.hasNext(); var2 &= var4.isFullyLoaded_base()) {
            var4 = (WorldMapData_1)var3.next();
            var4.method4894(var1);
         }

         if(var2) {
            var3 = this.worldMapData1List.iterator();

            while(var3.hasNext()) {
               var4 = (WorldMapData_1)var3.next();
               this.method4627(var4.getChunkX_base() * 8, var4.getChunkY_base() * 8, 8, 8, var4);
            }
         }

         return var2;
      }
   }

   @ObfuscatedName("ap")
   @ObfuscatedSignature(
      descriptor = "(ILja;[Lup;Lol;Lol;I)V",
      garbageValue = "-67039997"
   )
   void method4633(int var1, WorldMapScaleHandler var2, IndexedSprite[] var3, AbstractArchive var4, AbstractArchive var5) {
      this.pixelsPerTile = var1;
      if(this.worldMapData_0 != null || !this.worldMapData1List.isEmpty()) {
         if(class130.method3096(this.regionX, this.regionY, var1) == null) {
            boolean var6 = true;
            var6 &= this.method4730(var4);
            int var8;
            if(this.worldMapData_0 != null) {
               var8 = this.worldMapData_0.groupId;
            } else {
               var8 = ((AbstractWorldMapData)this.worldMapData1List.getFirst()).groupId;
            }

            var6 &= var5.tryLoadGroup_base(var8);
            if(var6) {
               byte[] var7 = var5.takeFileFlat_base(var8);
               WorldMapSprite var9;
               if(var7 == null) {
                  var9 = new WorldMapSprite();
               } else {
                  var9 = new WorldMapSprite(WorldMapArchiveLoader.method8712(var7).pixels);
               }

               SpritePixels var11 = new SpritePixels(this.pixelsPerTile * 64, this.pixelsPerTile * 64);
               var11.setRaster_base();
               if(this.worldMapData_0 != null) {
                  this.method4636(var2, var3, var9);
               } else {
                  this.method4731(var2, var3, var9);
               }

               int var12 = this.regionX;
               int var13 = this.regionY;
               int var14 = this.pixelsPerTile;
               DemotingHashTable var15 = WorldMapRegion_cachedSprites;
               long var17 = (long)(var14 << 16 | var12 << 8 | var13);
               var15.put_base(var11, var17, var11.pixels.length * 4);
               this.method4624_base();
            }
         }
      }
   }

   @ObfuscatedName("av")
   @ObfuscatedSignature(
      descriptor = "(IIILjava/util/HashSet;B)V",
      garbageValue = "99"
   )
   void method4634_base(int var1, int var2, int var3, HashSet var4) {
      if(var4 == null) {
         var4 = new HashSet();
      }

      this.drawNonLinkMapIcons_base(var1, var2, var4, var3);
      this.drawMapLinks_base(var1, var2, var4, var3);
   }

   @ObfuscatedName("ax")
   @ObfuscatedSignature(
      descriptor = "(Ljava/util/HashSet;III)V",
      garbageValue = "-1303977769"
   )
   void flashElements_base(HashSet var1, int var2, int var3) {
      Iterator var4 = this.iconMap.values().iterator();

      while(var4.hasNext()) {
         AbstractWorldMapIcon var5 = (AbstractWorldMapIcon)var4.next();
         if(var5.hasValidElement_base()) {
            int var6 = var5.getElement_base();
            if(var1.contains(Integer.valueOf(var6))) {
               WorldMapElement var7 = class141.method3209(var6);
               this.method4646(var7, var5.screenX, var5.screenY, var2, var3);
            }
         }
      }

      this.method4645_base(var1, var2, var3);
   }

   @ObfuscatedName("as")
   @ObfuscatedSignature(
      descriptor = "(Lja;[Lup;Lju;B)V",
      garbageValue = "41"
   )
   void method4636(WorldMapScaleHandler var1, IndexedSprite[] var2, WorldMapSprite var3) {
      int var4;
      int var5;
      for(var4 = 0; var4 < 64; ++var4) {
         for(var5 = 0; var5 < 64; ++var5) {
            this.method4688(var4, var5, this.worldMapData_0, var1, var3);
            this.method4640(var4, var5, this.worldMapData_0, var1);
         }
      }

      for(var4 = 0; var4 < 64; ++var4) {
         for(var5 = 0; var5 < 64; ++var5) {
            this.method4668(var4, var5, this.worldMapData_0, var1, var2);
         }
      }

   }

   @ObfuscatedName("ay")
   @ObfuscatedSignature(
      descriptor = "(Lja;[Lup;Lju;B)V",
      garbageValue = "85"
   )
   void method4731(WorldMapScaleHandler var1, IndexedSprite[] var2, WorldMapSprite var3) {
      Iterator var4 = this.worldMapData1List.iterator();

      WorldMapData_1 var5;
      int var6;
      int var7;
      while(var4.hasNext()) {
         var5 = (WorldMapData_1)var4.next();

         for(var6 = var5.getChunkX_base() * 8; var6 < var5.getChunkX_base() * 8 + 8; ++var6) {
            for(var7 = var5.getChunkY_base() * 8; var7 < var5.getChunkY_base() * 8 + 8; ++var7) {
               this.method4688(var6, var7, var5, var1, var3);
               this.method4640(var6, var7, var5, var1);
            }
         }
      }

      var4 = this.worldMapData1List.iterator();

      while(var4.hasNext()) {
         var5 = (WorldMapData_1)var4.next();

         for(var6 = var5.getChunkX_base() * 8; var6 < var5.getChunkX_base() * 8 + 8; ++var6) {
            for(var7 = var5.getChunkY_base() * 8; var7 < var5.getChunkY_base() * 8 + 8; ++var7) {
               this.method4668(var6, var7, var5, var1, var2);
            }
         }
      }

   }

   @ObfuscatedName("ak")
   @ObfuscatedSignature(
      descriptor = "(IILjm;Lja;[Lup;I)V",
      garbageValue = "1144109783"
   )
   void method4668(int var1, int var2, AbstractWorldMapData var3, WorldMapScaleHandler var4, IndexedSprite[] var5) {
      this.method4711(var1, var2, var3);
      this.method4642(var1, var2, var3, var5);
   }

   @ObfuscatedName("aj")
   @ObfuscatedSignature(
      descriptor = "(IILjm;Lja;Lju;I)V",
      garbageValue = "-102705399"
   )
   void method4688(int var1, int var2, AbstractWorldMapData var3, WorldMapScaleHandler var4, WorldMapSprite var5) {
      int var6 = var3.floorUnderlayIds[0][var1][var2] - 1;
      int var7 = var3.floorOverlayIds[0][var1][var2] - 1;
      if(var6 == -1 && var7 == -1) {
         Rasterizer2D.Rasterizer2D_fillRectangle_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile, this.pixelsPerTile, this.backgroundColor);
      }

      int var8 = 16711935;
      if(var7 != -1) {
         var8 = TriBool.method8281_base(var7, this.backgroundColor);
      }

      if(var7 > -1 && var3.field2560[0][var1][var2] == 0) {
         Rasterizer2D.Rasterizer2D_fillRectangle_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile, this.pixelsPerTile, var8);
      } else {
         int var9 = this.method4641(var1, var2, var3, var5);
         if(var7 == -1) {
            Rasterizer2D.Rasterizer2D_fillRectangle_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile, this.pixelsPerTile, var9);
         } else {
            var4.method5048_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), var9, var8, this.pixelsPerTile, this.pixelsPerTile, var3.field2560[0][var1][var2], var3.field2571[0][var1][var2]);
         }
      }
   }

   @ObfuscatedName("am")
   @ObfuscatedSignature(
      descriptor = "(IILjm;Lja;I)V",
      garbageValue = "-700567043"
   )
   void method4640(int var1, int var2, AbstractWorldMapData var3, WorldMapScaleHandler var4) {
      for(int var5 = 1; var5 < var3.planes; ++var5) {
         int var6 = var3.floorOverlayIds[var5][var1][var2] - 1;
         if(var6 > -1) {
            int var7 = TriBool.method8281_base(var6, this.backgroundColor);
            if(var3.field2560[var5][var1][var2] == 0) {
               Rasterizer2D.Rasterizer2D_fillRectangle_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile, this.pixelsPerTile, var7);
            } else {
               var4.method5048_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), 0, var7, this.pixelsPerTile, this.pixelsPerTile, var3.field2560[var5][var1][var2], var3.field2571[var5][var1][var2]);
            }
         }
      }

   }

   @ObfuscatedName("aq")
   @ObfuscatedSignature(
      descriptor = "(IILjm;Lju;B)I",
      garbageValue = "0"
   )
   int method4641(int var1, int var2, AbstractWorldMapData var3, WorldMapSprite var4) {
      return var3.floorUnderlayIds[0][var1][var2] == 0?this.backgroundColor:var4.getTileColor_base(var1, var2);
   }

   @ObfuscatedName("ai")
   @ObfuscatedSignature(
      descriptor = "(IILjm;[Lup;S)V",
      garbageValue = "168"
   )
   void method4642(int var1, int var2, AbstractWorldMapData var3, IndexedSprite[] var4) {
      for(int var5 = 0; var5 < var3.planes; ++var5) {
         WorldMapDecoration[] var6 = var3.decorations[var5][var1][var2];
         if(var6 != null && var6.length != 0) {
            WorldMapDecoration[] var7 = var6;

            for(int var8 = 0; var8 < var7.length; ++var8) {
               WorldMapDecoration var9 = var7[var8];
               int var11 = var9.decoration;
               boolean var10 = var11 >= WorldMapDecorationType.field3863.id && var11 <= WorldMapDecorationType.field3856.id;
               if(!var10) {
                  int var13 = var9.decoration;
                  boolean var12 = var13 == WorldMapDecorationType.field3844.id;
                  if(!var12) {
                     continue;
                  }
               }

               ObjectComposition var14 = WorldMapSection2.method4515(var9.objectDefinitionId);
               if(var14.mapSceneId != -1) {
                  if(var14.mapSceneId != 46 && var14.mapSceneId != 52) {
                     var4[var14.mapSceneId].method9718_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile * 2, this.pixelsPerTile * 2);
                  } else {
                     var4[var14.mapSceneId].method9718_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile * 2 + 1, this.pixelsPerTile * 2 + 1);
                  }
               }
            }
         }
      }

   }

   @ObfuscatedName("aw")
   @ObfuscatedSignature(
      descriptor = "(IILjm;I)V",
      garbageValue = "-393075620"
   )
   void method4711(int var1, int var2, AbstractWorldMapData var3) {
      for(int var4 = 0; var4 < var3.planes; ++var4) {
         WorldMapDecoration[] var5 = var3.decorations[var4][var1][var2];
         if(var5 != null && var5.length != 0) {
            WorldMapDecoration[] var6 = var5;

            for(int var7 = 0; var7 < var6.length; ++var7) {
               WorldMapDecoration var8 = var6[var7];
               int var10 = var8.decoration;
               boolean var9 = var10 >= WorldMapDecorationType.field3864.id && var10 <= WorldMapDecorationType.field3846.id || var10 == WorldMapDecorationType.field3847.id;
               if(var9) {
                  ObjectComposition var11 = WorldMapSection2.method4515(var8.objectDefinitionId);
                  int var12 = var11.int1 != 0?-3407872:-3355444;
                  if(var8.decoration == WorldMapDecorationType.field3864.id) {
                     this.method4657_base(var1, var2, var8.rotation, var12);
                  }

                  if(var8.decoration == WorldMapDecorationType.field3851.id) {
                     this.method4657_base(var1, var2, var8.rotation, -3355444);
                     this.method4657_base(var1, var2, var8.rotation + 1, var12);
                  }

                  if(var8.decoration == WorldMapDecorationType.field3846.id) {
                     if(var8.rotation == 0) {
                        Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), 1, var12);
                     }

                     if(var8.rotation == 1) {
                        Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(this.pixelsPerTile * var1 + this.pixelsPerTile - 1, this.pixelsPerTile * (63 - var2), 1, var12);
                     }

                     if(var8.rotation == 2) {
                        Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(this.pixelsPerTile + this.pixelsPerTile * var1 - 1, this.pixelsPerTile * (63 - var2) + this.pixelsPerTile - 1, 1, var12);
                     }

                     if(var8.rotation == 3) {
                        Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2) + this.pixelsPerTile - 1, 1, var12);
                     }
                  }

                  if(var8.decoration == WorldMapDecorationType.field3847.id) {
                     int var13 = var8.rotation % 2;
                     int var14;
                     if(var13 == 0) {
                        for(var14 = 0; var14 < this.pixelsPerTile; ++var14) {
                           Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(var14 + this.pixelsPerTile * var1, (64 - var2) * this.pixelsPerTile - 1 - var14, 1, var12);
                        }
                     } else {
                        for(var14 = 0; var14 < this.pixelsPerTile; ++var14) {
                           Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(var14 + this.pixelsPerTile * var1, var14 + this.pixelsPerTile * (63 - var2), 1, var12);
                        }
                     }
                  }
               }
            }
         }
      }

   }

   @ObfuscatedName("ae")
   @ObfuscatedSignature(
      descriptor = "(IILjava/util/HashSet;IS)V",
      garbageValue = "3124"
   )
   void drawNonLinkMapIcons_base(int var1, int var2, HashSet var3, int var4) {
      float var5 = (float)var4 / 64.0F;
      float var6 = var5 / 2.0F;
      Iterator var7 = this.iconMap.entrySet().iterator();

      while(var7.hasNext()) {
         Entry var8 = (Entry)var7.next();
         Coord var9 = (Coord)var8.getKey();
         int var10 = (int)((float)var9.x * var5 + (float)var1 - var6);
         int var11 = (int)((float)(var2 + var4) - var5 * (float)var9.y - var6);
         AbstractWorldMapIcon var12 = (AbstractWorldMapIcon)var8.getValue();
         if(var12 != null && var12.hasValidElement_base()) {
            var12.screenX = var10;
            var12.screenY = var11;
            WorldMapElement var13 = class141.method3209(var12.getElement_base());
            if(!var3.contains(Integer.valueOf(var13.getObjectId_base()))) {
               this.method4647(var12, var10, var11, var5);
            }
         }
      }

   }

   @ObfuscatedName("an")
   @ObfuscatedSignature(
      descriptor = "(Ljava/util/HashSet;IIB)V",
      garbageValue = "-44"
   )
   void method4645_base(HashSet var1, int var2, int var3) {
      Iterator var4 = this.icon0List.iterator();

      while(var4.hasNext()) {
         AbstractWorldMapIcon var5 = (AbstractWorldMapIcon)var4.next();
         if(var5.hasValidElement_base()) {
            WorldMapElement var6 = class141.method3209(var5.getElement_base());
            if(var6 != null && var1.contains(Integer.valueOf(var6.getObjectId_base()))) {
               this.method4646(var6, var5.screenX, var5.screenY, var2, var3);
            }
         }
      }

   }

   @ObfuscatedName("ag")
   @ObfuscatedSignature(
      descriptor = "(Lgr;IIIII)V",
      garbageValue = "1904364897"
   )
   void method4646(WorldMapElement var1, int var2, int var3, int var4, int var5) {
      SpritePixels var6 = var1.method3564(false);
      if(var6 != null) {
         var6.drawTransBgAt_base(var2 - var6.subWidth / 2, var3 - var6.subHeight / 2);
         if(var4 % var5 < var5 / 2) {
            Rasterizer2D.Rasterizer2D_drawCircleAlpha_base(var2, var3, 15, 16776960, 128);
            Rasterizer2D.Rasterizer2D_drawCircleAlpha_base(var2, var3, 7, 16777215, 256);
         }

      }
   }

   @ObfuscatedName("ad")
   @ObfuscatedSignature(
      descriptor = "(Ljc;IIFI)V",
      garbageValue = "1545285255"
   )
   void method4647(AbstractWorldMapIcon var1, int var2, int var3, float var4) {
      WorldMapElement var5 = class141.method3209(var1.getElement_base());
      this.method4648(var5, var2, var3);
      this.method4649(var1, var5, var2, var3, var4);
   }

   @ObfuscatedName("af")
   @ObfuscatedSignature(
      descriptor = "(Lgr;III)V",
      garbageValue = "-980453833"
   )
   void method4648(WorldMapElement var1, int var2, int var3) {
      SpritePixels var4 = var1.method3564(false);
      if(var4 != null) {
         int var5 = this.method4651(var4, var1.horizontalAlignment);
         int var6 = this.method4652(var4, var1.verticalAlignment);
         var4.drawTransBgAt_base(var5 + var2, var3 + var6);
      }

   }

   @ObfuscatedName("be")
   @ObfuscatedSignature(
      descriptor = "(Ljc;Lgr;IIFI)V",
      garbageValue = "1339330901"
   )
   void method4649(AbstractWorldMapIcon var1, WorldMapElement var2, int var3, int var4, float var5) {
      WorldMapLabel var6 = var1.vmethod4977();
      if(var6 != null) {
         if(var6.size.method4486_base(var5)) {
            Font var7 = (Font)this.fonts.get(var6.size);
            var7.drawLines_base(var6.text, var3 - var6.width / 2, var4, var6.width, var6.height, -16777216 | var2.field1830, 0, 1, 0, var7.ascent / 2);
         }
      }
   }

   @ObfuscatedName("bd")
   @ObfuscatedSignature(
      descriptor = "(IILjava/util/HashSet;IB)V",
      garbageValue = "57"
   )
   void drawMapLinks_base(int var1, int var2, HashSet var3, int var4) {
      float var5 = (float)var4 / 64.0F;
      Iterator var6 = this.icon0List.iterator();

      while(var6.hasNext()) {
         AbstractWorldMapIcon var7 = (AbstractWorldMapIcon)var6.next();
         if(var7.hasValidElement_base()) {
            int var8 = var7.coord2.x % 64;
            int var9 = var7.coord2.y % 64;
            var7.screenX = (int)((float)var8 * var5 + (float)var1);
            var7.screenY = (int)((float)var2 + var5 * (float)(63 - var9));
            if(!var3.contains(Integer.valueOf(var7.getElement_base()))) {
               this.method4647(var7, var7.screenX, var7.screenY, var5);
            }
         }
      }

   }

   @ObfuscatedName("bl")
   @ObfuscatedSignature(
      descriptor = "(Luz;Lhq;I)I",
      garbageValue = "1376501823"
   )
   int method4651(SpritePixels var1, HorizontalAlignment var2) {
      switch(var2.value) {
      case 0:
         return 0;
      case 2:
         return -var1.subWidth / 2;
      default:
         return -var1.subWidth;
      }
   }

   @ObfuscatedName("bi")
   @ObfuscatedSignature(
      descriptor = "(Luz;Lhg;I)I",
      garbageValue = "1990886316"
   )
   int method4652(SpritePixels var1, VerticalAlignment var2) {
      switch(var2.value) {
      case 0:
         return -var1.subHeight / 2;
      case 2:
         return 0;
      default:
         return -var1.subHeight;
      }
   }

   @ObfuscatedName("bf")
   @ObfuscatedSignature(
      descriptor = "(IB)Ljk;",
      garbageValue = "1"
   )
   WorldMapLabel method4653(int var1) {
      WorldMapElement var2 = class141.method3209(var1);
      return this.method4638(var2);
   }

   @ObfuscatedName("bg")
   @ObfuscatedSignature(
      descriptor = "(Lgr;I)Ljk;",
      garbageValue = "1614567762"
   )
   WorldMapLabel method4638(WorldMapElement var1) {
      if(var1.name != null && this.fonts != null && this.fonts.get(WorldMapLabelSize.WorldMapLabelSize_small) != null) {
         WorldMapLabelSize var2 = WorldMapLabelSize.method4487(var1.textSize);
         if(var2 == null) {
            return null;
         } else {
            Font var3 = (Font)this.fonts.get(var2);
            if(var3 == null) {
               return null;
            } else {
               int var4 = var3.lineCount_base(var1.name, 1000000);
               String[] var5 = new String[var4];
               var3.breakLines_base(var1.name, (int[])null, var5);
               int var6 = var5.length * var3.ascent / 2;
               int var7 = 0;
               String[] var8 = var5;

               for(int var9 = 0; var9 < var8.length; ++var9) {
                  String var10 = var8[var9];
                  int var11 = var3.stringWidth_base(var10);
                  if(var11 > var7) {
                     var7 = var11;
                  }
               }

               return new WorldMapLabel(var1.name, var7, var6, var2);
            }
         }
      } else {
         return null;
      }
   }

   @ObfuscatedName("ba")
   @ObfuscatedSignature(
      descriptor = "(IIIIIB)Ljava/util/List;",
      garbageValue = "102"
   )
   List method4699_base(int var1, int var2, int var3, int var4, int var5) {
      LinkedList var6 = new LinkedList();
      if(var4 >= var1 && var5 >= var2) {
         if(var4 < var3 + var1 && var5 < var3 + var2) {
            Iterator var7 = this.iconMap.values().iterator();

            AbstractWorldMapIcon var8;
            while(var7.hasNext()) {
               var8 = (AbstractWorldMapIcon)var7.next();
               if(var8.hasValidElement_base() && var8.fitsScreen_base(var4, var5)) {
                  var6.add(var8);
               }
            }

            var7 = this.icon0List.iterator();

            while(var7.hasNext()) {
               var8 = (AbstractWorldMapIcon)var7.next();
               if(var8.hasValidElement_base() && var8.fitsScreen_base(var4, var5)) {
                  var6.add(var8);
               }
            }

            return var6;
         } else {
            return var6;
         }
      } else {
         return var6;
      }
   }

   @ObfuscatedName("bm")
   @ObfuscatedSignature(
      descriptor = "(I)Ljava/util/List;",
      garbageValue = "201703863"
   )
   List icons_base() {
      LinkedList var1 = new LinkedList();
      var1.addAll(this.icon0List);
      var1.addAll(this.iconMap.values());
      return var1;
   }

   @ObfuscatedName("bp")
   @ObfuscatedSignature(
      descriptor = "(IIIII)V",
      garbageValue = "-164238097"
   )
   void method4657_base(int var1, int var2, int var3, int var4) {
      var3 %= 4;
      if(var3 == 0) {
         Rasterizer2D.Rasterizer2D_drawVerticalLine_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile, var4);
      }

      if(var3 == 1) {
         Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile, var4);
      }

      if(var3 == 2) {
         Rasterizer2D.Rasterizer2D_drawVerticalLine_base(this.pixelsPerTile + this.pixelsPerTile * var1 - 1, this.pixelsPerTile * (63 - var2), this.pixelsPerTile, var4);
      }

      if(var3 == 3) {
         Rasterizer2D.Rasterizer2D_drawHorizontalLine_base(this.pixelsPerTile * var1, this.pixelsPerTile * (63 - var2) + this.pixelsPerTile - 1, this.pixelsPerTile, var4);
      }

   }

   public List icons() {
      return this.icons_base();
   }

   public Collection getMapIcons() {
      return this.icons();
   }
}
