package mapped;

import java.util.HashSet;
import java.util.Set;
import net.runelite.api.DecorativeObject;
import net.runelite.api.GroundObject;
import net.runelite.api.Perspective;
import net.runelite.api.WallObject;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.hooks.DrawCallbacks;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSGameObject;
import net.runelite.rs.api.RSNode;
import net.runelite.rs.api.RSNodeDeque;
import net.runelite.rs.api.RSPlayer;
import net.runelite.rs.api.RSRenderable;
import net.runelite.rs.api.RSRuneLiteObject;
import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSSceneTileModel;
import net.runelite.rs.api.RSTile;
import net.runelite.rs.api.RSTileItem;

@ObfuscatedName("kf")
public class Scene implements RSScene {
   @ObfuscatedName("at")
   public static boolean Scene_isLowDetail;
   @ObfuscatedName("ay")
   static int tileUpdateCount;
   @ObfuscatedName("ak")
   static int Scene_plane;
   @ObfuscatedName("aj")
   static int Scene_drawnCount;
   @ObfuscatedName("am")
   static int Scene_cameraXTileMin;
   @ObfuscatedName("aq")
   static int Scene_cameraXTileMax;
   @ObfuscatedName("ai")
   static int Scene_cameraYTileMin;
   @ObfuscatedName("aw")
   static int Scene_cameraYTileMax;
   @ObfuscatedName("ae")
   static int Scene_cameraXTile;
   @ObfuscatedName("an")
   static int Scene_cameraYTile;
   @ObfuscatedName("ag")
   static int Scene_cameraX;
   @ObfuscatedName("ad")
   static int Scene_cameraY;
   @ObfuscatedName("af")
   static int Scene_cameraZ;
   @ObfuscatedName("be")
   static int Scene_cameraPitchSine;
   @ObfuscatedName("bd")
   static int Scene_cameraPitchCosine;
   @ObfuscatedName("bl")
   static int Scene_cameraYawSine;
   @ObfuscatedName("bi")
   static int Scene_cameraYawCosine;
   @ObfuscatedName("bv")
   @ObfuscatedSignature(
      descriptor = "[Lle;"
   )
   static GameObject[] gameObjects;
   @ObfuscatedName("bf")
   static boolean checkClick;
   @ObfuscatedName("bg")
   static int Scene_selectedPlane;
   @ObfuscatedName("ba")
   static int Scene_selectedScreenX;
   @ObfuscatedName("bm")
   static int Scene_selectedScreenY;
   @ObfuscatedName("bp")
   public static int Scene_selectedX;
   @ObfuscatedName("bw")
   public static int Scene_selectedY;
   @ObfuscatedName("bj")
   static boolean viewportWalking;
   @ObfuscatedName("bt")
   static int Scene_planesCount;
   @ObfuscatedName("bu")
   static int[] Scene_planeOccluderCounts;
   @ObfuscatedName("by")
   @ObfuscatedSignature(
      descriptor = "[[Lkw;"
   )
   static Occluder[][] Scene_planeOccluders;
   @ObfuscatedName("bh")
   static int Scene_currentOccludersCount;
   @ObfuscatedName("bz")
   @ObfuscatedSignature(
      descriptor = "[Lkw;"
   )
   static Occluder[] Scene_currentOccluders;
   @ObfuscatedName("bc")
   @ObfuscatedSignature(
      descriptor = "Lon;"
   )
   static NodeDeque Scene_tilesDeque;
   @ObfuscatedName("bs")
   static final int[] field2830;
   @ObfuscatedName("bx")
   static final int[] field2846;
   @ObfuscatedName("bb")
   static final int[] field2847;
   @ObfuscatedName("bk")
   static final int[] field2848;
   @ObfuscatedName("br")
   static final int[] field2849;
   @ObfuscatedName("bq")
   static final int[] field2835;
   @ObfuscatedName("cf")
   static final int[] field2851;
   @ObfuscatedName("ct")
   static boolean[][][][] visibilityMap;
   @ObfuscatedName("cw")
   static boolean[][] visibleTiles;
   @ObfuscatedName("cq")
   static int Scene_viewportXCenter;
   @ObfuscatedName("cl")
   static int Scene_viewportYCenter;
   @ObfuscatedName("cs")
   static int Scene_viewportXMin;
   @ObfuscatedName("co")
   static int Scene_viewportYMin;
   @ObfuscatedName("cm")
   static int Scene_viewportXMax;
   @ObfuscatedName("cn")
   static int Scene_viewportYMax;
   public static short[][][] rl$underlayIds;
   public static short[][][] rl$overlayIds;
   public static byte[][][] rl$tileShapes;
   public static int rl$drawDistance;
   public static int[] tmpX;
   public static int rl$roofRemovalMode;
   public static int[][][] rl$tiles;
   public static int[] tmpY;
   public static int rl$hoverX;
   public static int rl$hoverY;
   public static final Set rl$tilesToRemove;
   @ObfuscatedName("ah")
   int planes;
   @ObfuscatedName("ar")
   int xSize;
   @ObfuscatedName("ao")
   int ySize;
   @ObfuscatedName("ab")
   int[][][] tileHeights;
   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "[[[Lkv;"
   )
   Tile[][][] tiles;
   @ObfuscatedName("aa")
   int minPlane;
   @ObfuscatedName("ac")
   int tempGameObjectsCount;
   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "[Lle;"
   )
   GameObject[] tempGameObjects;
   @ObfuscatedName("az")
   int[][][] field2799;
   @ObfuscatedName("ce")
   int[][] tileShape2D;
   @ObfuscatedName("ci")
   int[][] tileRotation2D;
   public RSTile[][][] rl$extendedTiles;
   public byte[][][] rl$extendedTileSettings;

   static {
      Scene_isLowDetail = true;
      tileUpdateCount = 0;
      Scene_plane = 0;
      gameObjects = new GameObject[100];
      checkClick = false;
      Scene_selectedPlane = 0;
      Scene_selectedScreenX = 0;
      Scene_selectedScreenY = 0;
      Scene_selectedX = -1;
      Scene_selectedY = -1;
      viewportWalking = false;
      Scene_planesCount = 4;
      Scene_planeOccluderCounts = new int[Scene_planesCount];
      Scene_planeOccluders = new Occluder[Scene_planesCount][500];
      Scene_currentOccludersCount = 0;
      Scene_currentOccluders = new Occluder[500];
      Scene_tilesDeque = new NodeDeque();
      field2830 = new int[]{19, 55, 38, 155, 255, 110, 137, 205, 76};
      field2846 = new int[]{160, 192, 80, 96, 0, 144, 80, 48, 160};
      field2847 = new int[]{76, 8, 137, 4, 0, 1, 38, 2, 19};
      field2848 = new int[]{0, 0, 2, 0, 0, 2, 1, 1, 0};
      field2849 = new int[]{2, 0, 0, 2, 0, 0, 0, 4, 4};
      field2835 = new int[]{0, 4, 4, 8, 0, 0, 8, 0, 0};
      field2851 = new int[]{1, 1, 0, 0, 0, 8, 0, 0, 8};
      visibilityMap = new boolean[8][32][51][51];
      tmpX = new int[6];
      tmpY = new int[6];
      rl$roofRemovalMode = 0;
      rl$tiles = new int[4][104][104];
      rl$tilesToRemove = new HashSet();
      rl$hoverX = -1;
      rl$hoverY = -1;
   }

   public Scene(int var1, int var2, int var3, int[][][] var4) {
      this.minPlane = 0;
      this.tempGameObjectsCount = 0;
      this.tempGameObjects = new GameObject[5000];
      this.tileShape2D = new int[][]{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}};
      this.tileRotation2D = new int[][]{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}};
      this.planes = var1;
      this.xSize = var2;
      this.ySize = var3;
      this.tiles = new Tile[var1][var2][var3];
      this.field2799 = new int[var1][var2 + 1][var3 + 1];
      this.tileHeights = var4;
      this.clear_base();
   }

   @ObfuscatedName("at")
   public void clear_base() {
      int var1;
      int var2;
      for(var1 = 0; var1 < this.planes; ++var1) {
         for(var2 = 0; var2 < this.xSize; ++var2) {
            for(int var3 = 0; var3 < this.ySize; ++var3) {
               this.tiles[var1][var2][var3] = null;
            }
         }
      }

      for(var1 = 0; var1 < Scene_planesCount; ++var1) {
         for(var2 = 0; var2 < Scene_planeOccluderCounts[var1]; ++var2) {
            Scene_planeOccluders[var1][var2] = null;
         }

         Scene_planeOccluderCounts[var1] = 0;
      }

      for(var1 = 0; var1 < this.tempGameObjectsCount; ++var1) {
         this.tempGameObjects[var1] = null;
      }

      this.tempGameObjectsCount = 0;

      for(var1 = 0; var1 < gameObjects.length; ++var1) {
         gameObjects[var1] = null;
      }

   }

   @ObfuscatedName("ah")
   public void init_base(int var1) {
      this.init(var1);
      this.minPlane = var1;

      for(int var2 = 0; var2 < this.xSize; ++var2) {
         for(int var3 = 0; var3 < this.ySize; ++var3) {
            if(this.tiles[var1][var2][var3] == null) {
               this.tiles[var1][var2][var3] = new Tile(var1, var2, var3);
            }
         }
      }

      this.initEnd(var1);
   }

   @ObfuscatedName("ar")
   public void setLinkBelow_base(int var1, int var2) {
      Tile var3 = this.tiles[0][var1][var2];

      for(int var4 = 0; var4 < 3; ++var4) {
         Tile var5 = this.tiles[var4][var1][var2] = this.tiles[var4 + 1][var1][var2];
         if(var5 != null) {
            --var5.plane;

            for(int var6 = 0; var6 < var5.gameObjectsCount; ++var6) {
               GameObject var7 = var5.gameObjects[var6];
               long var9 = var7.tag;
               boolean var8 = class158.method3413_base(var9) == 2;
               if(var8 && var7.startX == var1 && var2 == var7.startY) {
                  --var7.plane;
               }
            }
         }
      }

      if(this.tiles[0][var1][var2] == null) {
         this.tiles[0][var1][var2] = new Tile(0, var1, var2);
      }

      this.tiles[0][var1][var2].linkedBelowTile = var3;
      this.tiles[3][var1][var2] = null;
   }

   @ObfuscatedName("ab")
   public void setTileMinPlane_base(int var1, int var2, int var3, int var4) {
      Tile var5 = this.tiles[var1][var2][var3];
      if(var5 != null) {
         this.tiles[var1][var2][var3].minPlane = var4;
      }
   }

   @ObfuscatedName("au")
   public void addTile_base(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9, int var10, int var11, int var12, int var13, int var14, int var15, int var16, int var17, int var18, int var19, int var20) {
      SceneTilePaint var21;
      int var22;
      if(var4 == 0) {
         var21 = new SceneTilePaint(var11, var12, var13, var14, -1, var19, false);

         for(var22 = var1; var22 >= 0; --var22) {
            if(this.tiles[var22][var2][var3] == null) {
               this.tiles[var22][var2][var3] = new Tile(var22, var2, var3);
            }
         }

         this.tiles[var1][var2][var3].paint = var21;
         this.rl$addTile(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18, var19, var20);
      } else if(var4 != 1) {
         SceneTileModel var23 = new SceneTileModel(var4, var5, var6, var2, var3, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18, var19, var20);

         for(var22 = var1; var22 >= 0; --var22) {
            if(this.tiles[var22][var2][var3] == null) {
               this.tiles[var22][var2][var3] = new Tile(var22, var2, var3);
            }
         }

         this.tiles[var1][var2][var3].model = var23;
         this.rl$addTile(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18, var19, var20);
      } else {
         var21 = new SceneTilePaint(var15, var16, var17, var18, var6, var20, var8 == var7 && var7 == var9 && var10 == var7);

         for(var22 = var1; var22 >= 0; --var22) {
            if(this.tiles[var22][var2][var3] == null) {
               this.tiles[var22][var2][var3] = new Tile(var22, var2, var3);
            }
         }

         this.tiles[var1][var2][var3].paint = var21;
         this.rl$addTile(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18, var19, var20);
      }
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(IIIILkt;JI)V"
   )
   public void method5330(int var1, int var2, int var3, int var4, Renderable var5, long var6, int var8) {
      if(var5 != null) {
         FloorDecoration var9 = new FloorDecoration();
         var9.renderable = var5;
         var9.x = var2 * 128 + 64;
         var9.y = var3 * 128 + 64;
         var9.z = var4;
         var9.tag = var6;
         var9.flags = var8;
         if(this.tiles[var1][var2][var3] == null) {
            this.tiles[var1][var2][var3] = new Tile(var1, var2, var3);
         }

         this.tiles[var1][var2][var3].floorDecoration = var9;
         this.tiles[var1][var2][var3].groundObjectChanged(-1);
      }
   }

   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "(IIIILkt;JLkt;Lkt;)V"
   )
   public void method5331(int var1, int var2, int var3, int var4, Renderable var5, long var6, Renderable var8, Renderable var9) {
      ItemLayer var10 = new ItemLayer();
      var10.first = var5;
      var10.x = var2 * 128 + 64;
      var10.y = var3 * -557692800 + -278846400;
      var10.z = var4;
      var10.tag = var6;
      var10.second = var8;
      var10.third = var9;
      int var11 = 0;
      Tile var12 = this.tiles[var1][var2][var3];
      if(var12 != null) {
         for(int var13 = 0; var13 < var12.gameObjectsCount; ++var13) {
            if((var12.gameObjects[var13].flags & 256) == 256 && var12.gameObjects[var13].renderable instanceof Model) {
               Model var14 = (Model)var12.gameObjects[var13].renderable;
               var14.calculateBoundsCylinder_base();
               if(var14.height > var11) {
                  var11 = var14.height;
               }
            }
         }
      }

      var10.height = var11;
      if(this.tiles[var1][var2][var3] == null) {
         this.tiles[var1][var2][var3] = new Tile(var1, var2, var3);
      }

      this.tiles[var1][var2][var3].itemLayer = var10;
      this.tiles[var1][var2][var3].itemLayerChanged(-1);
   }

   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "(IIIILkt;Lkt;IIJI)V"
   )
   public void method5332(int var1, int var2, int var3, int var4, Renderable var5, Renderable var6, int var7, int var8, long var9, int var11) {
      if(var5 != null || var6 != null) {
         BoundaryObject var12 = new BoundaryObject();
         var12.tag = var9;
         var12.flags = var11;
         var12.x = var2 * 128 + 64;
         var12.y = var3 * 128 + 64;
         var12.z = var4;
         var12.renderable1 = var5;
         var12.renderable2 = var6;
         var12.orientationA = var7;
         var12.orientationB = var8;

         for(int var13 = var1; var13 >= 0; --var13) {
            if(this.tiles[var13][var2][var3] == null) {
               this.tiles[var13][var2][var3] = new Tile(var13, var2, var3);
            }
         }

         this.tiles[var1][var2][var3].boundaryObject = var12;
         this.tiles[var1][var2][var3].wallObjectChanged(-1);
      }
   }

   @ObfuscatedName("az")
   @ObfuscatedSignature(
      descriptor = "(IIIILkt;Lkt;IIIIJI)V"
   )
   public void method5333(int var1, int var2, int var3, int var4, Renderable var5, Renderable var6, int var7, int var8, int var9, int var10, long var11, int var13) {
      if(var5 != null) {
         WallDecoration var14 = new WallDecoration();
         var14.tag = var11;
         var14.flags = var13;
         var14.x = var2 * 128 + 64;
         var14.y = var3 * 128 + 64;
         var14.z = var4;
         var14.renderable1 = var5;
         var14.renderable2 = var6;
         var14.orientation = var7;
         var14.orientation2 = var8;
         var14.xOffset = var9;
         var14.yOffset = var10;

         for(int var15 = var1; var15 >= 0; --var15) {
            if(this.tiles[var15][var2][var3] == null) {
               this.tiles[var15][var2][var3] = new Tile(var15, var2, var3);
            }
         }

         this.tiles[var1][var2][var3].wallDecoration = var14;
         this.tiles[var1][var2][var3].decorativeObjectChanged(-1);
      }
   }

   @ObfuscatedName("ap")
   @ObfuscatedSignature(
      descriptor = "(IIIIIILkt;IJI)Z"
   )
   public boolean method5334(int var1, int var2, int var3, int var4, int var5, int var6, Renderable var7, int var8, long var9, int var11) {
      if(var7 == null) {
         return true;
      } else {
         int var12 = var5 * 64 + var2 * 128;
         int var13 = var6 * 64 + var3 * 128;
         return this.method5435(var1, var2, var3, var5, var6, var12, var13, var4, var7, var8, false, var9, var11);
      }
   }

   @ObfuscatedName("av")
   @ObfuscatedSignature(
      descriptor = "(IIIIILkt;IJZ)Z"
   )
   public boolean method5444(int var1, int var2, int var3, int var4, int var5, Renderable var6, int var7, long var8, boolean var10) {
      if(var6 == null) {
         return true;
      } else {
         if(var6 instanceof RSRuneLiteObject) {
            RSRuneLiteObject var11 = (RSRuneLiteObject)var6;
            var5 = var11.getRadius();
            var7 = var11.getOrientation();
            var10 = var11.drawFrontTilesFirst();
         }

         int var15 = var2 - var5;
         int var12 = var3 - var5;
         int var13 = var5 + var2;
         int var14 = var3 + var5;
         if(var10) {
            if(var7 > 640 && var7 < 1408) {
               var14 += 128;
            }

            if(var7 > 1152 && var7 < 1920) {
               var13 += 128;
            }

            if(var7 > 1664 || var7 < 384) {
               var12 -= 128;
            }

            if(var7 > 128 && var7 < 896) {
               var15 -= 128;
            }
         }

         var15 /= 128;
         var12 /= 128;
         var13 /= 128;
         var14 /= 128;
         return this.newGameObject(var1, var15, var12, var13 - var15 + 1, var14 - var12 + 1, var2, var3, var4, (RSRenderable)var6, var7, true, var8, 0);
      }
   }

   @ObfuscatedName("ax")
   @ObfuscatedSignature(
      descriptor = "(IIIIILkt;IJIIII)Z"
   )
   public boolean method5373(int var1, int var2, int var3, int var4, int var5, Renderable var6, int var7, long var8, int var10, int var11, int var12, int var13) {
      return var6 == null?true:this.method5435(var1, var10, var11, var12 - var10 + 1, var13 - var11 + 1, var2, var3, var4, var6, var7, true, var8, 0);
   }

   @ObfuscatedName("as")
   @ObfuscatedSignature(
      descriptor = "(IIIIIIIILkt;IZJI)Z"
   )
   boolean method5435(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, Renderable var9, int var10, boolean var11, long var12, int var14) {
      boolean var15 = SpriteMask.client.getCallbacks().draw(var9, false);
      if(!var15) {
         int var16 = var6 >> 7;
         int var17 = var7 >> 7;
         SpriteMask.client.getOccupiedTilesTick()[var16][var17] = -1;
      }

      return var15 && this.copy$newGameObject(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var14);
   }

   @ObfuscatedName("ay")
   public void clearTempGameObjects_base() {
      for(int var1 = 0; var1 < this.tempGameObjectsCount; ++var1) {
         GameObject var2 = this.tempGameObjects[var1];
         this.method5400(var2);
         this.tempGameObjects[var1] = null;
      }

      this.tempGameObjectsCount = 0;
   }

   @ObfuscatedName("ak")
   @ObfuscatedSignature(
      descriptor = "(Lle;)V"
   )
   void method5400(GameObject var1) {
      for(int var2 = var1.startX; var2 <= var1.endX; ++var2) {
         for(int var3 = var1.startY; var3 <= var1.endY; ++var3) {
            Tile var4 = this.tiles[var1.plane][var2][var3];
            if(var4 != null) {
               int var5;
               for(var5 = 0; var5 < var4.gameObjectsCount; ++var5) {
                  if(var4.gameObjects[var5] == var1) {
                     --var4.gameObjectsCount;

                     for(int var6 = var5; var6 < var4.gameObjectsCount; ++var6) {
                        var4.gameObjects[var6] = var4.gameObjects[var6 + 1];
                        var4.gameObjectsChanged(var6);
                        var4.gameObjectEdgeMasks[var6] = var4.gameObjectEdgeMasks[var6 + 1];
                     }

                     var4.gameObjects[var4.gameObjectsCount] = null;
                     var4.gameObjectsChanged(var4.gameObjectsCount);
                     break;
                  }
               }

               var4.gameObjectsEdgeMask = 0;

               for(var5 = 0; var5 < var4.gameObjectsCount; ++var5) {
                  var4.gameObjectsEdgeMask |= var4.gameObjectEdgeMasks[var5];
               }
            }
         }
      }

   }

   @ObfuscatedName("aj")
   public void method5340_base(int var1, int var2, int var3, int var4) {
      Tile var5 = this.tiles[var1][var2][var3];
      if(var5 != null) {
         WallDecoration var6 = var5.wallDecoration;
         if(var6 != null) {
            var6.xOffset = var4 * var6.xOffset / 16;
            var6.yOffset = var4 * var6.yOffset / 16;
         }
      }
   }

   @ObfuscatedName("am")
   public void removeBoundaryObject_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      if(var4 != null) {
         var4.boundaryObject = null;
         var4.wallObjectChanged(-1);
      }
   }

   @ObfuscatedName("aq")
   public void removeWallDecoration_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      if(var4 != null) {
         var4.wallDecoration = null;
         var4.decorativeObjectChanged(-1);
      }
   }

   @ObfuscatedName("ai")
   public void removeGameObject_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      if(var4 != null) {
         for(int var5 = 0; var5 < var4.gameObjectsCount; ++var5) {
            GameObject var6 = var4.gameObjects[var5];
            long var8 = var6.tag;
            boolean var7 = class158.method3413_base(var8) == 2;
            if(var7 && var2 == var6.startX && var3 == var6.startY) {
               this.method5400(var6);
               return;
            }
         }

      }
   }

   @ObfuscatedName("aw")
   public void removeFloorDecoration_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      if(var4 != null) {
         var4.floorDecoration = null;
         var4.groundObjectChanged(-1);
      }
   }

   @ObfuscatedName("ae")
   public void removeGroundItemPile_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      if(var4 != null) {
         var4.itemLayer = null;
         var4.itemLayerChanged(-1);
      }
   }

   @ObfuscatedName("an")
   @ObfuscatedSignature(
      descriptor = "(III)Llv;"
   )
   public BoundaryObject method5346(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      return var4 == null?null:var4.boundaryObject;
   }

   @ObfuscatedName("ag")
   @ObfuscatedSignature(
      descriptor = "(III)Llj;"
   )
   public WallDecoration method5347(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      return var4 == null?null:var4.wallDecoration;
   }

   @ObfuscatedName("ad")
   @ObfuscatedSignature(
      descriptor = "(III)Lle;"
   )
   public GameObject method5348(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      if(var4 == null) {
         return null;
      } else {
         for(int var5 = 0; var5 < var4.gameObjectsCount; ++var5) {
            GameObject var6 = var4.gameObjects[var5];
            long var8 = var6.tag;
            boolean var7 = class158.method3413_base(var8) == 2;
            if(var7 && var2 == var6.startX && var3 == var6.startY) {
               return var6;
            }
         }

         return null;
      }
   }

   @ObfuscatedName("af")
   @ObfuscatedSignature(
      descriptor = "(III)Lkm;"
   )
   public FloorDecoration method5458(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      return var4 != null && var4.floorDecoration != null?var4.floorDecoration:null;
   }

   @ObfuscatedName("be")
   public long getBoundaryObjectTag_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      return var4 != null && var4.boundaryObject != null?var4.boundaryObject.tag:0L;
   }

   @ObfuscatedName("bd")
   public long getWallDecorationTag_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      return var4 != null && var4.wallDecoration != null?var4.wallDecoration.tag:0L;
   }

   @ObfuscatedName("bl")
   public long getGameObjectTag_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      if(var4 == null) {
         return 0L;
      } else {
         for(int var5 = 0; var5 < var4.gameObjectsCount; ++var5) {
            GameObject var6 = var4.gameObjects[var5];
            long var8 = var6.tag;
            boolean var7 = class158.method3413_base(var8) == 2;
            if(var7 && var2 == var6.startX && var3 == var6.startY) {
               return var6.tag;
            }
         }

         return 0L;
      }
   }

   @ObfuscatedName("bi")
   public long getFloorDecorationTag_base(int var1, int var2, int var3) {
      Tile var4 = this.tiles[var1][var2][var3];
      return var4 != null && var4.floorDecoration != null?var4.floorDecoration.tag:0L;
   }

   @ObfuscatedName("bv")
   public int getObjectFlags_base(int var1, int var2, int var3, long var4) {
      Tile var6 = this.tiles[var1][var2][var3];
      if(var6 == null) {
         return -1;
      } else if(var6.boundaryObject != null && var6.boundaryObject.tag == var4) {
         return var6.boundaryObject.flags & 255;
      } else if(var6.wallDecoration != null && var6.wallDecoration.tag == var4) {
         return var6.wallDecoration.flags & 255;
      } else if(var6.floorDecoration != null && var6.floorDecoration.tag == var4) {
         return var6.floorDecoration.flags & 255;
      } else {
         for(int var7 = 0; var7 < var6.gameObjectsCount; ++var7) {
            if(var6.gameObjects[var7].tag == var4) {
               return var6.gameObjects[var7].flags & 255;
            }
         }

         return -1;
      }
   }

   @ObfuscatedName("bf")
   public void method5329_base(int var1, int var2, int var3) {
      for(int var4 = 0; var4 < this.planes; ++var4) {
         for(int var5 = 0; var5 < this.xSize; ++var5) {
            for(int var6 = 0; var6 < this.ySize; ++var6) {
               Tile var7 = this.tiles[var4][var5][var6];
               if(var7 != null) {
                  BoundaryObject var8 = var7.boundaryObject;
                  ModelData var10;
                  if(var8 != null && var8.renderable1 instanceof ModelData) {
                     ModelData var9 = (ModelData)var8.renderable1;
                     this.method5462(var9, var4, var5, var6, 1, 1);
                     if(var8.renderable2 instanceof ModelData) {
                        var10 = (ModelData)var8.renderable2;
                        this.method5462(var10, var4, var5, var6, 1, 1);
                        ModelData.method5121(var9, var10, 0, 0, 0, false);
                        var8.renderable2 = var10.method5122(var10.ambient, var10.contrast, var1, var2, var3);
                     }

                     var8.renderable1 = var9.method5122(var9.ambient, var9.contrast, var1, var2, var3);
                  }

                  for(int var12 = 0; var12 < var7.gameObjectsCount; ++var12) {
                     GameObject var14 = var7.gameObjects[var12];
                     if(var14 != null && var14.renderable instanceof ModelData) {
                        ModelData var11 = (ModelData)var14.renderable;
                        this.method5462(var11, var4, var5, var6, var14.endX - var14.startX + 1, var14.endY - var14.startY + 1);
                        var14.renderable = var11.method5122(var11.ambient, var11.contrast, var1, var2, var3);
                     }
                  }

                  FloorDecoration var13 = var7.floorDecoration;
                  if(var13 != null && var13.renderable instanceof ModelData) {
                     var10 = (ModelData)var13.renderable;
                     this.method5355(var10, var4, var5, var6);
                     var13.renderable = var10.method5122(var10.ambient, var10.contrast, var1, var2, var3);
                  }
               }
            }
         }
      }

   }

   @ObfuscatedName("bg")
   @ObfuscatedSignature(
      descriptor = "(Lkq;III)V"
   )
   void method5355(ModelData var1, int var2, int var3, int var4) {
      int var6 = var3 + 1;
      int var7 = var4 - 1;
      int var8 = var4 + 1;

      for(int var9 = var3; var9 <= var6; ++var9) {
         if(var9 >= 0 && var9 < this.xSize) {
            for(int var10 = var7; var10 <= var8; ++var10) {
               if(var10 >= 0 && var10 < this.ySize && (var9 >= var6 || var10 >= var8)) {
                  Tile var11 = this.tiles[var2][var9][var10];
                  if(var11 != null && var11.floorDecoration != null && var11.floorDecoration.renderable instanceof ModelData) {
                     int var12 = this.method5357_base(var2, var9, var10, var2, var3, var4);
                     ModelData var13 = (ModelData)var11.floorDecoration.renderable;
                     ModelData.method5121(var1, var13, (var9 - var3) * 128, var12, (var10 - var4) * 128, true);
                  }
               }
            }
         }
      }

   }

   @ObfuscatedName("ba")
   @ObfuscatedSignature(
      descriptor = "(Lkq;IIIII)V"
   )
   void method5462(ModelData var1, int var2, int var3, int var4, int var5, int var6) {
      boolean var7 = true;
      int var8 = var3;
      int var9 = var3 + var5;
      int var10 = var4 - 1;
      int var11 = var4 + var6;

      for(int var12 = var2; var12 <= var2 + 1; ++var12) {
         if(var12 != this.planes) {
            for(int var13 = var8; var13 <= var9; ++var13) {
               if(var13 >= 0 && var13 < this.xSize) {
                  for(int var14 = var10; var14 <= var11; ++var14) {
                     if(var14 >= 0 && var14 < this.ySize && (!var7 || var13 >= var9 || var14 >= var11 || var14 < var4 && var3 != var13)) {
                        Tile var15 = this.tiles[var12][var13][var14];
                        if(var15 != null) {
                           int var16 = this.method5357_base(var12, var13, var14, var2, var3, var4);
                           BoundaryObject var17 = var15.boundaryObject;
                           if(var17 != null) {
                              ModelData var18;
                              if(var17.renderable1 instanceof ModelData) {
                                 var18 = (ModelData)var17.renderable1;
                                 ModelData.method5121(var1, var18, (1 - var5) * 64 + (var13 - var3) * 128, var16, (var14 - var4) * 128 + (1 - var6) * 64, var7);
                              }

                              if(var17.renderable2 instanceof ModelData) {
                                 var18 = (ModelData)var17.renderable2;
                                 ModelData.method5121(var1, var18, (1 - var5) * 64 + (var13 - var3) * 128, var16, (var14 - var4) * 128 + (1 - var6) * 64, var7);
                              }
                           }

                           for(int var23 = 0; var23 < var15.gameObjectsCount; ++var23) {
                              GameObject var19 = var15.gameObjects[var23];
                              if(var19 != null && var19.renderable instanceof ModelData) {
                                 ModelData var20 = (ModelData)var19.renderable;
                                 int var21 = var19.endX - var19.startX + 1;
                                 int var22 = var19.endY - var19.startY + 1;
                                 ModelData.method5121(var1, var20, (var21 - var5) * 64 + (var19.startX - var3) * 128, var16, (var19.startY - var4) * 128 + (var22 - var6) * 64, var7);
                              }
                           }
                        }
                     }
                  }
               }
            }

            --var8;
            var7 = false;
         }
      }

   }

   @ObfuscatedName("bm")
   int method5357_base(int var1, int var2, int var3, int var4, int var5, int var6) {
      return this.method5358_base(var1, var2, var3) - this.method5358_base(var4, var5, var6);
   }

   @ObfuscatedName("bp")
   int method5358_base(int var1, int var2, int var3) {
      return (this.tileHeights[var1][var2 + 1][var3 + 1] + this.tileHeights[var1][var2][var3] + this.tileHeights[var1][var2][var3 + 1] + this.tileHeights[var1][var2 + 1][var3]) / 4;
   }

   @ObfuscatedName("bw")
   public void drawTileMinimap_base(int[] var1, int var2, int var3, int var4, int var5, int var6) {
      if(!Client.hdMinimapEnabled) {
         this.copy$drawTileMinimap(var1, var2, var3, var4, var5, var6);
      } else {
         RSTile var7 = this.getTiles()[var4][var5][var6];
         if(var7 != null) {
            net.runelite.api.SceneTilePaint var8 = var7.getSceneTilePaint();
            int var10;
            int var11;
            int var12;
            int var13;
            int var16;
            if(var8 != null) {
               int var9 = var8.getRBG();
               if(var8.getSwColor() != 12345678) {
                  var10 = var8.getSwColor() & -128;
                  var11 = var8.getNwColor() & 127;
                  var12 = var8.getNeColor() & 127;
                  var13 = (var8.getSwColor() & 127) - var11;
                  int var14 = (var8.getSeColor() & 127) - var12;
                  var11 <<= 2;
                  var12 <<= 2;

                  for(int var15 = 0; var15 < 4; ++var15) {
                     if(var8.getTexture() == -1) {
                        var1[var2] = Rasterizer3D.Rasterizer3D_colorPalette[var10 | var11 >> 2];
                        var1[var2 + 1] = Rasterizer3D.Rasterizer3D_colorPalette[var10 | var12 + var11 * 3 >> 4];
                        var1[var2 + 2] = Rasterizer3D.Rasterizer3D_colorPalette[var10 | var11 + var12 >> 3];
                        var1[var2 + 3] = Rasterizer3D.Rasterizer3D_colorPalette[var10 | var11 + var12 * 3 >> 4];
                     } else {
                        var16 = 255 - ((var11 >> 1) * (var11 >> 1) >> 8);
                        var1[var2] = (var16 * (var9 & 65280) & 16711680) + ((var9 & 16711935) * var16 & -16711936) >> 8;
                        var16 = 255 - ((var12 + var11 * 3 >> 3) * (var12 + var11 * 3 >> 3) >> 8);
                        var1[var2 + 1] = (var16 * (var9 & 65280) & 16711680) + ((var9 & 16711935) * var16 & -16711936) >> 8;
                        var16 = 255 - ((var11 + var12 >> 2) * (var11 + var12 >> 2) >> 8);
                        var1[var2 + 2] = (var16 * (var9 & 65280) & 16711680) + ((var9 & 16711935) * var16 & -16711936) >> 8;
                        var16 = 255 - ((var11 + var12 * 3 >> 3) * (var11 + var12 * 3 >> 3) >> 8);
                        var1[var2 + 3] = (var16 * (var9 & 65280) & 16711680) + ((var9 & 16711935) * var16 & -16711936) >> 8;
                     }

                     var11 += var13;
                     var12 += var14;
                     var2 += var3;
                  }
               } else if(var9 != 0) {
                  for(var10 = 0; var10 < 4; ++var10) {
                     var1[var2] = var9;
                     var1[var2 + 1] = var9;
                     var1[var2 + 2] = var9;
                     var1[var2 + 3] = var9;
                     var2 += var3;
                  }
               }

            } else {
               net.runelite.api.SceneTileModel var24 = var7.getSceneTileModel();
               if(var24 != null) {
                  var10 = var24.getShape();
                  var11 = var24.getRotation();
                  var12 = var24.getModelOverlay();
                  var13 = var24.getModelUnderlay();
                  int[] var25 = this.getTileShape2D()[var10];
                  int[] var26 = this.getTileRotation2D()[var11];
                  var16 = 0;
                  int var17;
                  if(var24.getOverlaySwColor() != 12345678) {
                     var17 = var24.getOverlaySwColor() & -128;
                     int var18 = var24.getOverlaySeColor() & 127;
                     int var19 = var24.getOverlayNeColor() & 127;
                     int var20 = (var24.getOverlaySwColor() & 127) - var18;
                     int var21 = (var24.getOverlayNwColor() & 127) - var19;
                     var18 <<= 2;
                     var19 <<= 2;

                     int var22;
                     for(var22 = 0; var22 < 4; ++var22) {
                        if(var24.getTriangleTextureId() == null) {
                           if(var25[var26[var16++]] != 0) {
                              var1[var2] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var18 >> 2];
                           }

                           if(var25[var26[var16++]] != 0) {
                              var1[var2 + 1] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var19 + var18 * 3 >> 4];
                           }

                           if(var25[var26[var16++]] != 0) {
                              var1[var2 + 2] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var18 + var19 >> 3];
                           }

                           if(var25[var26[var16++]] != 0) {
                              var1[var2 + 3] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var18 + var19 * 3 >> 4];
                           }
                        } else {
                           int var23;
                           if(var25[var26[var16++]] != 0) {
                              var23 = 255 - ((var18 >> 1) * (var18 >> 1) >> 8);
                              var1[var2] = (var23 * (var12 & 65280) & 16711680) + ((var12 & 16711935) * var23 & -16711936) >> 8;
                           }

                           if(var25[var26[var16++]] != 0) {
                              var23 = 255 - ((var19 + var18 * 3 >> 3) * (var19 + var18 * 3 >> 3) >> 8);
                              var1[var2 + 1] = (var23 * (var12 & 65280) & 16711680) + ((var12 & 16711935) * var23 & -16711936) >> 8;
                           }

                           if(var25[var26[var16++]] != 0) {
                              var23 = 255 - ((var18 + var19 >> 2) * (var18 + var19 >> 2) >> 8);
                              var1[var2 + 2] = (var23 * (var12 & 65280) & 16711680) + ((var12 & 16711935) * var23 & -16711936) >> 8;
                           }

                           if(var25[var26[var16++]] != 0) {
                              var23 = 255 - ((var18 + var19 * 3 >> 3) * (var18 + var19 * 3 >> 3) >> 8);
                              var1[var2 + 3] = (var23 * (var12 & 65280) & 16711680) + ((var12 & 16711935) * var23 & -16711936) >> 8;
                           }
                        }

                        var18 += var20;
                        var19 += var21;
                        var2 += var3;
                     }

                     if(var13 != 0 && var24.getUnderlaySwColor() != 12345678) {
                        var2 -= var3 << 2;
                        var16 -= 16;
                        var17 = var24.getUnderlaySwColor() & -128;
                        var18 = var24.getUnderlaySeColor() & 127;
                        var19 = var24.getUnderlayNeColor() & 127;
                        var20 = (var24.getUnderlaySwColor() & 127) - var18;
                        var21 = (var24.getUnderlayNwColor() & 127) - var19;
                        var18 <<= 2;
                        var19 <<= 2;

                        for(var22 = 0; var22 < 4; ++var22) {
                           if(var25[var26[var16++]] == 0) {
                              var1[var2] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var18 >> 2];
                           }

                           if(var25[var26[var16++]] == 0) {
                              var1[var2 + 1] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var19 + var18 * 3 >> 4];
                           }

                           if(var25[var26[var16++]] == 0) {
                              var1[var2 + 2] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var18 + var19 >> 3];
                           }

                           if(var25[var26[var16++]] == 0) {
                              var1[var2 + 3] = Rasterizer3D.Rasterizer3D_colorPalette[var17 | var18 + var19 * 3 >> 4];
                           }

                           var18 += var20;
                           var19 += var21;
                           var2 += var3;
                        }
                     }
                  } else if(var13 != 0) {
                     for(var17 = 0; var17 < 4; ++var17) {
                        var1[var2] = var25[var26[var16++]] != 0?var12:var13;
                        var1[var2 + 1] = var25[var26[var16++]] != 0?var12:var13;
                        var1[var2 + 2] = var25[var26[var16++]] != 0?var12:var13;
                        var1[var2 + 3] = var25[var26[var16++]] != 0?var12:var13;
                        var2 += var3;
                     }
                  } else {
                     for(var17 = 0; var17 < 4; ++var17) {
                        if(var25[var26[var16++]] != 0) {
                           var1[var2] = var12;
                        }

                        if(var25[var26[var16++]] != 0) {
                           var1[var2 + 1] = var12;
                        }

                        if(var25[var26[var16++]] != 0) {
                           var1[var2 + 2] = var12;
                        }

                        if(var25[var26[var16++]] != 0) {
                           var1[var2 + 3] = var12;
                        }

                        var2 += var3;
                     }
                  }
               }

            }
         }
      }
   }

   @ObfuscatedName("bo")
   public void menuOpen_base(int var1, int var2, int var3, boolean var4) {
      if(!shouldSendWalk_base() || var4) {
         checkClick = true;
         viewportWalking = var4;
         Scene_selectedPlane = var1;
         Scene_selectedScreenX = var2;
         Scene_selectedScreenY = var3;
         Scene_selectedX = -1;
         Scene_selectedY = -1;
      }
   }

   @ObfuscatedName("bt")
   public void setViewportWalking_base() {
      viewportWalking = true;
   }

   public static final double JAG2RAD = 0.0030679615757712823D;

   @ObfuscatedName("bh")
   public void draw_base(int var1, int var2, int var3, int var4, int var5, int var6) {
      DrawCallbacks var7 = SpriteMask.client.getDrawCallbacks();
      if(var7 != null) {
         Client.viewportColor = 0;
         var7.drawScene(var1, var2, var3, var4, var5, var6);
         var7.drawScene(var1, var2, var3, var4 * JAG2RAD, var5 * JAG2RAD, var6);
      }

      boolean var8 = SpriteMask.client.isGpu();
      boolean var9 = SpriteMask.client.isCheckClick();
      boolean var10 = SpriteMask.client.isMenuOpen();
      if(!var10 && !var9) {
         SpriteMask.client.getScene().menuOpen(SpriteMask.client.getPlane(), SpriteMask.client.getMouseX() - SpriteMask.client.getViewportXOffset(), SpriteMask.client.getMouseY() - SpriteMask.client.getViewportYOffset(), false);
      }

      if(!var8 && Client.skyboxColor != 0) {
         SpriteMask.client.rasterizerFillRectangle(SpriteMask.client.getViewportXOffset(), SpriteMask.client.getViewportYOffset(), SpriteMask.client.getViewportWidth(), SpriteMask.client.getViewportHeight(), Client.skyboxColor);
      }

      int var11 = this.getMaxX();
      int var12 = this.getMaxY();
      int var13 = this.getMaxZ();
      int var14 = this.getMinLevel();
      RSTile[][][] var15 = this.getTiles();
      int var16 = var8?rl$drawDistance:25;
      if(var1 < 0) {
         var1 = 0;
      } else if(var1 >= var11 * 128) {
         var1 = var11 * 128 - 1;
      }

      if(var3 < 0) {
         var3 = 0;
      } else if(var3 >= var13 * 128) {
         var3 = var13 * 128 - 1;
      }

      int var17 = var4;
      if(var4 < 128) {
         var4 = 128;
      } else if(var4 > 383) {
         var4 = 383;
      }

      if(!Client.pitchRelaxEnabled) {
         var17 = var4;
      }

      SpriteMask.client.setCycle(SpriteMask.client.getCycle() + 1);
      SpriteMask.client.setPitchSin(Perspective.SINE[var17]);
      SpriteMask.client.setPitchCos(Perspective.COSINE[var17]);
      SpriteMask.client.setYawSin(Perspective.SINE[var5]);
      SpriteMask.client.setYawCos(Perspective.COSINE[var5]);
      int[][][] var18 = SpriteMask.client.getTileHeights();
      boolean[][] var19 = SpriteMask.client.getVisibilityMaps()[(var4 - 128) / 32][var5 / 64];
      SpriteMask.client.setRenderArea(var19);
      SpriteMask.client.setCameraX2(var1);
      SpriteMask.client.setCameraY2(var2);
      SpriteMask.client.setCameraZ2(var3);
      int var20 = var1 / 128;
      int var21 = var3 / 128;
      SpriteMask.client.setScreenCenterX(var20);
      SpriteMask.client.setScreenCenterZ(var21);
      SpriteMask.client.setScenePlane(var6);
      int var22 = var20 - var16;
      if(var22 < 0) {
         var22 = 0;
      }

      int var23 = var21 - var16;
      if(var23 < 0) {
         var23 = 0;
      }

      int var24 = var20 + var16;
      if(var24 > var11) {
         var24 = var11;
      }

      int var25 = var21 + var16;
      if(var25 > var13) {
         var25 = var13;
      }

      SpriteMask.client.setMinTileX(var22);
      SpriteMask.client.setMinTileZ(var23);
      SpriteMask.client.setMaxTileX(var24);
      SpriteMask.client.setMaxTileZ(var25);
      this.updateOccluders();
      SpriteMask.client.setTileUpdateCount(0);
      int var28;
      int var29;
      int var30;
      int var31;
      int var32;
      int var33;
      if(rl$roofRemovalMode != 0) {
         rl$tilesToRemove.clear();
         RSPlayer var26 = SpriteMask.client.getLocalPlayer();
         LocalPoint var27;
         if(var26 != null && (rl$roofRemovalMode & 1) != 0) {
            var27 = var26.getLocalLocation();
            if(var27.isInScene()) {
               rl$tilesToRemove.add(Integer.valueOf(rl$tiles[SpriteMask.client.getPlane()][var27.getSceneX()][var27.getSceneY()]));
            }
         }

         if(rl$hoverX >= 0 && rl$hoverX < 104 && rl$hoverY >= 0 && rl$hoverY < 104 && (rl$roofRemovalMode & 2) != 0) {
            rl$tilesToRemove.add(Integer.valueOf(rl$tiles[SpriteMask.client.getPlane()][rl$hoverX][rl$hoverY]));
         }

         var27 = SpriteMask.client.getLocalDestinationLocation();
         if(var27 != null && var27.isInScene() && (rl$roofRemovalMode & 4) != 0) {
            rl$tilesToRemove.add(Integer.valueOf(rl$tiles[SpriteMask.client.getPlane()][var27.getSceneX()][var27.getSceneY()]));
         }

         if(SpriteMask.client.getCameraPitch() < 310 && (rl$roofRemovalMode & 8) != 0 && var26 != null) {
            var28 = var26.getX() >> 7;
            var29 = var26.getY() >> 7;
            var30 = SpriteMask.client.getCameraX() >> 7;
            var31 = SpriteMask.client.getCameraY() >> 7;
            if(var28 >= 0 && var29 >= 0 && var30 >= 0 && var31 >= 0 && var28 < 104 && var29 < 104 && var30 < 104 && var31 < 104) {
               var32 = Math.abs(var28 - var30);
               var33 = Integer.compare(var28, var30);
               int var34 = -Math.abs(var29 - var31);
               int var35 = Integer.compare(var29, var31);
               int var36 = var32 + var34;

               while(var30 != var28 || var31 != var29) {
                  if(blocking(SpriteMask.client.getPlane(), var30, var31)) {
                     rl$tilesToRemove.add(Integer.valueOf(rl$tiles[SpriteMask.client.getPlane()][var30][var31]));
                  }

                  int var37 = var36 * 2;
                  if(var37 >= var34) {
                     var36 += var34;
                     var30 += var33;
                  } else {
                     var36 += var32;
                     var31 += var35;
                  }
               }
            }
         }
      }

      if(!var10) {
         rl$hoverY = -1;
         rl$hoverX = -1;
      }

      int var38;
      RSTile[][] var41;
      for(var38 = var14; var38 < var12; ++var38) {
         var41 = var15[var38];

         for(var28 = var22; var28 < var24; ++var28) {
            for(var29 = var23; var29 < var25; ++var29) {
               RSTile var39 = var41[var28][var29];
               if(var39 != null) {
                  var31 = rl$tiles[SpriteMask.client.getPlane()][var28][var29];
                  if(var39.getPhysicalLevel() > var6 && rl$roofRemovalMode == 0 || !var8 && !var19[var28 - var20 + 25][var29 - var21 + 25] && var18[var38][var28][var29] - var2 < 2000 || rl$roofRemovalMode != 0 && SpriteMask.client.getPlane() < var39.getPhysicalLevel() && var31 != 0 && rl$tilesToRemove.contains(Integer.valueOf(var31))) {
                     var39.setDraw(false);
                     var39.setVisible(false);
                     var39.setWallCullDirection(0);
                  } else {
                     var39.setDraw(true);
                     var39.setVisible(true);
                     var39.setDrawEntities(true);
                     SpriteMask.client.setTileUpdateCount(SpriteMask.client.getTileUpdateCount() + 1);
                  }
               }
            }
         }
      }

      RSTile var40;
      for(var38 = var14; var38 < var12; ++var38) {
         var41 = var15[var38];

         for(var28 = -var16; var28 <= 0; ++var28) {
            var29 = var28 + var20;
            var30 = var20 - var28;
            if(var29 >= var22 || var30 < var24) {
               for(var31 = -var16; var31 <= 0; ++var31) {
                  var32 = var31 + var21;
                  var33 = var21 - var31;
                  if(var29 >= var22) {
                     if(var32 >= var23) {
                        var40 = var41[var29][var32];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, true);
                        }
                     }

                     if(var33 < var25) {
                        var40 = var41[var29][var33];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, true);
                        }
                     }
                  }

                  if(var30 < var24) {
                     if(var32 >= var23) {
                        var40 = var41[var30][var32];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, true);
                        }
                     }

                     if(var33 < var25) {
                        var40 = var41[var30][var33];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, true);
                        }
                     }
                  }

                  if(SpriteMask.client.getTileUpdateCount() == 0) {
                     if(!var8 && SpriteMask.client.getOculusOrbState() != 0 && !SpriteMask.client.getComplianceValue("orbInteraction")) {
                        SpriteMask.client.setEntitiesAtMouseCount(0);
                     }

                     SpriteMask.client.setCheckClick(false);
                     SpriteMask.client.getCallbacks().drawScene();
                     if(SpriteMask.client.getDrawCallbacks() != null) {
                        SpriteMask.client.getDrawCallbacks().postDrawScene();
                     }

                     return;
                  }
               }
            }
         }
      }

      label302:
      for(var38 = var14; var38 < var12; ++var38) {
         var41 = var15[var38];

         for(var28 = -var16; var28 <= 0; ++var28) {
            var29 = var28 + var20;
            var30 = var20 - var28;
            if(var29 >= var22 || var30 < var24) {
               for(var31 = -var16; var31 <= 0; ++var31) {
                  var32 = var31 + var21;
                  var33 = var21 - var31;
                  if(var29 >= var22) {
                     if(var32 >= var23) {
                        var40 = var41[var29][var32];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, false);
                        }
                     }

                     if(var33 < var25) {
                        var40 = var41[var29][var33];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, false);
                        }
                     }
                  }

                  if(var30 < var24) {
                     if(var32 >= var23) {
                        var40 = var41[var30][var32];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, false);
                        }
                     }

                     if(var33 < var25) {
                        var40 = var41[var30][var33];
                        if(var40 != null && var40.isDraw()) {
                           this.draw(var40, false);
                        }
                     }
                  }

                  if(SpriteMask.client.getTileUpdateCount() == 0) {
                     break label302;
                  }
               }
            }
         }
      }

      if(!var8 && SpriteMask.client.getOculusOrbState() != 0 && !SpriteMask.client.getComplianceValue("orbInteraction")) {
         SpriteMask.client.setEntitiesAtMouseCount(0);
      }

      SpriteMask.client.setCheckClick(false);
      SpriteMask.client.getCallbacks().drawScene();
      if(SpriteMask.client.getDrawCallbacks() != null) {
         SpriteMask.client.getDrawCallbacks().postDrawScene();
      }

   }

   @ObfuscatedName("bz")
   @ObfuscatedSignature(
      descriptor = "(Lkv;Z)V"
   )
   void method5450(Tile var1, boolean var2) {
      Scene_tilesDeque.method7233(var1);

      while(true) {
         Tile var3;
         int var4;
         int var5;
         int var6;
         int var7;
         Tile[][] var8;
         Tile var9;
         int var11;
         int var14;
         int var15;
         int var16;
         int var24;
         int var25;
         do {
            do {
               do {
                  do {
                     do {
                        do {
                           while(true) {
                              BoundaryObject var10;
                              GameObject var12;
                              int var17;
                              int var18;
                              boolean var20;
                              int var21;
                              Tile var36;
                              while(true) {
                                 do {
                                    var3 = (Tile)Scene_tilesDeque.method7231();
                                    if(var3 == null) {
                                       return;
                                    }
                                 } while(!var3.drawSecondary);

                                 var4 = var3.x;
                                 var5 = var3.y;
                                 var6 = var3.plane;
                                 var7 = var3.originalPlane;
                                 var8 = this.tiles[var6];
                                 if(!var3.drawPrimary) {
                                    break;
                                 }

                                 if(var2) {
                                    if(var6 > 0) {
                                       var9 = this.tiles[var6 - 1][var4][var5];
                                       if(var9 != null && var9.drawSecondary) {
                                          continue;
                                       }
                                    }

                                    if(var4 <= Scene_cameraXTile && var4 > Scene_cameraXTileMin) {
                                       var9 = var8[var4 - 1][var5];
                                       if(var9 != null && var9.drawSecondary && (var9.drawPrimary || (var3.gameObjectsEdgeMask & 1) == 0)) {
                                          continue;
                                       }
                                    }

                                    if(var4 >= Scene_cameraXTile && var4 < Scene_cameraXTileMax - 1) {
                                       var9 = var8[var4 + 1][var5];
                                       if(var9 != null && var9.drawSecondary && (var9.drawPrimary || (var3.gameObjectsEdgeMask & 4) == 0)) {
                                          continue;
                                       }
                                    }

                                    if(var5 <= Scene_cameraYTile && var5 > Scene_cameraYTileMin) {
                                       var9 = var8[var4][var5 - 1];
                                       if(var9 != null && var9.drawSecondary && (var9.drawPrimary || (var3.gameObjectsEdgeMask & 8) == 0)) {
                                          continue;
                                       }
                                    }

                                    if(var5 >= Scene_cameraYTile && var5 < Scene_cameraYTileMax - 1) {
                                       var9 = var8[var4][var5 + 1];
                                       if(var9 != null && var9.drawSecondary && (var9.drawPrimary || (var3.gameObjectsEdgeMask & 2) == 0)) {
                                          continue;
                                       }
                                    }
                                 } else {
                                    var2 = true;
                                 }

                                 var3.drawPrimary = false;
                                 if(var3.linkedBelowTile != null) {
                                    var9 = var3.linkedBelowTile;
                                    if(var9.paint != null) {
                                       if(!this.method5374_base(0, var4, var5)) {
                                          this.method5484(var9.paint, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var4, var5);
                                       }
                                    } else if(var9.model != null && !this.method5374_base(0, var4, var5)) {
                                       this.method5369(var9.model, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var4, var5);
                                    }

                                    var10 = var9.boundaryObject;
                                    if(var10 != null) {
                                       renderDraw(var10.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var10.x - Scene_cameraX, var10.z - Scene_cameraY, var10.y - Scene_cameraZ, var10.tag);
                                    }

                                    for(var11 = 0; var11 < var9.gameObjectsCount; ++var11) {
                                       var12 = var9.gameObjects[var11];
                                       if(var12 != null) {
                                          renderDraw(var12.renderable, var12.orientation, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var12.centerX - Scene_cameraX, var12.z - Scene_cameraY, var12.centerY - Scene_cameraZ, var12.tag);
                                       }
                                    }
                                 }

                                 var20 = false;
                                 if(var3.paint != null) {
                                    if(!this.method5374_base(var7, var4, var5)) {
                                       var20 = true;
                                       if(var3.paint.neColor != 12345678 || checkClick && var6 <= Scene_selectedPlane) {
                                          this.method5484(var3.paint, var7, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var4, var5);
                                       }
                                    }
                                 } else if(var3.model != null && !this.method5374_base(var7, var4, var5)) {
                                    var20 = true;
                                    this.method5369(var3.model, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var4, var5);
                                 }

                                 var21 = 0;
                                 var11 = 0;
                                 BoundaryObject var31 = var3.boundaryObject;
                                 WallDecoration var13 = var3.wallDecoration;
                                 if(var31 != null || var13 != null) {
                                    if(var4 == Scene_cameraXTile) {
                                       ++var21;
                                    } else if(Scene_cameraXTile < var4) {
                                       var21 += 2;
                                    }

                                    if(var5 == Scene_cameraYTile) {
                                       var21 += 3;
                                    } else if(Scene_cameraYTile > var5) {
                                       var21 += 6;
                                    }

                                    var11 = field2830[var21];
                                    var3.field2762 = field2847[var21];
                                 }

                                 if(var31 != null) {
                                    if((var31.orientationA & field2846[var21]) != 0) {
                                       if(var31.orientationA == 16) {
                                          var3.drawGameObjectEdges = 3;
                                          var3.field2760 = field2848[var21];
                                          var3.field2747 = 3 - var3.field2760;
                                       } else if(var31.orientationA == 32) {
                                          var3.drawGameObjectEdges = 6;
                                          var3.field2760 = field2849[var21];
                                          var3.field2747 = 6 - var3.field2760;
                                       } else if(var31.orientationA == 64) {
                                          var3.drawGameObjectEdges = 12;
                                          var3.field2760 = field2835[var21];
                                          var3.field2747 = 12 - var3.field2760;
                                       } else {
                                          var3.drawGameObjectEdges = 9;
                                          var3.field2760 = field2851[var21];
                                          var3.field2747 = 9 - var3.field2760;
                                       }
                                    } else {
                                       var3.drawGameObjectEdges = 0;
                                    }

                                    if((var31.orientationA & var11) != 0 && !this.method5382_base(var7, var4, var5, var31.orientationA)) {
                                       renderDraw(var31.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var31.x - Scene_cameraX, var31.z - Scene_cameraY, var31.y - Scene_cameraZ, var31.tag);
                                    }

                                    if((var31.orientationB & var11) != 0 && !this.method5382_base(var7, var4, var5, var31.orientationB)) {
                                       renderDraw(var31.renderable2, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var31.x - Scene_cameraX, var31.z - Scene_cameraY, var31.y - Scene_cameraZ, var31.tag);
                                    }
                                 }

                                 if(var13 != null && !this.method5375_base(var7, var4, var5, var13.renderable1.height)) {
                                    if((var13.orientation & var11) != 0) {
                                       renderDraw(var13.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var13.x - Scene_cameraX + var13.xOffset, var13.z - Scene_cameraY, var13.y - Scene_cameraZ + var13.yOffset, var13.tag);
                                    } else if(var13.orientation == 256) {
                                       var14 = var13.x - Scene_cameraX;
                                       var15 = var13.z - Scene_cameraY;
                                       var16 = var13.y - Scene_cameraZ;
                                       var17 = var13.orientation2;
                                       if(var17 != 1 && var17 != 2) {
                                          var18 = var14;
                                       } else {
                                          var18 = -var14;
                                       }

                                       int var19;
                                       if(var17 != 2 && var17 != 3) {
                                          var19 = var16;
                                       } else {
                                          var19 = -var16;
                                       }

                                       if(var19 < var18) {
                                          renderDraw(var13.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var14 + var13.xOffset, var15, var16 + var13.yOffset, var13.tag);
                                       } else if(var13.renderable2 != null) {
                                          renderDraw(var13.renderable2, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var14, var15, var16, var13.tag);
                                       }
                                    }
                                 }

                                 if(var20) {
                                    FloorDecoration var22 = var3.floorDecoration;
                                    if(var22 != null) {
                                       renderDraw(var22.renderable, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var22.x - Scene_cameraX, var22.z - Scene_cameraY, var22.y - Scene_cameraZ, var22.tag);
                                    }

                                    ItemLayer var23 = var3.itemLayer;
                                    if(var23 != null && var23.height == 0) {
                                       if(var23.second != null) {
                                          renderDraw(var23.second, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var23.x - Scene_cameraX, var23.z - Scene_cameraY, var23.y * 1998503025 - Scene_cameraZ, var23.tag);
                                       }

                                       if(var23.third != null) {
                                          renderDraw(var23.third, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var23.x - Scene_cameraX, var23.z - Scene_cameraY, var23.y * 1998503025 - Scene_cameraZ, var23.tag);
                                       }

                                       if(var23.first != null) {
                                          renderDraw(var23.first, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var23.x - Scene_cameraX, var23.z - Scene_cameraY, var23.y * 1998503025 - Scene_cameraZ, var23.tag);
                                       }
                                    }
                                 }

                                 var14 = var3.gameObjectsEdgeMask;
                                 if(var14 != 0) {
                                    if(var4 < Scene_cameraXTile && (var14 & 4) != 0) {
                                       var36 = var8[var4 + 1][var5];
                                       if(var36 != null && var36.drawSecondary) {
                                          Scene_tilesDeque.method7233(var36);
                                       }
                                    }

                                    if(var5 < Scene_cameraYTile && (var14 & 2) != 0) {
                                       var36 = var8[var4][var5 + 1];
                                       if(var36 != null && var36.drawSecondary) {
                                          Scene_tilesDeque.method7233(var36);
                                       }
                                    }

                                    if(var4 > Scene_cameraXTile && (var14 & 1) != 0) {
                                       var36 = var8[var4 - 1][var5];
                                       if(var36 != null && var36.drawSecondary) {
                                          Scene_tilesDeque.method7233(var36);
                                       }
                                    }

                                    if(var5 > Scene_cameraYTile && (var14 & 8) != 0) {
                                       var36 = var8[var4][var5 - 1];
                                       if(var36 != null && var36.drawSecondary) {
                                          Scene_tilesDeque.method7233(var36);
                                       }
                                    }
                                 }
                                 break;
                              }

                              if(var3.drawGameObjectEdges != 0) {
                                 var20 = true;

                                 for(var21 = 0; var21 < var3.gameObjectsCount; ++var21) {
                                    if(var3.gameObjects[var21].lastDrawn != Scene_drawnCount && (var3.gameObjectEdgeMasks[var21] & var3.drawGameObjectEdges) == var3.field2760) {
                                       var20 = false;
                                       break;
                                    }
                                 }

                                 if(var20) {
                                    var10 = var3.boundaryObject;
                                    if(!this.method5382_base(var7, var4, var5, var10.orientationA)) {
                                       renderDraw(var10.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var10.x - Scene_cameraX, var10.z - Scene_cameraY, var10.y - Scene_cameraZ, var10.tag);
                                    }

                                    var3.drawGameObjectEdges = 0;
                                 }
                              }

                              if(!var3.drawGameObjects) {
                                 break;
                              }

                              try {
                                 int var34 = var3.gameObjectsCount;
                                 var3.drawGameObjects = false;
                                 var21 = 0;

                                 label563:
                                 for(var11 = 0; var11 < var34; ++var11) {
                                    var12 = var3.gameObjects[var11];
                                    if(var12.lastDrawn != Scene_drawnCount) {
                                       for(var24 = var12.startX; var24 <= var12.endX; ++var24) {
                                          for(var14 = var12.startY; var14 <= var12.endY; ++var14) {
                                             var36 = var8[var24][var14];
                                             if(var36.drawPrimary) {
                                                var3.drawGameObjects = true;
                                                continue label563;
                                             }

                                             if(var36.drawGameObjectEdges != 0) {
                                                var16 = 0;
                                                if(var24 > var12.startX) {
                                                   ++var16;
                                                }

                                                if(var24 < var12.endX) {
                                                   var16 += 4;
                                                }

                                                if(var14 > var12.startY) {
                                                   var16 += 8;
                                                }

                                                if(var14 < var12.endY) {
                                                   var16 += 2;
                                                }

                                                if((var16 & var36.drawGameObjectEdges) == var3.field2747) {
                                                   var3.drawGameObjects = true;
                                                   continue label563;
                                                }
                                             }
                                          }
                                       }

                                       gameObjects[var21++] = var12;
                                       var24 = Scene_cameraXTile - var12.startX;
                                       var14 = var12.endX - Scene_cameraXTile;
                                       if(var14 > var24) {
                                          var24 = var14;
                                       }

                                       var15 = Scene_cameraYTile - var12.startY;
                                       var16 = var12.endY - Scene_cameraYTile;
                                       if(var16 > var15) {
                                          var12.field3093 = var24 + var16;
                                       } else {
                                          var12.field3093 = var24 + var15;
                                       }
                                    }
                                 }

                                 while(var21 > 0) {
                                    var11 = -50;
                                    var25 = -1;

                                    for(var24 = 0; var24 < var21; ++var24) {
                                       GameObject var35 = gameObjects[var24];
                                       if(var35.lastDrawn != Scene_drawnCount) {
                                          if(var35.field3093 > var11) {
                                             var11 = var35.field3093;
                                             var25 = var24;
                                          } else if(var11 == var35.field3093) {
                                             var15 = var35.centerX - Scene_cameraX;
                                             var16 = var35.centerY - Scene_cameraZ;
                                             var17 = gameObjects[var25].centerX - Scene_cameraX;
                                             var18 = gameObjects[var25].centerY - Scene_cameraZ;
                                             if(var15 * var15 + var16 * var16 > var17 * var17 + var18 * var18) {
                                                var25 = var24;
                                             }
                                          }
                                       }
                                    }

                                    if(var25 == -1) {
                                       break;
                                    }

                                    GameObject var33 = gameObjects[var25];
                                    var33.lastDrawn = Scene_drawnCount;
                                    if(!this.method5376_base(var7, var33.startX, var33.endX, var33.startY, var33.endY, var33.renderable.height)) {
                                       renderDraw(var33.renderable, var33.orientation, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var33.centerX - Scene_cameraX, var33.z - Scene_cameraY, var33.centerY - Scene_cameraZ, var33.tag);
                                    }

                                    for(var14 = var33.startX; var14 <= var33.endX; ++var14) {
                                       for(var15 = var33.startY; var15 <= var33.endY; ++var15) {
                                          Tile var26 = var8[var14][var15];
                                          if(var26.drawGameObjectEdges != 0) {
                                             Scene_tilesDeque.method7233(var26);
                                          } else if((var14 != var4 || var15 != var5) && var26.drawSecondary) {
                                             Scene_tilesDeque.method7233(var26);
                                          }
                                       }
                                    }
                                 }

                                 if(!var3.drawGameObjects) {
                                    break;
                                 }
                              } catch (Exception var28) {
                                 var3.drawGameObjects = false;
                                 break;
                              }
                           }
                        } while(!var3.drawSecondary);
                     } while(var3.drawGameObjectEdges != 0);

                     if(var4 > Scene_cameraXTile || var4 <= Scene_cameraXTileMin) {
                        break;
                     }

                     var9 = var8[var4 - 1][var5];
                  } while(var9 != null && var9.drawSecondary);

                  if(var4 < Scene_cameraXTile || var4 >= Scene_cameraXTileMax - 1) {
                     break;
                  }

                  var9 = var8[var4 + 1][var5];
               } while(var9 != null && var9.drawSecondary);

               if(var5 > Scene_cameraYTile || var5 <= Scene_cameraYTileMin) {
                  break;
               }

               var9 = var8[var4][var5 - 1];
            } while(var9 != null && var9.drawSecondary);

            if(var5 < Scene_cameraYTile || var5 >= Scene_cameraYTileMax - 1) {
               break;
            }

            var9 = var8[var4][var5 + 1];
         } while(var9 != null && var9.drawSecondary);

         var3.drawSecondary = false;
         --tileUpdateCount;
         ItemLayer var32 = var3.itemLayer;
         if(var32 != null && var32.height != 0) {
            if(var32.second != null) {
               renderDraw(var32.second, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var32.x - Scene_cameraX, var32.z - Scene_cameraY - var32.height, var32.y * 1998503025 - Scene_cameraZ, var32.tag);
            }

            if(var32.third != null) {
               renderDraw(var32.third, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var32.x - Scene_cameraX, var32.z - Scene_cameraY - var32.height, var32.y * 1998503025 - Scene_cameraZ, var32.tag);
            }

            if(var32.first != null) {
               renderDraw(var32.first, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var32.x - Scene_cameraX, var32.z - Scene_cameraY - var32.height, var32.y * 1998503025 - Scene_cameraZ, var32.tag);
            }
         }

         if(var3.field2762 != 0) {
            WallDecoration var29 = var3.wallDecoration;
            if(var29 != null && !this.method5375_base(var7, var4, var5, var29.renderable1.height)) {
               if((var29.orientation & var3.field2762) != 0) {
                  renderDraw(var29.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var29.x - Scene_cameraX + var29.xOffset, var29.z - Scene_cameraY, var29.y - Scene_cameraZ + var29.yOffset, var29.tag);
               } else if(var29.orientation == 256) {
                  var11 = var29.x - Scene_cameraX;
                  var25 = var29.z - Scene_cameraY;
                  var24 = var29.y - Scene_cameraZ;
                  var14 = var29.orientation2;
                  if(var14 != 1 && var14 != 2) {
                     var15 = var11;
                  } else {
                     var15 = -var11;
                  }

                  if(var14 != 2 && var14 != 3) {
                     var16 = var24;
                  } else {
                     var16 = -var24;
                  }

                  if(var16 >= var15) {
                     renderDraw(var29.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var11 + var29.xOffset, var25, var24 + var29.yOffset, var29.tag);
                  } else if(var29.renderable2 != null) {
                     renderDraw(var29.renderable2, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var11, var25, var24, var29.tag);
                  }
               }
            }

            BoundaryObject var27 = var3.boundaryObject;
            if(var27 != null) {
               if((var27.orientationB & var3.field2762) != 0 && !this.method5382_base(var7, var4, var5, var27.orientationB)) {
                  renderDraw(var27.renderable2, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var27.x - Scene_cameraX, var27.z - Scene_cameraY, var27.y - Scene_cameraZ, var27.tag);
               }

               if((var27.orientationA & var3.field2762) != 0 && !this.method5382_base(var7, var4, var5, var27.orientationA)) {
                  renderDraw(var27.renderable1, 0, Scene_cameraPitchSine, Scene_cameraPitchCosine, Scene_cameraYawSine, Scene_cameraYawCosine, var27.x - Scene_cameraX, var27.z - Scene_cameraY, var27.y - Scene_cameraZ, var27.tag);
               }
            }
         }

         Tile var30;
         if(var6 < this.planes - 1) {
            var30 = this.tiles[var6 + 1][var4][var5];
            if(var30 != null && var30.drawSecondary) {
               Scene_tilesDeque.method7233(var30);
            }
         }

         if(var4 < Scene_cameraXTile) {
            var30 = var8[var4 + 1][var5];
            if(var30 != null && var30.drawSecondary) {
               Scene_tilesDeque.method7233(var30);
            }
         }

         if(var5 < Scene_cameraYTile) {
            var30 = var8[var4][var5 + 1];
            if(var30 != null && var30.drawSecondary) {
               Scene_tilesDeque.method7233(var30);
            }
         }

         if(var4 > Scene_cameraXTile) {
            var30 = var8[var4 - 1][var5];
            if(var30 != null && var30.drawSecondary) {
               Scene_tilesDeque.method7233(var30);
            }
         }

         if(var5 > Scene_cameraYTile) {
            var30 = var8[var4][var5 - 1];
            if(var30 != null && var30.drawSecondary) {
               Scene_tilesDeque.method7233(var30);
            }
         }
      }
   }

   @ObfuscatedName("bc")
   @ObfuscatedSignature(
      descriptor = "(Lke;IIIIIII)V"
   )
   void method5484(SceneTilePaint var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8) {
      byte[][][] var9 = SpriteMask.client.getTileSettings();
      boolean var10 = SpriteMask.client.isCheckClick();
      int var11 = var2;
      if((var9[1][var7][var7] & 2) != 0) {
         var11 = var2 - 1;
      }

      if(!SpriteMask.client.isGpu()) {
         try {
            this.copy$drawTileUnderlay(var1, var2, var3, var4, var5, var6, var7, var8);
         } catch (Exception var44) {
            SpriteMask.client.getLogger().warn("error during tile underlay rendering", var44);
         }

         if(rl$roofRemovalMode == 0 || !var10 || SpriteMask.client.getPlane() != var11) {
            return;
         }
      }

      DrawCallbacks var12 = SpriteMask.client.getDrawCallbacks();
      if(var12 != null) {
         try {
            int[][][] var13 = this.getTileHeights();
            int var14 = SpriteMask.client.getCameraX2();
            int var15 = SpriteMask.client.getCameraY2();
            int var16 = SpriteMask.client.getCameraZ2();
            int var17 = SpriteMask.client.get3dZoom();
            int var18 = SpriteMask.client.getCenterX();
            int var19 = SpriteMask.client.getCenterY();
            int var20 = SpriteMask.client.getMouseX2();
            int var21 = SpriteMask.client.getMouseY2();
            int var22;
            int var23 = var22 = (var7 << 7) - var14;
            int var24;
            int var25 = var24 = (var8 << 7) - var16;
            int var26;
            int var27 = var26 = var23 + 128;
            int var28;
            int var29 = var28 = var25 + 128;
            int var30 = var13[var2][var7][var8] - var15;
            int var31 = var13[var2][var7 + 1][var8] - var15;
            int var32 = var13[var2][var7 + 1][var8 + 1] - var15;
            int var33 = var13[var2][var7][var8 + 1] - var15;
            int var34 = var23 * var6 + var5 * var25 >> 16;
            var25 = var25 * var6 - var5 * var23 >> 16;
            var23 = var34;
            var34 = var30 * var4 - var3 * var25 >> 16;
            var25 = var25 * var4 + var3 * var30 >> 16;
            var30 = var34;
            if(var25 >= 50) {
               var34 = var27 * var6 + var5 * var24 >> 16;
               var24 = var24 * var6 - var5 * var27 >> 16;
               var27 = var34;
               var34 = var31 * var4 - var3 * var24 >> 16;
               var24 = var24 * var4 + var3 * var31 >> 16;
               var31 = var34;
               if(var24 >= 50) {
                  var34 = var26 * var6 + var5 * var29 >> 16;
                  var29 = var29 * var6 - var5 * var26 >> 16;
                  var26 = var34;
                  var34 = var32 * var4 - var3 * var29 >> 16;
                  var29 = var29 * var4 + var3 * var32 >> 16;
                  var32 = var34;
                  if(var29 >= 50) {
                     var34 = var22 * var6 + var5 * var28 >> 16;
                     var28 = var28 * var6 - var5 * var22 >> 16;
                     var22 = var34;
                     var34 = var33 * var4 - var3 * var28 >> 16;
                     var28 = var28 * var4 + var3 * var33 >> 16;
                     if(var28 >= 50) {
                        int var35 = var23 * var17 / var25 + var18;
                        int var36 = var30 * var17 / var25 + var19;
                        int var37 = var27 * var17 / var24 + var18;
                        int var38 = var31 * var17 / var24 + var19;
                        int var39 = var26 * var17 / var29 + var18;
                        int var40 = var32 * var17 / var29 + var19;
                        int var41 = var22 * var17 / var28 + var18;
                        int var42 = var34 * var17 / var28 + var19;
                        var12.drawScenePaint(0, var3, var4, var5, var6, -var14, -var15, -var16, var1, var2, var7, var8, var17, var18, var19);
                        if((var39 - var41) * (var38 - var42) - (var40 - var42) * (var37 - var41) > 0 && var10 && SpriteMask.client.containsBounds(var20, var21, var40, var42, var38, var39, var41, var37)) {
                           setTargetTile(var7, var8);
                           if(var20 >= SpriteMask.client.getViewportXOffset() && var20 < SpriteMask.client.getViewportXOffset() + SpriteMask.client.getViewportWidth() && var21 >= SpriteMask.client.getViewportYOffset() && var21 < SpriteMask.client.getViewportYOffset() + SpriteMask.client.getViewportHeight()) {
                              hoverTile(var7, var8, var11);
                           }
                        }

                        if((var35 - var37) * (var42 - var38) - (var36 - var38) * (var41 - var37) > 0 && var10 && SpriteMask.client.containsBounds(var20, var21, var36, var38, var42, var35, var37, var41)) {
                           setTargetTile(var7, var8);
                           if(var20 >= SpriteMask.client.getViewportXOffset() && var20 < SpriteMask.client.getViewportXOffset() + SpriteMask.client.getViewportWidth() && var21 >= SpriteMask.client.getViewportYOffset() && var21 < SpriteMask.client.getViewportYOffset() + SpriteMask.client.getViewportHeight()) {
                              hoverTile(var7, var8, var11);
                           }
                        }
                     }
                  }
               }
            }
         } catch (Exception var43) {
            SpriteMask.client.getLogger().warn("error during underlay rendering", var43);
         }

      }
   }

   @ObfuscatedName("bs")
   @ObfuscatedSignature(
      descriptor = "(Lkl;IIIIII)V"
   )
   void method5369(SceneTileModel var1, int var2, int var3, int var4, int var5, int var6, int var7) {
      RSTile var8 = this.getTiles()[SpriteMask.client.getPlane()][var6][var7];
      boolean var9 = SpriteMask.client.isCheckClick();
      if(!SpriteMask.client.isGpu()) {
         this.copy$drawTileOverlay(var1, var2, var3, var4, var5, var6, var7);
         if(rl$roofRemovalMode == 0 || !var9 || var8 == null || var8.getSceneTileModel() != var1 || var8.getPhysicalLevel() != SpriteMask.client.getPlane()) {
            return;
         }
      }

      DrawCallbacks var10 = SpriteMask.client.getDrawCallbacks();
      if(var10 != null) {
         try {
            int var11 = SpriteMask.client.getCameraX2();
            int var12 = SpriteMask.client.getCameraY2();
            int var13 = SpriteMask.client.getCameraZ2();
            int var14 = SpriteMask.client.get3dZoom();
            int var15 = SpriteMask.client.getCenterX();
            int var16 = SpriteMask.client.getCenterY();
            var10.drawSceneModel(0, var2, var3, var4, var5, -var11, -var12, -var13, var1, SpriteMask.client.getPlane(), var6, var7, var14, var15, var16);
            if(var9) {
               RSSceneTileModel var17 = (RSSceneTileModel)var1;
               int[] var18 = var17.getFaceX();
               int[] var19 = var17.getFaceY();
               int[] var20 = var17.getFaceZ();
               int[] var21 = var17.getVertexX();
               int[] var22 = var17.getVertexY();
               int[] var23 = var17.getVertexZ();
               int var24 = var21.length;
               int var25 = var18.length;
               int var26 = SpriteMask.client.getMouseX2();
               int var27 = SpriteMask.client.getMouseY2();

               int var28;
               int var29;
               int var30;
               int var31;
               int var32;
               int var33;
               int var34;
               int var35;
               int var36;
               int var37;
               for(var28 = 0; var28 < var24; ++var28) {
                  var29 = var21[var28] - var11;
                  var30 = var22[var28] - var12;
                  var31 = var23[var28] - var13;
                  var32 = var31 * var4 + var5 * var29 >> 16;
                  var33 = var5 * var31 - var29 * var4 >> 16;
                  var34 = var3 * var30 - var33 * var2 >> 16;
                  var35 = var30 * var2 + var3 * var33 >> 16;
                  if(var35 < 50) {
                     return;
                  }

                  var36 = var32 * var14 / var35 + var15;
                  var37 = var34 * var14 / var35 + var16;
                  tmpX[var28] = var36;
                  tmpY[var28] = var37;
               }

               for(var28 = 0; var28 < var25; ++var28) {
                  var29 = var18[var28];
                  var30 = var19[var28];
                  var31 = var20[var28];
                  var32 = tmpX[var29];
                  var33 = tmpX[var30];
                  var34 = tmpX[var31];
                  var35 = tmpY[var29];
                  var36 = tmpY[var30];
                  var37 = tmpY[var31];
                  if((var32 - var33) * (var37 - var36) - (var35 - var36) * (var34 - var33) > 0 && SpriteMask.client.containsBounds(var26, var27, var35, var36, var37, var32, var33, var34)) {
                     setTargetTile(var6, var7);
                     if(var8 != null && var1 == var8.getSceneTileModel() && var26 >= SpriteMask.client.getViewportXOffset() && var26 < SpriteMask.client.getViewportXOffset() + SpriteMask.client.getViewportWidth() && var27 >= SpriteMask.client.getViewportYOffset() && var27 < SpriteMask.client.getViewportYOffset() + SpriteMask.client.getViewportHeight()) {
                        hoverTile(var6, var7, var8.getPhysicalLevel());
                     }

                     return;
                  }
               }

            }
         } catch (Exception var39) {
            SpriteMask.client.getLogger().warn("error during overlay rendering", var39);
         }
      }
   }

   @ObfuscatedName("bk")
   void occlude_base() {
      int var1 = Scene_planeOccluderCounts[Scene_plane];
      Occluder[] var2 = Scene_planeOccluders[Scene_plane];
      Scene_currentOccludersCount = 0;

      for(int var3 = 0; var3 < var1; ++var3) {
         Occluder var4 = var2[var3];
         int var5;
         int var6;
         int var7;
         int var9;
         boolean var13;
         if(var4.type == 1) {
            var5 = var4.minTileX - Scene_cameraXTile + 90;
            if(var5 >= 0 && var5 <= 50) {
               var6 = var4.minTileY - Scene_cameraYTile + 90;
               if(var6 < 0) {
                  var6 = 0;
               }

               var7 = var4.maxTileY - Scene_cameraYTile + 90;
               if(var7 > 50) {
                  var7 = 50;
               }

               var13 = false;

               while(var6 <= var7) {
                  if(visibleTiles[var5][var6++]) {
                     var13 = true;
                     break;
                  }
               }

               if(var13) {
                  var9 = Scene_cameraX - var4.minX;
                  if(var9 > 32) {
                     var4.field2889 = 1;
                  } else {
                     if(var9 >= -32) {
                        continue;
                     }

                     var4.field2889 = 2;
                     var9 = -var9;
                  }

                  var4.field2893 = (var4.minZ - Scene_cameraZ << 8) / var9;
                  var4.field2894 = (var4.maxZ - Scene_cameraZ << 8) / var9;
                  var4.field2891 = (var4.minY - Scene_cameraY << 8) / var9;
                  var4.field2892 = (var4.maxY - Scene_cameraY << 8) / var9;
                  Scene_currentOccluders[Scene_currentOccludersCount++] = var4;
               }
            }
         } else if(var4.type == 2) {
            var5 = var4.minTileY - Scene_cameraYTile + 90;
            if(var5 >= 0 && var5 <= 50) {
               var6 = var4.minTileX - Scene_cameraXTile + 90;
               if(var6 < 0) {
                  var6 = 0;
               }

               var7 = var4.maxTileX - Scene_cameraXTile + 90;
               if(var7 > 50) {
                  var7 = 50;
               }

               var13 = false;

               while(var6 <= var7) {
                  if(visibleTiles[var6++][var5]) {
                     var13 = true;
                     break;
                  }
               }

               if(var13) {
                  var9 = Scene_cameraZ - var4.minZ;
                  if(var9 > 32) {
                     var4.field2889 = 3;
                  } else {
                     if(var9 >= -32) {
                        continue;
                     }

                     var4.field2889 = 4;
                     var9 = -var9;
                  }

                  var4.field2878 = (var4.minX - Scene_cameraX << 8) / var9;
                  var4.field2890 = (var4.maxX - Scene_cameraX << 8) / var9;
                  var4.field2891 = (var4.minY - Scene_cameraY << 8) / var9;
                  var4.field2892 = (var4.maxY - Scene_cameraY << 8) / var9;
                  Scene_currentOccluders[Scene_currentOccludersCount++] = var4;
               }
            }
         } else if(var4.type == 4) {
            var5 = var4.minY - Scene_cameraY;
            if(var5 > 128) {
               var6 = var4.minTileY - Scene_cameraYTile + 90;
               if(var6 < 0) {
                  var6 = 0;
               }

               var7 = var4.maxTileY - Scene_cameraYTile + 90;
               if(var7 > 50) {
                  var7 = 50;
               }

               if(var6 <= var7) {
                  int var8 = var4.minTileX - Scene_cameraXTile + 90;
                  if(var8 < 0) {
                     var8 = 0;
                  }

                  var9 = var4.maxTileX - Scene_cameraXTile + 90;
                  if(var9 > 50) {
                     var9 = 50;
                  }

                  boolean var10 = false;

                  label144:
                  for(int var11 = var8; var11 <= var9; ++var11) {
                     for(int var12 = var6; var12 <= var7; ++var12) {
                        if(visibleTiles[var11][var12]) {
                           var10 = true;
                           break label144;
                        }
                     }
                  }

                  if(var10) {
                     var4.field2889 = 5;
                     var4.field2878 = (var4.minX - Scene_cameraX << 8) / var5;
                     var4.field2890 = (var4.maxX - Scene_cameraX << 8) / var5;
                     var4.field2893 = (var4.minZ - Scene_cameraZ << 8) / var5;
                     var4.field2894 = (var4.maxZ - Scene_cameraZ << 8) / var5;
                     Scene_currentOccluders[Scene_currentOccludersCount++] = var4;
                  }
               }
            }
         }
      }

   }

   @ObfuscatedName("br")
   boolean method5374_base(int var1, int var2, int var3) {
      int var4 = this.field2799[var1][var2][var3];
      if(var4 == -Scene_drawnCount) {
         return false;
      } else if(var4 == Scene_drawnCount) {
         return true;
      } else {
         int var5 = var2 << 7;
         int var6 = var3 << 7;
         if(this.method5377_base(var5 + 1, this.tileHeights[var1][var2][var3], var6 + 1) && this.method5377_base(var5 + 128 - 1, this.tileHeights[var1][var2 + 1][var3], var6 + 1) && this.method5377_base(var5 + 128 - 1, this.tileHeights[var1][var2 + 1][var3 + 1], var6 + 128 - 1) && this.method5377_base(var5 + 1, this.tileHeights[var1][var2][var3 + 1], var6 + 128 - 1)) {
            this.field2799[var1][var2][var3] = Scene_drawnCount;
            return true;
         } else {
            this.field2799[var1][var2][var3] = -Scene_drawnCount;
            return false;
         }
      }
   }

   @ObfuscatedName("bq")
   boolean method5382_base(int var1, int var2, int var3, int var4) {
      if(!this.method5374_base(var1, var2, var3)) {
         return false;
      } else {
         int var5 = var2 << 7;
         int var6 = var3 << 7;
         int var7 = this.tileHeights[var1][var2][var3] - 1;
         int var8 = var7 - 120;
         int var9 = var7 - 230;
         int var10 = var7 - 238;
         if(var4 < 16) {
            if(var4 == 1) {
               if(var5 > Scene_cameraX) {
                  if(!this.method5377_base(var5, var7, var6)) {
                     return false;
                  }

                  if(!this.method5377_base(var5, var7, var6 + 128)) {
                     return false;
                  }
               }

               if(var1 > 0) {
                  if(!this.method5377_base(var5, var8, var6)) {
                     return false;
                  }

                  if(!this.method5377_base(var5, var8, var6 + 128)) {
                     return false;
                  }
               }

               if(!this.method5377_base(var5, var9, var6)) {
                  return false;
               }

               if(!this.method5377_base(var5, var9, var6 + 128)) {
                  return false;
               }

               return true;
            }

            if(var4 == 2) {
               if(var6 < Scene_cameraZ) {
                  if(!this.method5377_base(var5, var7, var6 + 128)) {
                     return false;
                  }

                  if(!this.method5377_base(var5 + 128, var7, var6 + 128)) {
                     return false;
                  }
               }

               if(var1 > 0) {
                  if(!this.method5377_base(var5, var8, var6 + 128)) {
                     return false;
                  }

                  if(!this.method5377_base(var5 + 128, var8, var6 + 128)) {
                     return false;
                  }
               }

               if(!this.method5377_base(var5, var9, var6 + 128)) {
                  return false;
               }

               if(!this.method5377_base(var5 + 128, var9, var6 + 128)) {
                  return false;
               }

               return true;
            }

            if(var4 == 4) {
               if(var5 < Scene_cameraX) {
                  if(!this.method5377_base(var5 + 128, var7, var6)) {
                     return false;
                  }

                  if(!this.method5377_base(var5 + 128, var7, var6 + 128)) {
                     return false;
                  }
               }

               if(var1 > 0) {
                  if(!this.method5377_base(var5 + 128, var8, var6)) {
                     return false;
                  }

                  if(!this.method5377_base(var5 + 128, var8, var6 + 128)) {
                     return false;
                  }
               }

               if(!this.method5377_base(var5 + 128, var9, var6)) {
                  return false;
               }

               if(!this.method5377_base(var5 + 128, var9, var6 + 128)) {
                  return false;
               }

               return true;
            }

            if(var4 == 8) {
               if(var6 > Scene_cameraZ) {
                  if(!this.method5377_base(var5, var7, var6)) {
                     return false;
                  }

                  if(!this.method5377_base(var5 + 128, var7, var6)) {
                     return false;
                  }
               }

               if(var1 > 0) {
                  if(!this.method5377_base(var5, var8, var6)) {
                     return false;
                  }

                  if(!this.method5377_base(var5 + 128, var8, var6)) {
                     return false;
                  }
               }

               if(!this.method5377_base(var5, var9, var6)) {
                  return false;
               }

               if(!this.method5377_base(var5 + 128, var9, var6)) {
                  return false;
               }

               return true;
            }
         }

         return !this.method5377_base(var5 + 64, var10, var6 + 64)?false:(var4 == 16?this.method5377_base(var5, var9, var6 + 128):(var4 == 32?this.method5377_base(var5 + 128, var9, var6 + 128):(var4 == 64?this.method5377_base(var5 + 128, var9, var6):(var4 == 128?this.method5377_base(var5, var9, var6):true))));
      }
   }

   @ObfuscatedName("cf")
   boolean method5375_base(int var1, int var2, int var3, int var4) {
      if(!this.method5374_base(var1, var2, var3)) {
         return false;
      } else {
         int var5 = var2 << 7;
         int var6 = var3 << 7;
         return this.method5377_base(var5 + 1, this.tileHeights[var1][var2][var3] - var4, var6 + 1) && this.method5377_base(var5 + 128 - 1, this.tileHeights[var1][var2 + 1][var3] - var4, var6 + 1) && this.method5377_base(var5 + 128 - 1, this.tileHeights[var1][var2 + 1][var3 + 1] - var4, var6 + 128 - 1) && this.method5377_base(var5 + 1, this.tileHeights[var1][var2][var3 + 1] - var4, var6 + 128 - 1);
      }
   }

   @ObfuscatedName("cg")
   boolean method5376_base(int var1, int var2, int var3, int var4, int var5, int var6) {
      int var7;
      int var8;
      if(var3 == var2 && var5 == var4) {
         if(!this.method5374_base(var1, var2, var4)) {
            return false;
         } else {
            var7 = var2 << 7;
            var8 = var4 << 7;
            return this.method5377_base(var7 + 1, this.tileHeights[var1][var2][var4] - var6, var8 + 1) && this.method5377_base(var7 + 128 - 1, this.tileHeights[var1][var2 + 1][var4] - var6, var8 + 1) && this.method5377_base(var7 + 128 - 1, this.tileHeights[var1][var2 + 1][var4 + 1] - var6, var8 + 128 - 1) && this.method5377_base(var7 + 1, this.tileHeights[var1][var2][var4 + 1] - var6, var8 + 128 - 1);
         }
      } else {
         for(var7 = var2; var7 <= var3; ++var7) {
            for(var8 = var4; var8 <= var5; ++var8) {
               if(this.field2799[var1][var7][var8] == -Scene_drawnCount) {
                  return false;
               }
            }
         }

         var7 = (var2 << 7) + 1;
         var8 = (var4 << 7) + 2;
         int var9 = this.tileHeights[var1][var2][var4] - var6;
         if(!this.method5377_base(var7, var9, var8)) {
            return false;
         } else {
            int var10 = (var3 << 7) - 1;
            if(!this.method5377_base(var10, var9, var8)) {
               return false;
            } else {
               int var11 = (var5 << 7) - 1;
               if(!this.method5377_base(var7, var9, var11)) {
                  return false;
               } else if(!this.method5377_base(var10, var9, var11)) {
                  return false;
               } else {
                  return true;
               }
            }
         }
      }
   }

   @ObfuscatedName("cv")
   boolean method5377_base(int var1, int var2, int var3) {
      for(int var4 = 0; var4 < Scene_currentOccludersCount; ++var4) {
         Occluder var5 = Scene_currentOccluders[var4];
         int var6;
         int var7;
         int var8;
         int var9;
         int var10;
         if(var5.field2889 == 1) {
            var6 = var5.minX - var1;
            if(var6 > 0) {
               var7 = (var6 * var5.field2893 >> 8) + var5.minZ;
               var8 = (var6 * var5.field2894 >> 8) + var5.maxZ;
               var9 = (var6 * var5.field2891 >> 8) + var5.minY;
               var10 = (var6 * var5.field2892 >> 8) + var5.maxY;
               if(var3 >= var7 && var3 <= var8 && var2 >= var9 && var2 <= var10) {
                  return true;
               }
            }
         } else if(var5.field2889 == 2) {
            var6 = var1 - var5.minX;
            if(var6 > 0) {
               var7 = (var6 * var5.field2893 >> 8) + var5.minZ;
               var8 = (var6 * var5.field2894 >> 8) + var5.maxZ;
               var9 = (var6 * var5.field2891 >> 8) + var5.minY;
               var10 = (var6 * var5.field2892 >> 8) + var5.maxY;
               if(var3 >= var7 && var3 <= var8 && var2 >= var9 && var2 <= var10) {
                  return true;
               }
            }
         } else if(var5.field2889 == 3) {
            var6 = var5.minZ - var3;
            if(var6 > 0) {
               var7 = (var6 * var5.field2878 >> 8) + var5.minX;
               var8 = (var6 * var5.field2890 >> 8) + var5.maxX;
               var9 = (var6 * var5.field2891 >> 8) + var5.minY;
               var10 = (var6 * var5.field2892 >> 8) + var5.maxY;
               if(var1 >= var7 && var1 <= var8 && var2 >= var9 && var2 <= var10) {
                  return true;
               }
            }
         } else if(var5.field2889 == 4) {
            var6 = var3 - var5.minZ;
            if(var6 > 0) {
               var7 = (var6 * var5.field2878 >> 8) + var5.minX;
               var8 = (var6 * var5.field2890 >> 8) + var5.maxX;
               var9 = (var6 * var5.field2891 >> 8) + var5.minY;
               var10 = (var6 * var5.field2892 >> 8) + var5.maxY;
               if(var1 >= var7 && var1 <= var8 && var2 >= var9 && var2 <= var10) {
                  return true;
               }
            }
         } else if(var5.field2889 == 5) {
            var6 = var2 - var5.minY;
            if(var6 > 0) {
               var7 = (var6 * var5.field2878 >> 8) + var5.minX;
               var8 = (var6 * var5.field2890 >> 8) + var5.maxX;
               var9 = (var6 * var5.field2893 >> 8) + var5.minZ;
               var10 = (var6 * var5.field2894 >> 8) + var5.maxZ;
               if(var1 >= var7 && var1 <= var8 && var3 >= var9 && var3 <= var10) {
                  return true;
               }
            }
         }
      }

      return false;
   }

   public void init(int var1) {
      DrawCallbacks var2 = SpriteMask.client.getDrawCallbacks();
      if(var2 != null) {
         var2.loadScene(this);
         var2.swapScene(this);
      }

   }

   public RSTile[][][] getTiles() {
      return this.tiles;
   }

   public void copy$drawTileMinimap(int[] var1, int var2, int var3, int var4, int var5, int var6) {
      Tile var7 = this.tiles[var4][var5][var6];
      if(var7 != null) {
         SceneTilePaint var8 = var7.paint;
         int var10;
         if(var8 != null) {
            int var9 = var8.rgb;
            if(var9 != 0) {
               for(var10 = 0; var10 < 4; ++var10) {
                  var1[var2] = var9;
                  var1[var2 + 1] = var9;
                  var1[var2 + 2] = var9;
                  var1[var2 + 3] = var9;
                  var2 += var3;
               }

            }
         } else {
            SceneTileModel var18 = var7.model;
            if(var18 != null) {
               var10 = var18.shape;
               int var11 = var18.rotation;
               int var12 = var18.underlayRgb;
               int var13 = var18.overlayRgb;
               int[] var14 = this.tileShape2D[var10];
               int[] var15 = this.tileRotation2D[var11];
               int var16 = 0;
               int var17;
               if(var12 != 0) {
                  for(var17 = 0; var17 < 4; ++var17) {
                     var1[var2] = var14[var15[var16++]] == 0?var12:var13;
                     var1[var2 + 1] = var14[var15[var16++]] == 0?var12:var13;
                     var1[var2 + 2] = var14[var15[var16++]] == 0?var12:var13;
                     var1[var2 + 3] = var14[var15[var16++]] == 0?var12:var13;
                     var2 += var3;
                  }
               } else {
                  for(var17 = 0; var17 < 4; ++var17) {
                     if(var14[var15[var16++]] != 0) {
                        var1[var2] = var13;
                     }

                     if(var14[var15[var16++]] != 0) {
                        var1[var2 + 1] = var13;
                     }

                     if(var14[var15[var16++]] != 0) {
                        var1[var2 + 2] = var13;
                     }

                     if(var14[var15[var16++]] != 0) {
                        var1[var2 + 3] = var13;
                     }

                     var2 += var3;
                  }
               }

            }
         }
      }
   }

   @ObfuscatedSignature(
      descriptor = "(IIIIIIIILkt;IZJI)Z"
   )
   public boolean copy$newGameObject(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, Renderable var9, int var10, boolean var11, long var12, int var14) {
      int var16;
      for(int var15 = var2; var15 < var2 + var4; ++var15) {
         for(var16 = var3; var16 < var3 + var5; ++var16) {
            if(var15 < 0 || var16 < 0 || var15 >= this.xSize || var16 >= this.ySize) {
               return false;
            }

            Tile var17 = this.tiles[var1][var15][var16];
            if(var17 != null && var17.gameObjectsCount >= 5) {
               return false;
            }
         }
      }

      GameObject var21 = new GameObject();
      var21.tag = var12;
      var21.flags = var14;
      var21.plane = var1;
      var21.centerX = var6;
      var21.centerY = var7;
      var21.z = var8;
      var21.renderable = var9;
      var21.orientation = var10;
      var21.startX = var2;
      var21.startY = var3;
      var21.endX = var2 + var4 - 1;
      var21.endY = var3 + var5 - 1;

      for(var16 = var2; var16 < var2 + var4; ++var16) {
         for(int var22 = var3; var22 < var3 + var5; ++var22) {
            int var18 = 0;
            if(var16 > var2) {
               ++var18;
            }

            if(var16 < var2 + var4 - 1) {
               var18 += 4;
            }

            if(var22 > var3) {
               var18 += 8;
            }

            if(var22 < var3 + var5 - 1) {
               var18 += 2;
            }

            for(int var19 = var1; var19 >= 0; --var19) {
               if(this.tiles[var19][var16][var22] == null) {
                  this.tiles[var19][var16][var22] = new Tile(var19, var16, var22);
               }
            }

            Tile var23 = this.tiles[var1][var16][var22];
            var23.gameObjects[var23.gameObjectsCount] = var21;
            var23.gameObjectsChanged(var23.gameObjectsCount);
            var23.gameObjectEdgeMasks[var23.gameObjectsCount] = var18;
            var23.gameObjectsEdgeMask |= var18;
            ++var23.gameObjectsCount;
         }
      }

      if(var11) {
         this.tempGameObjects[this.tempGameObjectsCount++] = var21;
      }

      return true;
   }

   public void initEnd(int var1) {
      this.rl$extendedTiles = new RSTile[4][184][184];
      this.rl$extendedTileSettings = new byte[4][184][184];

      for(int var2 = 0; var2 < 4; ++var2) {
         for(int var3 = 0; var3 < 104; ++var3) {
            for(int var4 = 0; var4 < 104; ++var4) {
               RSTile var5 = this.getTiles()[var2][var3][var4];
               if(var5 != null) {
                  this.rl$extendedTiles[var2][var3][var4] = var5;
                  this.rl$extendedTileSettings[var2][var3][var4] = SpriteMask.client.getTileSettings()[var2][var3][var4];
               }
            }
         }
      }

   }

   public void rl$addTile(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9, int var10, int var11, int var12, int var13, int var14, int var15, int var16, int var17, int var18, int var19, int var20) {
      if(var4 != 0 && var4 != 1) {
         RSTile var21 = this.getTiles()[var1][var2][var3];
         net.runelite.api.SceneTileModel var22 = var21.getSceneTileModel();
         var22.setUnderlaySwColor(var11);
         var22.setUnderlayNwColor(var12);
         var22.setUnderlayNeColor(var13);
         var22.setUnderlaySeColor(var14);
         var22.setOverlaySwColor(var15);
         var22.setOverlayNwColor(var16);
         var22.setOverlayNeColor(var17);
         var22.setOverlaySeColor(var18);
      }

   }

   @ObfuscatedSignature(
      descriptor = "(Lke;IIIIIII)V"
   )
   public void copy$drawTileUnderlay(SceneTilePaint var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8) {
      int var9;
      int var10 = var9 = (var7 << 7) - Scene_cameraX;
      int var11;
      int var12 = var11 = (var8 << 7) - Scene_cameraZ;
      int var13;
      int var14 = var13 = var10 + 128;
      int var15;
      int var16 = var15 = var12 + 128;
      int var17 = this.tileHeights[var2][var7][var8] - Scene_cameraY;
      int var18 = this.tileHeights[var2][var7 + 1][var8] - Scene_cameraY;
      int var19 = this.tileHeights[var2][var7 + 1][var8 + 1] - Scene_cameraY;
      int var20 = this.tileHeights[var2][var7][var8 + 1] - Scene_cameraY;
      int var21 = var10 * var6 + var5 * var12 >> 16;
      var12 = var12 * var6 - var5 * var10 >> 16;
      var10 = var21;
      var21 = var17 * var4 - var3 * var12 >> 16;
      var12 = var12 * var4 + var3 * var17 >> 16;
      var17 = var21;
      if(var12 >= 50) {
         var21 = var14 * var6 + var5 * var11 >> 16;
         var11 = var11 * var6 - var5 * var14 >> 16;
         var14 = var21;
         var21 = var18 * var4 - var3 * var11 >> 16;
         var11 = var11 * var4 + var3 * var18 >> 16;
         var18 = var21;
         if(var11 >= 50) {
            var21 = var13 * var6 + var5 * var16 >> 16;
            var16 = var16 * var6 - var5 * var13 >> 16;
            var13 = var21;
            var21 = var19 * var4 - var3 * var16 >> 16;
            var16 = var16 * var4 + var3 * var19 >> 16;
            var19 = var21;
            if(var16 >= 50) {
               var21 = var9 * var6 + var5 * var15 >> 16;
               var15 = var15 * var6 - var5 * var9 >> 16;
               var9 = var21;
               var21 = var20 * var4 - var3 * var15 >> 16;
               var15 = var15 * var4 + var3 * var20 >> 16;
               if(var15 >= 50) {
                  int var22 = Rasterizer3D.getClipMidX_base() + var10 * Rasterizer3D.get3dZoom_base() / var12;
                  int var23 = Rasterizer3D.getClipMidY_base() + var17 * Rasterizer3D.get3dZoom_base() / var12;
                  int var24 = Rasterizer3D.getClipMidX_base() + var14 * Rasterizer3D.get3dZoom_base() / var11;
                  int var25 = Rasterizer3D.getClipMidY_base() + var18 * Rasterizer3D.get3dZoom_base() / var11;
                  int var26 = Rasterizer3D.getClipMidX_base() + var13 * Rasterizer3D.get3dZoom_base() / var16;
                  int var27 = Rasterizer3D.getClipMidY_base() + var19 * Rasterizer3D.get3dZoom_base() / var16;
                  int var28 = Rasterizer3D.getClipMidX_base() + var9 * Rasterizer3D.get3dZoom_base() / var15;
                  int var29 = Rasterizer3D.getClipMidY_base() + var21 * Rasterizer3D.get3dZoom_base() / var15;
                  float var30 = WorldMapAreaData.method5039_base(var12);
                  float var31 = WorldMapAreaData.method5039_base(var11);
                  float var32 = WorldMapAreaData.method5039_base(var16);
                  float var33 = WorldMapAreaData.method5039_base(var15);
                  Rasterizer3D.clips.field3051 = 0;
                  int var34;
                  int var35;
                  if((var26 - var28) * (var25 - var29) - (var27 - var29) * (var24 - var28) > 0) {
                     Rasterizer3D.clips.field3036 = false;
                     var34 = Rasterizer3D.method5237_base();
                     if(var26 < 0 || var28 < 0 || var24 < 0 || var26 > var34 || var28 > var34 || var24 > var34) {
                        Rasterizer3D.clips.field3036 = true;
                     }

                     if(checkClick && containsBounds_base(Scene_selectedScreenX, Scene_selectedScreenY, var27, var29, var25, var26, var28, var24)) {
                        Scene_selectedX = var7;
                        Scene_selectedY = var8;
                     }

                     if(var1.texture == -1) {
                        if(var1.neColor != 12345678) {
                           Rasterizer3D.rasterGouraud_base(var27, var29, var25, var26, var28, var24, var32, var33, var31, var1.neColor, var1.nwColor, var1.seColor);
                        }
                     } else if(!Scene_isLowDetail) {
                        if(var1.isFlat) {
                           Rasterizer3D.method5211_base(var27, var29, var25, var26, var28, var24, var32, var33, var31, var1.neColor, var1.nwColor, var1.seColor, var10, var14, var9, var17, var18, var21, var12, var11, var15, var1.texture);
                        } else {
                           Rasterizer3D.method5211_base(var27, var29, var25, var26, var28, var24, var32, var33, var31, var1.neColor, var1.nwColor, var1.seColor, var13, var9, var14, var19, var21, var18, var16, var15, var11, var1.texture);
                        }
                     } else {
                        var35 = Rasterizer3D.clips.Rasterizer3D_textureLoader.getAverageTextureRGB_base(var1.texture);
                        Rasterizer3D.rasterGouraud_base(var27, var29, var25, var26, var28, var24, var32, var33, var31, method5370_base(var35, var1.neColor), method5370_base(var35, var1.nwColor), method5370_base(var35, var1.seColor));
                     }
                  }

                  if((var22 - var24) * (var29 - var25) - (var23 - var25) * (var28 - var24) > 0) {
                     Rasterizer3D.clips.field3036 = false;
                     var34 = Rasterizer3D.method5237_base();
                     if(var22 < 0 || var24 < 0 || var28 < 0 || var22 > var34 || var24 > var34 || var28 > var34) {
                        Rasterizer3D.clips.field3036 = true;
                     }

                     if(checkClick && containsBounds_base(Scene_selectedScreenX, Scene_selectedScreenY, var23, var25, var29, var22, var24, var28)) {
                        Scene_selectedX = var7;
                        Scene_selectedY = var8;
                     }

                     if(var1.texture == -1) {
                        if(var1.swColor != 12345678) {
                           Rasterizer3D.rasterGouraud_base(var23, var25, var29, var22, var24, var28, var30, var31, var33, var1.swColor, var1.seColor, var1.nwColor);
                        }
                     } else if(!Scene_isLowDetail) {
                        Rasterizer3D.method5211_base(var23, var25, var29, var22, var24, var28, var30, var31, var33, var1.swColor, var1.seColor, var1.nwColor, var10, var14, var9, var17, var18, var21, var12, var11, var15, var1.texture);
                     } else {
                        var35 = Rasterizer3D.clips.Rasterizer3D_textureLoader.getAverageTextureRGB_base(var1.texture);
                        Rasterizer3D.rasterGouraud_base(var23, var25, var29, var22, var24, var28, var30, var31, var33, method5370_base(var35, var1.swColor), method5370_base(var35, var1.seColor), method5370_base(var35, var1.nwColor));
                     }
                  }

               }
            }
         }
      }
   }

   @ObfuscatedSignature(
      descriptor = "(Lkl;IIIIII)V"
   )
   public void copy$drawTileOverlay(SceneTileModel var1, int var2, int var3, int var4, int var5, int var6, int var7) {
      int var8 = var1.vertexX.length;

      int var9;
      int var10;
      int var11;
      int var12;
      int var13;
      for(var9 = 0; var9 < var8; ++var9) {
         var10 = var1.vertexX[var9] - Scene_cameraX;
         var11 = var1.vertexY[var9] - Scene_cameraY;
         var12 = var1.vertexZ[var9] - Scene_cameraZ;
         var13 = var12 * var4 + var5 * var10 >> 16;
         var12 = var5 * var12 - var10 * var4 >> 16;
         var10 = var13;
         var13 = var3 * var11 - var12 * var2 >> 16;
         var12 = var11 * var2 + var3 * var12 >> 16;
         if(var12 < 50) {
            return;
         }

         if(var1.triangleTextureId != null) {
            SceneTileModel.field2924[var9] = var10;
            SceneTileModel.field2925[var9] = var13;
            SceneTileModel.field2906[var9] = var12;
         }

         SceneTileModel.field2907[var9] = Rasterizer3D.getClipMidX_base() + var10 * Rasterizer3D.get3dZoom_base() / var12;
         SceneTileModel.field2923[var9] = Rasterizer3D.getClipMidY_base() + var13 * Rasterizer3D.get3dZoom_base() / var12;
         SceneTileModel.field2921[var9] = WorldMapAreaData.method5039_base(var12);
      }

      Rasterizer3D.clips.field3051 = 0;
      var8 = var1.faceX.length;

      for(var9 = 0; var9 < var8; ++var9) {
         var10 = var1.faceX[var9];
         var11 = var1.faceY[var9];
         var12 = var1.faceZ[var9];
         var13 = SceneTileModel.field2907[var10];
         int var14 = SceneTileModel.field2907[var11];
         int var15 = SceneTileModel.field2907[var12];
         int var16 = SceneTileModel.field2923[var10];
         int var17 = SceneTileModel.field2923[var11];
         int var18 = SceneTileModel.field2923[var12];
         float var19 = SceneTileModel.field2921[var10];
         float var20 = SceneTileModel.field2921[var11];
         float var21 = SceneTileModel.field2921[var12];
         if((var13 - var14) * (var18 - var17) - (var16 - var17) * (var15 - var14) > 0) {
            Rasterizer3D.clips.field3036 = false;
            int var22 = Rasterizer3D.method5237_base();
            if(var13 < 0 || var14 < 0 || var15 < 0 || var13 > var22 || var14 > var22 || var15 > var22) {
               Rasterizer3D.clips.field3036 = true;
            }

            if(checkClick && containsBounds_base(Scene_selectedScreenX, Scene_selectedScreenY, var16, var17, var18, var13, var14, var15)) {
               Scene_selectedX = var6;
               Scene_selectedY = var7;
            }

            if(var1.triangleTextureId != null && var1.triangleTextureId[var9] != -1) {
               if(!Scene_isLowDetail) {
                  if(var1.isFlat) {
                     Rasterizer3D.method5211_base(var16, var17, var18, var13, var14, var15, var19, var20, var21, var1.triangleColorA[var9], var1.triangleColorB[var9], var1.triangleColorC[var9], SceneTileModel.field2924[0], SceneTileModel.field2924[1], SceneTileModel.field2924[3], SceneTileModel.field2925[0], SceneTileModel.field2925[1], SceneTileModel.field2925[3], SceneTileModel.field2906[0], SceneTileModel.field2906[1], SceneTileModel.field2906[3], var1.triangleTextureId[var9]);
                  } else {
                     Rasterizer3D.method5211_base(var16, var17, var18, var13, var14, var15, var19, var20, var21, var1.triangleColorA[var9], var1.triangleColorB[var9], var1.triangleColorC[var9], SceneTileModel.field2924[var10], SceneTileModel.field2924[var11], SceneTileModel.field2924[var12], SceneTileModel.field2925[var10], SceneTileModel.field2925[var11], SceneTileModel.field2925[var12], SceneTileModel.field2906[var10], SceneTileModel.field2906[var11], SceneTileModel.field2906[var12], var1.triangleTextureId[var9]);
                  }
               } else {
                  int var23 = Rasterizer3D.clips.Rasterizer3D_textureLoader.getAverageTextureRGB_base(var1.triangleTextureId[var9]);
                  Rasterizer3D.rasterGouraud_base(var16, var17, var18, var13, var14, var15, var19, var20, var21, method5370_base(var23, var1.triangleColorA[var9]), method5370_base(var23, var1.triangleColorB[var9]), method5370_base(var23, var1.triangleColorC[var9]));
               }
            } else if(var1.triangleColorA[var9] != 12345678) {
               Rasterizer3D.rasterGouraud_base(var16, var17, var18, var13, var14, var15, var19, var20, var21, var1.triangleColorA[var9], var1.triangleColorB[var9], var1.triangleColorC[var9]);
            }
         }
      }

   }

   public int[][][] getTileHeights() {
      return this.tileHeights;
   }

   public int[][] getTileShape2D() {
      return this.tileShape2D;
   }

   public boolean newGameObject(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, RSRenderable var9, int var10, boolean var11, long var12, int var14) {
      return this.method5435(var1, var2, var3, var4, var5, var6, var7, var8, (Renderable)var9, var10, var11, var12, var14);
   }

   public int[][] getTileRotation2D() {
      return this.tileRotation2D;
   }

   public void iterateDeque(net.runelite.api.Tile var1, int var2) {
      RSTile[][][] var3 = this.getTiles();
      RSNodeDeque var4 = SpriteMask.client.getTilesDeque();
      var4.addFirst((RSNode)var1);

      RSTile var5;
      while((var5 = (RSTile)var4.removeLast()) != null) {
         int var6 = var5.getX();
         int var7 = var5.getY();
         int var8 = var5.getPlane();
         if(rl$tiles[var8][var6][var7] == 0) {
            if(blocking(var8, var6, var7)) {
               neighbourTile(var4, var3, var8, var6 - 1, var7);
               neighbourTile(var4, var3, var8, var6 + 1, var7);
               neighbourTile(var4, var3, var8, var6, var7 - 1);
               neighbourTile(var4, var3, var8, var6, var7 + 1);
               neighbourTile(var4, var3, var8, var6 - 1, var7 - 1);
               neighbourTile(var4, var3, var8, var6 + 1, var7 - 1);
               neighbourTile(var4, var3, var8, var6 - 1, var7 + 1);
               neighbourTile(var4, var3, var8, var6 + 1, var7 + 1);
            }

            rl$tiles[var8][var6][var7] = var2;
         }
      }

   }

   public int getMaxX() {
      return this.xSize;
   }

   public int getMaxY() {
      return this.planes;
   }

   public int getMaxZ() {
      return this.ySize;
   }

   public int getMinLevel() {
      return this.minPlane;
   }

   public void updateOccluders() {
      this.occlude_base();
   }

   public void draw(net.runelite.api.Tile var1, boolean var2) {
      this.method5450((Tile)var1, var2);
   }

   @ObfuscatedSignature(
      descriptor = "(IIIIILkt;IJZ)Z"
   )
   public boolean copy$drawEntity(int var1, int var2, int var3, int var4, int var5, Renderable var6, int var7, long var8, boolean var10) {
      if(var6 == null) {
         return true;
      } else {
         int var11 = var2 - var5;
         int var12 = var3 - var5;
         int var13 = var5 + var2;
         int var14 = var3 + var5;
         if(var10) {
            if(var7 > 640 && var7 < 1408) {
               var14 += 128;
            }

            if(var7 > 1152 && var7 < 1920) {
               var13 += 128;
            }

            if(var7 > 1664 || var7 < 384) {
               var12 -= 128;
            }

            if(var7 > 128 && var7 < 896) {
               var11 -= 128;
            }
         }

         var11 /= 128;
         var12 /= 128;
         var13 /= 128;
         var14 /= 128;
         return this.method5435(var1, var11, var12, var13 - var11 + 1, var14 - var12 + 1, var2, var3, var4, var6, var7, true, var8, 0);
      }
   }

   public int getDrawDistance() {
      return rl$drawDistance;
   }

   public void setDrawDistance(int var1) {
      rl$drawDistance = var1;
   }

   public void addItem(int var1, int var2, WorldPoint var3) {
      int var4 = var3.getX() - SpriteMask.client.getBaseX();
      int var5 = var3.getY() - SpriteMask.client.getBaseY();
      int var6 = var3.getPlane();
      if(var4 >= 0 && var5 >= 0 && var4 < 104 && var5 < 104) {
         RSTileItem var7 = SpriteMask.client.newTileItem();
         var7.setId(var1);
         var7.setQuantity(var2);
         RSNodeDeque[][][] var8 = SpriteMask.client.getGroundItemDeque();
         if(var8[var6][var4][var5] == null) {
            var8[var6][var4][var5] = SpriteMask.client.newNodeDeque();
         }

         var8[var6][var4][var5].addFirst(var7);
         if(var6 == SpriteMask.client.getPlane()) {
            SpriteMask.client.updateItemPile(var4, var5);
         }

      }
   }

   public void removeItem(int var1, int var2, WorldPoint var3) {
      int var4 = var3.getX() - SpriteMask.client.getBaseX();
      int var5 = var3.getY() - SpriteMask.client.getBaseY();
      int var6 = var3.getPlane();
      if(var4 >= 0 && var5 >= 0 && var4 < 104 && var5 < 104) {
         RSNodeDeque var7 = SpriteMask.client.getGroundItemDeque()[var6][var4][var5];
         if(var7 != null) {
            for(RSTileItem var8 = (RSTileItem)var7.last(); var8 != null; var8 = (RSTileItem)var7.previous()) {
               if(var8.getId() == var1 && var2 == 1) {
                  var8.unlink();
                  break;
               }
            }

            if(var7.last() == null) {
               SpriteMask.client.getGroundItemDeque()[var6][var4][var5] = null;
            }

            SpriteMask.client.updateItemPile(var4, var5);
         }
      }
   }

   public void setRoofRemovalMode(int var1) {
      rl$roofRemovalMode = var1;
   }

   public void generateHouses() {
      rl$tiles = new int[4][104][104];
      RSTile[][][] var1 = this.getTiles();
      int var2 = 1;

      for(int var3 = 0; var3 < 4; ++var3) {
         for(int var4 = 0; var4 < 104; ++var4) {
            for(int var5 = 0; var5 < 104; ++var5) {
               RSTile var6 = var1[var3][var5][var4];
               if(var6 != null && rl$tiles[var3][var5][var4] == 0 && blocking(var3, var5, var4)) {
                  this.iterateDeque(var6, var2);
                  ++var2;
               }
            }
         }
      }

   }

   public short[][][] getUnderlayIds() {
      return rl$underlayIds;
   }

   public void setUnderlayIds(short[][][] var1) {
      rl$underlayIds = var1;
   }

   public short[][][] getOverlayIds() {
      return rl$overlayIds;
   }

   public void setOverlayIds(short[][][] var1) {
      rl$overlayIds = var1;
   }

   public byte[][][] getTileShapes() {
      return rl$tileShapes;
   }

   public void setTileShapes(byte[][][] var1) {
      rl$tileShapes = var1;
   }

   public void removeWallObject(WallObject var1) {
      RSTile[][][] var2 = this.getTiles();

      for(int var3 = 0; var3 < 104; ++var3) {
         for(int var4 = 0; var4 < 104; ++var4) {
            RSTile var5 = var2[SpriteMask.client.getPlane()][var4][var3];
            if(var5 != null && var5.getWallObject() == var1) {
               var5.setWallObject((WallObject)null);
            }
         }
      }

   }

   public void removeDecorativeObject(DecorativeObject var1) {
      RSTile[][][] var2 = this.getTiles();

      for(int var3 = 0; var3 < 104; ++var3) {
         for(int var4 = 0; var4 < 104; ++var4) {
            RSTile var5 = var2[SpriteMask.client.getPlane()][var4][var3];
            if(var5 != null && var5.getDecorativeObject() == var1) {
               var5.setDecorativeObject((DecorativeObject)null);
            }
         }
      }

   }

   public void removeGroundObject(GroundObject var1) {
      RSTile[][][] var2 = this.getTiles();

      for(int var3 = 0; var3 < 104; ++var3) {
         for(int var4 = 0; var4 < 104; ++var4) {
            RSTile var5 = var2[SpriteMask.client.getPlane()][var4][var3];
            if(var5 != null && var5.getGroundObject() == var1) {
               var5.setGroundObject((GroundObject)null);
            }
         }
      }

   }

   public net.runelite.api.Tile[][][] getExtendedTiles() {
      return this.rl$extendedTiles;
   }

   public byte[][][] getExtendedTileSettings() {
      return this.rl$extendedTileSettings;
   }

   public boolean isInstance() {
      return Client.isInInstance;
   }

   public int[][][] getInstanceTemplateChunks() {
      return Client.instanceChunkTemplates;
   }

   public int getBaseX() {
      return NpcOverrides.baseX;
   }

   public void setMinLevel(int var1) {
      this.minPlane = var1;
   }

   public RSGameObject[] getObjects() {
      return this.tempGameObjects;
   }

   public void newGroundItemPile(int var1, int var2, int var3, int var4, RSRenderable var5, long var6, RSRenderable var8, RSRenderable var9) {
      this.method5331(var1, var2, var3, var4, (Renderable)var5, var6, (Renderable)var8, (Renderable)var9);
   }

   public boolean drawEntity(int var1, int var2, int var3, int var4, int var5, net.runelite.api.Renderable var6, int var7, long var8, boolean var10) {
      return this.method5444(var1, var2, var3, var4, var5, (Renderable)var6, var7, var8, var10);
   }

   public void removeGameObject(net.runelite.api.GameObject var1) {
      this.method5400((GameObject)var1);
   }

   public void removeWallObject(int var1, int var2, int var3) {
      this.removeBoundaryObject_base(var1, var2, var3);
   }

   public void removeDecorativeObject(int var1, int var2, int var3) {
      this.removeWallDecoration_base(var1, var2, var3);
   }

   public void removeGameObject(int var1, int var2, int var3) {
      this.removeGameObject_base(var1, var2, var3);
   }

   public void removeGroundObject(int var1, int var2, int var3) {
      this.removeFloorDecoration_base(var1, var2, var3);
   }

   public void drawTile(int[] var1, int var2, int var3, int var4, int var5, int var6) {
      this.drawTileMinimap_base(var1, var2, var3, var4, var5, var6);
   }

   public void menuOpen(int var1, int var2, int var3, boolean var4) {
      this.menuOpen_base(var1, var2, var3, var4);
   }

   public int getBaseY() {
      return class101.baseY;
   }

   @ObfuscatedName("ao")
   public static void Scene_addOccluder_base(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7) {
      Occluder var8 = new Occluder();
      var8.minTileX = var2 / 128;
      var8.maxTileX = var3 / 128;
      var8.minTileY = var4 / 128;
      var8.maxTileY = var5 / 128;
      var8.type = var1;
      var8.minX = var2;
      var8.maxX = var3;
      var8.minZ = var4;
      var8.maxZ = var5;
      var8.minY = var6;
      var8.maxY = var7;
      Scene_planeOccluders[var0][Scene_planeOccluderCounts[var0]++] = var8;
   }

   @ObfuscatedName("bj")
   public static void Scene_buildVisiblityMap_base(int[] var0, int var1, int var2, int var3, int var4) {
      Scene_viewportXMin = 0;
      Scene_viewportYMin = 0;
      Scene_viewportXMax = var3;
      Scene_viewportYMax = var4;
      Scene_viewportXCenter = var3 / 2;
      Scene_viewportYCenter = var4 / 2;
      boolean[][][][] var5 = new boolean[var0.length][32][53][53];

      int var6;
      int var7;
      int var8;
      int var9;
      int var11;
      int var12;
      for(var6 = 128; var6 <= 383; var6 += 32) {
         for(var7 = 0; var7 < 2048; var7 += 64) {
            Scene_cameraPitchSine = Rasterizer3D.Rasterizer3D_sine[var6];
            Scene_cameraPitchCosine = Rasterizer3D.Rasterizer3D_cosine[var6];
            Scene_cameraYawSine = Rasterizer3D.Rasterizer3D_sine[var7];
            Scene_cameraYawCosine = Rasterizer3D.Rasterizer3D_cosine[var7];
            var8 = (var6 - 128) / 32;
            var9 = var7 / 64;

            for(int var10 = -26; var10 < 26; ++var10) {
               for(var11 = -26; var11 < 26; ++var11) {
                  var12 = var10 * 128;
                  int var13 = var11 * 128;
                  boolean var14 = false;

                  for(int var15 = -var1; var15 <= var2; var15 += 128) {
                     if(method5361_base(var12, var0[var8] + var15, var13)) {
                        var14 = true;
                        break;
                     }
                  }

                  var5[var8][var9][var10 + 1 + 25][var11 + 1 + 25] = var14;
               }
            }
         }
      }

      for(var6 = 0; var6 < 8; ++var6) {
         for(var7 = 0; var7 < 32; ++var7) {
            for(var8 = -25; var8 < 25; ++var8) {
               for(var9 = -25; var9 < 25; ++var9) {
                  boolean var16 = false;

                  label76:
                  for(var11 = -1; var11 <= 1; ++var11) {
                     for(var12 = -1; var12 <= 1; ++var12) {
                        if(var5[var6][var7][var8 + var11 + 1 + 25][var9 + var12 + 1 + 25]) {
                           var16 = true;
                           break label76;
                        }

                        if(var5[var6][(var7 + 1) % 31][var8 + var11 + 1 + 25][var9 + var12 + 1 + 25]) {
                           var16 = true;
                           break label76;
                        }

                        if(var5[var6 + 1][var7][var8 + var11 + 1 + 25][var9 + var12 + 1 + 25]) {
                           var16 = true;
                           break label76;
                        }

                        if(var5[var6 + 1][(var7 + 1) % 31][var8 + var11 + 1 + 25][var9 + var12 + 1 + 25]) {
                           var16 = true;
                           break label76;
                        }
                     }
                  }

                  visibilityMap[var6][var7][var8 + 25][var9 + 25] = var16;
               }
            }
         }
      }

   }

   @ObfuscatedName("bn")
   static boolean method5361_base(int var0, int var1, int var2) {
      int var3 = var0 * Scene_cameraYawCosine + var2 * Scene_cameraYawSine >> 16;
      int var4 = var2 * Scene_cameraYawCosine - var0 * Scene_cameraYawSine >> 16;
      int var5 = var4 * Scene_cameraPitchCosine + Scene_cameraPitchSine * var1 >> 16;
      int var6 = Scene_cameraPitchCosine * var1 - var4 * Scene_cameraPitchSine >> 16;
      if(var5 >= 50 && var5 <= 3500) {
         int var7 = var3 * 128 / var5 + Scene_viewportXCenter;
         int var8 = var6 * 128 / var5 + Scene_viewportYCenter;
         return var7 >= Scene_viewportXMin && var7 <= Scene_viewportXMax && var8 >= Scene_viewportYMin && var8 <= Scene_viewportYMax;
      } else {
         return false;
      }
   }

   @ObfuscatedName("bu")
   public static boolean shouldSendWalk_base() {
      return viewportWalking && Scene_selectedX != -1;
   }

   @ObfuscatedName("by")
   public static void method5365_base() {
      Scene_selectedX = -1;
      viewportWalking = false;
   }

   @ObfuscatedName("bx")
   static final int method5370_base(int var0, int var1) {
      var1 = (var0 & 127) * var1 >> 7;
      if(var1 < 2) {
         var1 = 2;
      } else if(var1 > 126) {
         var1 = 126;
      }

      return (var0 & 65408) + var1;
   }

   @ObfuscatedName("bb")
   static boolean containsBounds_base(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7) {
      if(var1 < var2 && var1 < var3 && var1 < var4) {
         return false;
      } else if(var1 > var2 && var1 > var3 && var1 > var4) {
         return false;
      } else if(var0 < var5 && var0 < var6 && var0 < var7) {
         return false;
      } else if(var0 > var5 && var0 > var6 && var0 > var7) {
         return false;
      } else {
         int var8 = (var1 - var2) * (var6 - var5) - (var0 - var5) * (var3 - var2);
         int var9 = (var7 - var6) * (var1 - var3) - (var0 - var6) * (var4 - var3);
         int var10 = (var5 - var7) * (var1 - var4) - (var2 - var4) * (var0 - var7);
         return var8 == 0?(var9 != 0?(var9 < 0?var10 <= 0:var10 >= 0):true):(var8 < 0?var9 <= 0 && var10 <= 0:var9 >= 0 && var10 >= 0);
      }
   }

   public static boolean blocking(int var0, int var1, int var2) {
      return (SpriteMask.client.getTileSettings()[var0][var1][var2] & 4) != 0;
   }

   public static void neighbourTile(RSNodeDeque var0, net.runelite.api.Tile[][][] var1, int var2, int var3, int var4) {
      if(var3 >= 0 && var3 < 104 && var4 >= 0 && var4 < 104) {
         net.runelite.api.Tile var5 = var1[var2][var3][var4];
         if(var5 != null) {
            var0.addFirst((RSNode)var5);
         }
      }

   }

   public static void renderDraw(net.runelite.api.Renderable var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, long var9) {
      DrawCallbacks var11 = SpriteMask.client.getDrawCallbacks();
      if(var11 != null) {
         var11.draw(var0, var1, var2, var3, var4, var5, var6, var7, var8, var9);
      } else {
         var0.draw(var1, var2, var3, var4, var5, var6, var7, var8, var9);
      }

   }

   public static void setTargetTile(int var0, int var1) {
      SpriteMask.client.setSelectedSceneTileX(var0);
      SpriteMask.client.setSelectedSceneTileY(var1);
   }

   public static void hoverTile(int var0, int var1, int var2) {
      if(var2 == SpriteMask.client.getPlane() && !SpriteMask.client.isMenuOpen()) {
         rl$hoverX = var0;
         rl$hoverY = var1;
      }

   }

   @ObfuscatedSignature(
      descriptor = "(Ldf;IIIIIS)V",
      garbageValue = "-15628"
   )
   public static final void copy$drawActor2d(Actor var0, int var1, int var2, int var3, int var4, int var5, short var6) {
      if(var0 != null && var0.isVisible_base()) {
         if(var0 instanceof NPC) {
            NPCComposition var7 = ((NPC)var0).definition;
            if(var7.transforms != null) {
               var7 = var7.method3698();
            }

            if(var7 == null) {
               return;
            }
         }

         int var76 = Players.Players_count;
         int[] var8 = Players.Players_indices;
         boolean var9 = var1 < var76;
         int var10 = -2;
         if(var0.overheadText != null && (!var9 || !var0.field1174 && (Client.publicChatMode == 4 || !var0.field1206 && (Client.publicChatMode == 0 || Client.publicChatMode == 3 || Client.publicChatMode == 1 && ((Player)var0).isFriend_base())))) {
            Canvas.method331(var0, var0.defaultHeight);
            if(Client.viewportTempX > -1 && Client.overheadTextCount < Client.overheadTextLimit) {
               Client.overheadTextXOffsets[Client.overheadTextCount] = GrandExchangeOfferTotalQuantityComparator.fontBold12.stringWidth_base(var0.overheadText) / 2;
               Client.overheadTextAscents[Client.overheadTextCount] = GrandExchangeOfferTotalQuantityComparator.fontBold12.ascent;
               Client.overheadTextXs[Client.overheadTextCount] = Client.viewportTempX;
               Client.overheadTextYs[Client.overheadTextCount] = Client.viewportTempY - var10;
               Client.overheadTextColors[Client.overheadTextCount] = var0.field1196;
               Client.overheadTextEffects[Client.overheadTextCount] = var0.field1197;
               Client.overheadTextCyclesRemaining[Client.overheadTextCount] = var0.overheadTextCyclesRemaining;
               Client.field597[Client.overheadTextCount] = var0.field1236;
               Client.overheadText[Client.overheadTextCount] = var0.overheadText;
               ++Client.overheadTextCount;
               var10 += 12;
            }
         }

         int var16;
         int var23;
         int var24;
         if(!var0.healthBars.method7350_base()) {
            Canvas.method331(var0, var0.defaultHeight + 15);

            for(HealthBar var11 = (HealthBar)var0.healthBars.method7290(); var11 != null; var11 = (HealthBar)var0.healthBars.method7292()) {
               HealthBarUpdate var12 = var11.method2648(Client.cycle);
               if(var12 == null) {
                  if(var11.isEmpty_base()) {
                     var11.remove_base();
                  }
               } else {
                  HealthBarDefinition var13 = var11.definition;
                  SpritePixels var14 = var13.method3635();
                  SpritePixels var15 = var13.method3634();
                  int var17 = 0;
                  if(var14 != null && var15 != null) {
                     if(var13.widthPadding * 2 < var15.subWidth) {
                        var17 = var13.widthPadding;
                     }

                     var16 = var15.subWidth - var17 * 2;
                  } else {
                     var16 = var13.width;
                  }

                  int var18 = 255;
                  boolean var19 = true;
                  int var20 = Client.cycle - var12.cycle;
                  int var21 = var16 * var12.health2 / var13.width;
                  int var22;
                  int var100;
                  if(var12.cycleOffset > var20) {
                     var22 = var13.field1874 == 0?0:var13.field1874 * (var20 / var13.field1874);
                     var23 = var16 * var12.health / var13.width;
                     var100 = var22 * (var21 - var23) / var12.cycleOffset + var23;
                  } else {
                     var100 = var21;
                     var22 = var13.int5 + var12.cycleOffset - var20;
                     if(var13.int3 >= 0) {
                        var18 = (var22 << 8) / (var13.int5 - var13.int3);
                     }
                  }

                  if(var12.health2 > 0 && var100 < 1) {
                     var100 = 1;
                  }

                  if(var14 != null && var15 != null) {
                     if(var100 == var16) {
                        var100 += var17 * 2;
                     } else {
                        var100 += var17;
                     }

                     var22 = var14.subHeight;
                     var10 += var22;
                     var23 = var2 + Client.viewportTempX - (var16 >> 1);
                     var24 = var3 + Client.viewportTempY - var10;
                     var23 -= var17;
                     if(var18 >= 0 && var18 < 255) {
                        var14.drawTransAt_base(var23, var24, var18);
                        Rasterizer2D.Rasterizer2D_expandClip_base(var23, var24, var100 + var23, var24 + var22);
                        var15.drawTransAt_base(var23, var24, var18);
                     } else {
                        var14.drawTransBgAt_base(var23, var24);
                        Rasterizer2D.Rasterizer2D_expandClip_base(var23, var24, var100 + var23, var24 + var22);
                        var15.drawTransBgAt_base(var23, var24);
                     }

                     Rasterizer2D.Rasterizer2D_setClip_base(var2, var3, var2 + var4, var3 + var5);
                     var10 += 2;
                  } else {
                     var10 += 5;
                     if(Client.viewportTempX > -1) {
                        var22 = var2 + Client.viewportTempX - (var16 >> 1);
                        var23 = var3 + Client.viewportTempY - var10;
                        Rasterizer2D.Rasterizer2D_fillRectangle_base(var22, var23, var100, 5, 65280);
                        Rasterizer2D.Rasterizer2D_fillRectangle_base(var100 + var22, var23, var16 - var100, 5, 16711680);
                     }

                     var10 += 2;
                  }
               }
            }
         }

         if(var10 == -2) {
            var10 += 7;
         }

         if(var9 && var0.playerCycle == Client.cycle) {
            Player var93 = (Player)var0;
            boolean var77;
            if(Client.drawPlayerNames == 0) {
               var77 = false;
            } else if(var93 != class229.localPlayer) {
               boolean var78 = (Client.drawPlayerNames & 4) != 0;
               boolean var79 = var78 || AbstractByteArrayCopier.method6822_base() && var93.isFriend_base();
               if(!var79) {
                  boolean var80 = (Client.drawPlayerNames & 2) != 0;
                  var79 = var80 && var93.isFriendsChatMember_base();
               }

               var77 = var79;
            } else {
               var77 = Projectile.method2209_base();
            }

            if(var77) {
               Player var95 = (Player)var0;
               if(var9) {
                  Canvas.method331(var0, var0.defaultHeight + 15);
                  AbstractFont var97 = (AbstractFont)Client.fontsMap.get(FontName.FontName_plain12);
                  var10 += 4;
                  var97.drawCentered_base(var95.username.getName_base(), var2 + Client.viewportTempX, var3 + Client.viewportTempY - var10, 16777215, 0);
                  var10 += 18;
               }
            }
         }

         if(var9) {
            Player var91 = (Player)var0;
            if(var91.isHidden) {
               return;
            }

            if(var91.headIconPk != -1 || var91.headIconPrayer != -1) {
               Canvas.method331(var0, var0.defaultHeight + 15);
               if(Client.viewportTempX > -1) {
                  if(var91.headIconPk != -1) {
                     var10 += 25;
                     UrlRequest.headIconPkSprites[var91.headIconPk].drawTransBgAt_base(var2 + Client.viewportTempX - 12, var3 + Client.viewportTempY - var10);
                  }

                  if(var91.headIconPrayer != -1) {
                     var10 += 25;
                     AbstractByteArrayCopier.headIconPrayerSprites[var91.headIconPrayer].drawTransBgAt_base(var2 + Client.viewportTempX - 12, var3 + Client.viewportTempY - var10);
                  }
               }
            }

            if(var1 >= 0 && Client.hintArrowType == 10 && var8[var1] == Client.hintArrowPlayerIndex) {
               Canvas.method331(var0, var0.defaultHeight + 15);
               if(Client.viewportTempX > -1) {
                  var10 += class60.headIconHintSprites[1].subHeight;
                  class60.headIconHintSprites[1].drawTransBgAt_base(var2 + Client.viewportTempX - 12, var3 + Client.viewportTempY - var10);
               }
            }
         } else {
            NPC var92 = (NPC)var0;
            int[] var94 = var92.method2701_base();
            short[] var96 = var92.method2667_base();
            if(var96 != null && var94 != null) {
               for(int var104 = 0; var104 < var96.length; ++var104) {
                  if(var96[var104] >= 0 && var94[var104] >= 0) {
                     long var82 = (long)var94[var104] << 8 | (long)var96[var104];
                     SpritePixels var84 = (SpritePixels)Client.field779.method8022_base(Long.valueOf(var82));
                     if(var84 == null) {
                        SpritePixels[] var85 = VertexNormal.method5702(GrandExchangeOfferOwnWorldComparator.archive8, var94[var104], 0);
                        if(var85 != null && var96[var104] < var85.length) {
                           var84 = var85[var96[var104]];
                           Client.field779.method8037_base(Long.valueOf(var82), var84);
                        }
                     }

                     if(var84 != null) {
                        Canvas.method331(var0, var0.defaultHeight + 15);
                        if(Client.viewportTempX > -1) {
                           var84.drawTransBgAt_base(var2 + Client.viewportTempX - (var84.subWidth >> 1), Client.viewportTempY + (var3 - var84.subHeight) - 4);
                        }
                     }
                  }
               }
            }

            if(Client.hintArrowType == 1 && Client.npcIndices[var1 - var76] == Client.hintArrowNpcIndex && Client.cycle % 20 < 10) {
               Canvas.method331(var0, var0.defaultHeight + 15);
               if(Client.viewportTempX > -1) {
                  class60.headIconHintSprites[0].drawTransBgAt_base(var2 + Client.viewportTempX - 12, var3 + Client.viewportTempY - 28);
               }
            }
         }

         for(int var102 = 0; var102 < 4; ++var102) {
            int var81 = var0.hitSplatCycles[var102];
            int var103 = var0.hitSplatTypes[var102];
            HitSplatDefinition var98 = null;
            int var105 = 0;
            if(var103 >= 0) {
               if(var81 <= Client.cycle) {
                  continue;
               }

               var98 = class149.method3275(var0.hitSplatTypes[var102]);
               var105 = var98.field2060;
               if(var98 != null && var98.transforms != null) {
                  var98 = var98.method3854();
                  if(var98 == null) {
                     var0.hitSplatCycles[var102] = -1;
                     continue;
                  }
               }
            } else if(var81 < 0) {
               continue;
            }

            var16 = var0.hitSplatTypes2[var102];
            HitSplatDefinition var106 = null;
            if(var16 >= 0) {
               var106 = class149.method3275(var16);
               if(var106 != null && var106.transforms != null) {
                  var106 = var106.method3854();
               }
            }

            if(var81 - var105 <= Client.cycle) {
               if(var98 == null) {
                  var0.hitSplatCycles[var102] = -1;
               } else {
                  Canvas.method331(var0, var0.defaultHeight / 2);
                  if(Client.viewportTempX > -1) {
                     boolean var99 = true;
                     if(var102 == 1) {
                        Client.viewportTempY -= 20;
                     }

                     if(var102 == 2) {
                        Client.viewportTempX -= 15;
                        Client.viewportTempY -= 10;
                     }

                     if(var102 == 3) {
                        Client.viewportTempX += 15;
                        Client.viewportTempY -= 10;
                     }

                     SpritePixels var86 = null;
                     SpritePixels var87 = null;
                     SpritePixels var88 = null;
                     SpritePixels var89 = null;
                     var23 = 0;
                     var24 = 0;
                     int var25 = 0;
                     int var26 = 0;
                     int var27 = 0;
                     int var28 = 0;
                     int var29 = 0;
                     int var30 = 0;
                     SpritePixels var31 = null;
                     SpritePixels var32 = null;
                     SpritePixels var33 = null;
                     SpritePixels var34 = null;
                     int var35 = 0;
                     int var36 = 0;
                     int var37 = 0;
                     int var38 = 0;
                     int var39 = 0;
                     int var40 = 0;
                     int var41 = 0;
                     int var42 = 0;
                     int var43 = 0;
                     var86 = var98.method3860();
                     int var44;
                     if(var86 != null) {
                        var23 = var86.subWidth;
                        var44 = var86.subHeight;
                        if(var44 > var43) {
                           var43 = var44;
                        }

                        var27 = var86.xOffset;
                     }

                     var87 = var98.method3856();
                     if(var87 != null) {
                        var24 = var87.subWidth;
                        var44 = var87.subHeight;
                        if(var44 > var43) {
                           var43 = var44;
                        }

                        var28 = var87.xOffset;
                     }

                     var88 = var98.method3857();
                     if(var88 != null) {
                        var25 = var88.subWidth;
                        var44 = var88.subHeight;
                        if(var44 > var43) {
                           var43 = var44;
                        }

                        var29 = var88.xOffset;
                     }

                     var89 = var98.method3865();
                     if(var89 != null) {
                        var26 = var89.subWidth;
                        var44 = var89.subHeight;
                        if(var44 > var43) {
                           var43 = var44;
                        }

                        var30 = var89.xOffset;
                     }

                     if(var106 != null) {
                        var31 = var106.method3860();
                        if(var31 != null) {
                           var35 = var31.subWidth;
                           var44 = var31.subHeight;
                           if(var44 > var43) {
                              var43 = var44;
                           }

                           var39 = var31.xOffset;
                        }

                        var32 = var106.method3856();
                        if(var32 != null) {
                           var36 = var32.subWidth;
                           var44 = var32.subHeight;
                           if(var44 > var43) {
                              var43 = var44;
                           }

                           var40 = var32.xOffset;
                        }

                        var33 = var106.method3857();
                        if(var33 != null) {
                           var37 = var33.subWidth;
                           var44 = var33.subHeight;
                           if(var44 > var43) {
                              var43 = var44;
                           }

                           var41 = var33.xOffset;
                        }

                        var34 = var106.method3865();
                        if(var34 != null) {
                           var38 = var34.subWidth;
                           var44 = var34.subHeight;
                           if(var44 > var43) {
                              var43 = var44;
                           }

                           var42 = var34.xOffset;
                        }
                     }

                     Font var90 = var98.method3859();
                     if(var90 == null) {
                        var90 = class369.fontPlain11;
                     }

                     Font var45;
                     if(var106 != null) {
                        var45 = var106.method3859();
                        if(var45 == null) {
                           var45 = class369.fontPlain11;
                        }
                     } else {
                        var45 = class369.fontPlain11;
                     }

                     String var46 = null;
                     String var47 = null;
                     boolean var48 = false;
                     int var49 = 0;
                     var46 = var98.getString_base(var0.hitSplatValues[var102]);
                     int var101 = var90.stringWidth_base(var46);
                     if(var106 != null) {
                        var47 = var106.getString_base(var0.hitSplatValues2[var102]);
                        var49 = var45.stringWidth_base(var47);
                     }

                     int var50 = 0;
                     int var51 = 0;
                     if(var24 > 0) {
                        if(var88 == null && var89 == null) {
                           var50 = 1;
                        } else {
                           var50 = var101 / var24 + 1;
                        }
                     }

                     if(var106 != null && var36 > 0) {
                        if(var33 == null && var34 == null) {
                           var51 = 1;
                        } else {
                           var51 = var49 / var36 + 1;
                        }
                     }

                     int var52 = 0;
                     int var53 = var52;
                     if(var23 > 0) {
                        var52 += var23;
                     }

                     var52 += 2;
                     int var54 = var52;
                     if(var25 > 0) {
                        var52 += var25;
                     }

                     int var55 = var52;
                     int var56 = var52;
                     int var57;
                     if(var24 > 0) {
                        var57 = var24 * var50;
                        var52 += var57;
                        var56 += (var57 - var101) / 2;
                     } else {
                        var52 += var101;
                     }

                     var57 = var52;
                     if(var26 > 0) {
                        var52 += var26;
                     }

                     int var58 = 0;
                     int var59 = 0;
                     int var60 = 0;
                     int var61 = 0;
                     int var62 = 0;
                     int var63;
                     if(var106 != null) {
                        var52 += 2;
                        var58 = var52;
                        if(var35 > 0) {
                           var52 += var35;
                        }

                        var52 += 2;
                        var59 = var52;
                        if(var37 > 0) {
                           var52 += var37;
                        }

                        var60 = var52;
                        var62 = var52;
                        if(var36 > 0) {
                           var63 = var36 * var51;
                           var52 += var63;
                           var62 += (var63 - var49) / 2;
                        } else {
                           var52 += var49;
                        }

                        var61 = var52;
                        if(var38 > 0) {
                           var52 += var38;
                        }
                     }

                     var63 = var0.hitSplatCycles[var102] - Client.cycle;
                     int var64 = var98.field2065 - var63 * var98.field2065 / var98.field2060;
                     int var65 = var63 * var98.field2066 / var98.field2060 + -var98.field2066;
                     int var66 = var64 + (var2 + Client.viewportTempX - (var52 >> 1));
                     int var67 = var65 + (var3 + Client.viewportTempY - 12);
                     int var68 = var67;
                     int var69 = var67 + var43;
                     int var70 = var67 + var98.field2059 + 15;
                     int var71 = var70 - var90.maxAscent;
                     int var72 = var70 + var90.maxDescent;
                     if(var71 < var67) {
                        var68 = var71;
                     }

                     if(var72 > var69) {
                        var69 = var72;
                     }

                     int var73 = 0;
                     int var74;
                     int var75;
                     if(var106 != null) {
                        var73 = var67 + var106.field2059 + 15;
                        var74 = var73 - var45.maxAscent;
                        var75 = var73 + var45.maxDescent;
                        if(var74 < var68) {
                           ;
                        }

                        if(var75 > var69) {
                           ;
                        }
                     }

                     var74 = 255;
                     if(var98.field2067 >= 0) {
                        var74 = (var63 << 8) / (var98.field2060 - var98.field2067);
                     }

                     if(var74 >= 0 && var74 < 255) {
                        if(var86 != null) {
                           var86.drawTransAt_base(var66 + var53 - var27, var67, var74);
                        }

                        if(var88 != null) {
                           var88.drawTransAt_base(var54 + var66 - var29, var67, var74);
                        }

                        if(var87 != null) {
                           for(var75 = 0; var75 < var50; ++var75) {
                              var87.drawTransAt_base(var75 * var24 + (var55 + var66 - var28), var67, var74);
                           }
                        }

                        if(var89 != null) {
                           var89.drawTransAt_base(var66 + var57 - var30, var67, var74);
                        }

                        var90.drawAlpha_base(var46, var56 + var66, var70, var98.textColor, 0, var74);
                        if(var106 != null) {
                           if(var31 != null) {
                              var31.drawTransAt_base(var58 + var66 - var39, var67, var74);
                           }

                           if(var33 != null) {
                              var33.drawTransAt_base(var66 + var59 - var41, var67, var74);
                           }

                           if(var32 != null) {
                              for(var75 = 0; var75 < var51; ++var75) {
                                 var32.drawTransAt_base(var75 * var36 + (var60 + var66 - var40), var67, var74);
                              }
                           }

                           if(var34 != null) {
                              var34.drawTransAt_base(var61 + var66 - var42, var67, var74);
                           }

                           var45.drawAlpha_base(var47, var62 + var66, var73, var106.textColor, 0, var74);
                        }
                     } else {
                        if(var86 != null) {
                           var86.drawTransBgAt_base(var53 + var66 - var27, var67);
                        }

                        if(var88 != null) {
                           var88.drawTransBgAt_base(var66 + var54 - var29, var67);
                        }

                        if(var87 != null) {
                           for(var75 = 0; var75 < var50; ++var75) {
                              var87.drawTransBgAt_base(var75 * var24 + (var55 + var66 - var28), var67);
                           }
                        }

                        if(var89 != null) {
                           var89.drawTransBgAt_base(var66 + var57 - var30, var67);
                        }

                        var90.draw_base(var46, var66 + var56, var70, var98.textColor | -16777216, 0);
                        if(var106 != null) {
                           if(var31 != null) {
                              var31.drawTransBgAt_base(var66 + var58 - var39, var67);
                           }

                           if(var33 != null) {
                              var33.drawTransBgAt_base(var59 + var66 - var41, var67);
                           }

                           if(var32 != null) {
                              for(var75 = 0; var75 < var51; ++var75) {
                                 var32.drawTransBgAt_base(var75 * var36 + (var60 + var66 - var40), var67);
                              }
                           }

                           if(var34 != null) {
                              var34.drawTransBgAt_base(var61 + var66 - var42, var67);
                           }

                           var45.draw_base(var47, var66 + var62, var73, var106.textColor | -16777216, 0);
                        }
                     }
                  }
               }
            }
         }

      }
   }

   @ObfuscatedSignature(
      descriptor = "(Lds;IIIB)V",
      garbageValue = "0"
   )
   public static final void copy$addPlayerToMenu(Player var0, int var1, int var2, int var3, byte var4) {
      if(class229.localPlayer != var0) {
         if(Client.menuOptionsCount < 400) {
            String var5;
            if(var0.skillLevel == 0) {
               var5 = var0.actions[0] + var0.username + var0.actions[1] + class28.method450_base(var0.combatLevel, class229.localPlayer.combatLevel) + " " + " (" + "level-" + var0.combatLevel + ")" + var0.actions[2];
            } else {
               var5 = var0.actions[0] + var0.username + var0.actions[1] + " " + " (" + "skill-" + var0.skillLevel + ")" + var0.actions[2];
            }

            int var6;
            if(Client.isItemSelected == 1) {
               WorldMapSectionType.insertMenuItemNoShift_base("Use", Client.field767 + " " + "->" + " " + class167.colorStartTag_base(16777215) + var5, 14, var1, var2, var3);
            } else if(Client.isSpellSelected) {
               if((UrlRequest.selectedSpellFlags & 8) == 8 && !Client.shouldHideAttackOptionFor(var0)) {
                  WorldMapSectionType.insertMenuItemNoShift_base(Client.selectedSpellActionName, Client.selectedSpellName + " " + "->" + " " + class167.colorStartTag_base(16777215) + var5, 15, var1, var2, var3);
               }
            } else {
               for(var6 = 7; var6 >= 0; --var6) {
                  if(Client.playerMenuActions[var6] != null) {
                     short var7 = 0;
                     if(Client.playerMenuActions[var6].equalsIgnoreCase("Attack")) {
                        if(Client.playerAttackOption == AttackOption.AttackOption_hidden || Client.shouldHideAttackOptionFor(var0)) {
                           continue;
                        }

                        if(Client.playerAttackOption == AttackOption.AttackOption_alwaysRightClick || AttackOption.AttackOption_dependsOnCombatLevels == Client.playerAttackOption && var0.combatLevel > class229.localPlayer.combatLevel) {
                           var7 = 2000;
                        }

                        if(class229.localPlayer.team != 0 && var0.team != 0) {
                           if(var0.team == class229.localPlayer.team) {
                              var7 = 2000;
                           } else {
                              var7 = 0;
                           }
                        } else if(Client.playerAttackOption == AttackOption.field1334 && var0.isClanMember_base()) {
                           var7 = 2000;
                        }
                     } else if(Client.playerOptionsPriorities[var6]) {
                        var7 = 2000;
                     }

                     boolean var8 = false;
                     int var9 = Client.playerMenuOpcodes[var6] + var7;
                     WorldMapSectionType.insertMenuItemNoShift_base(Client.playerMenuActions[var6], class167.colorStartTag_base(16777215) + var5, var9, var1, var2, var3);
                  }
               }
            }

            for(var6 = 0; var6 < Client.menuOptionsCount; ++var6) {
               if(Client.menuOpcodes[var6] == 23) {
                  Client.menuTargets[var6] = class167.colorStartTag_base(16777215) + var5;
                  break;
               }
            }

         }
      }
   }

   @ObfuscatedSignature(
      descriptor = "(Ldn;IIII)V",
      garbageValue = "-140985889"
   )
   public static final void copy$addNpcToMenu(NPC var0, int var1, int var2, int var3, int var4) {
      NPCComposition var5 = var0.definition;
      if(Client.menuOptionsCount < 400) {
         if(var5.transforms != null) {
            var5 = var5.method3698();
         }

         if(var5 != null) {
            if(var5.isInteractable) {
               if(!var5.isFollower || Client.followerIndex == var1) {
                  String var6 = var0.method2662_base();
                  int var7;
                  if(var5.combatLevel != 0 && var0.field1247 != 0) {
                     var7 = var0.field1247 != -1?var0.field1247:var5.combatLevel;
                     var6 = var6 + class28.method450_base(var7, class229.localPlayer.combatLevel) + " " + " (" + "level-" + var7 + ")";
                  }

                  if(var5.isFollower && Client.followerOpsLowPriority) {
                     WorldMapSectionType.insertMenuItemNoShift_base("Examine", class167.colorStartTag_base(16776960) + var6, 1003, var1, var2, var3);
                  }

                  if(Client.isItemSelected == 1) {
                     WorldMapSectionType.insertMenuItemNoShift_base("Use", Client.field767 + " " + "->" + " " + class167.colorStartTag_base(16776960) + var6, 7, var1, var2, var3);
                  } else if(Client.isSpellSelected) {
                     if((UrlRequest.selectedSpellFlags & 2) == 2) {
                        WorldMapSectionType.insertMenuItemNoShift_base(Client.selectedSpellActionName, Client.selectedSpellName + " " + "->" + " " + class167.colorStartTag_base(16776960) + var6, 8, var1, var2, var3);
                     }
                  } else {
                     var7 = var5.isFollower && Client.followerOpsLowPriority?2000:0;
                     String[] var8 = var5.actions;
                     int var9;
                     int var10;
                     if(var8 != null) {
                        for(var9 = 4; var9 >= 0; --var9) {
                           if(var0.method2661_base(var9) && var8[var9] != null && !var8[var9].equalsIgnoreCase("Attack")) {
                              var10 = 0;
                              if(var9 == 0) {
                                 var10 = var7 + 9;
                              }

                              if(var9 == 1) {
                                 var10 = var7 + 10;
                              }

                              if(var9 == 2) {
                                 var10 = var7 + 11;
                              }

                              if(var9 == 3) {
                                 var10 = var7 + 12;
                              }

                              if(var9 == 4) {
                                 var10 = var7 + 13;
                              }

                              WorldMapSectionType.insertMenuItemNoShift_base(var8[var9], class167.colorStartTag_base(16776960) + var6, var10, var1, var2, var3);
                           }
                        }
                     }

                     if(var8 != null) {
                        for(var9 = 4; var9 >= 0; --var9) {
                           if(var0.method2661_base(var9) && var8[var9] != null && var8[var9].equalsIgnoreCase("Attack")) {
                              short var11 = 0;
                              if(Client.npcAttackOption != AttackOption.AttackOption_hidden) {
                                 if(AttackOption.AttackOption_alwaysRightClick == Client.npcAttackOption || AttackOption.AttackOption_dependsOnCombatLevels == Client.npcAttackOption && var5.combatLevel > class229.localPlayer.combatLevel) {
                                    var11 = 2000;
                                 }

                                 var10 = 0;
                                 if(var9 == 0) {
                                    var10 = var11 + 9;
                                 }

                                 if(var9 == 1) {
                                    var10 = var11 + 10;
                                 }

                                 if(var9 == 2) {
                                    var10 = var11 + 11;
                                 }

                                 if(var9 == 3) {
                                    var10 = var11 + 12;
                                 }

                                 if(var9 == 4) {
                                    var10 = var11 + 13;
                                 }

                                 WorldMapSectionType.insertMenuItemNoShift_base(var8[var9], class167.colorStartTag_base(16776960) + var6, var10, var1, var2, var3);
                              }
                           }
                        }
                     }

                     if(!var5.isFollower || !Client.followerOpsLowPriority) {
                        WorldMapSectionType.insertMenuItemNoShift_base("Examine", class167.colorStartTag_base(16776960) + var6, 1003, var1, var2, var3);
                     }
                  }

               }
            }
         }
      }
   }
}
