diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-07-17 11:52:28 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-07-17 11:52:28 +0200 |
| commit | 25f0e7fd62db22036969120843165f4759530b8f (patch) | |
| tree | 262ed44e0e68464ba99f7650fed8df102c982fe5 /src/main/kotlin/features/inventory/PetFeatures.kt | |
| parent | 13d64762bbf110fbc52719fb9d93490648199dd2 (diff) | |
| download | Firmament-25f0e7fd62db22036969120843165f4759530b8f.tar.gz Firmament-25f0e7fd62db22036969120843165f4759530b8f.tar.bz2 Firmament-25f0e7fd62db22036969120843165f4759530b8f.zip | |
feat: Launch on 1.21.7
Diffstat (limited to 'src/main/kotlin/features/inventory/PetFeatures.kt')
| -rw-r--r-- | src/main/kotlin/features/inventory/PetFeatures.kt | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/src/main/kotlin/features/inventory/PetFeatures.kt b/src/main/kotlin/features/inventory/PetFeatures.kt index 9393b03..701d30c 100644 --- a/src/main/kotlin/features/inventory/PetFeatures.kt +++ b/src/main/kotlin/features/inventory/PetFeatures.kt @@ -1,6 +1,6 @@ package moe.nea.firmament.features.inventory -import moe.nea.jarvis.api.Point +import org.joml.Vector2i import net.minecraft.item.ItemStack import net.minecraft.text.Text import net.minecraft.util.Formatting @@ -10,6 +10,7 @@ import moe.nea.firmament.events.HudRenderEvent import moe.nea.firmament.events.SlotRenderEvents import moe.nea.firmament.features.FirmamentFeature import moe.nea.firmament.gui.config.ManagedConfig +import moe.nea.firmament.jarvis.JarvisIntegration import moe.nea.firmament.util.FirmFormatters.formatPercent import moe.nea.firmament.util.FirmFormatters.shortFormat import moe.nea.firmament.util.MC @@ -31,7 +32,9 @@ object PetFeatures : FirmamentFeature { object TConfig : ManagedConfig(identifier, Category.INVENTORY) { val highlightEquippedPet by toggle("highlight-pet") { true } var petOverlay by toggle("pet-overlay") { false } - val petOverlayHud by position("pet-overlay-hud", 80, 10) { Point(0.5, 1.0) } + val petOverlayHud by position("pet-overlay-hud", 80, 10) { + Vector2i() + } } val petMenuTitle = "Pets(?: \\([0-9]+/[0-9]+\\))?".toPattern() @@ -43,12 +46,12 @@ object PetFeatures : FirmamentFeature { val stack = event.slot.stack if (stack.petData?.active == true) petMenuTitle.useMatch(MC.screenName ?: return) { - petItemStack = stack - event.context.drawGuiTexture( - Firmament.identifier("selected_pet_background"), - event.slot.x, event.slot.y, 16, 16, - ) - } + petItemStack = stack + event.context.drawGuiTexture( + Firmament.identifier("selected_pet_background"), + event.slot.x, event.slot.y, 16, 16, + ) + } } @Subscribe @@ -62,25 +65,48 @@ object PetFeatures : FirmamentFeature { val petType = titleCase(petData.type) val heldItem = petData.heldItem?.let { item -> "Held Item: ${titleCase(item)}" } - it.context.matrices.push() - TConfig.petOverlayHud.applyTransformations(it.context.matrices) + it.context.matrices.pushMatrix() + TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.matrices) val lines = mutableListOf<Text>() - it.context.matrices.push() - it.context.matrices.translate(-0.5, -0.5, 0.0) - it.context.matrices.scale(2f, 2f, 1f) + it.context.matrices.pushMatrix() + it.context.matrices.translate(-0.5F, -0.5F) + it.context.matrices.scale(2f, 2f) it.context.drawItem(itemStack, 0, 0) - it.context.matrices.pop() + it.context.matrices.popMatrix() lines.add(Text.literal("[Lvl ${xp.currentLevel}] ").append(Text.literal(petType).withColor(rarityCode))) if (heldItem != null) lines.add(Text.literal(heldItem)) - if (xp.currentLevel != xp.maxLevel) lines.add(Text.literal("Required L${xp.currentLevel + 1}: ${shortFormat(xp.expInCurrentLevel.toDouble())}/${shortFormat(xp.expRequiredForNextLevel.toDouble())} (${formatPercent(xp.percentageToNextLevel.toDouble())})")) - lines.add(Text.literal("Required L100: ${shortFormat(xp.expTotal.toDouble())}/${shortFormat(xp.expRequiredForMaxLevel.toDouble())} (${formatPercent(xp.percentageToMaxLevel.toDouble())})")) + if (xp.currentLevel != xp.maxLevel) lines.add( + Text.literal( + "Required L${xp.currentLevel + 1}: ${shortFormat(xp.expInCurrentLevel.toDouble())}/${ + shortFormat( + xp.expRequiredForNextLevel.toDouble() + ) + } (${formatPercent(xp.percentageToNextLevel.toDouble())})" + ) + ) + lines.add( + Text.literal( + "Required L100: ${shortFormat(xp.expTotal.toDouble())}/${shortFormat(xp.expRequiredForMaxLevel.toDouble())} (${ + formatPercent( + xp.percentageToMaxLevel.toDouble() + ) + })" + ) + ) for ((index, line) in lines.withIndex()) { - it.context.drawText(MC.font, line.copy().withColor(Formatting.GRAY), 36, MC.font.fontHeight * index, -1, true) + it.context.drawText( + MC.font, + line.copy().withColor(Formatting.GRAY), + 36, + MC.font.fontHeight * index, + -1, + true + ) } - it.context.matrices.pop() + it.context.matrices.popMatrix() } } |
