feat: Add block breaking indicators to jade

This commit is contained in:
Linnea Gräf
2025-03-07 00:21:38 +01:00
parent 6ad259ca40
commit b4a93bd751
10 changed files with 101 additions and 39 deletions

View File

@@ -0,0 +1,17 @@
package moe.nea.firmament.mixins.accessor;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.entity.player.BlockBreakingInfo;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.SortedSet;
@Mixin(WorldRenderer.class)
public interface AccessorWorldRenderer {
@Accessor("blockBreakingProgressions")
@NotNull
Long2ObjectMap<SortedSet<BlockBreakingInfo>> getBlockBreakingProgressions_firmament();
}

View File

@@ -81,6 +81,7 @@ data class SBItemStack constructor(
}
val EMPTY = SBItemStack(SkyblockId.NULL, 0)
private val BREAKING_POWER_REGEX = "Breaking Power (?<power>[0-9]+)".toPattern()
operator fun invoke(itemStack: ItemStack): SBItemStack {
val skyblockId = itemStack.skyBlockId ?: SkyblockId.NULL
return SBItemStack(
@@ -349,6 +350,12 @@ data class SBItemStack constructor(
private var itemStack_: ItemStack? = null
val breakingPower: Int
get() =
BREAKING_POWER_REGEX.useMatch(asImmutableItemStack().loreAccordingToNbt.firstOrNull()?.string) {
group("power").toInt()
} ?: 0
private val itemStack: ItemStack
get() {
val itemStack = itemStack_ ?: run {

View File

@@ -16,12 +16,13 @@ import kotlin.time.Duration.Companion.seconds
inline fun <T> String.ifMatches(regex: Regex, block: (MatchResult) -> T): T? =
regex.matchEntire(this)?.let(block)
inline fun <T> Pattern.useMatch(string: String, block: Matcher.() -> T): T? {
inline fun <T> Pattern.useMatch(string: String?, block: Matcher.() -> T): T? {
contract {
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
}
return matcher(string)
.takeIf(Matcher::matches)
return string
?.let(this::matcher)
?.takeIf(Matcher::matches)
?.let(block)
}

View File

@@ -25,3 +25,4 @@ accessible field net/minecraft/client/render/OverlayTexture texture Lnet/minecra
accessible method net/minecraft/client/render/RenderPhase$Texture getId ()Ljava/util/Optional;
accessible field net/minecraft/client/render/RenderLayer$MultiPhase phases Lnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;
accessible field net/minecraft/client/render/RenderLayer$MultiPhaseParameters texture Lnet/minecraft/client/render/RenderPhase$TextureBase;
accessible field net/minecraft/client/network/ClientPlayerInteractionManager currentBreakingPos Lnet/minecraft/util/math/BlockPos;