Add tools for copying id, texture id and nbt data

This commit is contained in:
nea
2023-09-09 03:37:29 +02:00
parent e0f784a1b2
commit 255e4f5899
9 changed files with 250 additions and 114 deletions

View File

@@ -16,5 +16,5 @@ import org.spongepowered.asm.mixin.gen.Accessor;
public interface AccessorHandledScreen {
@Accessor("focusedSlot")
@Nullable
Slot getFocusedSlot_NEU();
Slot getFocusedSlot_Firmament();
}

View File

@@ -13,6 +13,7 @@ import moe.nea.firmament.features.chat.ChatLinks
import moe.nea.firmament.features.debug.DebugView
import moe.nea.firmament.features.debug.DeveloperFeatures
import moe.nea.firmament.features.debug.MinorTrolling
import moe.nea.firmament.features.debug.PowerUserTools
import moe.nea.firmament.features.fixes.Fixes
import moe.nea.firmament.features.inventory.CraftingOverlay
import moe.nea.firmament.features.inventory.PriceData
@@ -48,6 +49,7 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature
loadFeature(SlotLocking)
loadFeature(StorageOverlay)
loadFeature(CraftingOverlay)
loadFeature(PowerUserTools)
loadFeature(ChatLinks)
loadFeature(SaveCursorPosition)
loadFeature(CustomSkyBlockTextures)

View File

