aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorBrandon <brandon.wamboldt@gmail.com>2023-09-08 12:13:03 -0300
committerGitHub <noreply@github.com>2023-09-08 17:13:03 +0200
commitdddd91d1cead43a8164425f28dffd6ea799ab22f (patch)
tree3540b62b412fb16389b5afb876a044e7df4255a2 /src/main/java
parentb7548f3b69426c41d4a11e788f5e2ae02c71e8d7 (diff)
downloadskyhanni-dddd91d1cead43a8164425f28dffd6ea799ab22f.tar.gz
skyhanni-dddd91d1cead43a8164425f28dffd6ea799ab22f.tar.bz2
skyhanni-dddd91d1cead43a8164425f28dffd6ea799ab22f.zip
Merge pull request #445
* Add nametags for minions as soon as they are placed
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
index d876f2bb3..ec2a212c1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
@@ -21,9 +22,11 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.init.Blocks
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.client.event.RenderLivingEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.event.entity.player.PlayerInteractEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent
@@ -34,6 +37,8 @@ class MinionFeatures {
private val config get() = SkyHanniMod.feature.minions
private var lastClickedEntity: LorenzVec? = null
private var lastMinion: LorenzVec? = null
+ private var newMinion: LorenzVec? = null
+ private var newMinionName: String? = null
private var lastMinionOpened = 0L
private var minionInventoryOpen = false
@@ -42,6 +47,24 @@ class MinionFeatures {
private val minionUpgradePattern = "§aYou have upgraded your Minion to Tier (?<tier>.*)".toPattern()
@SubscribeEvent
+ fun onPlayerInteract(event: PlayerInteractEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return;
+
+ val lookingAt = event.pos.offset(event.face)
+ val equipped = InventoryUtils.getItemInHand() ?: return
+
+ if (equipped.displayName.contains(" Minion ") && event.world.getBlockState(lookingAt).block == Blocks.air) {
+ newMinion = lookingAt.toLorenzVec().add(0.5, 0.0, 0.5)
+ newMinionName = getMinionName(equipped.cleanName())
+ } else {
+ newMinion = null
+ newMinionName = null
+ }
+ }
+
+ @SubscribeEvent
fun onClick(event: InputEvent.MouseInputEvent) {
if (!LorenzUtils.inSkyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
@@ -212,6 +235,18 @@ class MinionFeatures {
lastMinionOpened = 0L
}
}
+ if (message.startsWith("§bYou placed a minion!")) {
+ if (newMinion != null) {
+ minions = minions?.editCopy {
+ this[newMinion!!] = Storage.ProfileSpecific.MinionConfig().apply {
+ displayName = newMinionName
+ lastClicked = 0
+ }
+ }
+ newMinion = null
+ newMinionName = null
+ }
+ }
minionUpgradePattern.matchMatcher(message) {
val newTier = group("tier").romanToDecimalIfNeeded()