diff options
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/features/debug/PowerUserTools.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/features/debug/itemeditor/ItemExporter.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt | 9 | ||||
-rw-r--r-- | src/main/kotlin/features/inventory/SlotLocking.kt | 68 | ||||
-rw-r--r-- | src/main/kotlin/features/inventory/TimerInLore.kt | 1 | ||||
-rw-r--r-- | src/main/kotlin/features/items/EtherwarpOverlay.kt | 3 | ||||
-rw-r--r-- | src/main/kotlin/features/macros/RadialMenu.kt | 6 | ||||
-rw-r--r-- | src/main/kotlin/repo/RepoManager.kt | 32 | ||||
-rw-r--r-- | src/main/kotlin/util/render/LerpUtils.kt | 6 | ||||
-rw-r--r-- | src/main/kotlin/util/skyblock/SkyBlockItems.kt | 1 |
10 files changed, 101 insertions, 31 deletions
diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt index 1a7b2cf..0800a4f 100644 --- a/src/main/kotlin/features/debug/PowerUserTools.kt +++ b/src/main/kotlin/features/debug/PowerUserTools.kt @@ -41,6 +41,7 @@ import moe.nea.firmament.util.mc.iterableArmorItems import moe.nea.firmament.util.mc.loreAccordingToNbt import moe.nea.firmament.util.skyBlockId import moe.nea.firmament.util.tr +import moe.nea.firmament.util.grey object PowerUserTools : FirmamentFeature { override val identifier: String @@ -60,6 +61,7 @@ object PowerUserTools : FirmamentFeature { val exportUIRecipes by keyBindingWithDefaultUnbound("export-recipe") val exportNpcLocation by keyBindingWithDefaultUnbound("export-npc-location") val highlightNonOverlayItems by toggle("highlight-non-overlay") { false } + val dontHighlightSemicolonItems by toggle("dont-highlight-semicolon-items") { false } } override val config @@ -228,7 +230,7 @@ object PowerUserTools : FirmamentFeature { fun addItemId(it: ItemTooltipEvent) { if (TConfig.showItemIds) { val id = it.stack.skyBlockId ?: return - it.lines.add(Text.stringifiedTranslatable("firmament.tooltip.skyblockid", id.neuItem)) + it.lines.add(Text.stringifiedTranslatable("firmament.tooltip.skyblockid", id.neuItem).grey()) } val (item, text) = lastCopiedStack ?: return if (!ItemStack.areEqual(item, it.stack)) { diff --git a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt index c521b5a..2a56204 100644 --- a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt +++ b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt @@ -215,6 +215,8 @@ object ItemExporter { return } val stack = event.slot.stack ?: return + val id = event.slot.stack.skyBlockId?.neuItem + if (PowerUserTools.TConfig.dontHighlightSemicolonItems && id != null && id.contains(";")) return val isExported = nonOverlayCache.getOrPut(stack.skyBlockId ?: return) { RepoDownloadManager.repoSavedLocation.resolve("itemsOverlay") .resolve(ExportedTestConstantMeta.current.dataVersion.toString()) diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt index ad03b16..ecf3d2c 100644 --- a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt +++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt @@ -5,6 +5,7 @@ import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put import kotlin.concurrent.thread +import kotlin.jvm.optionals.getOrNull import net.minecraft.component.DataComponentTypes import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtByte @@ -14,6 +15,7 @@ import net.minecraft.nbt.NbtInt import net.minecraft.nbt.NbtList import net.minecraft.nbt.NbtOps import net.minecraft.nbt.NbtString +import net.minecraft.registry.tag.ItemTags import net.minecraft.text.Text import net.minecraft.util.Unit import moe.nea.firmament.Firmament @@ -39,6 +41,7 @@ import moe.nea.firmament.util.unformattedString class LegacyItemExporter private constructor(var itemStack: ItemStack) { init { require(!itemStack.isEmpty) + itemStack.count = 1 } var lore = itemStack.loreAccordingToNbt @@ -171,7 +174,11 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) { } private fun copyColour() { - val leatherTint = itemStack.get(DataComponentTypes.DYED_COLOR) ?: return + if (!itemStack.isIn(ItemTags.DYEABLE)) { + itemStack.remove(DataComponentTypes.DYED_COLOR) + return + } + val leatherTint = itemStack.componentChanges.get(DataComponentTypes.DYED_COLOR)?.getOrNull() ?: return legacyNbt.getOrPutCompound("display").put("color", NbtInt.of(leatherTint.rgb)) } diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt index d3348a2..0a3f01b 100644 --- a/src/main/kotlin/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/features/inventory/SlotLocking.kt @@ -4,7 +4,6 @@ package moe.nea.firmament.features.inventory import java.util.UUID import org.lwjgl.glfw.GLFW -import util.render.CustomRenderLayers import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers @@ -19,9 +18,8 @@ import kotlinx.serialization.json.int import kotlinx.serialization.serializer import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.render.RenderLayer -import net.minecraft.client.render.RenderLayers -import net.minecraft.client.render.TexturedRenderLayers import net.minecraft.entity.player.PlayerInventory +import net.minecraft.item.ItemStack import net.minecraft.screen.GenericContainerScreenHandler import net.minecraft.screen.slot.Slot import net.minecraft.screen.slot.SlotActionType @@ -44,14 +42,20 @@ import moe.nea.firmament.util.MC import moe.nea.firmament.util.SBData import moe.nea.firmament.util.SkyBlockIsland import moe.nea.firmament.util.data.ProfileSpecificDataHolder +import moe.nea.firmament.util.extraAttributes import moe.nea.firmament.util.json.DashlessUUIDSerializer +import moe.nea.firmament.util.lime import moe.nea.firmament.util.mc.ScreenUtil.getSlotByIndex import moe.nea.firmament.util.mc.SlotUtils.swapWithHotBar import moe.nea.firmament.util.mc.displayNameAccordingToNbt import moe.nea.firmament.util.mc.loreAccordingToNbt +import moe.nea.firmament.util.red import moe.nea.firmament.util.render.drawLine +import moe.nea.firmament.util.skyBlockId import moe.nea.firmament.util.skyblock.DungeonUtil +import moe.nea.firmament.util.skyblock.SkyBlockItems import moe.nea.firmament.util.skyblockUUID +import moe.nea.firmament.util.tr import moe.nea.firmament.util.unformattedString object SlotLocking : FirmamentFeature { @@ -132,6 +136,7 @@ object SlotLocking : FirmamentFeature { val slotBindRequireShift by toggle("require-quick-move") { true } val slotRenderLines by choice("bind-render") { SlotRenderLinesMode.ONLY_BOXES } val allowMultiBinding by toggle("multi-bind") { true } // TODO: filter based on this option + val protectAllHuntingBoxes by toggle("hunting-box") { false } val allowDroppingInDungeons by toggle("drop-in-dungeons") { true } } @@ -193,10 +198,12 @@ 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, - IsSlotProtectedEvent.MoveOrigin.SALVAGE, - stack) + if (IsSlotProtectedEvent.shouldBlockInteraction( + null, + SlotActionType.THROW, + IsSlotProtectedEvent.MoveOrigin.SALVAGE, + stack + ) ) anyBlocked = true } @@ -219,12 +226,20 @@ object SlotLocking : FirmamentFeature { && doesNotDeleteItem ) return val stack = event.itemStack ?: return + if (TConfig.protectAllHuntingBoxes && (stack.isHuntingBox())) { + event.protect() + return + } val uuid = stack.skyblockUUID ?: return if (uuid in (lockedUUIDs ?: return)) { event.protect() } } + fun ItemStack.isHuntingBox(): Boolean { + return skyBlockId == SkyBlockItems.HUNTING_TOOLKIT || extraAttributes.get("tool_kit") != null + } + @Subscribe fun onProtectSlot(it: IsSlotProtectedEvent) { if (it.slot != null && it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())) { @@ -271,6 +286,21 @@ object SlotLocking : FirmamentFeature { val slot = inventory.focusedSlot_Firmament ?: return val stack = slot.stack ?: return + if (stack.isHuntingBox()) { + MC.sendChat( + tr( + "firmament.slot-locking.hunting-box-unbindable-hint", + "The hunting box cannot be UUID bound reliably. It changes its own UUID frequently when switching tools. " + ).red().append( + tr( + "firmament.slot-locking.hunting-box-unbindable-hint.solution", + "Use the Firmament config option for locking all hunting boxes instead." + ).lime() + ) + ) + CommonSoundEffects.playFailure() + return + } val uuid = stack.skyblockUUID ?: return val lockedUUIDs = lockedUUIDs ?: return if (uuid in lockedUUIDs) { @@ -350,12 +380,16 @@ object SlotLocking : FirmamentFeature { hotX + sx, hotY + sy, color(anyHovered) ) - event.context.drawBorder(hotbarSlot.x + sx, - hotbarSlot.y + sy, - 16, 16, color(hotbarSlot in highlitSlots).color) - event.context.drawBorder(inventorySlot.x + sx, - inventorySlot.y + sy, - 16, 16, color(inventorySlot in highlitSlots).color) + event.context.drawBorder( + hotbarSlot.x + sx, + hotbarSlot.y + sy, + 16, 16, color(hotbarSlot in highlitSlots).color + ) + event.context.drawBorder( + inventorySlot.x + sx, + inventorySlot.y + sy, + 16, 16, color(inventorySlot in highlitSlots).color + ) } } @@ -383,9 +417,11 @@ object SlotLocking : FirmamentFeature { hovX + sx, hovY + sy, me.shedaniel.math.Color.ofOpaque(0x00FF00) ) - event.context.drawBorder(hoveredSlot.x + sx, - hoveredSlot.y + sy, - 16, 16, 0xFF00FF00u.toInt()) + event.context.drawBorder( + hoveredSlot.x + sx, + hoveredSlot.y + sy, + 16, 16, 0xFF00FF00u.toInt() + ) } } diff --git a/src/main/kotlin/features/inventory/TimerInLore.kt b/src/main/kotlin/features/inventory/TimerInLore.kt index cc1df9a..e939404 100644 --- a/src/main/kotlin/features/inventory/TimerInLore.kt +++ b/src/main/kotlin/features/inventory/TimerInLore.kt @@ -47,6 +47,7 @@ object TimerInLore { appendValue(ChronoField.SECOND_OF_MINUTE, 2) }), AMERICAN("EEEE, MMM d h:mm a yyyy"), + RFCPrecise(DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss.SSS Z")), ; constructor(block: DateTimeFormatterBuilder.() -> Unit) diff --git a/src/main/kotlin/features/items/EtherwarpOverlay.kt b/src/main/kotlin/features/items/EtherwarpOverlay.kt index b1f695a..f6ab1a2 100644 --- a/src/main/kotlin/features/items/EtherwarpOverlay.kt +++ b/src/main/kotlin/features/items/EtherwarpOverlay.kt @@ -19,6 +19,7 @@ object EtherwarpOverlay : FirmamentFeature { object TConfig : ManagedConfig(identifier, Category.ITEMS) { var etherwarpOverlay by toggle("etherwarp-overlay") { false } + var onlyShowWhileSneaking by toggle("only-show-while-sneaking") { true } var cube by toggle("cube") { true } val cubeColour by colour("cube-colour") { ChromaColour.fromStaticRGB(172, 0, 255, 60) } var wireframe by toggle("wireframe") { false } @@ -32,7 +33,7 @@ object EtherwarpOverlay : FirmamentFeature { fun renderEtherwarpOverlay(event: WorldRenderLastEvent) { if (!TConfig.etherwarpOverlay) return val player = MC.player ?: return - if (!player.isSneaking) return + if (TConfig.onlyShowWhileSneaking && !player.isSneaking) return val world = player.world val camera = MC.camera ?: return val heldItem = MC.stackInHand diff --git a/src/main/kotlin/features/macros/RadialMenu.kt b/src/main/kotlin/features/macros/RadialMenu.kt index 2e09c44..9e5222f 100644 --- a/src/main/kotlin/features/macros/RadialMenu.kt +++ b/src/main/kotlin/features/macros/RadialMenu.kt @@ -36,7 +36,11 @@ object RadialMenuViewer { var activeMenu: RadialMenu? = null set(value) { - field = value + if (value?.options.isNullOrEmpty()) { + field = null + } else { + field = value + } delta = Vector2f(0F, 0F) } var delta = Vector2f(0F, 0F) diff --git a/src/main/kotlin/repo/RepoManager.kt b/src/main/kotlin/repo/RepoManager.kt index df89092..c3d1c52 100644 --- a/src/main/kotlin/repo/RepoManager.kt +++ b/src/main/kotlin/repo/RepoManager.kt @@ -7,7 +7,9 @@ import io.github.moulberry.repo.data.NEURecipe import io.github.moulberry.repo.data.Rarity import java.nio.file.Path import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import net.minecraft.client.MinecraftClient import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket import net.minecraft.recipe.display.CuttingRecipeDisplay @@ -35,11 +37,13 @@ object RepoManager { branch = "master" save() } - + val enableREI by toggle("enable-rei") { true } val disableItemGroups by toggle("disable-item-groups") { true } val reload by button("reload") { save() - RepoManager.reload() + Firmament.coroutineScope.launch { + RepoManager.reload() + } } val redownload by button("redownload") { save() @@ -56,6 +60,9 @@ object RepoManager { RENDER_AND_TEXT("text"), ; + fun rendersPerfectText() = this == RENDER_AND_TEXT + fun rendersPerfectVisuals() = this == RENDER || this == RENDER_AND_TEXT + override fun asString(): String? = label } @@ -131,16 +138,17 @@ object RepoManager { fun reloadForTest(from: Path) { neuRepo = makeNEURepository(from) - reload() + reloadSync() } - fun reload() { - if (!TestUtil.isInTest && !MC.instance.isOnThread) { - MC.instance.send { - reload() - } - return + + suspend fun reload() { + withContext(Dispatchers.IO) { + reloadSync() } + } + + fun reloadSync() { try { logger.info("Repo reload started.") neuRepo.reload() @@ -168,7 +176,9 @@ object RepoManager { if (Config.autoUpdate) { launchAsyncUpdate() } else { - reload() + Firmament.coroutineScope.launch { + reload() + } } } @@ -196,4 +206,6 @@ object RepoManager { fun getRepoRef(): String { return "${Config.username}/${Config.reponame}#${Config.branch}" } + + fun shouldLoadREI(): Boolean = Config.enableREI } diff --git a/src/main/kotlin/util/render/LerpUtils.kt b/src/main/kotlin/util/render/LerpUtils.kt index 63a13ec..e7f226c 100644 --- a/src/main/kotlin/util/render/LerpUtils.kt +++ b/src/main/kotlin/util/render/LerpUtils.kt @@ -1,11 +1,15 @@ package moe.nea.firmament.util.render import me.shedaniel.math.Color +import kotlin.math.absoluteValue val π = Math.PI val τ = Math.PI * 2 -fun lerpAngle(a: Float, b: Float, progress: Float): Float { +fun lerpAngle(a: Float, b: Float, progress: Float): Float { // TODO: there is at least 10 mods to many in here lol + if (((b - a).absoluteValue - π).absoluteValue < 0.0001) { + return lerp(a, b, progress) + } val shortestAngle = ((((b.mod(τ) - a.mod(τ)).mod(τ)) + τ + π).mod(τ)) - π return ((a + (shortestAngle) * progress).mod(τ)).toFloat() } diff --git a/src/main/kotlin/util/skyblock/SkyBlockItems.kt b/src/main/kotlin/util/skyblock/SkyBlockItems.kt index 4f208dd..d552fd7 100644 --- a/src/main/kotlin/util/skyblock/SkyBlockItems.kt +++ b/src/main/kotlin/util/skyblock/SkyBlockItems.kt @@ -19,4 +19,5 @@ object SkyBlockItems { val BONE_BOOMERANG = SkyblockId("BONE_BOOMERANG") val STARRED_BONE_BOOMERANG = SkyblockId("STARRED_BONE_BOOMERANG") val TRIBAL_SPEAR = SkyblockId("TRIBAL_SPEAR") + val HUNTING_TOOLKIT = SkyblockId("HUNTING_TOOLKIT") } |