@@ -68,7 +68,7 @@ object DeveloperFeatures : FirmamentFeature {
HandledScreenKeyPressedEvent.subscribe {
if (it.matches(IKeyBinding.ofKeyCode(GLFW.GLFW_KEY_K))) {
it.screen as AccessorHandledScreen
val focussedSlot = it.screen.focusedSlot_NEU ?: return@subscribe
val focussedSlot = it.screen.focusedSlot_Firmament ?: return@subscribe
val item = focussedSlot.stack ?: return@subscribe
val ident = item.skyBlockId?.identifier.toString()
MinecraftClient.getInstance().inGameHud.chatHud.addMessage(

View File

@@ -0,0 +1,94 @@
/*
* SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package moe.nea.firmament.features.debug
import net.minecraft.item.ItemStack
import net.minecraft.text.Text
import moe.nea.firmament.events.CustomItemModelEvent
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.events.ScreenOpenEvent
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.ClipboardUtils
import moe.nea.firmament.util.skyBlockId
object PowerUserTools : FirmamentFeature {
override val identifier: String
get() = "power-user"
object TConfig : ManagedConfig(identifier) {
val showItemIds by toggle("show-item-id") { false }
val copyItemId by keyBindingWithDefaultUnbound("copy-item-id")
val copyTexturePackId by keyBindingWithDefaultUnbound("copy-texture-pack-id")
val copyNbtData by keyBindingWithDefaultUnbound("copy-nbt-data")
}
override val config
get() = TConfig
var lastCopiedStack: Pair<ItemStack, Text>? = null
set(value) {
field = value
if (value != null)
lastCopiedStackViewTime = true
}
var lastCopiedStackViewTime = false
override fun onLoad() {
ItemTooltipEvent.subscribe {
if (TConfig.showItemIds) {
val id = it.stack.skyBlockId ?: return@subscribe
it.lines.add(Text.translatable("firmament.tooltip.skyblockid", id.neuItem))
}
val (item, text) = lastCopiedStack ?: return@subscribe
if (item != it.stack) {
lastCopiedStack = null
return@subscribe
}
lastCopiedStackViewTime = true
it.lines.add(text)
}
TickEvent.subscribe {
if (!lastCopiedStackViewTime)
lastCopiedStack = null
lastCopiedStackViewTime = false
}
ScreenOpenEvent.subscribe {
lastCopiedStack = null
}
HandledScreenKeyPressedEvent.subscribe {
if (it.screen !is AccessorHandledScreen) return@subscribe
val item = it.screen.focusedSlot_Firmament?.stack ?: return@subscribe
if (it.matches(TConfig.copyItemId)) {
val sbId = item.skyBlockId
if (sbId == null) {
lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skyblockid.fail"))
return@subscribe
}
ClipboardUtils.setTextContent(sbId.neuItem)
lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skyblockid", sbId.neuItem))
} else if (it.matches(TConfig.copyTexturePackId)) {
val model = CustomItemModelEvent.getModelIdentifier(item)
if (model == null) {
lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.modelid.fail"))
return@subscribe
}
ClipboardUtils.setTextContent(model.toString())
lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.modelid", model.toString()))
} else if (it.matches(TConfig.copyNbtData)) {
val nbt = item.orCreateNbt.toString()
ClipboardUtils.setTextContent(nbt)
lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.nbt"))
}
}
}
}

View File

@@ -45,7 +45,7 @@ object SlotLocking : FirmamentFeature {
val inventory = MC.handledScreen ?: return@subscribe
inventory as AccessorHandledScreen
val slot = inventory.focusedSlot_NEU ?: return@subscribe
val slot = inventory.focusedSlot_Firmament ?: return@subscribe
val lockedSlots = lockedSlots ?: return@subscribe
if (slot.inventory is PlayerInventory) {
if (slot.index in lockedSlots) {

View File

@@ -19,7 +19,7 @@ object SkyblockItemIdFocusedStackProvider : FocusedStackProvider {
override fun provide(screen: Screen?, mouse: Point?): CompoundEventResult<EntryStack<*>> {
if (screen !is HandledScreen<*>) return CompoundEventResult.pass()
screen as AccessorHandledScreen
val focusedSlot = screen.focusedSlot_NEU ?: return CompoundEventResult.pass()
val focusedSlot = screen.focusedSlot_Firmament ?: return CompoundEventResult.pass()
val item = focusedSlot.stack ?: return CompoundEventResult.pass()
val skyblockId = item.skyBlockId ?: return CompoundEventResult.pass()
return CompoundEventResult.interruptTrue(SBItemEntryDefinition.getEntry(skyblockId))

View File

@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package moe.nea.firmament.util
import moe.nea.firmament.Firmament
object ClipboardUtils {
fun setTextContent(string: String) {
try {
MC.keyboard.clipboard = string.ifEmpty { " " }
} catch (e: Exception) {
Firmament.logger.error("Could not write clipboard", e)
}
}
fun getTextContents(): String {
try {
return MC.keyboard.clipboard ?: ""
} catch (e: Exception) {
Firmament.logger.error("Could not read clipboard", e)
return ""
}
}
}

View File

@@ -16,6 +16,7 @@ object MC {
player?.networkHandler?.sendCommand(command)
}
inline val keyboard get() = MinecraftClient.getInstance().keyboard
inline val textureManager get() = MinecraftClient.getInstance().textureManager
inline val inGameHud get() = MinecraftClient.getInstance().inGameHud
inline val font get() = MinecraftClient.getInstance().textRenderer

View File

@@ -1,112 +1,123 @@
{
"firmament.dev.resourcerebuild.start": "Invoking gradle resource rebuild (./gradlew :processResources)",
"firmament.dev.resourcerebuild.done": "Gradle resource rebuild done in %s",
"firmament.command.toggle.no-config-found": "Could not find config %s",
"firmament.command.toggle.no-property-found": "Could not find property %s",
"firmament.command.toggle.not-a-toggle": "Property %s is not a toggle",
"firmament.command.toggle.toggled": "Toggled %s / %s %s",
"firmament.toggle.true": "On",
"firmament.toggle.false": "Off",
"firmament.config.developer": "Developer Settings",
"firmament.config.developer.auto-rebuild": "Automatically rebuild resources",
"firmament.price": "Checking price for %s",
"firmament.price.bazaar": "Bazaar stats:",
"firmament.price.bazaar.productid": "Stock id: %s",
"firmament.price.bazaar.buy.price": "Buy Price: %s",
"firmament.price.bazaar.buy.order": "Buy orders: %d",
"firmament.tooltip.bazaar.sell-order": "Bazaar Sell Order: %s",
"firmament.tooltip.bazaar.buy-order": "Bazaar Buy Order: %s",
"firmament.tooltip.ah.lowestbin": "Lowest BIN: %d",
"firmament.pv.pets": "Pets",
"firmament.debug.skyblockid": "SkyBlock ID: %s",
"firmament.debug.skyblockid.copy": "Click to copy SkyBlock ID",
"firmament.price.bazaar.sell.price": "Sell Price: %s",
"firmament.price.bazaar.sell.order": "Sell orders: %d",
"firmament.price.lowestbin": "Lowest BIN: %s",
"firmament.repo.reload.network": "Trying to redownload the repository",
"firmament.repo.reload.disk": "Reloading repository from disk. This may lag a bit.",
"firmament.repo.cache": "Recaching items",
"firmament.repo.brokenitem": "Failed to render item: %s",
"firmanent.config.edit": "Edit",
"firmament.config.repo": "Firmament Repo Settings",
"firmament.config.repo.autoUpdate": "Auto Update",
"firmament.config.repo.username": "Repo Username",
"firmament.config.repo.username.hint": "NotEnoughUpdates",
"firmament.config.repo.reponame": "Repo Name",
"firmament.config.repo.reponame.hint": "NotEnoughUpdates-REPO",
"firmament.config.repo.branch": "Repo Branch",
"firmament.config.repo.branch.hint": "dangerous",
"firmament.config.repo.reset": "Reset",
"firmament.config.repo.disable-item-groups": "Disable Item Groups",
"firmament.config.repo.reload": "Reload Item List",
"firmament.config.repo.redownload": "Redownload Item List",
"firmament.ursa.debugrequest.start": "Ursa request launched",
"firmament.ursa.debugrequest.result": "Ursa request succeeded: %s",
"firmament.sbinfo.nolocraw": "No locraw data available",
"firmament.sbinfo.profile": "Current profile cutename: %s",
"firmament.sbinfo.server": "Locraw Server: %s",
"firmament.sbinfo.gametype": "Locraw Gametype: %s",
"firmament.sbinfo.mode": "Locraw Mode: %s",
"firmament.sbinfo.map": "Locraw Map: %s",
"firmament.config.price-data": "Price data",
"firmament.config.price-data.enable-always": "Enable Item Price",
"firmament.config.price-data.enable-keybind": "Enable only with Keybinding",
"firmament.config.fairy-souls": "Fairy Souls",
"firmament.config.fairy-souls.show": "Show Fairy Soul Waypoints",
"firmament.config.fairy-souls.reset": "Reset Collected Fairy Souls",
"firmament.config.fishing-warning": "Fishing Warning",
"firmament.config.fishing-warning.display-warning": "Display a warning when you are about to hook a fish",
"firmament.config.fishing-warning.highlight-wake-chain": "Highlight fishing particles",
"firmament.key.slotlocking": "Lock Slot / Slot Binding",
"firmament.key.category": "Firmament",
"firmament.protectitem": "Firmament protected your item: ",
"firmament.recipe.forge.time": "Forging Time: %s",
"firmament.pv.skills": "Skills",
"firmament.pv.skills.farming": "Farming",
"firmament.pv.skills.foraging": "Foraging",
"firmament.pv.skills.mining": "Mining",
"firmament.pv.skills.alchemy": "Alchemy",
"firmament.pv.skills.taming": "Taming",
"firmament.pv.skills.fishing": "Fishing",
"firmament.pv.skills.runecrafting": "Runecrafting",
"firmament.pv.skills.carpentry": "Carpentry",
"firmament.pv.skills.combat": "Combat",
"firmament.pv.skills.social": "Social",
"firmament.pv.skills.rift": "Rift",
"firmament.pv.skills.enchanting": "Enchanting",
"firmament.pv.skills.total": "Total Exp: %s",
"firmament.pv.lookingup": "Looking up %s",
"firmament.pv.noprofile": "%s has no SkyBlock profiles",
"firmament.pv.noplayer": "%s is not a Minecraft player",
"firmament.config.save-cursor-position.enable": "Enable",
"firmament.config.save-cursor-position.tolerance": "Tolerance",
"firmament.config.save-cursor-position": "Save Cursor Position",
"firmament.config.storage-overlay": "Storage Overlay",
"firmament.config.storage-overlay.rows": "Rows",
"firmament.config.storage-overlay.padding": "Padding",
"firmament.config.storage-overlay.scroll-speed": "Scroll Speed",
"firmament.config.storage-overlay.inverse-scroll": "Invert Scroll",
"firmament.config.storage-overlay.margin": "Margin",
"firmament.config.chat-links": "Chat Links",
"firmament.config.chat-links.links-enabled": "Enable Clickable Links",
"firmament.config.chat-links.image-enabled": "Enable Image Preview",
"firmament.config.chat-links.allow-all-hosts": "Allow all Image Hosts",
"firmament.config.chat-links.allowed-hosts": "Allowed Image Hosts",
"firmament.config.chat-links.position": "Chat Image Preview",
"firmament.hud.edit": "Edit %s",
"firmament.keybinding.external": "External",
"firmament.config.slot-locking": "Slot Locking",
"firmament.config.slot-locking.lock": "Lock Slot",
"firmament.config.fixes.auto-sprint": "Auto Sprint",
"firmament.config.fixes.auto-sprint-keybinding": "Auto Sprint KeyBinding",
"firmament.config.fixes.auto-sprint-hud": "Sprint State Hud",
"firmament.config.fixes.peek-chat": "Peek Chat",
"firmament.fixes.auto-sprint.on": "Sprint toggled",
"firmament.fixes.auto-sprint.sprinting": "Sprinting",
"firmament.fixes.auto-sprint.not-sprinting": "Not Sprinting",
"firmament.config.custom-skyblock-textures": "Custom SkyBlock Item Textures",
"firmament.config.custom-skyblock-textures.cache-duration": "Model Cache Duration",
"firmament.config.custom-skyblock-textures.enabled": "Enable Custom Item Textures",
"firmament.config.fixes": "Fixes",
"firmament.config.fixes.player-skins": "Fix unsigned Player Skins"
"firmament.dev.resourcerebuild.start": "Invoking gradle resource rebuild (./gradlew :processResources)",
"firmament.dev.resourcerebuild.done": "Gradle resource rebuild done in %s",
"firmament.command.toggle.no-config-found": "Could not find config %s",
"firmament.command.toggle.no-property-found": "Could not find property %s",
"firmament.command.toggle.not-a-toggle": "Property %s is not a toggle",
"firmament.command.toggle.toggled": "Toggled %s / %s %s",
"firmament.toggle.true": "On",
"firmament.toggle.false": "Off",
"firmament.config.developer": "Developer Settings",
"firmament.config.developer.auto-rebuild": "Automatically rebuild resources",
"firmament.price": "Checking price for %s",
"firmament.price.bazaar": "Bazaar stats:",
"firmament.price.bazaar.productid": "Stock id: %s",
"firmament.price.bazaar.buy.price": "Buy Price: %s",
"firmament.price.bazaar.buy.order": "Buy orders: %d",
"firmament.tooltip.bazaar.sell-order": "Bazaar Sell Order: %s",
"firmament.tooltip.bazaar.buy-order": "Bazaar Buy Order: %s",
"firmament.tooltip.ah.lowestbin": "Lowest BIN: %d",
"firmament.pv.pets": "Pets",
"firmament.debug.skyblockid": "SkyBlock ID: %s",
"firmament.debug.skyblockid.copy": "Click to copy SkyBlock ID",
"firmament.price.bazaar.sell.price": "Sell Price: %s",
"firmament.price.bazaar.sell.order": "Sell orders: %d",
"firmament.price.lowestbin": "Lowest BIN: %s",
"firmament.repo.reload.network": "Trying to redownload the repository",
"firmament.repo.reload.disk": "Reloading repository from disk. This may lag a bit.",
"firmament.repo.cache": "Recaching items",
"firmament.repo.brokenitem": "Failed to render item: %s",
"firmanent.config.edit": "Edit",
"firmament.config.repo": "Firmament Repo Settings",
"firmament.config.repo.autoUpdate": "Auto Update",
"firmament.config.repo.username": "Repo Username",
"firmament.config.repo.username.hint": "NotEnoughUpdates",
"firmament.config.repo.reponame": "Repo Name",
"firmament.config.repo.reponame.hint": "NotEnoughUpdates-REPO",
"firmament.config.repo.branch": "Repo Branch",
"firmament.config.repo.branch.hint": "dangerous",
"firmament.config.repo.reset": "Reset",
"firmament.config.repo.disable-item-groups": "Disable Item Groups",
"firmament.config.repo.reload": "Reload Item List",
"firmament.config.repo.redownload": "Redownload Item List",
"firmament.ursa.debugrequest.start": "Ursa request launched",
"firmament.ursa.debugrequest.result": "Ursa request succeeded: %s",
"firmament.sbinfo.nolocraw": "No locraw data available",
"firmament.sbinfo.profile": "Current profile cutename: %s",
"firmament.sbinfo.server": "Locraw Server: %s",
"firmament.sbinfo.gametype": "Locraw Gametype: %s",
"firmament.sbinfo.mode": "Locraw Mode: %s",
"firmament.sbinfo.map": "Locraw Map: %s",
"firmament.config.price-data": "Price data",
"firmament.config.price-data.enable-always": "Enable Item Price",
"firmament.config.price-data.enable-keybind": "Enable only with Keybinding",
"firmament.config.fairy-souls": "Fairy Souls",
"firmament.config.fairy-souls.show": "Show Fairy Soul Waypoints",
"firmament.config.fairy-souls.reset": "Reset Collected Fairy Souls",
"firmament.config.fishing-warning": "Fishing Warning",
"firmament.config.fishing-warning.display-warning": "Display a warning when you are about to hook a fish",
"firmament.config.fishing-warning.highlight-wake-chain": "Highlight fishing particles",
"firmament.key.slotlocking": "Lock Slot / Slot Binding",
"firmament.key.category": "Firmament",
"firmament.protectitem": "Firmament protected your item: ",
"firmament.recipe.forge.time": "Forging Time: %s",
"firmament.pv.skills": "Skills",
"firmament.pv.skills.farming": "Farming",
"firmament.pv.skills.foraging": "Foraging",
"firmament.pv.skills.mining": "Mining",
"firmament.pv.skills.alchemy": "Alchemy",
"firmament.pv.skills.taming": "Taming",
"firmament.pv.skills.fishing": "Fishing",
"firmament.pv.skills.runecrafting": "Runecrafting",
"firmament.pv.skills.carpentry": "Carpentry",
"firmament.pv.skills.combat": "Combat",
"firmament.pv.skills.social": "Social",
"firmament.pv.skills.rift": "Rift",
"firmament.pv.skills.enchanting": "Enchanting",
"firmament.pv.skills.total": "Total Exp: %s",
"firmament.pv.lookingup": "Looking up %s",
"firmament.pv.noprofile": "%s has no SkyBlock profiles",
"firmament.pv.noplayer": "%s is not a Minecraft player",
"firmament.config.save-cursor-position.enable": "Enable",
"firmament.config.save-cursor-position.tolerance": "Tolerance",
"firmament.config.save-cursor-position": "Save Cursor Position",
"firmament.config.storage-overlay": "Storage Overlay",
"firmament.config.storage-overlay.rows": "Rows",
"firmament.config.storage-overlay.padding": "Padding",
"firmament.config.storage-overlay.scroll-speed": "Scroll Speed",
"firmament.config.storage-overlay.inverse-scroll": "Invert Scroll",
"firmament.config.storage-overlay.margin": "Margin",
"firmament.config.chat-links": "Chat Links",
"firmament.config.chat-links.links-enabled": "Enable Clickable Links",
"firmament.config.chat-links.image-enabled": "Enable Image Preview",
"firmament.config.chat-links.allow-all-hosts": "Allow all Image Hosts",
"firmament.config.chat-links.allowed-hosts": "Allowed Image Hosts",
"firmament.config.chat-links.position": "Chat Image Preview",
"firmament.hud.edit": "Edit %s",
"firmament.keybinding.external": "External",
"firmament.config.slot-locking": "Slot Locking",
"firmament.config.slot-locking.lock": "Lock Slot",
"firmament.config.fixes.auto-sprint": "Auto Sprint",
"firmament.config.fixes.auto-sprint-keybinding": "Auto Sprint KeyBinding",
"firmament.config.fixes.auto-sprint-hud": "Sprint State Hud",
"firmament.config.fixes.peek-chat": "Peek Chat",
"firmament.fixes.auto-sprint.on": "Sprint toggled",
"firmament.fixes.auto-sprint.sprinting": "Sprinting",
"firmament.fixes.auto-sprint.not-sprinting": "Not Sprinting",
"firmament.config.custom-skyblock-textures": "Custom SkyBlock Item Textures",
"firmament.config.custom-skyblock-textures.cache-duration": "Model Cache Duration",
"firmament.config.custom-skyblock-textures.enabled": "Enable Custom Item Textures",
"firmament.config.fixes": "Fixes",
"firmament.config.fixes.player-skins": "Fix unsigned Player Skins",
"firmament.config.power-user.show-item-id": "Show SkyBlock Ids",
"firmament.config.power-user.copy-item-id": "Copy SkyBlock Id",
"firmament.config.power-user.copy-texture-pack-id": "Copy Texture Pack Id",
"firmament.config.power-user.copy-nbt-data": "Copy NBT data",
"firmament.config.power-user": "Power Users",
"firmament.tooltip.skyblockid": "SkyBlock Id: %s",
"firmament.tooltip.copied.skyblockid.fail": "Failed to copy SkyBlock Id",
"firmament.tooltip.copied.skyblockid": "Copied SkyBlock Id: %s",
"firmament.tooltip.copied.modelid.fail": "Failed to copy Texture Id",
"firmament.tooltip.copied.modelid": "Copied Texture Id: %s",
"firmament.tooltip.copied.nbt": "Copied NBT data"
}