diff options
author | jani270 <69345714+jani270@users.noreply.github.com> | 2024-01-11 15:50:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-11 15:50:52 +0100 |
commit | 2e12fc657e03c26f26e61b5e9da939b23a73f528 (patch) | |
tree | 44a08f611a8f7560b7e784b158915f3d602a6b34 /src/main/java/at/hannibal2 | |
parent | 96cdf8e2aef9dbc025f431a81df0d5aa6f257dbb (diff) | |
download | skyhanni-2e12fc657e03c26f26e61b5e9da939b23a73f528.tar.gz skyhanni-2e12fc657e03c26f26e61b5e9da939b23a73f528.tar.bz2 skyhanni-2e12fc657e03c26f26e61b5e9da939b23a73f528.zip |
Added-Lesser-Orb-of-Healing-Hider (#904)
Lesser Orb of Healing Hider. #904
Diffstat (limited to 'src/main/java/at/hannibal2')
4 files changed, 70 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 93e84a6d2..0551554cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -255,6 +255,7 @@ import at.hannibal2.skyhanni.features.misc.SkyBlockKickDuration import at.hannibal2.skyhanni.features.misc.SuperpairsClicksAlert import at.hannibal2.skyhanni.features.misc.TimeFeatures import at.hannibal2.skyhanni.features.misc.TpsCounter +import at.hannibal2.skyhanni.features.misc.LesserOrbHider import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList import at.hannibal2.skyhanni.features.misc.compacttablist.TabListReader import at.hannibal2.skyhanni.features.misc.compacttablist.TabListRenderer @@ -529,6 +530,7 @@ class SkyHanniMod { loadModule(CompactBingoChat()) loadModule(BrewingStandOverlay()) loadModule(FishingTimer()) + loadModule(LesserOrbHider()) loadModule(FishingHookDisplay()) loadModule(CrimsonIsleReputationHelper(this)) loadModule(SharkFishCounter()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 350f321f2..69db7f53d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -205,6 +205,14 @@ public class MiscConfig { @Expose @ConfigOption( + name = "Lesser Orb of Healing Hider", + desc = "Hides the Lesser Orb of Healing.") + @ConfigEditorBoolean + @FeatureToggle + public boolean lesserOrbHider = false; + + @Expose + @ConfigOption( name = "Lock Mouse Message", desc = "Show a message in chat when toggling the /shmouselock.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt new file mode 100644 index 000000000..000587afd --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt @@ -0,0 +1,54 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent +import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture +import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class LesserOrbHider { + private val config get() = SkyHanniMod.feature.misc + private val hiddenEntities = LorenzUtils.weakReferenceList<EntityArmorStand>() + + private val lesserTexture = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjgzMjM2NjM5NjA3MDM2YzFiYTM5MWMyYjQ2YTljN2IwZWZkNzYwYzhiZmEyOTk2YTYwNTU1ODJiNGRhNSJ9fX0=" + + @SubscribeEvent + fun onArmorChange(event: EntityEquipmentChangeEvent) { + val entity = event.entity + val itemStack = event.newItemStack ?: return + + if (entity is EntityArmorStand && event.isHand && itemStack.getSkullTexture() == lesserTexture) { + hiddenEntities.add(entity) + } + } + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!isEnabled()) return + + if (event.entity in hiddenEntities) { + event.isCanceled = true + } + } + + @SubscribeEvent + fun onReceiveParticle(event: ReceiveParticleEvent) { + if (!isEnabled()) return + if (event.type != EnumParticleTypes.REDSTONE) return + + for (armorStand in hiddenEntities) { + val distance = armorStand.distanceTo(event.location) + if (distance < 4) { + event.isCanceled = true + } + } + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.lesserOrbHider +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index c4c2dfa93..6f189da4d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -35,6 +35,7 @@ import java.text.SimpleDateFormat import java.util.Collections import java.util.Timer import java.util.TimerTask +import java.util.WeakHashMap import java.util.regex.Matcher import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty1 @@ -523,8 +524,8 @@ object LorenzUtils { val tileSign = (this as AccessorGuiEditSign).tileSign return (tileSign.signText[1].unformattedText.removeColor() == "^^^^^^" - && tileSign.signText[2].unformattedText.removeColor() == "Set your" - && tileSign.signText[3].unformattedText.removeColor() == "speed cap!") + && tileSign.signText[2].unformattedText.removeColor() == "Set your" + && tileSign.signText[3].unformattedText.removeColor() == "speed cap!") } fun IslandType.isInIsland() = inSkyBlock && skyBlockIsland == this @@ -655,4 +656,7 @@ object LorenzUtils { fun Matcher.groupOrNull(groupName: String): String? { return runCatching { this.group(groupName) }.getOrNull() } + + // Let garbage collector handle the removal of entries in this list + inline fun <reified T> weakReferenceList(): MutableSet<T> = Collections.newSetFromMap(WeakHashMap<T, Boolean>()) } |