fix: Weird tools for BP 7; feat: Options for jade; fix: tools for glass blocks in jade
This commit is contained in:
@@ -15,8 +15,9 @@ class CustomFakeBlockProvider(val registration: IWailaClientRegistration) : Jade
|
||||
accessor: Accessor<*>?,
|
||||
originalAccessor: Accessor<*>?
|
||||
): Accessor<*>? {
|
||||
if (!JadeIntegration.TConfig.blockDetection) return accessor
|
||||
if (accessor !is BlockAccessor) return accessor
|
||||
val customBlock = CurrentCustomBlockHolder.customBlocks[accessor.block]
|
||||
val customBlock = JadeIntegration.customBlocks[accessor.block]
|
||||
if (customBlock == null) return accessor
|
||||
return registration.blockAccessor()
|
||||
.from(accessor)
|
||||
@@ -25,6 +26,12 @@ class CustomFakeBlockProvider(val registration: IWailaClientRegistration) : Jade
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun hasCustomBlock(accessor: BlockAccessor): Boolean {
|
||||
return getCustomBlock(accessor) != null
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getCustomBlock(accessor: BlockAccessor): MiningRepoData.CustomMiningBlock? {
|
||||
if (!accessor.isFakeBlock) return null
|
||||
val item = accessor.fakeBlock
|
||||
|
||||
@@ -66,6 +66,7 @@ object CustomMiningHardnessProvider : IBlockComponentProvider {
|
||||
|
||||
@JvmStatic
|
||||
fun replaceBreakProgress(original: Float): Float {
|
||||
if (!JadeIntegration.TConfig.miningProgress) return original
|
||||
if (!isOnMiningIsland()) return original
|
||||
val pos = MC.interactionManager?.currentBreakingPos ?: return original
|
||||
val info = currentBreakingInfo
|
||||
|
||||
@@ -31,9 +31,8 @@ class DrillToolProvider : IBlockComponentProvider {
|
||||
p2: IPluginConfig?
|
||||
) {
|
||||
val customBlock = CustomFakeBlockProvider.getCustomBlock(accessor) ?: return
|
||||
if (customBlock.breakingPower <= 0) return
|
||||
val tool = RepoManager.miningData.getToolsThatCanBreak(customBlock.breakingPower).firstOrNull()
|
||||
?.asItemStack() ?: return
|
||||
?.asImmutableItemStack() ?: return
|
||||
tooltip.replace(JadeIds.MC_HARVEST_TOOL, UnaryOperator { elements ->
|
||||
elements.map { inner ->
|
||||
val lastItemIndex = inner.indexOfLast { it is ItemStackElement }
|
||||
|
||||
@@ -6,8 +6,15 @@ import moe.nea.firmament.repo.MiningRepoData
|
||||
import moe.nea.firmament.repo.RepoManager
|
||||
import moe.nea.firmament.util.ErrorUtil
|
||||
import net.minecraft.block.Block
|
||||
import moe.nea.firmament.events.ReloadRegistrationEvent
|
||||
import moe.nea.firmament.gui.config.ManagedConfig
|
||||
|
||||
object JadeIntegration {
|
||||
object TConfig : ManagedConfig("jade-integration", Category.INTEGRATIONS) {
|
||||
val miningProgress by toggle("progress") { true }
|
||||
val blockDetection by toggle("blocks") { true }
|
||||
}
|
||||
|
||||
object CurrentCustomBlockHolder {
|
||||
var customBlocks: Map<Block, MiningRepoData.CustomMiningBlock> = mapOf()
|
||||
|
||||
fun refreshBlockInfo() {
|
||||
@@ -31,6 +38,11 @@ object CurrentCustomBlockHolder {
|
||||
}.toMap()
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onRepoReload(event: ReloadRegistrationEvent) {
|
||||
event.repo.registerReloadListener { refreshBlockInfo() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onWorldSwap(event: SkyblockServerUpdateEvent) {
|
||||
refreshBlockInfo()
|
||||
@@ -0,0 +1,33 @@
|
||||
package moe.nea.firmament.mixins.compat.jade;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import moe.nea.firmament.compat.jade.CustomFakeBlockProvider;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import snownee.jade.addon.harvest.HarvestToolProvider;
|
||||
import snownee.jade.api.BlockAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(HarvestToolProvider.class)
|
||||
public class EnforceToolDisplayForCustomBlocksInHarvestToolProvider {
|
||||
@ModifyExpressionValue(method = "getText", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isToolRequired()Z"))
|
||||
private boolean overwriteRequiresTool(boolean original, @Local(argsOnly = true) BlockAccessor accessor) {
|
||||
if (CustomFakeBlockProvider.hasCustomBlock(accessor))
|
||||
return true;
|
||||
return original;
|
||||
}
|
||||
|
||||
private static final List<ItemStack> REPLACEABLE_TOOL = List.of(new ItemStack(Blocks.ENCHANTING_TABLE));
|
||||
|
||||
@ModifyExpressionValue(method = "getText", at = @At(value = "INVOKE", target = "Lcom/google/common/cache/Cache;get(Ljava/lang/Object;Ljava/util/concurrent/Callable;)Ljava/lang/Object;"))
|
||||
private Object overwriteAvailableTools(Object original, @Local(argsOnly = true) BlockAccessor accessor) {
|
||||
var orig = (List<ItemStack>) original;
|
||||
if (orig.isEmpty() && CustomFakeBlockProvider.hasCustomBlock(accessor))
|
||||
return REPLACEABLE_TOOL;
|
||||
return orig;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class MiningRepoData : IReloadable {
|
||||
private set
|
||||
var customMiningBlocks: List<CustomMiningBlock> = listOf()
|
||||
private set
|
||||
var toolsByBreakingPower: NavigableMap<BreakingPowerKey, NEUItem> = Collections.emptyNavigableMap()
|
||||
var toolsByBreakingPower: NavigableMap<BreakingPowerKey, SBItemStack> = Collections.emptyNavigableMap()
|
||||
private set
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class MiningRepoData : IReloadable {
|
||||
.comparingInt<BreakingPowerKey> { it.breakingPower }
|
||||
.thenComparing(Comparator.comparing(
|
||||
{ it.itemId },
|
||||
nullsFirst(Comparator.naturalOrder<SkyblockId>())))
|
||||
nullsFirst(Comparator.comparing<SkyblockId, Boolean> { "PICK" in it.neuItem || "BING" in it.neuItem }.thenComparing(Comparator.naturalOrder<SkyblockId>()))))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,13 +60,14 @@ class MiningRepoData : IReloadable {
|
||||
repo.items.items
|
||||
.values
|
||||
.asSequence()
|
||||
.map { SBItemStack(it.skyblockId) }
|
||||
.filter { it.breakingPower > 0 }
|
||||
.associateTo(TreeMap<BreakingPowerKey, NEUItem>(BreakingPowerKey.COMPARATOR)) {
|
||||
.associateTo(TreeMap<BreakingPowerKey, SBItemStack>(BreakingPowerKey.COMPARATOR)) {
|
||||
BreakingPowerKey(it.breakingPower, it.skyblockId) to it
|
||||
})
|
||||
}
|
||||
|
||||
fun getToolsThatCanBreak(breakingPower: Int): Collection<NEUItem> {
|
||||
fun getToolsThatCanBreak(breakingPower: Int): Collection<SBItemStack> {
|
||||
return toolsByBreakingPower.tailMap(BreakingPowerKey(breakingPower, null), true).values
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ object RepoManager {
|
||||
registerReloadListener(ItemNameLookup)
|
||||
registerReloadListener(ReforgeStore)
|
||||
registerReloadListener(essenceRecipeProvider)
|
||||
registerReloadListener(recipeCache)
|
||||
registerReloadListener(miningData)
|
||||
ReloadRegistrationEvent.publish(ReloadRegistrationEvent(this))
|
||||
registerReloadListener {
|
||||
@@ -75,7 +76,6 @@ object RepoManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
registerReloadListener(recipeCache)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import moe.nea.firmament.util.modifyExtraAttributes
|
||||
import moe.nea.firmament.util.petData
|
||||
import moe.nea.firmament.util.prepend
|
||||
import moe.nea.firmament.util.reconstitute
|
||||
import moe.nea.firmament.util.removeColorCodes
|
||||
import moe.nea.firmament.util.skyBlockId
|
||||
import moe.nea.firmament.util.skyblock.ItemType
|
||||
import moe.nea.firmament.util.skyblock.Rarity
|
||||
@@ -352,7 +353,7 @@ data class SBItemStack constructor(
|
||||
|
||||
val breakingPower: Int
|
||||
get() =
|
||||
BREAKING_POWER_REGEX.useMatch(asImmutableItemStack().loreAccordingToNbt.firstOrNull()?.string) {
|
||||
BREAKING_POWER_REGEX.useMatch(neuItem?.lore?.firstOrNull()?.removeColorCodes()) {
|
||||
group("power").toInt()
|
||||
} ?: 0
|
||||
|
||||
|
||||
@@ -134,6 +134,11 @@
|
||||
"firmament.config.item-rarity-cosmetics.background-hotbar": "Hotbar Background Rarity",
|
||||
"firmament.config.item-rarity-cosmetics.background-hotbar.description": "Show item rarity background in the hotbar.",
|
||||
"firmament.config.item-rarity-cosmetics.background.description": "Show a background behind each item, depending on its rarity.",
|
||||
"firmament.config.jade-integration": "Jade / WAILA",
|
||||
"firmament.config.jade-integration.blocks": "Enable Custom Blocks",
|
||||
"firmament.config.jade-integration.blocks.description": "Show custom block descriptions and hardness levels in Jade.",
|
||||
"firmament.config.jade-integration.progress": "Enable Custom Mining Progress",
|
||||
"firmament.config.jade-integration.progress.description": "Show the custom mining progress in Jade, when in a world with mining fatigue.",
|
||||
"firmament.config.lore-timers": "Lore Timers",
|
||||
"firmament.config.lore-timers.format": "Time Format",
|
||||
"firmament.config.lore-timers.format.choice.american": "§9Ame§cri§fcan",
|
||||
|
||||
Reference in New Issue
Block a user