mining plugin: draw overlay at correct height for mlm and amethyst

Achieved by adding support for a zoffset to rocks in the mining plugin
This commit is contained in:
Twiglet1022
2019-06-03 22:53:37 +01:00
parent 3252d1dd91
commit 8eee63d72c
4 changed files with 24 additions and 18 deletions

View File

@@ -77,7 +77,7 @@ class MiningOverlay extends Overlay
continue; continue;
} }
Point point = Perspective.localToCanvas(client, loc, client.getPlane()); Point point = Perspective.localToCanvas(client, loc, client.getPlane(), rockRespawn.getZOffset());
if (point == null) if (point == null)
{ {
it.remove(); it.remove();

View File

@@ -124,7 +124,7 @@ public class MiningPlugin extends Plugin
Rock rock = Rock.getRock(object.getId()); Rock rock = Rock.getRock(object.getId());
if (rock != null) if (rock != null)
{ {
RockRespawn rockRespawn = new RockRespawn(rock, object.getWorldLocation(), Instant.now(), (int) rock.getRespawnTime(inMiningGuild()).toMillis()); RockRespawn rockRespawn = new RockRespawn(rock, object.getWorldLocation(), Instant.now(), (int) rock.getRespawnTime(inMiningGuild()).toMillis(), rock.getZOffset());
respawns.add(rockRespawn); respawns.add(rockRespawn);
} }
} }
@@ -144,7 +144,7 @@ public class MiningPlugin extends Plugin
case EMPTY_WALL: case EMPTY_WALL:
{ {
Rock rock = Rock.AMETHYST; Rock rock = Rock.AMETHYST;
RockRespawn rockRespawn = new RockRespawn(rock, object.getWorldLocation(), Instant.now(), (int) rock.getRespawnTime(inMiningGuild()).toMillis()); RockRespawn rockRespawn = new RockRespawn(rock, object.getWorldLocation(), Instant.now(), (int) rock.getRespawnTime(inMiningGuild()).toMillis(), rock.getZOffset());
respawns.add(rockRespawn); respawns.add(rockRespawn);
break; break;
} }
@@ -154,7 +154,7 @@ public class MiningPlugin extends Plugin
case DEPLETED_VEIN_26668: // Depleted motherlode vein case DEPLETED_VEIN_26668: // Depleted motherlode vein
{ {
Rock rock = Rock.ORE_VEIN; Rock rock = Rock.ORE_VEIN;
RockRespawn rockRespawn = new RockRespawn(rock, object.getWorldLocation(), Instant.now(), (int) rock.getRespawnTime(inMiningGuild()).toMillis()); RockRespawn rockRespawn = new RockRespawn(rock, object.getWorldLocation(), Instant.now(), (int) rock.getRespawnTime(inMiningGuild()).toMillis(), rock.getZOffset());
respawns.add(rockRespawn); respawns.add(rockRespawn);
break; break;
} }

View File

