Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Secret Chime #2453

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public class DungeonConfig {
@Accordion
public HighlightClickedBlocksConfig clickedBlocks = new HighlightClickedBlocksConfig();

@Expose
@ConfigOption(name = "Secret Chime", desc = "Play a sound effect when levers, chests, and wither essence are clicked in dungeons.")
@Accordion
public SecretChimeConfig secretChime = new SecretChimeConfig();

@Expose
@ConfigOption(name = "Milestones Display", desc = "Show the current milestone in Dungeons.")
@ConfigEditorBoolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package at.hannibal2.skyhanni.config.features.dungeon;

import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.features.dungeon.DungeonSecretChime;
import at.hannibal2.skyhanni.utils.OSUtils;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

public class SecretChimeConfig {
@Expose
@ConfigOption(name = "Enabled", desc = "Play a sound effect when levers, chests, and wither essence are clicked in dungeons.")
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = false;

@Expose
@ConfigOption(name = "Secret Chime Sound", desc = "The sound played for the secret chime.")
@ConfigEditorText
public String name = "random.orb";

@Expose
@ConfigOption(name = "Pitch", desc = "The pitch of the secret chime sound.")
@ConfigEditorSlider(minValue = 0.5f, maxValue = 2.0f, minStep = 0.1f)
public float pitch = 1.0f;


@ConfigOption(name = "Sounds", desc = "Click to open the list of available sounds.")
@ConfigEditorButton(buttonText = "OPEN")
public Runnable sounds = () -> OSUtils.openBrowser("https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/mapping-and-modding-tutorials/2213619-1-8-all-playsound-sound-arguments");


@ConfigOption(name = "Play Sound", desc = "Plays current secret chime sound.")
@ConfigEditorButton(buttonText = "Play")
public Runnable checkSound = DungeonSecretChime::playSound;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package at.hannibal2.skyhanni.features.dungeon

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.events.BlockClickEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.BlockUtils
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.SoundUtils.playSound
import net.minecraft.init.Blocks
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object DungeonSecretChime {
private val config get() = SkyHanniMod.feature.dungeon.secretChime
private const val WITHER_ESSENCE_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzRkYjRhZGZhOWJmNDhmZjVkNDE3MDdhZTM0ZWE3OGJkMjM3MTY1OWZjZDhjZDg5MzQ3NDlhZjRjY2U5YiJ9fX0="

@SubscribeEvent
fun onBlockClick(event: BlockClickEvent) {
if (!isEnabled() || event.clickType != ClickType.RIGHT_CLICK) return

val block = event.position.getBlockAt()
when (block) {
Blocks.chest, Blocks.trapped_chest, Blocks.lever -> playSound()
Blocks.skull -> {
val texture = BlockUtils.getTextureFromSkull(event.position.toBlockPos())
if (texture == WITHER_ESSENCE_TEXTURE) {
playSound()
}
}
else -> return
}
}

fun isEnabled() = !DungeonAPI.inBossRoom && DungeonAPI.inDungeon() && config.enabled

@JvmStatic
fun playSound() {
with(config) {
SoundUtils.createSound(name, pitch).playSound()
}
}
}
Loading