Merge pull request #1661 from Gamer1120/mlm-check-floor

Only render mining spots on same floor in MLM. Fixes #1642
This commit is contained in:
Adam
2018-04-20 23:15:49 -04:00
committed by GitHub
3 changed files with 31 additions and 12 deletions

View File

@@ -228,30 +228,30 @@ public class Perspective
* Calculates the above ground height of a tile point. * Calculates the above ground height of a tile point.
* *
* @param client * @param client
* @param x the ground coordinate on the x axis * @param localX the ground coordinate on the x axis
* @param y the ground coordinate on the y axis * @param localY the ground coordinate on the y axis
* @param plane the client plane/ground level * @param plane the client plane/ground level
* @return the offset from the ground of the tile * @return the offset from the ground of the tile
*/ */
public static int getTileHeight(Client client, int x, int y, int plane) public static int getTileHeight(Client client, int localX, int localY, int plane)
{ {
int var3 = x >> 7; int sceneX = localX >> LOCAL_COORD_BITS;
int var4 = y >> 7; int sceneY = localY >> LOCAL_COORD_BITS;
if (var3 >= 0 && var4 >= 0 && var3 <= 103 && var4 <= 103) if (sceneX >= 0 && sceneY >= 0 && sceneX <= 103 && sceneY <= 103)
{ {
byte[][][] tileSettings = client.getTileSettings(); byte[][][] tileSettings = client.getTileSettings();
int[][][] tileHeights = client.getTileHeights(); int[][][] tileHeights = client.getTileHeights();
int var5 = plane; int var5 = plane;
if (plane < 3 && (tileSettings[1][var3][var4] & 2) == 2) if (plane < 3 && (tileSettings[1][sceneX][sceneY] & 2) == 2)
{ {
var5 = plane + 1; var5 = plane + 1;
} }
int var6 = x & 127; int var6 = localX & 127;
int var7 = y & 127; int var7 = localY & 127;
int var8 = var6 * tileHeights[var5][var3 + 1][var4] + (128 - var6) * tileHeights[var5][var3][var4] >> 7; int var8 = var6 * tileHeights[var5][sceneX + 1][sceneY] + (128 - var6) * tileHeights[var5][sceneX][sceneY] >> 7;
int var9 = tileHeights[var5][var3][var4 + 1] * (128 - var6) + var6 * tileHeights[var5][var3 + 1][var4 + 1] >> 7; int var9 = tileHeights[var5][sceneX][sceneY + 1] * (128 - var6) + var6 * tileHeights[var5][sceneX + 1][sceneY + 1] >> 7;
return (128 - var7) * var8 + var7 * var9 >> 7; return (128 - var7) * var8 + var7 * var9 >> 7;
} }

View File

@@ -53,8 +53,10 @@ import static net.runelite.api.ObjectID.ORE_VEIN_26663;
import static net.runelite.api.ObjectID.ORE_VEIN_26664; import static net.runelite.api.ObjectID.ORE_VEIN_26664;
import static net.runelite.api.ObjectID.ROCKFALL; import static net.runelite.api.ObjectID.ROCKFALL;
import static net.runelite.api.ObjectID.ROCKFALL_26680; import static net.runelite.api.ObjectID.ROCKFALL_26680;
import net.runelite.api.Perspective;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.WallObject; import net.runelite.api.WallObject;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameObjectChanged; import net.runelite.api.events.GameObjectChanged;
import net.runelite.api.events.GameObjectDespawned; import net.runelite.api.events.GameObjectDespawned;
@@ -86,6 +88,8 @@ public class MotherlodePlugin extends Plugin
private static final int SACK_LARGE_SIZE = 162; private static final int SACK_LARGE_SIZE = 162;
private static final int SACK_SIZE = 81; private static final int SACK_SIZE = 81;
private static final int UPPER_FLOOR_HEIGHT = -500;
@Inject @Inject
private MotherlodeOverlay overlay; private MotherlodeOverlay overlay;
@@ -399,4 +403,15 @@ public class MotherlodePlugin extends Plugin
return true; return true;
} }
/**
* Checks if the given point is "upstairs" in the mlm.
* The upper floor is actually on z=0.
* @param localPoint
* @return
*/
boolean isUpstairs(LocalPoint localPoint)
{
return Perspective.getTileHeight(client, localPoint.getX(), localPoint.getY(), 0) < UPPER_FLOOR_HEIGHT;
}
} }

View File

@@ -91,7 +91,11 @@ class MotherlodeRocksOverlay extends Overlay
LocalPoint location = vein.getLocalLocation(); LocalPoint location = vein.getLocalLocation();
if (localLocation.distanceTo(location) <= MAX_DISTANCE) if (localLocation.distanceTo(location) <= MAX_DISTANCE)
{ {
renderVein(graphics, vein); // Only draw veins on the same level
if (plugin.isUpstairs(localLocation) == plugin.isUpstairs(vein.getLocalLocation()))
{
renderVein(graphics, vein);
}
} }
} }