@@ -27,6 +27,8 @@ package net.runelite.client.plugins.mining;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import java.time.Duration; import java.time.Duration;
import java.util.Map; import java.util.Map;
import lombok.AccessLevel;
import lombok.Getter;
import static net.runelite.api.ObjectID.ROCKS_11161; import static net.runelite.api.ObjectID.ROCKS_11161;
import static net.runelite.api.ObjectID.ROCKS_11360; import static net.runelite.api.ObjectID.ROCKS_11360;
import static net.runelite.api.ObjectID.ROCKS_11361; import static net.runelite.api.ObjectID.ROCKS_11361;
@@ -48,9 +50,9 @@ import static net.runelite.api.ObjectID.ROCKS_11387;
enum Rock enum Rock
{ {
TIN(Duration.ofMillis(2300), ROCKS_11360, ROCKS_11361), TIN(Duration.ofMillis(2300), 0, ROCKS_11360, ROCKS_11361),
COPPER(Duration.ofMillis(2200), ROCKS_11161), COPPER(Duration.ofMillis(2200), 0, ROCKS_11161),
IRON(Duration.ofMillis(5300), ROCKS_11364, ROCKS_11365) IRON(Duration.ofMillis(5300), 0, ROCKS_11364, ROCKS_11365)
{ {
@Override @Override
Duration getRespawnTime(boolean inMiningGuild) Duration getRespawnTime(boolean inMiningGuild)
@@ -58,7 +60,7 @@ enum Rock
return inMiningGuild ? Duration.ofMillis(2200) : super.respawnTime; return inMiningGuild ? Duration.ofMillis(2200) : super.respawnTime;
} }
}, },
COAL(Duration.ofSeconds(40), ROCKS_11366, ROCKS_11367) COAL(Duration.ofSeconds(40), 0, ROCKS_11366, ROCKS_11367)
{ {
@Override @Override
Duration getRespawnTime(boolean inMiningGuild) Duration getRespawnTime(boolean inMiningGuild)
@@ -66,11 +68,11 @@ enum Rock
return inMiningGuild ? Duration.ofMillis(14_500) : super.respawnTime; return inMiningGuild ? Duration.ofMillis(14_500) : super.respawnTime;
} }
}, },
SILVER(Duration.ofMinutes(1), ROCKS_11369), SILVER(Duration.ofMinutes(1), 0, ROCKS_11369),
SANDSTONE(Duration.ofMillis(5400), ROCKS_11386), SANDSTONE(Duration.ofMillis(5400), 0, ROCKS_11386),
GOLD(Duration.ofMinutes(1), ROCKS_11370, ROCKS_11371), GOLD(Duration.ofMinutes(1), 0, ROCKS_11370, ROCKS_11371),
GRANITE(Duration.ofMillis(5400), ROCKS_11387), GRANITE(Duration.ofMillis(5400), 0, ROCKS_11387),
MITHRIL(Duration.ofMinutes(2), ROCKS_11372, ROCKS_11373) MITHRIL(Duration.ofMinutes(2), 0, ROCKS_11372, ROCKS_11373)
{ {
@Override @Override
Duration getRespawnTime(boolean inMiningGuild) Duration getRespawnTime(boolean inMiningGuild)
@@ -78,7 +80,7 @@ enum Rock
return inMiningGuild ? Duration.ofMinutes(1) : super.respawnTime; return inMiningGuild ? Duration.ofMinutes(1) : super.respawnTime;
} }
}, },
ADAMANTITE(Duration.ofMinutes(4), ROCKS_11374, ROCKS_11375) ADAMANTITE(Duration.ofMinutes(4), 0, ROCKS_11374, ROCKS_11375)
{ {
@Override @Override
Duration getRespawnTime(boolean inMiningGuild) Duration getRespawnTime(boolean inMiningGuild)
@@ -86,7 +88,7 @@ enum Rock
return inMiningGuild ? Duration.ofMinutes(2) : super.respawnTime; return inMiningGuild ? Duration.ofMinutes(2) : super.respawnTime;
} }
}, },
RUNITE(Duration.ofMinutes(12), ROCKS_11376, ROCKS_11377) RUNITE(Duration.ofMinutes(12), 0, ROCKS_11376, ROCKS_11377)
{ {
@Override @Override
Duration getRespawnTime(boolean inMiningGuild) Duration getRespawnTime(boolean inMiningGuild)
@@ -94,8 +96,8 @@ enum Rock
return inMiningGuild ? Duration.ofMinutes(6) : super.respawnTime; return inMiningGuild ? Duration.ofMinutes(6) : super.respawnTime;
} }
}, },
ORE_VEIN(Duration.ofSeconds(108)), ORE_VEIN(Duration.ofSeconds(108), 150),
AMETHYST(Duration.ofSeconds(75)); AMETHYST(Duration.ofSeconds(75), 120);
private static final Map<Integer, Rock> ROCKS; private static final Map<Integer, Rock> ROCKS;
@@ -113,11 +115,14 @@ enum Rock
} }
private final Duration respawnTime; private final Duration respawnTime;
@Getter(AccessLevel.PACKAGE)
private final int zOffset;
private final int[] ids; private final int[] ids;
Rock(Duration respawnTime, int... ids) Rock(Duration respawnTime, int zOffset, int... ids)
{ {
this.respawnTime = respawnTime; this.respawnTime = respawnTime;
this.zOffset = zOffset;
this.ids = ids; this.ids = ids;
} }

View File

@@ -37,4 +37,5 @@ class RockRespawn
private final WorldPoint worldPoint; private final WorldPoint worldPoint;
private final Instant startTime; private final Instant startTime;
private final int respawnTime; private final int respawnTime;
private final int zOffset;
} }