feat: Add custom hardness tooltips
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package moe.nea.firmament.compat.jade
|
||||
|
||||
import snownee.jade.api.BlockAccessor
|
||||
import snownee.jade.api.IBlockComponentProvider
|
||||
import snownee.jade.api.ITooltip
|
||||
import snownee.jade.api.config.IPluginConfig
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.util.Identifier
|
||||
import moe.nea.firmament.Firmament
|
||||
import moe.nea.firmament.annotations.Subscribe
|
||||
import moe.nea.firmament.events.SkyblockServerUpdateEvent
|
||||
import moe.nea.firmament.repo.MiningRepoData
|
||||
import moe.nea.firmament.repo.RepoManager
|
||||
import moe.nea.firmament.util.ErrorUtil
|
||||
import moe.nea.firmament.util.tr
|
||||
|
||||
object CustomMiningHardnessProvider : IBlockComponentProvider {
|
||||
|
||||
var customBlocks: Map<Block, MiningRepoData.CustomMiningBlock> = mapOf()
|
||||
|
||||
fun refreshBlockInfo() {
|
||||
if (!isOnMiningIsland()) {
|
||||
customBlocks = mapOf()
|
||||
return
|
||||
}
|
||||
val blocks = RepoManager.miningData.customMiningBlocks
|
||||
.flatMap { customBlock ->
|
||||
// TODO: add a lifted helper method for this
|
||||
customBlock.blocks189.filter { it.isCurrentlyActive }
|
||||
.mapNotNull { it.block }
|
||||
.map { customBlock to it }
|
||||
}
|
||||
.groupBy { it.second }
|
||||
customBlocks = blocks.mapNotNull { (block, customBlocks) ->
|
||||
val singleMatch =
|
||||
ErrorUtil.notNullOr(customBlocks.singleOrNull()?.first,
|
||||
"Two custom blocks both want to supply custom mining behaviour for $block.") { return@mapNotNull null }
|
||||
block to singleMatch
|
||||
}.toMap()
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onWorldSwap(event: SkyblockServerUpdateEvent) {
|
||||
refreshBlockInfo()
|
||||
}
|
||||
|
||||
|
||||
override fun appendTooltip(
|
||||
tooltip: ITooltip,
|
||||
block: BlockAccessor,
|
||||
config: IPluginConfig?
|
||||
) {
|
||||
val customBlock = customBlocks[block.block]
|
||||
?: return
|
||||
if (customBlock.breakingPower > 0)
|
||||
tooltip.add(tr("firmament.jade.breaking_power", "Required Breaking Power: ${customBlock.breakingPower}"))
|
||||
}
|
||||
|
||||
override fun getUid(): Identifier =
|
||||
Firmament.identifier("custom_mining_hardness")
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import snownee.jade.api.IWailaClientRegistration
|
||||
import snownee.jade.api.IWailaCommonRegistration
|
||||
import snownee.jade.api.IWailaPlugin
|
||||
import snownee.jade.api.WailaPlugin
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.Blocks
|
||||
import moe.nea.firmament.Firmament
|
||||
|
||||
@@ -15,34 +16,7 @@ class FirmamentJadePlugin : IWailaPlugin {
|
||||
}
|
||||
|
||||
override fun registerClient(registration: IWailaClientRegistration) {
|
||||
registration.registerBlockComponent(MithrilProvider("prismarine"), Blocks.PRISMARINE::class.java)
|
||||
registration.registerBlockComponent(MithrilProvider("gray_wool"), Blocks.GRAY_WOOL::class.java)
|
||||
registration.registerBlockComponent(MithrilProvider("gray_concrete"), Blocks.GRAY_CONCRETE::class.java)
|
||||
// and together, we are the crystal gems of celeste minecraft (surely there's a better way to do this :sob:)
|
||||
registration.registerBlockComponent(GemstoneProvider("red_stained_glass", "ruby"), Blocks.RED_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("red_stained_glass_pane", "ruby"), Blocks.RED_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("purple_stained_glass", "amethyst"), Blocks.PURPLE_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("purple_stained_glass_pane", "amethyst"), Blocks.PURPLE_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("lime_stained_glass", "jade"), Blocks.LIME_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("lime_stained_glass_pane", "jade"), Blocks.LIME_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("blue_stained_glass", "sapphire"), Blocks.BLUE_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("blue_stained_glass_pane", "sapphire"), Blocks.BLUE_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("orange_stained_glass", "amber"), Blocks.ORANGE_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("orange_stained_glass_pane", "amber"), Blocks.ORANGE_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("yellow_stained_glass", "topaz"), Blocks.YELLOW_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("yellow_stained_glass_pane", "topaz"), Blocks.YELLOW_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("magenta_stained_glass", "jasper"), Blocks.MAGENTA_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("magenta_stained_glass_pane", "jasper"), Blocks.MAGENTA_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("white_stained_glass", "opal"), Blocks.WHITE_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("white_stained_glass_pane", "opal"), Blocks.WHITE_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("blue_stained_glass", "aquamarine"), Blocks.BLUE_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("blue_stained_glass_pane", "aquamarine"), Blocks.BLUE_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("black_stained_glass", "onyx"), Blocks.BLACK_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("black_stained_glass_pane", "onyx"), Blocks.BLACK_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("brown_stained_glass", "citrine"), Blocks.BROWN_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("brown_stained_glass_pane", "citrine"), Blocks.BROWN_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("green_stained_glass", "peridot"), Blocks.GREEN_STAINED_GLASS::class.java)
|
||||
registration.registerBlockComponent(GemstoneProvider("green_stained_glass_pane", "peridot"), Blocks.GREEN_STAINED_GLASS_PANE::class.java)
|
||||
registration.registerBlockComponent(CustomMiningHardnessProvider, Block::class.java)
|
||||
registration.registerProgressClient(SkyblockProgressProvider())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NbtCompound
|
||||
import moe.nea.firmament.repo.ReforgeStore.kJson
|
||||
import moe.nea.firmament.util.MC
|
||||
import moe.nea.firmament.util.SBData
|
||||
import moe.nea.firmament.util.SkyBlockIsland
|
||||
import moe.nea.firmament.util.SkyblockId
|
||||
|
||||
@@ -51,6 +52,10 @@ class MiningRepoData : IReloadable {
|
||||
@Transient
|
||||
val block = convertToModernBlock()
|
||||
|
||||
val isCurrentlyActive: Boolean
|
||||
get() = isActiveIn(SBData.skyblockLocation ?: SkyBlockIsland.NIL)
|
||||
fun isActiveIn(location: SkyBlockIsland) = onlyIn == null || location in onlyIn
|
||||
|
||||
private fun convertToModernBlock(): Block? {
|
||||
// TODO: this should be in a shared util, really
|
||||
val newCompound = ItemCache.convert189ToModern(NbtCompound().apply {
|
||||
|
||||
@@ -40,6 +40,7 @@ private constructor(
|
||||
val MINESHAFT = forMode("mineshaft")
|
||||
val GARDEN = forMode("garden")
|
||||
val DUNGEON = forMode("dungeon")
|
||||
val NIL = forMode("_")
|
||||
}
|
||||
|
||||
val hasCustomMining
|
||||
|
||||
@@ -287,6 +287,7 @@
|
||||
"firmament.inventory-buttons.import-failed": "One of your buttons could only be imported partially",
|
||||
"firmament.inventory-buttons.load-preset": "Load Preset",
|
||||
"firmament.inventory-buttons.save-preset": "Save Preset",
|
||||
"firmament.jade.breaking_power": "Required Breaking Power: %s",
|
||||
"firmament.key.category": "Firmament",
|
||||
"firmament.keybinding.external": "%s",
|
||||
"firmament.mixins.start": "Applied firmament mixins:",
|
||||
|
||||
Reference in New Issue
Block a user