aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-20 16:09:51 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-20 16:09:51 +0100
commit3e00309ecaaacd810670cf42ba739bc1f6bbdcbf (patch)
tree0e6fba6abb9b0d26db2486c7ef79a5cac945141c /src/main/java
parentb05aadae5208a46220ee91df4a78f5fde2a9cb19 (diff)
downloadskyhanni-3e00309ecaaacd810670cf42ba739bc1f6bbdcbf.tar.gz
skyhanni-3e00309ecaaacd810670cf42ba739bc1f6bbdcbf.tar.bz2
skyhanni-3e00309ecaaacd810670cf42ba739bc1f6bbdcbf.zip
added VisitorStatus, added color for refused visitors
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt77
1 files changed, 53 insertions, 24 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
index 584732a81..203ae63b4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
@@ -74,9 +75,11 @@ class GardenVisitorFeatures {
val internalName = NEUItems.getInternalName(itemName)
visitor.items[internalName] = amount
}
+ if (visitor.status == VisitorStatus.NEW) {
+ visitor.status = VisitorStatus.WAITING
+ }
- checkVisitorsReady()
- updateDisplay()
+ update()
}
private fun updateDisplay() {
@@ -92,7 +95,7 @@ class GardenVisitorFeatures {
val requiredItems = mutableMapOf<String, Int>()
val newVisitors = mutableListOf<String>()
for ((visitorName, visitor) in visitors) {
- if (visitor.done) continue
+ if (visitor.status != VisitorStatus.WAITING) continue
val items = visitor.items
if (items.isEmpty()) {
@@ -127,6 +130,17 @@ class GardenVisitorFeatures {
}
@SubscribeEvent(priority = EventPriority.HIGH)
+ fun onStackClick(event: SlotClickEvent) {
+ if (!inVisitorInventory) return
+ if (event.slotId != 33) return
+
+ visitors.map { it.value }.find { it.entityId == lastClickedNpc }?.let {
+ it.status = VisitorStatus.REFUSED
+ update()
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGH)
fun onTooltip(event: ItemTooltipEvent) {
if (!GardenAPI.inGarden()) return
if (!inVisitorInventory) return
@@ -254,7 +268,7 @@ class GardenVisitorFeatures {
}
for (name in visitorsInTab) {
if (!visitors.containsKey(name)) {
- visitors[name] = Visitor(-1)
+ visitors[name] = Visitor(status = VisitorStatus.NEW)
if (config.visitorNotificationTitle) {
SendTitleHelper.sendTitle("§eNew Visitor", 5_000)
}
@@ -274,13 +288,17 @@ class GardenVisitorFeatures {
val visitorName = matcher.group(1)
for (visitor in visitors) {
if (visitor.key == visitorName) {
- visitor.value.done = true
- updateDisplay()
- checkVisitorsReady()
+ visitor.value.status = VisitorStatus.ACCEPTED
+ update()
}
}
}
+ private fun update() {
+ checkVisitorsReady()
+ updateDisplay()
+ }
+
private fun checkVisitorsReady() {
for ((visitorName, visitor) in visitors) {
val entity = Minecraft.getMinecraft().theWorld.getEntityByID(visitor.entityId)
@@ -288,21 +306,19 @@ class GardenVisitorFeatures {
findEntityByNametag(visitorName, visitor)
}
- if (entity is EntityLivingBase) {
- if (visitor.done) {
- val color = LorenzColor.DARK_GRAY.toColor().withAlpha(60)
- RenderLivingEntityHelper.setEntityColor(entity, color)
- { config.visitorHighlight }
- } else if (visitor.items.isEmpty()) {
- val color = LorenzColor.DARK_AQUA.toColor().withAlpha(120)
- RenderLivingEntityHelper.setEntityColor(entity, color)
- { config.visitorHighlight }
- } else if (isReady(visitor)) {
- val color = LorenzColor.GREEN.toColor().withAlpha(120)
- RenderLivingEntityHelper.setEntityColor(entity, color)
- { config.visitorHighlight }
- } else {
- RenderLivingEntityHelper.removeEntityColor(entity)
+ val status = visitor.status
+ if (status == VisitorStatus.WAITING || status == VisitorStatus.READY) {
+ visitor.status = if (isReady(visitor)) VisitorStatus.READY else VisitorStatus.WAITING
+ }
+
+ if (config.visitorHighlight) {
+ if (entity is EntityLivingBase) {
+ val color = status.color
+ if (color != -1) {
+ RenderLivingEntityHelper.setEntityColor(entity, color) { config.visitorHighlight }
+ } else {
+ RenderLivingEntityHelper.removeEntityColor(entity)
+ }
}
}
}
@@ -356,5 +372,18 @@ class GardenVisitorFeatures {
config.visitorNeedsPos.renderStringsAndItems(display)
}
- class Visitor(var entityId: Int, var done: Boolean = false, val items: MutableMap<String, Int> = mutableMapOf())
-} \ No newline at end of file
+ class Visitor(
+ var entityId: Int = -1,
+ var status: VisitorStatus,
+ val items: MutableMap<String, Int> = mutableMapOf(),
+ )
+
+ enum class VisitorStatus(val color: Int) {
+ NEW(LorenzColor.YELLOW.toColor().withAlpha(120)),
+ WAITING(-1),
+ READY(LorenzColor.GREEN.toColor().withAlpha(60)),
+ ACCEPTED(LorenzColor.DARK_GRAY.toColor().withAlpha(60)),
+ REFUSED(LorenzColor.RED.toColor().withAlpha(60)),
+ }
+}
+