blast furance plugin: add bar dispenser to clickbox overlay
Also added support to color the dispenser / conveyor depending on the bar dispenser state. These are the current expected values: 0 = No bars being processed 1 = Ores are being processed on the conveyor belt, bar dispenser cannot be checked 2 = Bars are cooling down 3 = Bars can be collected
This commit is contained in:
@@ -201,6 +201,17 @@ public enum Varbits
|
|||||||
*/
|
*/
|
||||||
IN_GAME_BA(3923),
|
IN_GAME_BA(3923),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blast Furnace Bar Dispenser
|
||||||
|
*
|
||||||
|
* These are the expected values:
|
||||||
|
* 0 = No bars being processed
|
||||||
|
* 1 = Ores are being processed on the conveyor belt, bar dispenser cannot be checked
|
||||||
|
* 2 = Bars are cooling down
|
||||||
|
* 3 = Bars can be collected
|
||||||
|
*/
|
||||||
|
BAR_DISPENSER(936),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Motherlode mine sack
|
* Motherlode mine sack
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,13 +30,19 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.EquipmentInventorySlot;
|
||||||
import net.runelite.api.GameObject;
|
import net.runelite.api.GameObject;
|
||||||
|
import net.runelite.api.InventoryID;
|
||||||
|
import net.runelite.api.Item;
|
||||||
|
import net.runelite.api.ItemContainer;
|
||||||
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
|
||||||
class ConveyorBeltOverlay extends Overlay
|
class BlastFurnaceClickBoxOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private static final int MAX_DISTANCE = 2350;
|
private static final int MAX_DISTANCE = 2350;
|
||||||
|
|
||||||
@@ -45,7 +51,7 @@ class ConveyorBeltOverlay extends Overlay
|
|||||||
private final BlastFurnaceConfig config;
|
private final BlastFurnaceConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ConveyorBeltOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
|
BlastFurnaceClickBoxOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
@@ -56,17 +62,52 @@ class ConveyorBeltOverlay extends Overlay
|
|||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
if (!config.showConveyorBelt() || plugin.getConveyorBelt() == null)
|
int dispenserState = client.getVar(Varbits.BAR_DISPENSER);
|
||||||
|
|
||||||
|
if (config.showConveyorBelt() && plugin.getConveyorBelt() != null)
|
||||||
{
|
{
|
||||||
return null;
|
Color color = dispenserState == 1 ? Color.RED : Color.GREEN;
|
||||||
|
renderObject(plugin.getConveyorBelt(), graphics, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.showBarDispenser() && plugin.getBarDispenser() != null)
|
||||||
|
{
|
||||||
|
boolean hasIceGloves = hasIceGloves();
|
||||||
|
Color color = dispenserState == 2 && hasIceGloves ? Color.GREEN : (dispenserState == 3 ? Color.GREEN : Color.RED);
|
||||||
|
|
||||||
|
renderObject(plugin.getBarDispenser(), graphics, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasIceGloves()
|
||||||
|
{
|
||||||
|
ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT);
|
||||||
|
if (equipmentContainer == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item[] items = equipmentContainer.getItems();
|
||||||
|
int idx = EquipmentInventorySlot.GLOVES.getSlotIdx();
|
||||||
|
|
||||||
|
if (items == null || idx >= items.length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item glove = items[idx];
|
||||||
|
return glove != null && glove.getId() == ItemID.ICE_GLOVES;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderObject(GameObject object, Graphics2D graphics, Color color)
|
||||||
|
{
|
||||||
LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
|
LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
|
||||||
Point mousePosition = client.getMouseCanvasPosition();
|
Point mousePosition = client.getMouseCanvasPosition();
|
||||||
|
|
||||||
GameObject object = plugin.getConveyorBelt();
|
|
||||||
|
|
||||||
LocalPoint location = object.getLocalLocation();
|
LocalPoint location = object.getLocalLocation();
|
||||||
|
|
||||||
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
||||||
{
|
{
|
||||||
Area objectClickbox = object.getClickbox();
|
Area objectClickbox = object.getClickbox();
|
||||||
@@ -74,17 +115,16 @@ class ConveyorBeltOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
||||||
{
|
{
|
||||||
graphics.setColor(Color.RED.darker());
|
graphics.setColor(color.darker());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics.setColor(Color.RED);
|
graphics.setColor(color);
|
||||||
}
|
}
|
||||||
graphics.draw(objectClickbox);
|
graphics.draw(objectClickbox);
|
||||||
graphics.setColor(new Color(0xFF, 0, 0, 20));
|
graphics.setColor(new Color(0xFF, 0, 0, 20));
|
||||||
graphics.fill(objectClickbox);
|
graphics.fill(objectClickbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,11 +37,23 @@ public interface BlastFurnaceConfig extends Config
|
|||||||
{
|
{
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "showConveyorBelt",
|
keyName = "showConveyorBelt",
|
||||||
name = "Show Conveyor belt clickbox",
|
name = "Show conveyor belt clickbox",
|
||||||
description = "Configures whether or not the clickbox for the conveyor belt is displayed"
|
description = "Configures whether or not the clickbox for the conveyor belt is displayed",
|
||||||
|
position = 1
|
||||||
)
|
)
|
||||||
default boolean showConveyorBelt()
|
default boolean showConveyorBelt()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "showBarDispenser",
|
||||||
|
name = "Show bar dispenser clickbox",
|
||||||
|
description = "Configures whether or not the clickbox for the bar dispenser is displayed",
|
||||||
|
position = 2
|
||||||
|
)
|
||||||
|
default boolean showBarDispenser()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import lombok.Getter;
|
|||||||
import net.runelite.api.GameObject;
|
import net.runelite.api.GameObject;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import static net.runelite.api.ObjectID.CONVEYOR_BELT;
|
import static net.runelite.api.ObjectID.CONVEYOR_BELT;
|
||||||
|
import static net.runelite.api.ObjectID.NULL_9092;
|
||||||
import net.runelite.api.events.GameObjectDespawned;
|
import net.runelite.api.events.GameObjectDespawned;
|
||||||
import net.runelite.api.events.GameObjectSpawned;
|
import net.runelite.api.events.GameObjectSpawned;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
@@ -47,9 +48,14 @@ import net.runelite.client.ui.overlay.Overlay;
|
|||||||
)
|
)
|
||||||
public class BlastFurnacePlugin extends Plugin
|
public class BlastFurnacePlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
private static final int BAR_DISPENSER = NULL_9092;
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private GameObject conveyorBelt;
|
private GameObject conveyorBelt;
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private GameObject barDispenser;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BlastFurnaceOverlay overlay;
|
private BlastFurnaceOverlay overlay;
|
||||||
|
|
||||||
@@ -57,12 +63,13 @@ public class BlastFurnacePlugin extends Plugin
|
|||||||
private BlastFurnaceCofferOverlay cofferOverlay;
|
private BlastFurnaceCofferOverlay cofferOverlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ConveyorBeltOverlay conveyorBeltOverlay;
|
private BlastFurnaceClickBoxOverlay clickBoxOverlay;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown()
|
protected void shutDown()
|
||||||
{
|
{
|
||||||
conveyorBelt = null;
|
conveyorBelt = null;
|
||||||
|
barDispenser = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -74,16 +81,23 @@ public class BlastFurnacePlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public Collection<Overlay> getOverlays()
|
public Collection<Overlay> getOverlays()
|
||||||
{
|
{
|
||||||
return Arrays.asList(overlay, cofferOverlay, conveyorBeltOverlay);
|
return Arrays.asList(overlay, cofferOverlay, clickBoxOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameObjectSpawn(GameObjectSpawned event)
|
public void onGameObjectSpawn(GameObjectSpawned event)
|
||||||
{
|
{
|
||||||
GameObject gameObject = event.getGameObject();
|
GameObject gameObject = event.getGameObject();
|
||||||
if (gameObject.getId() == CONVEYOR_BELT)
|
|
||||||
|
switch (gameObject.getId())
|
||||||
{
|
{
|
||||||
conveyorBelt = gameObject;
|
case CONVEYOR_BELT:
|
||||||
|
conveyorBelt = gameObject;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BAR_DISPENSER:
|
||||||
|
barDispenser = gameObject;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,9 +105,16 @@ public class BlastFurnacePlugin extends Plugin
|
|||||||
public void onGameObjectDespawn(GameObjectDespawned event)
|
public void onGameObjectDespawn(GameObjectDespawned event)
|
||||||
{
|
{
|
||||||
GameObject gameObject = event.getGameObject();
|
GameObject gameObject = event.getGameObject();
|
||||||
if (gameObject.getId() == CONVEYOR_BELT)
|
|
||||||
|
switch (gameObject.getId())
|
||||||
{
|
{
|
||||||
conveyorBelt = null;
|
case CONVEYOR_BELT:
|
||||||
|
conveyorBelt = null;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BAR_DISPENSER:
|
||||||
|
barDispenser = null;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +124,7 @@ public class BlastFurnacePlugin extends Plugin
|
|||||||
if (event.getGameState() == GameState.LOADING)
|
if (event.getGameState() == GameState.LOADING)
|
||||||
{
|
{
|
||||||
conveyorBelt = null;
|
conveyorBelt = null;
|
||||||
|
barDispenser = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user