diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-17 18:00:43 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-17 18:00:43 +0100 |
commit | 74a043e53540c120ebe58b0199f57bfa36d30e47 (patch) | |
tree | 62b3505d5cc707eb854ad611a4bec38285ec29f8 /src/main/kotlin/features | |
parent | 19bc576b67c856b33922ee99c3e22a14f39ab55f (diff) | |
download | Firmament-74a043e53540c120ebe58b0199f57bfa36d30e47.tar.gz Firmament-74a043e53540c120ebe58b0199f57bfa36d30e47.tar.bz2 Firmament-74a043e53540c120ebe58b0199f57bfa36d30e47.zip |
feat: Allow dropping protected items in dungeons
Diffstat (limited to 'src/main/kotlin/features')
-rw-r--r-- | src/main/kotlin/features/FeatureManager.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/features/inventory/SlotLocking.kt | 24 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/main/kotlin/features/FeatureManager.kt b/src/main/kotlin/features/FeatureManager.kt index 0f5ebf8..9a3cbf8 100644 --- a/src/main/kotlin/features/FeatureManager.kt +++ b/src/main/kotlin/features/FeatureManager.kt @@ -45,10 +45,6 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature private var hasAutoloaded = false - init { - autoload() - } - fun autoload() { synchronized(this) { if (hasAutoloaded) return diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt index 99130d5..7a3a152 100644 --- a/src/main/kotlin/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/features/inventory/SlotLocking.kt @@ -15,6 +15,7 @@ import net.minecraft.screen.slot.SlotActionType import net.minecraft.util.Identifier import net.minecraft.util.StringIdentifiable import moe.nea.firmament.annotations.Subscribe +import moe.nea.firmament.events.FeaturesInitializedEvent import moe.nea.firmament.events.HandledScreenForegroundEvent import moe.nea.firmament.events.HandledScreenKeyPressedEvent import moe.nea.firmament.events.HandledScreenKeyReleasedEvent @@ -37,6 +38,7 @@ import moe.nea.firmament.util.mc.displayNameAccordingToNbt import moe.nea.firmament.util.mc.loreAccordingToNbt import moe.nea.firmament.util.render.GuiRenderLayers import moe.nea.firmament.util.render.drawLine +import moe.nea.firmament.util.skyblock.DungeonUtil import moe.nea.firmament.util.skyblockUUID import moe.nea.firmament.util.unformattedString @@ -60,6 +62,7 @@ object SlotLocking : FirmamentFeature { val slotBind by keyBinding("bind") { GLFW.GLFW_KEY_L } val slotBindRequireShift by toggle("require-quick-move") { true } val slotRenderLines by choice("bind-render") { SlotRenderLinesMode.ONLY_BOXES } + val allowDroppingInDungeons by toggle("drop-in-dungeons") { true } } enum class SlotRenderLinesMode : StringIdentifiable { @@ -120,7 +123,11 @@ object SlotLocking : FirmamentFeature { var anyBlocked = false for (i in 0 until event.slot.index) { val stack = inv.getStack(i) - if (IsSlotProtectedEvent.shouldBlockInteraction(null, SlotActionType.THROW, stack)) + if (IsSlotProtectedEvent.shouldBlockInteraction(null, + SlotActionType.THROW, + IsSlotProtectedEvent.MoveOrigin.SALVAGE, + stack) + ) anyBlocked = true } if (anyBlocked) { @@ -156,6 +163,19 @@ object SlotLocking : FirmamentFeature { } @Subscribe + fun onEvent(event: FeaturesInitializedEvent) { + IsSlotProtectedEvent.subscribe(receivesCancelled = true, "SlotLocking:unlockInDungeons") { + if (it.isProtected + && it.origin == IsSlotProtectedEvent.MoveOrigin.DROP_FROM_HOTBAR + && DungeonUtil.isInActiveDungeon + && TConfig.allowDroppingInDungeons + ) { + it.isProtected = false + } + } + } + + @Subscribe fun onQuickMoveBoundSlot(it: IsSlotProtectedEvent) { val boundSlots = DConfig.data?.boundSlots ?: mapOf() val isValidAction = @@ -245,7 +265,7 @@ object SlotLocking : FirmamentFeature { val (hotX, hotY) = hotbarSlot.lineCenter() val (invX, invY) = inventorySlot.lineCenter() val anyHovered = accScreen.focusedSlot_Firmament === hotbarSlot - || accScreen.focusedSlot_Firmament === inventorySlot + || accScreen.focusedSlot_Firmament === inventorySlot if (!anyHovered && TConfig.slotRenderLines == SlotRenderLinesMode.NOTHING) continue val color = if (anyHovered) |