aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features')
-rw-r--r--src/main/kotlin/features/chat/AutoCompletions.kt2
-rw-r--r--src/main/kotlin/features/chat/ChatLinks.kt48
-rw-r--r--src/main/kotlin/features/chat/CopyChat.kt4
-rw-r--r--src/main/kotlin/features/chat/PartyCommands.kt4
-rw-r--r--src/main/kotlin/features/chat/QuickCommands.kt26
-rw-r--r--src/main/kotlin/features/debug/AnimatedClothingScanner.kt34
-rw-r--r--src/main/kotlin/features/debug/DebugLogger.kt4
-rw-r--r--src/main/kotlin/features/debug/DeveloperFeatures.kt12
-rw-r--r--src/main/kotlin/features/debug/ExportedTestConstantMeta.kt2
-rw-r--r--src/main/kotlin/features/debug/MinorTrolling.kt4
-rw-r--r--src/main/kotlin/features/debug/PowerUserTools.kt134
-rw-r--r--src/main/kotlin/features/debug/SkinPreviews.kt18
-rw-r--r--src/main/kotlin/features/debug/SoundVisualizer.kt4
-rw-r--r--src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt30
-rw-r--r--src/main/kotlin/features/debug/itemeditor/ItemExporter.kt20
-rw-r--r--src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt8
-rw-r--r--src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt98
-rw-r--r--src/main/kotlin/features/diana/AncestralSpadeSolver.kt16
-rw-r--r--src/main/kotlin/features/diana/NearbyBurrowsSolver.kt12
-rw-r--r--src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt30
-rw-r--r--src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt28
-rw-r--r--src/main/kotlin/features/events/carnival/MinesweeperHelper.kt38
-rw-r--r--src/main/kotlin/features/fixes/Fixes.kt30
-rw-r--r--src/main/kotlin/features/garden/HideComposterNoises.kt14
-rw-r--r--src/main/kotlin/features/inventory/CraftingOverlay.kt26
-rw-r--r--src/main/kotlin/features/inventory/ItemRarityCosmetics.kt18
-rw-r--r--src/main/kotlin/features/inventory/JunkHighlighter.kt2
-rw-r--r--src/main/kotlin/features/inventory/PetFeatures.kt134
-rw-r--r--src/main/kotlin/features/inventory/PriceData.kt18
-rw-r--r--src/main/kotlin/features/inventory/REIDependencyWarner.kt26
-rw-r--r--src/main/kotlin/features/inventory/SaveCursorPosition.kt6
-rw-r--r--src/main/kotlin/features/inventory/SlotLocking.kt128
-rw-r--r--src/main/kotlin/features/inventory/TimerInLore.kt12
-rw-r--r--src/main/kotlin/features/inventory/WardrobeKeybinds.kt12
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButton.kt42
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt116
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt4
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtons.kt30
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt20
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt30
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt52
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt142
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt54
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt22
-rw-r--r--src/main/kotlin/features/items/BlockZapperOverlay.kt24
-rw-r--r--src/main/kotlin/features/items/BonemerangOverlay.kt36
-rw-r--r--src/main/kotlin/features/items/EtherwarpOverlay.kt76
-rw-r--r--src/main/kotlin/features/macros/ComboProcessor.kt22
-rw-r--r--src/main/kotlin/features/macros/HotkeyAction.kt8
-rw-r--r--src/main/kotlin/features/macros/KeyComboTrie.kt10
-rw-r--r--src/main/kotlin/features/macros/MacroUI.kt8
-rw-r--r--src/main/kotlin/features/macros/RadialMenu.kt14
-rw-r--r--src/main/kotlin/features/mining/CommissionFeatures.kt2
-rw-r--r--src/main/kotlin/features/mining/HotmPresets.kt60
-rw-r--r--src/main/kotlin/features/mining/MiningBlockInfoUi.kt4
-rw-r--r--src/main/kotlin/features/mining/PickaxeAbility.kt42
-rw-r--r--src/main/kotlin/features/mining/PristineProfitTracker.kt6
-rw-r--r--src/main/kotlin/features/misc/CustomCapes.kt80
-rw-r--r--src/main/kotlin/features/misc/Hud.kt46
-rw-r--r--src/main/kotlin/features/misc/LicenseViewer.kt16
-rw-r--r--src/main/kotlin/features/misc/ModAnnouncer.kt28
-rw-r--r--src/main/kotlin/features/world/ColeWeightCompat.kt24
-rw-r--r--src/main/kotlin/features/world/FairySouls.kt4
-rw-r--r--src/main/kotlin/features/world/FirmWaypointManager.kt10
-rw-r--r--src/main/kotlin/features/world/FirmWaypoints.kt2
-rw-r--r--src/main/kotlin/features/world/NavigableWaypoint.kt2
-rw-r--r--src/main/kotlin/features/world/NavigationHelper.kt24
-rw-r--r--src/main/kotlin/features/world/NpcWaypointGui.kt4
-rw-r--r--src/main/kotlin/features/world/TemporaryWaypoints.kt14
-rw-r--r--src/main/kotlin/features/world/Waypoints.kt46
70 files changed, 1063 insertions, 1063 deletions
diff --git a/src/main/kotlin/features/chat/AutoCompletions.kt b/src/main/kotlin/features/chat/AutoCompletions.kt
index c9fd133..f13fe7e 100644
--- a/src/main/kotlin/features/chat/AutoCompletions.kt
+++ b/src/main/kotlin/features/chat/AutoCompletions.kt
@@ -9,7 +9,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType
import kotlin.concurrent.thread
import net.minecraft.SharedConstants
-import net.minecraft.command.TranslatableBuiltInExceptions
+import net.minecraft.commands.BrigadierExceptions
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.suggestsList
diff --git a/src/main/kotlin/features/chat/ChatLinks.kt b/src/main/kotlin/features/chat/ChatLinks.kt
index 76eb48d..aca7af8 100644
--- a/src/main/kotlin/features/chat/ChatLinks.kt
+++ b/src/main/kotlin/features/chat/ChatLinks.kt
@@ -9,15 +9,15 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.future.await
import kotlin.math.min
-import net.minecraft.client.gui.screen.ChatScreen
-import net.minecraft.client.texture.NativeImage
-import net.minecraft.client.texture.NativeImageBackedTexture
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.HoverEvent
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.Identifier
+import net.minecraft.client.gui.screens.ChatScreen
+import com.mojang.blaze3d.platform.NativeImage
+import net.minecraft.client.renderer.texture.DynamicTexture
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.HoverEvent
+import net.minecraft.network.chat.Style
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ModifyChatEvent
@@ -54,7 +54,7 @@ object ChatLinks {
val nextTexId = AtomicInteger(0)
data class Image(
- val texture: Identifier,
+ val texture: ResourceLocation,
val width: Int,
val height: Int,
)
@@ -76,9 +76,9 @@ object ChatLinks {
.await()
val image = NativeImage.read(inputStream)
val texId = Firmament.identifier("dynamic_image_preview${nextTexId.getAndIncrement()}")
- MC.textureManager.registerTexture(
+ MC.textureManager.register(
texId,
- NativeImageBackedTexture({ texId.path }, image)
+ DynamicTexture({ texId.path }, image)
)
Image(texId, image.width, image.height)
} catch (exc: Exception) {
@@ -99,7 +99,7 @@ object ChatLinks {
if (!TConfig.imageEnabled) return
if (it.screen !is ChatScreen) return
val hoveredComponent =
- MC.inGameHud.chatHud.getTextStyleAt(it.mouseX.toDouble(), it.mouseY.toDouble()) ?: return
+ MC.inGameHud.chat.getClickedComponentStyleAt(it.mouseX.toDouble(), it.mouseY.toDouble()) ?: return
val hoverEvent = hoveredComponent.hoverEvent as? HoverEvent.ShowText ?: return
val value = hoverEvent.value
val url = urlRegex.matchEntire(value.unformattedString)?.groupValues?.get(0) ?: return
@@ -107,11 +107,11 @@ object ChatLinks {
val imageFuture = imageCache[url] ?: return
if (!imageFuture.isCompleted) return
val image = imageFuture.getCompleted() ?: return
- it.drawContext.matrices.pushMatrix()
+ it.drawContext.pose().pushMatrix()
val pos = TConfig.position
- pos.applyTransformations(JarvisIntegration.jarvis, it.drawContext.matrices)
+ pos.applyTransformations(JarvisIntegration.jarvis, it.drawContext.pose())
val scale = min(1F, min((9 * 20F) / image.height, (16 * 20F) / image.width))
- it.drawContext.matrices.scale(scale, scale)
+ it.drawContext.pose().scale(scale, scale)
it.drawContext.drawTexture(
image.texture,
0,
@@ -123,7 +123,7 @@ object ChatLinks {
image.width,
image.height,
)
- it.drawContext.matrices.popMatrix()
+ it.drawContext.pose().popMatrix()
}
@Subscribe
@@ -132,23 +132,23 @@ object ChatLinks {
it.replaceWith = it.replaceWith.transformEachRecursively { child ->
val text = child.string
if ("://" !in text) return@transformEachRecursively child
- val s = Text.empty().setStyle(child.style)
+ val s = Component.empty().setStyle(child.style)
var index = 0
while (index < text.length) {
val nextMatch = urlRegex.find(text, index)
val url = nextMatch?.groupValues[0]
val uri = runCatching { url?.let(::URI) }.getOrNull()
if (nextMatch == null || url == null || uri == null) {
- s.append(Text.literal(text.substring(index, text.length)))
+ s.append(Component.literal(text.substring(index, text.length)))
break
}
val range = nextMatch.groups[0]!!.range
- s.append(Text.literal(text.substring(index, range.first)))
+ s.append(Component.literal(text.substring(index, range.first)))
s.append(
- Text.literal(url).setStyle(
- Style.EMPTY.withUnderline(true).withColor(
- Formatting.AQUA
- ).withHoverEvent(HoverEvent.ShowText(Text.literal(url)))
+ Component.literal(url).setStyle(
+ Style.EMPTY.withUnderlined(true).withColor(
+ ChatFormatting.AQUA
+ ).withHoverEvent(HoverEvent.ShowText(Component.literal(url)))
.withClickEvent(ClickEvent.OpenUrl(uri))
)
)
diff --git a/src/main/kotlin/features/chat/CopyChat.kt b/src/main/kotlin/features/chat/CopyChat.kt
index 5c46465..6bef99f 100644
--- a/src/main/kotlin/features/chat/CopyChat.kt
+++ b/src/main/kotlin/features/chat/CopyChat.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.features.chat
-import net.minecraft.text.OrderedText
+import net.minecraft.util.FormattedCharSequence
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.reconstitute
@@ -15,7 +15,7 @@ object CopyChat {
val copyChat by toggle("copy-chat") { false }
}
- fun orderedTextToString(orderedText: OrderedText): String {
+ fun orderedTextToString(orderedText: FormattedCharSequence): String {
return orderedText.reconstitute().string
}
}
diff --git a/src/main/kotlin/features/chat/PartyCommands.kt b/src/main/kotlin/features/chat/PartyCommands.kt
index 1b34946..85daf51 100644
--- a/src/main/kotlin/features/chat/PartyCommands.kt
+++ b/src/main/kotlin/features/chat/PartyCommands.kt
@@ -5,7 +5,7 @@ import com.mojang.brigadier.StringReader
import com.mojang.brigadier.exceptions.CommandSyntaxException
import com.mojang.brigadier.tree.LiteralCommandNode
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.CaseInsensitiveLiteralCommandNode
import moe.nea.firmament.commands.thenExecute
@@ -80,7 +80,7 @@ object PartyCommands {
register("coords") {
executes {
- val p = MC.player?.blockPos ?: BlockPos.ORIGIN
+ val p = MC.player?.blockPosition() ?: BlockPos.ZERO
MC.sendCommand("pc x: ${p.x}, y: ${p.y}, z: ${p.z}")
0
}
diff --git a/src/main/kotlin/features/chat/QuickCommands.kt b/src/main/kotlin/features/chat/QuickCommands.kt
index 5221205..b857f8a 100644
--- a/src/main/kotlin/features/chat/QuickCommands.kt
+++ b/src/main/kotlin/features/chat/QuickCommands.kt
@@ -5,9 +5,9 @@ import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.fabricmc.fabric.impl.command.client.ClientCommandInternals
-import net.minecraft.command.CommandRegistryAccess
-import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket
-import net.minecraft.text.Text
+import net.minecraft.commands.CommandBuildContext
+import net.minecraft.network.protocol.game.ClientboundCommandsPacket
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.DefaultSource
import moe.nea.firmament.commands.RestArgumentType
@@ -45,13 +45,13 @@ object QuickCommands {
ClientCommandInternals.setActiveDispatcher(dispatcher)
ClientCommandRegistrationCallback.EVENT.invoker()
.register(
- dispatcher, CommandRegistryAccess.of(
- network.combinedDynamicRegistries,
- network.enabledFeatures
+ dispatcher, CommandBuildContext.simple(
+ network.registryAccess,
+ network.enabledFeatures()
)
)
ClientCommandInternals.finalizeInit()
- network.onCommandTree(lastPacket)
+ network.handleCommands(lastPacket)
} catch (ex: Exception) {
ClientCommandInternals.setActiveDispatcher(fallback)
throw ex
@@ -69,7 +69,7 @@ object QuickCommands {
return lf
}
- var lastReceivedTreePacket: CommandTreeS2CPacket? = null
+ var lastReceivedTreePacket: ClientboundCommandsPacket? = null
val kuudraLevelNames = listOf("NORMAL", "HOT", "BURNING", "FIERY", "INFERNAL")
val dungeonLevelNames = listOf("ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN")
@@ -103,10 +103,10 @@ object QuickCommands {
}
val joinName = getNameForFloor(what.replace(" ", "").lowercase())
if (joinName == null) {
- source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown", what))
+ source.sendFeedback(Component.translatableEscape("firmament.quick-commands.join.unknown", what))
} else {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.success",
joinName
)
@@ -116,7 +116,7 @@ object QuickCommands {
}
}
thenExecute {
- source.sendFeedback(Text.translatable("firmament.quick-commands.join.explain"))
+ source.sendFeedback(Component.translatable("firmament.quick-commands.join.explain"))
}
}
}
@@ -132,7 +132,7 @@ object QuickCommands {
}
if (l !in kuudraLevelNames.indices) {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.unknown-kuudra",
kuudraLevel
)
@@ -157,7 +157,7 @@ object QuickCommands {
}
if (l !in dungeonLevelNames.indices) {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.unknown-catacombs",
kuudraLevel
)
diff --git a/src/main/kotlin/features/debug/AnimatedClothingScanner.kt b/src/main/kotlin/features/debug/AnimatedClothingScanner.kt
index 4edccfb..dc77115 100644
--- a/src/main/kotlin/features/debug/AnimatedClothingScanner.kt
+++ b/src/main/kotlin/features/debug/AnimatedClothingScanner.kt
@@ -1,13 +1,13 @@
package moe.nea.firmament.features.debug
-import net.minecraft.command.argument.RegistryKeyArgumentType
-import net.minecraft.component.ComponentType
-import net.minecraft.entity.Entity
-import net.minecraft.entity.decoration.ArmorStandEntity
-import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NbtElement
+import net.minecraft.commands.arguments.ResourceKeyArgument
+import net.minecraft.core.component.DataComponentType
+import net.minecraft.world.entity.Entity
+import net.minecraft.world.entity.decoration.ArmorStand
+import net.minecraft.world.item.ItemStack
+import net.minecraft.nbt.Tag
import net.minecraft.nbt.NbtOps
-import net.minecraft.registry.RegistryKeys
+import net.minecraft.core.registries.Registries
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.thenArgument
@@ -27,11 +27,11 @@ object AnimatedClothingScanner {
data class LensOfFashionTheft<T>(
val prism: NbtPrism,
- val component: ComponentType<T>,
+ val component: DataComponentType<T>,
) {
- fun observe(itemStack: ItemStack): Collection<NbtElement> {
+ fun observe(itemStack: ItemStack): Collection<Tag> {
val x = itemStack.get(component) ?: return listOf()
- val nbt = component.codecOrThrow.encodeStart(NbtOps.INSTANCE, x).orThrow
+ val nbt = component.codecOrThrow().encodeStart(NbtOps.INSTANCE, x).orThrow
return prism.access(nbt)
}
}
@@ -115,16 +115,16 @@ object AnimatedClothingScanner {
)
)
val p = MC.player!!
- val nearestPet = p.world.getEntitiesByClass(
- ArmorStandEntity::class.java,
- p.boundingBox.expand(10.0),
+ val nearestPet = p.level.getEntitiesOfClass(
+ ArmorStand::class.java,
+ p.boundingBox.inflate(10.0),
{ it.isMarker })
- .minBy { it.squaredDistanceTo(p) }
+ .minBy { it.distanceToSqr(p) }
toggleObserve(nearestPet)
}
}
thenExecute {
- val ent = MC.instance.targetedEntity
+ val ent = MC.instance.crosshairPickEntity
if (ent == null) {
source.sendFeedback(
tr(
@@ -140,7 +140,7 @@ object AnimatedClothingScanner {
thenLiteral("path") {
thenArgument(
"component",
- RegistryKeyArgumentType.registryKey(RegistryKeys.DATA_COMPONENT_TYPE)
+ ResourceKeyArgument.key(Registries.DATA_COMPONENT_TYPE)
) { component ->
thenArgument("path", NbtPrism.Argument) { path ->
thenExecute {
@@ -151,7 +151,7 @@ object AnimatedClothingScanner {
source.sendFeedback(
tr(
"firmament.fitstealer.lensset",
- "Analyzing path ${get(path)} for component ${get(component).value}"
+ "Analyzing path ${get(path)} for component ${get(component).location()}"
)
)
}
diff --git a/src/main/kotlin/features/debug/DebugLogger.kt b/src/main/kotlin/features/debug/DebugLogger.kt
index 52f6143..2c8ced0 100644
--- a/src/main/kotlin/features/debug/DebugLogger.kt
+++ b/src/main/kotlin/features/debug/DebugLogger.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.debug
import kotlinx.serialization.serializer
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TestUtil
import moe.nea.firmament.util.collections.InstanceList
@@ -24,6 +24,6 @@ class DebugLogger(val tag: String) {
fun log(text: String) = log { text }
fun log(text: () -> String) {
if (!isEnabled()) return
- MC.sendChat(Text.literal(text()))
+ MC.sendChat(Component.literal(text()))
}
}
diff --git a/src/main/kotlin/features/debug/DeveloperFeatures.kt b/src/main/kotlin/features/debug/DeveloperFeatures.kt
index e86c6ad..8638bb6 100644
--- a/src/main/kotlin/features/debug/DeveloperFeatures.kt
+++ b/src/main/kotlin/features/debug/DeveloperFeatures.kt
@@ -10,8 +10,8 @@ import org.spongepowered.asm.mixin.Mixin
import kotlinx.serialization.json.encodeToStream
import kotlin.io.path.absolute
import kotlin.io.path.exists
-import net.minecraft.client.MinecraftClient
-import net.minecraft.text.Text
+import net.minecraft.client.Minecraft
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.DebugInstantiateEvent
@@ -92,17 +92,17 @@ object DeveloperFeatures {
}
@JvmStatic
- fun hookOnBeforeResourceReload(client: MinecraftClient): CompletableFuture<Void> {
+ fun hookOnBeforeResourceReload(client: Minecraft): CompletableFuture<Void> {
val reloadFuture = if (TConfig.autoRebuildResources && Firmament.DEBUG && gradleDir != null) {
val builder = ProcessBuilder("./gradlew", ":processResources")
builder.directory(gradleDir.toFile())
builder.inheritIO()
val process = builder.start()
- MC.sendChat(Text.translatable("firmament.dev.resourcerebuild.start"))
+ MC.sendChat(Component.translatable("firmament.dev.resourcerebuild.start"))
val startTime = TimeMark.now()
process.toHandle().onExit().thenApply {
MC.sendChat(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.dev.resourcerebuild.done",
startTime.passedTime()
)
@@ -112,7 +112,7 @@ object DeveloperFeatures {
} else {
CompletableFuture.completedFuture(Unit)
}
- return reloadFuture.thenCompose { client.reloadResources() }
+ return reloadFuture.thenCompose { client.reloadResourcePacks() }
}
}
diff --git a/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt b/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt
index bdc1f9a..a2b42fd 100644
--- a/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt
+++ b/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt
@@ -12,7 +12,7 @@ data class ExportedTestConstantMeta(
) {
companion object {
val current = ExportedTestConstantMeta(
- SharedConstants.getGameVersion().dataVersion().id,
+ SharedConstants.getCurrentVersion().dataVersion().version,
Optional.of("Firmament ${Firmament.version.friendlyString}")
)
diff --git a/src/main/kotlin/features/debug/MinorTrolling.kt b/src/main/kotlin/features/debug/MinorTrolling.kt
index d802d40..7936521 100644
--- a/src/main/kotlin/features/debug/MinorTrolling.kt
+++ b/src/main/kotlin/features/debug/MinorTrolling.kt
@@ -2,7 +2,7 @@
package moe.nea.firmament.features.debug
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ModifyChatEvent
@@ -20,6 +20,6 @@ object MinorTrolling {
val (_, name, text) = m.groupValues
if (name !in trollers) return
if (!text.startsWith("c:")) return
- it.replaceWith = Text.literal(text.substring(2).replace("&", "§"))
+ it.replaceWith = Component.literal(text.substring(2).replace("&", "§"))
}
}
diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt
index fc36806..1a14f73 100644
--- a/src/main/kotlin/features/debug/PowerUserTools.kt
+++ b/src/main/kotlin/features/debug/PowerUserTools.kt
@@ -2,24 +2,24 @@ package moe.nea.firmament.features.debug
import com.mojang.serialization.JsonOps
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.block.SkullBlock
-import net.minecraft.block.entity.SkullBlockEntity
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.ProfileComponent
-import net.minecraft.entity.Entity
-import net.minecraft.entity.LivingEntity
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtList
+import net.minecraft.world.level.block.SkullBlock
+import net.minecraft.world.level.block.entity.SkullBlockEntity
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.ResolvableProfile
+import net.minecraft.world.entity.Entity
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.predicate.NbtPredicate
-import net.minecraft.text.Text
-import net.minecraft.text.TextCodecs
-import net.minecraft.util.Identifier
-import net.minecraft.util.Nameable
-import net.minecraft.util.hit.BlockHitResult
-import net.minecraft.util.hit.EntityHitResult
-import net.minecraft.util.hit.HitResult
+import net.minecraft.advancements.critereon.NbtPredicate
+import net.minecraft.network.chat.Component
+import net.minecraft.network.chat.ComponentSerialization
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.world.Nameable
+import net.minecraft.world.phys.BlockHitResult
+import net.minecraft.world.phys.EntityHitResult
+import net.minecraft.world.phys.HitResult
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.CustomItemModelEvent
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
@@ -69,7 +69,7 @@ object PowerUserTools {
val autoCopyAnimatedSkins by toggle("copy-animated-skins") { false }
}
- var lastCopiedStack: Pair<ItemStack, Text>? = null
+ var lastCopiedStack: Pair<ItemStack, Component>? = null
set(value) {
field = value
if (value != null) lastCopiedStackViewTime = 2
@@ -86,20 +86,20 @@ object PowerUserTools {
lastCopiedStack = null
}
- fun debugFormat(itemStack: ItemStack): Text {
- return Text.literal(itemStack.skyBlockId?.toString() ?: itemStack.toString())
+ fun debugFormat(itemStack: ItemStack): Component {
+ return Component.literal(itemStack.skyBlockId?.toString() ?: itemStack.toString())
}
@Subscribe
fun onRender(event: SlotRenderEvents.After) {
if (TConfig.showSlotNumbers.isPressed()) {
- event.context.drawText(
+ event.context.drawString(
MC.font,
- event.slot.id.toString(), event.slot.x, event.slot.y, 0xFF00FF00.toInt(), true
+ event.slot.index.toString(), event.slot.x, event.slot.y, 0xFF00FF00.toInt(), true
)
- event.context.drawText(
+ event.context.drawString(
MC.font,
- event.slot.index.toString(), event.slot.x, event.slot.y + MC.font.fontHeight, 0xFFFF0000.toInt(), true
+ event.slot.containerSlot.toString(), event.slot.x, event.slot.y + MC.font.lineHeight, 0xFFFF0000.toInt(), true
)
}
}
@@ -107,37 +107,37 @@ object PowerUserTools {
@Subscribe
fun onEntityInfo(event: WorldKeyboardEvent) {
if (!event.matches(TConfig.copyEntityData)) return
- val target = (MC.instance.crosshairTarget as? EntityHitResult)?.entity
+ val target = (MC.instance.hitResult as? EntityHitResult)?.entity
if (target == null) {
- MC.sendChat(Text.translatable("firmament.poweruser.entity.fail"))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.fail"))
return
}
showEntity(target)
}
fun showEntity(target: Entity) {
- val nbt = NbtPredicate.entityToNbt(target)
+ val nbt = NbtPredicate.getEntityTagToCompare(target)
nbt.remove("Inventory")
- nbt.put("StyledName", TextCodecs.CODEC.encodeStart(NbtOps.INSTANCE, target.styledDisplayName).orThrow)
+ nbt.put("StyledName", ComponentSerialization.CODEC.encodeStart(NbtOps.INSTANCE, target.feedbackDisplayName).orThrow)
println(SNbtFormatter.prettify(nbt))
ClipboardUtils.setTextContent(SNbtFormatter.prettify(nbt))
- MC.sendChat(Text.translatable("firmament.poweruser.entity.type", target.type))
- MC.sendChat(Text.translatable("firmament.poweruser.entity.name", target.name))
- MC.sendChat(Text.stringifiedTranslatable("firmament.poweruser.entity.position", target.pos))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.type", target.type))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.name", target.name))
+ MC.sendChat(Component.translatableEscape("firmament.poweruser.entity.position", target.position))
if (target is LivingEntity) {
- MC.sendChat(Text.translatable("firmament.poweruser.entity.armor"))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.armor"))
for ((slot, armorItem) in target.iterableArmorItems) {
- MC.sendChat(Text.translatable("firmament.poweruser.entity.armor.item", debugFormat(armorItem)))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.armor.item", debugFormat(armorItem)))
}
}
- MC.sendChat(Text.stringifiedTranslatable("firmament.poweruser.entity.passengers", target.passengerList.size))
- target.passengerList.forEach {
+ MC.sendChat(Component.translatableEscape("firmament.poweruser.entity.passengers", target.passengers.size))
+ target.passengers.forEach {
showEntity(it)
}
}
// TODO: leak this through some other way, maybe.
- lateinit var getSkullId: (profile: ProfileComponent) -> Identifier?
+ lateinit var getSkullId: (profile: ResolvableProfile) -> ResourceLocation?
@Subscribe
fun copyInventoryInfo(it: HandledScreenKeyPressedEvent) {
@@ -146,71 +146,71 @@ object PowerUserTools {
if (it.matches(TConfig.copyItemId)) {
val sbId = item.skyBlockId
if (sbId == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skyblockid.fail"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skyblockid.fail"))
return
}
ClipboardUtils.setTextContent(sbId.neuItem)
lastCopiedStack =
- Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skyblockid", sbId.neuItem))
+ Pair(item, Component.translatableEscape("firmament.tooltip.copied.skyblockid", sbId.neuItem))
} else if (it.matches(TConfig.copyTexturePackId)) {
val model = CustomItemModelEvent.getModelIdentifier0(item, object : IntrospectableItemModelManager {
- override fun hasModel_firmament(identifier: Identifier): Boolean {
+ override fun hasModel_firmament(identifier: ResourceLocation): Boolean {
return true
}
}).getOrNull() // TODO: remove global texture overrides, maybe
if (model == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.modelid.fail"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.modelid.fail"))
return
}
ClipboardUtils.setTextContent(model.toString())
lastCopiedStack =
- Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.modelid", model.toString()))
+ Pair(item, Component.translatableEscape("firmament.tooltip.copied.modelid", model.toString()))
} else if (it.matches(TConfig.copyNbtData)) {
// TODO: copy full nbt
- val nbt = item.get(DataComponentTypes.CUSTOM_DATA)?.unsafeNbt?.toPrettyString() ?: "<empty>"
+ val nbt = item.get(DataComponents.CUSTOM_DATA)?.unsafeNbt?.toPrettyString() ?: "<empty>"
ClipboardUtils.setTextContent(nbt)
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.nbt"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.nbt"))
} else if (it.matches(TConfig.copyLoreData)) {
val list = mutableListOf(item.displayNameAccordingToNbt)
list.addAll(item.loreAccordingToNbt)
ClipboardUtils.setTextContent(list.joinToString("\n") {
- TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, it).result().getOrNull().toString()
+ ComponentSerialization.CODEC.encodeStart(JsonOps.INSTANCE, it).result().getOrNull().toString()
})
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.lore"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.lore"))
} else if (it.matches(TConfig.copySkullTexture)) {
if (item.item != Items.PLAYER_HEAD) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-skull"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skull-id.fail.no-skull"))
return
}
- val profile = item.get(DataComponentTypes.PROFILE)
+ val profile = item.get(DataComponents.PROFILE)
if (profile == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-profile"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skull-id.fail.no-profile"))
return
}
val skullTexture = getSkullId(profile)
if (skullTexture == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-texture"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skull-id.fail.no-texture"))
return
}
ClipboardUtils.setTextContent(skullTexture.toString())
lastCopiedStack =
- Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skull-id", skullTexture.toString()))
+ Pair(item, Component.translatableEscape("firmament.tooltip.copied.skull-id", skullTexture.toString()))
println("Copied skull id: $skullTexture")
} else if (it.matches(TConfig.copyItemStack)) {
val nbt = ItemStack.CODEC
- .encodeStart(MC.currentOrDefaultRegistries.getOps(NbtOps.INSTANCE), item)
+ .encodeStart(MC.currentOrDefaultRegistries.createSerializationContext(NbtOps.INSTANCE), item)
.orThrow
ClipboardUtils.setTextContent(nbt.toPrettyString())
- lastCopiedStack = Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.stack"))
+ lastCopiedStack = Pair(item, Component.translatableEscape("firmament.tooltip.copied.stack"))
} else if (it.matches(TConfig.copyTitle)) {
- val allTitles = NbtList()
+ val allTitles = ListTag()
val inventoryNames =
- it.screen.screenHandler.slots
- .mapNotNullTo(mutableSetOf()) { it.inventory }
+ it.screen.menu.slots
+ .mapNotNullTo(mutableSetOf()) { it.container }
.filterIsInstance<Nameable>()
.map { it.name }
for (it in listOf(it.screen.title) + inventoryNames) {
- allTitles.add(TextCodecs.CODEC.encodeStart(NbtOps.INSTANCE, it).result().getOrNull()!!)
+ allTitles.add(ComponentSerialization.CODEC.encodeStart(NbtOps.INSTANCE, it).result().getOrNull()!!)
}
ClipboardUtils.setTextContent(allTitles.toPrettyString())
MC.sendChat(tr("firmament.power-user.title.copied", "Copied screen and inventory titles"))
@@ -221,23 +221,23 @@ object PowerUserTools {
fun onCopyWorldInfo(it: WorldKeyboardEvent) {
if (it.matches(TConfig.copySkullTexture)) {
val p = MC.camera ?: return
- val blockHit = p.raycast(20.0, 0.0f, false) ?: return
+ val blockHit = p.pick(20.0, 0.0f, false) ?: return
if (blockHit.type != HitResult.Type.BLOCK || blockHit !is BlockHitResult) {
- MC.sendChat(Text.translatable("firmament.tooltip.copied.skull.fail"))
+ MC.sendChat(Component.translatable("firmament.tooltip.copied.skull.fail"))
return
}
- val blockAt = p.world.getBlockState(blockHit.blockPos)?.block
- val entity = p.world.getBlockEntity(blockHit.blockPos)
- if (blockAt !is SkullBlock || entity !is SkullBlockEntity || entity.owner == null) {
- MC.sendChat(Text.translatable("firmament.tooltip.copied.skull.fail"))
+ val blockAt = p.level.getBlockState(blockHit.blockPos)?.block
+ val entity = p.level.getBlockEntity(blockHit.blockPos)
+ if (blockAt !is SkullBlock || entity !is SkullBlockEntity || entity.ownerProfile == null) {
+ MC.sendChat(Component.translatable("firmament.tooltip.copied.skull.fail"))
return
}
- val id = getSkullId(entity.owner!!)
+ val id = getSkullId(entity.ownerProfile!!)
if (id == null) {
- MC.sendChat(Text.translatable("firmament.tooltip.copied.skull.fail"))
+ MC.sendChat(Component.translatable("firmament.tooltip.copied.skull.fail"))
} else {
ClipboardUtils.setTextContent(id.toString())
- MC.sendChat(Text.stringifiedTranslatable("firmament.tooltip.copied.skull", id.toString()))
+ MC.sendChat(Component.translatableEscape("firmament.tooltip.copied.skull", id.toString()))
}
}
}
@@ -246,10 +246,10 @@ object PowerUserTools {
fun addItemId(it: ItemTooltipEvent) {
if (TConfig.showItemIds) {
val id = it.stack.skyBlockId ?: return
- it.lines.add(Text.stringifiedTranslatable("firmament.tooltip.skyblockid", id.neuItem).grey())
+ it.lines.add(Component.translatableEscape("firmament.tooltip.skyblockid", id.neuItem).grey())
}
val (item, text) = lastCopiedStack ?: return
- if (!ItemStack.areEqual(item, it.stack)) {
+ if (!ItemStack.matches(item, it.stack)) {
lastCopiedStack = null
return
}
diff --git a/src/main/kotlin/features/debug/SkinPreviews.kt b/src/main/kotlin/features/debug/SkinPreviews.kt
index a853cd1..56c63db 100644
--- a/src/main/kotlin/features/debug/SkinPreviews.kt
+++ b/src/main/kotlin/features/debug/SkinPreviews.kt
@@ -5,11 +5,11 @@ import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.ProfileComponent
-import net.minecraft.entity.EquipmentSlot
-import net.minecraft.entity.LivingEntity
-import net.minecraft.util.math.Vec3d
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.ResolvableProfile
+import net.minecraft.world.entity.EquipmentSlot
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.phys.Vec3
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityUpdateEvent
import moe.nea.firmament.events.IsSlotProtectedEvent
@@ -32,11 +32,11 @@ object SkinPreviews {
@Subscribe
fun onEntityUpdate(event: EntityUpdateEvent) {
if (!isRecording) return
- if (event.entity.pos != pos)
+ if (event.entity.position != pos)
return
val entity = event.entity as? LivingEntity ?: return
- val stack = entity.getEquippedStack(EquipmentSlot.HEAD) ?: return
- val profile = stack.get(DataComponentTypes.PROFILE)?.gameProfile ?: return
+ val stack = entity.getItemBySlot(EquipmentSlot.HEAD) ?: return
+ val profile = stack.get(DataComponents.PROFILE)?.partialProfile() ?: return
if (profile == animation.lastOrNull()) return
animation.add(profile)
val shortened = animation.shortenCycle()
@@ -65,7 +65,7 @@ object SkinPreviews {
}
var animation = mutableListOf<GameProfile>()
- var pos = Vec3d(-1.0, 72.0, -101.25)
+ var pos = Vec3(-1.0, 72.0, -101.25)
var isRecording = false
var skinColor: String? = null
var skinId: String? = null
diff --git a/src/main/kotlin/features/debug/SoundVisualizer.kt b/src/main/kotlin/features/debug/SoundVisualizer.kt
index f805e6b..37b248a 100644
--- a/src/main/kotlin/features/debug/SoundVisualizer.kt
+++ b/src/main/kotlin/features/debug/SoundVisualizer.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.features.debug
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.commands.thenLiteral
@@ -43,7 +43,7 @@ object SoundVisualizer {
sounds.forEach { event ->
withFacingThePlayer(event.position) {
text(
- Text.literal(event.sound.value().id.toString()).also {
+ Component.literal(event.sound.value().location.toString()).also {
if (event.cancelled)
it.red()
},
diff --git a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt
index b3dc69a..d12d667 100644
--- a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt
+++ b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt
@@ -4,9 +4,9 @@ import kotlinx.coroutines.launch
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
-import net.minecraft.client.network.AbstractClientPlayerEntity
-import net.minecraft.entity.decoration.ArmorStandEntity
-import net.minecraft.util.AssetInfo
+import net.minecraft.client.player.AbstractClientPlayer
+import net.minecraft.world.entity.decoration.ArmorStand
+import net.minecraft.core.ClientAsset
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
@@ -52,23 +52,23 @@ object ExportRecipe {
if (!event.matches(PowerUserTools.TConfig.exportNpcLocation)) {
return
}
- val entity = MC.instance.targetedEntity
+ val entity = MC.instance.crosshairPickEntity
if (entity == null) {
MC.sendChat(tr("firmament.repo.export.npc.noentity", "Could not find entity to export"))
return
}
Firmament.coroutineScope.launch {
- val guessName = entity.world.getEntitiesByClass(
- ArmorStandEntity::class.java,
- entity.boundingBox.expand(0.1),
+ val guessName = entity.level.getEntitiesOfClass(
+ ArmorStand::class.java,
+ entity.boundingBox.inflate(0.1),
{ !it.name.string.contains("CLICK") })
.firstOrNull()?.customName?.string
?: ""
val reply = waitForTextInput("$guessName (NPC)", "Export stub")
val id = generateName(reply)
ItemExporter.exportStub(id, "§9$reply") {
- val playerEntity = entity as? AbstractClientPlayerEntity
- val textureUrl = (playerEntity?.skin?.body as? AssetInfo.SkinAssetInfo)?.url
+ val playerEntity = entity as? AbstractClientPlayer
+ val textureUrl = (playerEntity?.skin?.body as? ClientAsset.DownloadedTexture)?.url
if (textureUrl != null)
it.setSkullOwner(playerEntity.uuid, textureUrl)
}
@@ -89,19 +89,19 @@ object ExportRecipe {
return
}
val title = event.screen.title.string
- val sellSlot = event.screen.getSlotByIndex(49, false)?.stack
+ val sellSlot = event.screen.getSlotByIndex(49, false)?.item
val craftingTableSlot = event.screen.getSlotByIndex(craftingTableSlut, false)
- if (craftingTableSlot?.stack?.displayNameAccordingToNbt?.unformattedString == "Crafting Table") {
+ if (craftingTableSlot?.item?.displayNameAccordingToNbt?.unformattedString == "Crafting Table") {
slotIndices.forEach { (_, index) ->
- event.screen.getSlotByIndex(index, false)?.stack?.let(ItemExporter::ensureExported)
+ event.screen.getSlotByIndex(index, false)?.item?.let(ItemExporter::ensureExported)
}
val inputs = slotIndices.associate { (name, index) ->
- val id = event.screen.getSlotByIndex(index, false)?.stack?.takeIf { !it.isEmpty() }?.let {
+ val id = event.screen.getSlotByIndex(index, false)?.item?.takeIf { !it.isEmpty() }?.let {
"${it.skyBlockId?.neuItem}:${it.count}"
} ?: ""
name to JsonPrimitive(id)
}
- val output = event.screen.getSlotByIndex(resultSlot, false)?.stack!!
+ val output = event.screen.getSlotByIndex(resultSlot, false)?.item!!
val overrideOutputId = output.skyBlockId!!.neuItem
val count = output.count
val recipe = JsonObject(
@@ -123,7 +123,7 @@ object ExportRecipe {
ItemExporter.exportStub(shopId, "§9$title (NPC)")
}
for (index in (9..9 * 5)) {
- val item = event.screen.getSlotByIndex(index, false)?.stack ?: continue
+ val item = event.screen.getSlotByIndex(index, false)?.item ?: continue
val skyblockId = item.skyBlockId ?: continue
val costLines = item.loreAccordingToNbt
.map { it.string.trim() }
diff --git a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt
index ccbd7e0..f664da3 100644
--- a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt
+++ b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt
@@ -12,10 +12,10 @@ import kotlin.io.path.notExists
import kotlin.io.path.readText
import kotlin.io.path.relativeTo
import kotlin.io.path.writeText
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtString
-import net.minecraft.text.Text
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.nbt.StringTag
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.RestArgumentType
@@ -47,7 +47,7 @@ import moe.nea.firmament.util.tr
object ItemExporter {
- fun exportItem(itemStack: ItemStack): Text {
+ fun exportItem(itemStack: ItemStack): Component {
nonOverlayCache.clear()
val exporter = LegacyItemExporter.createExporter(itemStack)
var json = exporter.exportJson()
@@ -197,7 +197,7 @@ object ItemExporter {
display.putString("Name", mutJson["displayname"]!!.jsonPrimitive.content)
display.put(
"Lore",
- (mutJson["lore"] as JsonArray).map { NbtString.of(it.jsonPrimitive.content) }
+ (mutJson["lore"] as JsonArray).map { StringTag.valueOf(it.jsonPrimitive.content) }
.toNbtList()
)
mutJson["nbttag"] = JsonPrimitive(legacyTag.toLegacyString())
@@ -220,8 +220,8 @@ object ItemExporter {
if (!PowerUserTools.TConfig.highlightNonOverlayItems) {
return
}
- val stack = event.slot.stack ?: return
- val id = event.slot.stack.skyBlockId?.neuItem
+ val stack = event.slot.item ?: return
+ val id = event.slot.item.skyBlockId?.neuItem
if (PowerUserTools.TConfig.dontHighlightSemicolonItems && id != null && id.contains(";")) return
val sbId = stack.skyBlockId ?: return
val isExported = nonOverlayCache.getOrPut(sbId) {
@@ -240,8 +240,8 @@ object ItemExporter {
fun exportStub(skyblockId: SkyblockId, title: String, extra: (ItemStack) -> Unit = {}) {
exportItem(ItemStack(Items.PLAYER_HEAD).also {
- it.displayNameAccordingToNbt = Text.literal(title)
- it.loreAccordingToNbt = listOf(Text.literal(""))
+ it.displayNameAccordingToNbt = Component.literal(title)
+ it.loreAccordingToNbt = listOf(Component.literal(""))
it.setSkyBlockId(skyblockId)
extra(it) // LOL
})
diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt
index 4b647c7..2bc51bc 100644
--- a/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt
+++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.debug.itemeditor
import kotlinx.serialization.Serializable
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.util.Identifier
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache
@@ -54,14 +54,14 @@ object LegacyItemData {
).getOrThrow()
val enchantmentData = getLegacyData<List<EnchantmentData>>("enchantments")
- val enchantmentLut = enchantmentData.associateBy { Identifier.ofVanilla(it.name) }
+ val enchantmentLut = enchantmentData.associateBy { ResourceLocation.withDefaultNamespace(it.name) }
val itemDat = getLegacyData<List<ItemData>>("items")
@OptIn(ExpensiveItemCacheApi::class) // This is fine, we get loaded in a thread.
val itemLut = itemDat.flatMap { item ->
item.allVariants().map { legacyItemType ->
- val nbt = ItemCache.convert189ToModern(NbtCompound().apply {
+ val nbt = ItemCache.convert189ToModern(CompoundTag().apply {
putString("id", legacyItemType.name)
putByte("Count", 1)
putShort("Damage", legacyItemType.metadata)
diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt
index 65f9fa1..7b855d1 100644
--- a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt
+++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt
@@ -6,18 +6,18 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlin.concurrent.thread
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtByte
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.nbt.NbtElement
-import net.minecraft.nbt.NbtInt
-import net.minecraft.nbt.NbtList
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.nbt.ByteTag
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.IntTag
+import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.nbt.NbtString
-import net.minecraft.registry.tag.ItemTags
-import net.minecraft.text.Text
+import net.minecraft.nbt.StringTag
+import net.minecraft.tags.ItemTags
+import net.minecraft.network.chat.Component
import net.minecraft.util.Unit
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
@@ -51,7 +51,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
val originalId = itemStack.extraAttributes.getString("id")
var name = itemStack.displayNameAccordingToNbt
val extraAttribs = itemStack.extraAttributes.copy()
- val legacyNbt = NbtCompound()
+ val legacyNbt = CompoundTag()
val warnings = mutableListOf<String>()
// TODO: check if lore contains non 1.8.9 able hex codes and emit lore in overlay files if so
@@ -70,8 +70,8 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
extraAttribs.putString("id", it.neuItem)
}
trimLore()
- itemStack.loreAccordingToNbt = itemStack.item.defaultStack.loreAccordingToNbt
- itemStack.remove(DataComponentTypes.CUSTOM_NAME)
+ itemStack.loreAccordingToNbt = itemStack.item.defaultInstance.loreAccordingToNbt
+ itemStack.remove(DataComponents.CUSTOM_NAME)
}
fun trimLore() {
@@ -94,11 +94,11 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
name = name.transformEachRecursively {
var string = it.directLiteralStringContent ?: return@transformEachRecursively it
string = string.replace("Lvl \\d+".toRegex(), "Lvl {LVL}")
- Text.literal(string).setStyle(it.style)
+ Component.literal(string).setStyle(it.style)
}
if (lore.isEmpty())
- lore = listOf(Text.empty())
+ lore = listOf(Component.empty())
}
private fun trimStats() {
@@ -112,7 +112,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
v.siblings.removeIf { it.directLiteralStringContent!!.contains("(") }
val last = v.siblings.last()
v.siblings[v.siblings.lastIndex] =
- Text.literal(last.directLiteralStringContent!!.trimEnd())
+ Component.literal(last.directLiteralStringContent!!.trimEnd())
.setStyle(last.style)
lore[index] = v
}
@@ -120,7 +120,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
fun collapseWhitespaces() {
- lore = (listOf(null as Text?) + lore).zipWithNext()
+ lore = (listOf(null as Component?) + lore).zipWithNext()
.filter { !it.first?.unformattedString.isNullOrBlank() || !it.second?.unformattedString.isNullOrBlank() }
.map { it.second!! }
}
@@ -140,7 +140,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
fun processNbt() {
// TODO: calculate hideflags
- legacyNbt.put("HideFlags", NbtInt.of(254))
+ legacyNbt.put("HideFlags", IntTag.valueOf(254))
copyUnbreakable()
copyItemModel()
copyPotion()
@@ -154,51 +154,51 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
private fun copyPotion() {
- val effects = itemStack.get(DataComponentTypes.POTION_CONTENTS) ?: return
- legacyNbt.put("CustomPotionEffects", NbtList().also {
- effects.effects.forEach { effect ->
- val effectId = effect.effectType.key.get().value.path
+ val effects = itemStack.get(DataComponents.POTION_CONTENTS) ?: return
+ legacyNbt.put("CustomPotionEffects", ListTag().also {
+ effects.allEffects.forEach { effect ->
+ val effectId = effect.effect.unwrapKey().get().location().path
val duration = effect.duration
val legacyId = LegacyItemData.effectList[effectId]!!
- it.add(NbtCompound().apply {
- put("Ambient", NbtByte.of(false))
- put("Duration", NbtInt.of(duration))
- put("Id", NbtByte.of(legacyId.id.toByte()))
- put("Amplifier", NbtByte.of(effect.amplifier.toByte()))
+ it.add(CompoundTag().apply {
+ put("Ambient", ByteTag.valueOf(false))
+ put("Duration", IntTag.valueOf(duration))
+ put("Id", ByteTag.valueOf(legacyId.id.toByte()))
+ put("Amplifier", ByteTag.valueOf(effect.amplifier.toByte()))
})
}
})
}
- fun NbtCompound.getOrPutCompound(name: String): NbtCompound {
+ fun CompoundTag.getOrPutCompound(name: String): CompoundTag {
val compound = getCompoundOrEmpty(name)
put(name, compound)
return compound
}
private fun copyColour() {
- if (!itemStack.isIn(ItemTags.DYEABLE)) {
- itemStack.remove(DataComponentTypes.DYED_COLOR)
+ if (!itemStack.`is`(ItemTags.DYEABLE)) {
+ itemStack.remove(DataComponents.DYED_COLOR)
return
}
- val leatherTint = itemStack.componentChanges.get(DataComponentTypes.DYED_COLOR)?.getOrNull() ?: return
- legacyNbt.getOrPutCompound("display").put("color", NbtInt.of(leatherTint.rgb))
+ val leatherTint = itemStack.componentsPatch.get(DataComponents.DYED_COLOR)?.getOrNull() ?: return
+ legacyNbt.getOrPutCompound("display").put("color", IntTag.valueOf(leatherTint.rgb))
}
private fun copyItemModel() {
- val itemModel = itemStack.get(DataComponentTypes.ITEM_MODEL) ?: return
- legacyNbt.put("ItemModel", NbtString.of(itemModel.toString()))
+ val itemModel = itemStack.get(DataComponents.ITEM_MODEL) ?: return
+ legacyNbt.put("ItemModel", StringTag.valueOf(itemModel.toString()))
}
private fun copyDisplay() {
legacyNbt.getOrPutCompound("display").apply {
- put("Lore", lore.map { NbtString.of(it.getLegacyFormatString(trimmed = true)) }.toNbtList())
+ put("Lore", lore.map { StringTag.valueOf(it.getLegacyFormatString(trimmed = true)) }.toNbtList())
putString("Name", name.getLegacyFormatString(trimmed = true))
}
}
- fun exportModernSnbt(): NbtElement {
+ fun exportModernSnbt(): Tag {
val overlay = ItemStack.CODEC.encodeStart(MC.currentOrDefaultRegistryNbtOps, itemStack.copy().also {
it.modifyExtraAttributes { attribs ->
originalId.ifPresent { attribs.putString("id", it) }
@@ -251,30 +251,30 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
fun copyEnchantGlint() {
- if (itemStack.get(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE) == true) {
+ if (itemStack.get(DataComponents.ENCHANTMENT_GLINT_OVERRIDE) == true) {
val ench = legacyNbt.getListOrEmpty("ench")
legacyNbt.put("ench", ench)
}
}
private fun copyUnbreakable() {
- if (itemStack.get(DataComponentTypes.UNBREAKABLE) == Unit.INSTANCE) {
+ if (itemStack.get(DataComponents.UNBREAKABLE) == Unit.INSTANCE) {
legacyNbt.putBoolean("Unbreakable", true)
}
}
fun copyEnchantments() {
- val enchantments = itemStack.get(DataComponentTypes.ENCHANTMENTS)?.takeIf { !it.isEmpty } ?: return
+ val enchantments = itemStack.get(DataComponents.ENCHANTMENTS)?.takeIf { !it.isEmpty } ?: return
val enchTag = legacyNbt.getListOrEmpty("ench")
legacyNbt.put("ench", enchTag)
- enchantments.enchantmentEntries.forEach { entry ->
- val id = entry.key.key.get().value
+ enchantments.entrySet().forEach { entry ->
+ val id = entry.key.unwrapKey().get().location()
val legacyId = LegacyItemData.enchantmentLut[id]
if (legacyId == null) {
warnings.add("Could not find legacy enchantment id for ${id}")
return@forEach
}
- enchTag.add(NbtCompound().apply {
+ enchTag.add(CompoundTag().apply {
putShort("lvl", entry.intValue.toShort())
putShort(
"id",
@@ -289,15 +289,15 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
fun copyLegacySkullNbt() {
- val profile = itemStack.get(DataComponentTypes.PROFILE) ?: return
- legacyNbt.put("SkullOwner", NbtCompound().apply {
- putString("Id", profile.gameProfile.id.toString())
+ val profile = itemStack.get(DataComponents.PROFILE) ?: return
+ legacyNbt.put("SkullOwner", CompoundTag().apply {
+ putString("Id", profile.partialProfile().id.toString())
putBoolean("hypixelPopulated", true)
- put("Properties", NbtCompound().apply {
- profile.gameProfile.properties().forEach { prop, value ->
+ put("Properties", CompoundTag().apply {
+ profile.partialProfile().properties().forEach { prop, value ->
val list = getListOrEmpty(prop)
put(prop, list)
- list.add(NbtCompound().apply {
+ list.add(CompoundTag().apply {
value.signature?.let {
putString("Signature", it)
}
diff --git a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
index a2869f0..72806c9 100644
--- a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
+++ b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
@@ -1,9 +1,9 @@
package moe.nea.firmament.features.diana
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.particle.ParticleTypes
-import net.minecraft.sound.SoundEvents
-import net.minecraft.util.math.Vec3d
+import net.minecraft.core.particles.ParticleTypes
+import net.minecraft.sounds.SoundEvents
+import net.minecraft.world.phys.Vec3
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ParticleSpawnEvent
import moe.nea.firmament.events.SoundReceiveEvent
@@ -23,8 +23,8 @@ object AncestralSpadeSolver {
var lastDing = TimeMark.farPast()
private set
private val pitches = mutableListOf<Float>()
- val particlePositions = mutableListOf<Vec3d>()
- var nextGuess: Vec3d? = null
+ val particlePositions = mutableListOf<Vec3>()
+ var nextGuess: Vec3? = null
private set
private var lastTeleportAttempt = TimeMark.farPast()
@@ -32,7 +32,7 @@ object AncestralSpadeSolver {
fun isEnabled() =
DianaWaypoints.TConfig.ancestralSpadeSolver
&& SBData.skyblockLocation == SkyBlockIsland.HUB
- && MC.player?.inventory?.containsAny { it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE } == true // TODO: add a reactive property here
+ && MC.player?.inventory?.hasAnyMatching { it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE } == true // TODO: add a reactive property here
@Subscribe
fun onKeyBind(event: WorldKeyboardEvent) {
@@ -59,7 +59,7 @@ object AncestralSpadeSolver {
@Subscribe
fun onPlaySound(event: SoundReceiveEvent) {
if (!isEnabled()) return
- if (!SoundEvents.BLOCK_NOTE_BLOCK_HARP.matchesId(event.sound.value().id)) return
+ if (!SoundEvents.NOTE_BLOCK_HARP.`is`(event.sound.value().location)) return
if (lastDing.passedTime() > 1.seconds) {
particlePositions.clear()
@@ -93,7 +93,7 @@ object AncestralSpadeSolver {
.let { (a, _, b) -> b.subtract(a) }
.normalize()
- nextGuess = event.position.add(lastParticleDirection.multiply(soundDistanceEstimate))
+ nextGuess = event.position.add(lastParticleDirection.scale(soundDistanceEstimate))
}
@Subscribe
diff --git a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
index e1fb856..35af660 100644
--- a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
+++ b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
@@ -2,10 +2,10 @@ package moe.nea.firmament.features.diana
import me.shedaniel.math.Color
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.particle.ParticleTypes
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.MathHelper
-import net.minecraft.util.math.Position
+import net.minecraft.core.particles.ParticleTypes
+import net.minecraft.core.BlockPos
+import net.minecraft.util.Mth
+import net.minecraft.core.Position
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ParticleSpawnEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -63,7 +63,7 @@ object NearbyBurrowsSolver {
fun onParticles(event: ParticleSpawnEvent) {
if (!DianaWaypoints.TConfig.nearbyWaypoints) return
- val position: BlockPos = event.position.toBlockPos().down()
+ val position: BlockPos = event.position.toBlockPos().below()
if (wasRecentlyDug(position)) return
@@ -135,5 +135,5 @@ object NearbyBurrowsSolver {
}
fun Position.toBlockPos(): BlockPos {
- return BlockPos(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z))
+ return BlockPos(Mth.floor(x()), Mth.floor(y()), Mth.floor(z()))
}
diff --git a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
index ded5e13..955d23b 100644
--- a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
@@ -4,9 +4,9 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.xml.Bind
import org.joml.Vector2i
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.entity.passive.PigEntity
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
+import net.minecraft.world.entity.animal.Pig
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityInteractionEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -36,16 +36,16 @@ object AnniversaryFeatures {
}
data class ClickedPig(
- val clickedAt: TimeMark,
- val startLocation: BlockPos,
- val pigEntity: PigEntity
+ val clickedAt: TimeMark,
+ val startLocation: BlockPos,
+ val pigEntity: Pig
) {
@Bind("timeLeft")
fun getTimeLeft(): Double = 1 - clickedAt.passedTime() / pigDuration
}
val clickedPigs = ObservableList<ClickedPig>(mutableListOf())
- var lastClickedPig: PigEntity? = null
+ var lastClickedPig: Pig? = null
val pigDuration = 90.seconds
@@ -62,14 +62,14 @@ object AnniversaryFeatures {
if (event.unformattedString == "Oink! Bring the pig back to the Shiny Orb!") {
val pig = lastClickedPig ?: return
// TODO: store proper location based on the orb location, maybe
- val startLocation = pig.blockPos ?: return
+ val startLocation = pig.blockPosition() ?: return
clickedPigs.add(ClickedPig(TimeMark.now(), startLocation, pig))
lastClickedPig = null
}
if (event.unformattedString == "SHINY! The orb is charged! Click on it for loot!") {
val player = MC.player ?: return
val lowest =
- clickedPigs.minByOrNull { it.startLocation.getSquaredDistance(player.pos) } ?: return
+ clickedPigs.minByOrNull { it.startLocation.distToCenterSqr(player.position) } ?: return
clickedPigs.remove(lowest)
}
pattern.useMatch(event.unformattedString) {
@@ -166,7 +166,7 @@ object AnniversaryFeatures {
@Subscribe
fun onEntityClick(event: EntityInteractionEvent) {
- if (event.entity is PigEntity) {
+ if (event.entity is Pig) {
lastClickedPig = event.entity
}
}
@@ -203,12 +203,12 @@ object AnniversaryFeatures {
@OptIn(ExpensiveItemCacheApi::class)
@Bind
- fun name(): Text {
+ fun name(): Component {
return when (backedBy) {
- is Reward.Coins -> Text.literal("Coins")
- is Reward.EXP -> Text.literal(backedBy.skill)
- is Reward.Items -> itemStack.asImmutableItemStack().name
- is Reward.Unknown -> Text.literal(backedBy.text)
+ is Reward.Coins -> Component.literal("Coins")
+ is Reward.EXP -> Component.literal(backedBy.skill)
+ is Reward.Items -> itemStack.asImmutableItemStack().hoverName
+ is Reward.Unknown -> Component.literal(backedBy.text)
}
}
diff --git a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
index 13ecd7b..9b87cc6 100644
--- a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
@@ -3,9 +3,9 @@ package moe.nea.firmament.features.events.anniversity
import java.util.Optional
import me.shedaniel.math.Color
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.text.Style
-import net.minecraft.util.Formatting
+import net.minecraft.world.entity.player.Player
+import net.minecraft.network.chat.Style
+import net.minecraft.ChatFormatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityRenderTintEvent
import moe.nea.firmament.util.MC
@@ -26,18 +26,18 @@ object CenturyRaffleFeatures {
val cakeIcon = "⛃"
val cakeColors = listOf(
- CakeTeam(SkyBlockItems.SLICE_OF_BLUEBERRY_CAKE, Formatting.BLUE),
- CakeTeam(SkyBlockItems.SLICE_OF_CHEESECAKE, Formatting.YELLOW),
- CakeTeam(SkyBlockItems.SLICE_OF_GREEN_VELVET_CAKE, Formatting.GREEN),
- CakeTeam(SkyBlockItems.SLICE_OF_RED_VELVET_CAKE, Formatting.RED),
- CakeTeam(SkyBlockItems.SLICE_OF_STRAWBERRY_SHORTCAKE, Formatting.LIGHT_PURPLE),
+ CakeTeam(SkyBlockItems.SLICE_OF_BLUEBERRY_CAKE, ChatFormatting.BLUE),
+ CakeTeam(SkyBlockItems.SLICE_OF_CHEESECAKE, ChatFormatting.YELLOW),
+ CakeTeam(SkyBlockItems.SLICE_OF_GREEN_VELVET_CAKE, ChatFormatting.GREEN),
+ CakeTeam(SkyBlockItems.SLICE_OF_RED_VELVET_CAKE, ChatFormatting.RED),
+ CakeTeam(SkyBlockItems.SLICE_OF_STRAWBERRY_SHORTCAKE, ChatFormatting.LIGHT_PURPLE),
)
data class CakeTeam(
- val id: SkyblockId,
- val formatting: Formatting,
+ val id: SkyblockId,
+ val formatting: ChatFormatting,
) {
- val searchedTextRgb = formatting.colorValue!!
+ val searchedTextRgb = formatting.color!!
val brightenedRgb = Color.ofOpaque(searchedTextRgb)//.brighter(2.0)
val tintOverlay by lazy {
TintedOverlayTexture().setColor(brightenedRgb)
@@ -51,13 +51,13 @@ object CenturyRaffleFeatures {
if (!TConfig.highlightPlayersForSlice) return
val requestedCakeTeam = sliceToColor[MC.stackInHand?.skyBlockId] ?: return
// TODO: cache the requested color
- val player = event.entity as? PlayerEntity ?: return
- val cakeColor: Style = player.styledDisplayName.visit(
+ val player = event.entity as? Player ?: return
+ val cakeColor: Style = player.feedbackDisplayName.visit(
{ style, text ->
if (text == cakeIcon) Optional.of(style)
else Optional.empty()
}, Style.EMPTY).getOrNull() ?: return
- if (cakeColor.color?.rgb == requestedCakeTeam.searchedTextRgb) {
+ if (cakeColor.color?.value == requestedCakeTeam.searchedTextRgb) {
event.renderState.overlayTexture_firmament = requestedCakeTeam.tintOverlay
}
}
diff --git a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
index e675cc9..64b3814 100644
--- a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
+++ b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
@@ -5,14 +5,14 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import io.github.notenoughupdates.moulconfig.xml.Bind
import java.util.UUID
-import net.minecraft.block.Blocks
-import net.minecraft.item.Item
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
-import net.minecraft.world.WorldAccess
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
+import net.minecraft.world.level.LevelAccessor
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.AttackBlockEvent
@@ -118,19 +118,19 @@ object MinesweeperHelper {
val itemStack = createSkullItem(UUID.randomUUID(), textureUrl)
.setSkyBlockFirmamentUiId("MINESWEEPER_$name")
@get:Bind("fruitName")
- val textFruitName = Text.literal(fruitName)
+ val textFruitName = Component.literal(fruitName)
@Bind
fun getIcon() = MoulConfigPlatform.wrap(itemStack)
@get:Bind("pieceLabel")
- val pieceLabel = Text.literal(fruitColor.formattingCode + fruitName)
+ val pieceLabel = Component.literal(fruitColor.formattingCode + fruitName)
@get:Bind("boardLabel")
- val boardLabel = Text.literal("§a$totalPerBoard§7/§rboard")
+ val boardLabel = Component.literal("§a$totalPerBoard§7/§rboard")
@get:Bind("description")
- val getDescription = Text.literal(buildString {
+ val getDescription = Component.literal(buildString {
append(specialAbility)
if (points >= 0) {
append(" Default points: $points.")
@@ -176,10 +176,10 @@ object MinesweeperHelper {
) {
fun toBlockPos() = BlockPos(sandBoxLow.x + x, sandBoxLow.y, sandBoxLow.z + y)
- fun getBlock(world: WorldAccess) = world.getBlockState(toBlockPos()).block
- fun isUnopened(world: WorldAccess) = getBlock(world) == Blocks.SAND
- fun isOpened(world: WorldAccess) = getBlock(world) == Blocks.SANDSTONE
- fun isScorched(world: WorldAccess) = getBlock(world) == Blocks.SANDSTONE_STAIRS
+ fun getBlock(world: LevelAccessor) = world.getBlockState(toBlockPos()).block
+ fun isUnopened(world: LevelAccessor) = getBlock(world) == Blocks.SAND
+ fun isOpened(world: LevelAccessor) = getBlock(world) == Blocks.SANDSTONE
+ fun isScorched(world: LevelAccessor) = getBlock(world) == Blocks.SANDSTONE_STAIRS
companion object {
fun fromBlockPos(blockPos: BlockPos): BoardPosition? {
@@ -222,7 +222,7 @@ object MinesweeperHelper {
@Subscribe
fun onChat(event: ProcessChatEvent) {
if (CarnivalFeatures.TConfig.displayTutorials && event.unformattedString == startGameQuestion) {
- MC.sendChat(Text.translatable("firmament.carnival.tutorial.minesweeper").styled {
+ MC.sendChat(Component.translatable("firmament.carnival.tutorial.minesweeper").withStyle {
it.withClickEvent(ClickEvent.RunCommand("/firm minesweepertutorial"))
})
}
@@ -260,7 +260,7 @@ object MinesweeperHelper {
val boardPosition = BoardPosition.fromBlockPos(event.blockPos)
log.log { "Breaking block at ${event.blockPos} ($boardPosition)" }
gs.lastClickedPosition = boardPosition
- gs.lastDowsingMode = DowsingMode.fromItem(event.player.mainHandStack)
+ gs.lastDowsingMode = DowsingMode.fromItem(event.player.mainHandItem)
}
@Subscribe
@@ -268,7 +268,7 @@ object MinesweeperHelper {
val gs = gameState ?: return
RenderInWorldContext.renderInWorld(event) {
for ((pos, bombCount) in gs.nearbyBombs) {
- this.text(pos.toBlockPos().up().toCenterPos(), Text.literal("§a$bombCount \uD83D\uDCA3"))
+ this.text(pos.toBlockPos().above().center, Component.literal("§a$bombCount \uD83D\uDCA3"))
}
}
}
diff --git a/src/main/kotlin/features/fixes/Fixes.kt b/src/main/kotlin/features/fixes/Fixes.kt
index e7027ac..161c7e5 100644
--- a/src/main/kotlin/features/fixes/Fixes.kt
+++ b/src/main/kotlin/features/fixes/Fixes.kt
@@ -2,9 +2,9 @@ package moe.nea.firmament.features.fixes
import org.joml.Vector2i
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.option.KeyBinding
-import net.minecraft.text.Text
+import net.minecraft.client.Minecraft
+import net.minecraft.client.KeyMapping
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.WorldKeyboardEvent
@@ -34,37 +34,37 @@ object Fixes {
}
fun handleIsPressed(
- keyBinding: KeyBinding,
- cir: CallbackInfoReturnable<Boolean>
+ keyBinding: KeyMapping,
+ cir: CallbackInfoReturnable<Boolean>
) {
- if (keyBinding !== MinecraftClient.getInstance().options.sprintKey) return
+ if (keyBinding !== Minecraft.getInstance().options.keySprint) return
if (!TConfig.autoSprint) return
val player = MC.player ?: return
if (player.isSprinting) return
- if (!TConfig.autoSprintUnderWater && player.isTouchingWater) return
+ if (!TConfig.autoSprintUnderWater && player.isInWater) return
cir.returnValue = true
}
@Subscribe
fun onRenderHud(it: HudRenderEvent) {
if (!TConfig.autoSprintKeyBinding.isBound) return
- it.context.matrices.pushMatrix()
- TConfig.autoSprintHud.applyTransformations(it.context.matrices)
- it.context.drawText(
+ it.context.pose().pushMatrix()
+ TConfig.autoSprintHud.applyTransformations(it.context.pose())
+ it.context.drawString(
MC.font, (
if (MC.player?.isSprinting == true) {
- Text.translatable("firmament.fixes.auto-sprint.sprinting")
+ Component.translatable("firmament.fixes.auto-sprint.sprinting")
} else if (TConfig.autoSprint) {
- if (!TConfig.autoSprintUnderWater && MC.player?.isTouchingWater == true)
+ if (!TConfig.autoSprintUnderWater && MC.player?.isInWater == true)
tr("firmament.fixes.auto-sprint.under-water", "In Water")
else
- Text.translatable("firmament.fixes.auto-sprint.on")
+ Component.translatable("firmament.fixes.auto-sprint.on")
} else {
- Text.translatable("firmament.fixes.auto-sprint.not-sprinting")
+ Component.translatable("firmament.fixes.auto-sprint.not-sprinting")
}
), 0, 0, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
@Subscribe
diff --git a/src/main/kotlin/features/garden/HideComposterNoises.kt b/src/main/kotlin/features/garden/HideComposterNoises.kt
index 843e4f9..edd511f 100644
--- a/src/main/kotlin/features/garden/HideComposterNoises.kt
+++ b/src/main/kotlin/features/garden/HideComposterNoises.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.garden
-import net.minecraft.entity.passive.WolfSoundVariants
-import net.minecraft.sound.SoundEvent
-import net.minecraft.sound.SoundEvents
+import net.minecraft.world.entity.animal.wolf.WolfSoundVariants
+import net.minecraft.sounds.SoundEvent
+import net.minecraft.sounds.SoundEvents
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SoundReceiveEvent
import moe.nea.firmament.util.SBData
@@ -17,10 +17,10 @@ object HideComposterNoises {
}
val composterSoundEvents: List<SoundEvent> = listOf(
- SoundEvents.BLOCK_PISTON_EXTEND,
- SoundEvents.BLOCK_WATER_AMBIENT,
- SoundEvents.ENTITY_CHICKEN_EGG,
- SoundEvents.WOLF_SOUNDS[WolfSoundVariants.Type.CLASSIC]!!.growlSound().value(),
+ SoundEvents.PISTON_EXTEND,
+ SoundEvents.WATER_AMBIENT,
+ SoundEvents.CHICKEN_EGG,
+ SoundEvents.WOLF_SOUNDS[WolfSoundVariants.SoundSet.CLASSIC]!!.growlSound().value(),
)
@Subscribe
diff --git a/src/main/kotlin/features/inventory/CraftingOverlay.kt b/src/main/kotlin/features/inventory/CraftingOverlay.kt
index 30d2c6b..5241f54 100644
--- a/src/main/kotlin/features/inventory/CraftingOverlay.kt
+++ b/src/main/kotlin/features/inventory/CraftingOverlay.kt
@@ -1,9 +1,9 @@
package moe.nea.firmament.features.inventory
import io.github.moulberry.repo.data.NEUCraftingRecipe
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.item.ItemStack
-import net.minecraft.util.Formatting
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.world.item.ItemStack
+import net.minecraft.ChatFormatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotRenderEvents
@@ -14,7 +14,7 @@ import moe.nea.firmament.util.skyblockId
object CraftingOverlay {
- private var screen: GenericContainerScreen? = null
+ private var screen: ContainerScreen? = null
private var recipe: NEUCraftingRecipe? = null
private var useNextScreen = false
private val craftingOverlayIndices = listOf(
@@ -24,7 +24,7 @@ object CraftingOverlay {
)
val CRAFTING_SCREEN_NAME = "Craft Item"
- fun setOverlay(screen: GenericContainerScreen?, recipe: NEUCraftingRecipe) {
+ fun setOverlay(screen: ContainerScreen?, recipe: NEUCraftingRecipe) {
this.screen = screen
if (screen == null) {
useNextScreen = true
@@ -34,7 +34,7 @@ object CraftingOverlay {
@Subscribe
fun onScreenChange(event: ScreenChangeEvent) {
- if (useNextScreen && event.new is GenericContainerScreen
+ if (useNextScreen && event.new is ContainerScreen
&& event.new.title?.string == "Craft Item"
) {
useNextScreen = false
@@ -50,11 +50,11 @@ object CraftingOverlay {
fun onSlotRender(event: SlotRenderEvents.After) {
val slot = event.slot
val recipe = this.recipe ?: return
- if (slot.inventory != screen?.screenHandler?.inventory) return
- val recipeIndex = craftingOverlayIndices.indexOf(slot.index)
+ if (slot.container != screen?.menu?.container) return
+ val recipeIndex = craftingOverlayIndices.indexOf(slot.containerSlot)
if (recipeIndex < 0) return
val expectedItem = recipe.inputs[recipeIndex]
- val actualStack = slot.stack ?: ItemStack.EMPTY!!
+ val actualStack = slot.item ?: ItemStack.EMPTY!!
val actualEntry = SBItemStack(actualStack)
if ((actualEntry.skyblockId != expectedItem.skyblockId || actualEntry.getStackSize() < expectedItem.amount)
&& expectedItem.amount.toInt() != 0
@@ -67,15 +67,15 @@ object CraftingOverlay {
0x80FF0000.toInt()
)
}
- if (!slot.hasStack()) {
+ if (!slot.hasItem()) {
val itemStack = SBItemStack(expectedItem)?.asImmutableItemStack() ?: return
- event.context.drawItem(itemStack, event.slot.x, event.slot.y)
- event.context.drawStackOverlay(
+ event.context.renderItem(itemStack, event.slot.x, event.slot.y)
+ event.context.renderItemDecorations(
MC.font,
itemStack,
event.slot.x,
event.slot.y,
- "${Formatting.RED}${expectedItem.amount.toInt()}"
+ "${ChatFormatting.RED}${expectedItem.amount.toInt()}"
)
}
}
diff --git a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
index 7a474f9..9712067 100644
--- a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
+++ b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
@@ -1,10 +1,10 @@
package moe.nea.firmament.features.inventory
import java.awt.Color
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.item.ItemStack
-import net.minecraft.util.Identifier
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.world.item.ItemStack
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HotbarItemRenderEvent
import moe.nea.firmament.events.SlotRenderEvents
@@ -23,16 +23,16 @@ object ItemRarityCosmetics {
}
private val rarityToColor = Rarity.colourMap.mapValues {
- val c = Color(it.value.colorValue!!)
+ val c = Color(it.value.color!!)
c.rgb
}
- fun drawItemStackRarity(drawContext: DrawContext, x: Int, y: Int, item: ItemStack) {
+ fun drawItemStackRarity(drawContext: GuiGraphics, x: Int, y: Int, item: ItemStack) {
val rarity = Rarity.fromItem(item) ?: return
val rgb = rarityToColor[rarity] ?: 0xFF00FF80.toInt()
- drawContext.drawGuiTexture(
+ drawContext.blitSprite(
RenderPipelines.GUI_TEXTURED,
- Identifier.of("firmament:item_rarity_background"),
+ ResourceLocation.parse("firmament:item_rarity_background"),
x, y,
16, 16,
rgb
@@ -43,7 +43,7 @@ object ItemRarityCosmetics {
@Subscribe
fun onRenderSlot(it: SlotRenderEvents.Before) {
if (!TConfig.showItemRarityBackground) return
- val stack = it.slot.stack ?: return
+ val stack = it.slot.item ?: return
drawItemStackRarity(it.context, it.slot.x, it.slot.y, stack)
}
diff --git a/src/main/kotlin/features/inventory/JunkHighlighter.kt b/src/main/kotlin/features/inventory/JunkHighlighter.kt
index 45d265e..15bdcfa 100644
--- a/src/main/kotlin/features/inventory/JunkHighlighter.kt
+++ b/src/main/kotlin/features/inventory/JunkHighlighter.kt
@@ -23,7 +23,7 @@ object JunkHighlighter {
if (!TConfig.highlightBind.isPressed() || TConfig.junkRegex.isEmpty()) return
val junkRegex = TConfig.junkRegex.toPattern()
val slot = event.slot
- junkRegex.useMatch(slot.stack.getSearchName()) {
+ junkRegex.useMatch(slot.item.getSearchName()) {
event.context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, 0xffff0000.toInt())
}
}
diff --git a/src/main/kotlin/features/inventory/PetFeatures.kt b/src/main/kotlin/features/inventory/PetFeatures.kt
index 646989c..e0bb4b1 100644
--- a/src/main/kotlin/features/inventory/PetFeatures.kt
+++ b/src/main/kotlin/features/inventory/PetFeatures.kt
@@ -2,11 +2,11 @@ package moe.nea.firmament.features.inventory
import java.util.regex.Matcher
import org.joml.Vector2i
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
@@ -52,14 +52,14 @@ object PetFeatures {
val petOverlayHudStyle by choice("pet-overlay-hud-style") { PetOverlayHudStyles.PLAIN_NO_BACKGROUND }
}
- enum class PetOverlayHudStyles : StringIdentifiable {
+ enum class PetOverlayHudStyles : StringRepresentable {
PLAIN_NO_BACKGROUND,
COLOUR_NO_BACKGROUND,
PLAIN_BACKGROUND,
COLOUR_BACKGROUND,
ICON_ONLY;
- override fun asString() : String {
+ override fun getSerializedName() : String {
return name
}
}
@@ -86,7 +86,7 @@ object PetFeatures {
fun onSlotRender(event: SlotRenderEvents.Before) {
// Cache pets
petMenuTitle.useMatch(MC.screenName ?: return) {
- val stack = event.slot.stack
+ val stack = event.slot.item
if (!stack.isEmpty) cachePet(stack)
if (stack.petData?.active == true) {
if (currentPetUUID == "") currentPetUUID = stack.skyblockUUID.toString()
@@ -114,7 +114,7 @@ object PetFeatures {
fun onSlotClick(event: SlotClickEvent) {
// Check for switching/removing pet manually
petMenuTitle.useMatch(MC.screenName ?: return) {
- if (event.slot.inventory is PlayerInventory) return
+ if (event.slot.container is Inventory) return
if (event.button != 0 && event.button != 1) return
val petData = event.stack.petData ?: return
if (petData.active == true) {
@@ -175,23 +175,23 @@ object PetFeatures {
}
}
- private fun renderLinesAndBackground(it: HudRenderEvent, lines: List<Text>) {
+ private fun renderLinesAndBackground(it: HudRenderEvent, lines: List<Component>) {
// Render background for the hud
if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_BACKGROUND) {
var maxWidth = 0
- lines.forEach { if (MC.font.getWidth(it) > maxWidth) maxWidth = MC.font.getWidth(it.unformattedString) }
- val height = if (MC.font.fontHeight * lines.size > 32) MC.font.fontHeight * lines.size else 32
+ lines.forEach { if (MC.font.width(it) > maxWidth) maxWidth = MC.font.width(it.unformattedString) }
+ val height = if (MC.font.lineHeight * lines.size > 32) MC.font.lineHeight * lines.size else 32
it.context.fill(0, -3, 40 + maxWidth, height + 2, 0x80000000.toInt())
}
// Render text for the hud
lines.forEachIndexed { index, line ->
- it.context.drawText(
+ it.context.drawString(
MC.font,
- line.copy().withColor(Formatting.GRAY),
+ line.copy().withColor(ChatFormatting.GRAY),
36,
- MC.font.fontHeight * index,
+ MC.font.lineHeight * index,
-1,
true
)
@@ -217,13 +217,13 @@ object PetFeatures {
val tabPet = PetParser.parseTabWidget(TabListAPI.getWidgetLines(TabListAPI.WidgetName.PET))
if (pet == null && tabPet == null && tempTabPet == null && tempChatPet == null) {
// No data on current pet
- it.context.matrices.pushMatrix()
- TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.matrices)
- val lines = mutableListOf<Text>()
- lines.add(Text.literal("" + Formatting.WHITE + "Unknown Pet"))
- lines.add(Text.literal("Open Pets Menu To Fix"))
+ it.context.pose().pushMatrix()
+ TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.pose())
+ val lines = mutableListOf<Component>()
+ lines.add(Component.literal("" + ChatFormatting.WHITE + "Unknown Pet"))
+ lines.add(Component.literal("Open Pets Menu To Fix"))
renderLinesAndBackground(it, lines)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
return
}
if (pet == null) {
@@ -255,71 +255,71 @@ object PetFeatures {
// Set the text for the HUD
- val lines = mutableListOf<Text>()
+ val lines = mutableListOf<Component>()
if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_NO_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_BACKGROUND) {
// Colour Style
- lines.add(Text.literal("[Lvl ${pet.level}] ").append(Text.literal(pet.name)
- .withColor((Rarity.colourMap[pet.rarity]) ?: Formatting.WHITE)))
+ lines.add(Component.literal("[Lvl ${pet.level}] ").append(Component.literal(pet.name)
+ .withColor((Rarity.colourMap[pet.rarity]) ?: ChatFormatting.WHITE)))
- lines.add(Text.literal(pet.petItem))
+ lines.add(Component.literal(pet.petItem))
if (pet.level != pet.maxLevel) {
// Exp data
lines.add(
- Text.literal(
- "" + Formatting.YELLOW + "Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}" +
- Formatting.GOLD + "/" + Formatting.YELLOW +
- "${shortFormat(pet.expForNextLevel)} " + Formatting.GOLD +
+ Component.literal(
+ "" + ChatFormatting.YELLOW + "Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}" +
+ ChatFormatting.GOLD + "/" + ChatFormatting.YELLOW +
+ "${shortFormat(pet.expForNextLevel)} " + ChatFormatting.GOLD +
"(${formatPercent(pet.currentExp / pet.expForNextLevel)})"
)
)
lines.add(
- Text.literal(
- "" + Formatting.YELLOW + "Required L100: ${shortFormat(pet.totalExp)}" +
- Formatting.GOLD + "/" + Formatting.YELLOW +
- "${shortFormat(pet.expForMax)} " + Formatting.GOLD +
+ Component.literal(
+ "" + ChatFormatting.YELLOW + "Required L100: ${shortFormat(pet.totalExp)}" +
+ ChatFormatting.GOLD + "/" + ChatFormatting.YELLOW +
+ "${shortFormat(pet.expForMax)} " + ChatFormatting.GOLD +
"(${formatPercent(pet.totalExp / pet.expForMax)})"
)
)
} else {
// Overflow Exp data
- lines.add(Text.literal(
- "" + Formatting.AQUA + Formatting.BOLD + "MAX LEVEL"
+ lines.add(Component.literal(
+ "" + ChatFormatting.AQUA + ChatFormatting.BOLD + "MAX LEVEL"
))
- lines.add(Text.literal(
- "" + Formatting.GOLD + "+" + Formatting.YELLOW + "${shortFormat(pet.overflowExp)} XP"
+ lines.add(Component.literal(
+ "" + ChatFormatting.GOLD + "+" + ChatFormatting.YELLOW + "${shortFormat(pet.overflowExp)} XP"
))
}
} else if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_NO_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_BACKGROUND) {
// Plain Style
- lines.add(Text.literal("[Lvl ${pet.level}] ").append(Text.literal(pet.name)
- .withColor((Rarity.colourMap[pet.rarity]) ?: Formatting.WHITE)))
+ lines.add(Component.literal("[Lvl ${pet.level}] ").append(Component.literal(pet.name)
+ .withColor((Rarity.colourMap[pet.rarity]) ?: ChatFormatting.WHITE)))
- lines.add(Text.literal(if (pet.petItem != "None" && pet.petItem != "Unknown")
+ lines.add(Component.literal(if (pet.petItem != "None" && pet.petItem != "Unknown")
pet.petItem.substring(2) else pet.petItem))
if (pet.level != pet.maxLevel) {
// Exp data
lines.add(
- Text.literal(
+ Component.literal(
"Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}/" +
"${shortFormat(pet.expForNextLevel)} " +
"(${formatPercent(pet.currentExp / pet.expForNextLevel)})"
)
)
lines.add(
- Text.literal(
+ Component.literal(
"Required L100: ${shortFormat(pet.totalExp)}/${shortFormat(pet.expForMax)} " +
"(${formatPercent(pet.totalExp / pet.expForMax)})"
)
)
} else {
// Overflow Exp data
- lines.add(Text.literal(
+ lines.add(Component.literal(
"MAX LEVEL"
))
- lines.add(Text.literal(
+ lines.add(Component.literal(
"+${shortFormat(pet.overflowExp)} XP"
))
}
@@ -327,19 +327,19 @@ object PetFeatures {
// Render HUD
- it.context.matrices.pushMatrix()
- TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.matrices)
+ it.context.pose().pushMatrix()
+ TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.pose())
renderLinesAndBackground(it, lines)
// Draw the ItemStack
- it.context.matrices.pushMatrix()
- it.context.matrices.translate(-0.5F, -0.5F)
- it.context.matrices.scale(2f, 2f)
- it.context.drawItem(pet.petItemStack.value, 0, 0)
- it.context.matrices.popMatrix()
+ it.context.pose().pushMatrix()
+ it.context.pose().translate(-0.5F, -0.5F)
+ it.context.pose().scale(2f, 2f)
+ it.context.renderItem(pet.petItemStack.value, 0, 0)
+ it.context.pose().popMatrix()
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
}
@@ -404,7 +404,7 @@ object PetParser {
}
@OptIn(ExpensiveItemCacheApi::class)
- fun parseTabWidget(lines: List<Text>): ParsedPet? {
+ fun parseTabWidget(lines: List<Component>): ParsedPet? {
found.clear()
for (line in lines.reversed()) {
if (!found.containsKey("kat")) {
@@ -524,20 +524,20 @@ object PetParser {
}
data class ParsedPet(
- val name: String,
- val rarity: Rarity,
- var level: Int,
- val maxLevel: Int,
- val expLadder: ExpLadders.ExpLadder?,
- var currentExp: Double,
- var expForNextLevel: Double,
- var totalExp: Double,
- var totalExpBeforeLevel: Double,
- val expForMax: Double,
- var overflowExp: Double,
- var petItem: String,
- var petItemStack: Lazy<ItemStack>,
- var isComplete: Boolean
+ val name: String,
+ val rarity: Rarity,
+ var level: Int,
+ val maxLevel: Int,
+ val expLadder: ExpLadders.ExpLadder?,
+ var currentExp: Double,
+ var expForNextLevel: Double,
+ var totalExp: Double,
+ var totalExpBeforeLevel: Double,
+ val expForMax: Double,
+ var overflowExp: Double,
+ var petItem: String,
+ var petItemStack: Lazy<ItemStack>,
+ var isComplete: Boolean
) {
fun update(other: ParsedPet) {
// Update the pet data to reflect another instance (of itself)
diff --git a/src/main/kotlin/features/inventory/PriceData.kt b/src/main/kotlin/features/inventory/PriceData.kt
index 5f9268e..54802db 100644
--- a/src/main/kotlin/features/inventory/PriceData.kt
+++ b/src/main/kotlin/features/inventory/PriceData.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
-import net.minecraft.text.Text
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.network.chat.Component
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.repo.HypixelStaticData
@@ -34,25 +34,25 @@ object PriceData {
}
}
- enum class AvgLowestBin : StringIdentifiable {
+ enum class AvgLowestBin : StringRepresentable {
OFF,
ONEDAYAVGLOWESTBIN,
THREEDAYAVGLOWESTBIN,
SEVENDAYAVGLOWESTBIN;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
- fun formatPrice(label: Text, price: Double): Text {
- return Text.literal("")
+ fun formatPrice(label: Component, price: Double): Component {
+ return Component.literal("")
.yellow()
.bold()
.append(label)
.append(": ")
.append(
- Text.literal(formatCommas(price, fractionalDigits = 1))
+ Component.literal(formatCommas(price, fractionalDigits = 1))
.append(if (price != 1.0) " coins" else " coin")
.gold()
.bold()
@@ -84,7 +84,7 @@ object PriceData {
AvgLowestBin.OFF -> null
}
if (bazaarData != null) {
- it.lines.add(Text.literal(""))
+ it.lines.add(Component.literal(""))
it.lines.add(multiplierText)
it.lines.add(
formatPrice(
@@ -99,7 +99,7 @@ object PriceData {
)
)
} else if (lowestBin != null) {
- it.lines.add(Text.literal(""))
+ it.lines.add(Component.literal(""))
it.lines.add(multiplierText)
it.lines.add(
formatPrice(
diff --git a/src/main/kotlin/features/inventory/REIDependencyWarner.kt b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
index 9e8a4db..e508016 100644
--- a/src/main/kotlin/features/inventory/REIDependencyWarner.kt
+++ b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
@@ -6,8 +6,8 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
import net.minecraft.SharedConstants
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.Text
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
@@ -31,22 +31,22 @@ object REIDependencyWarner {
var sentWarning = false
fun modrinthLink(slug: String) =
- "https://modrinth.com/mod/$slug/versions?g=${SharedConstants.getGameVersion().name()}&l=fabric"
+ "https://modrinth.com/mod/$slug/versions?g=${SharedConstants.getCurrentVersion().name()}&l=fabric"
- fun downloadButton(modName: String, modId: String, slug: String): Text {
+ fun downloadButton(modName: String, modId: String, slug: String): Component {
val alreadyDownloaded = FabricLoader.getInstance().isModLoaded(modId)
- return Text.literal(" - ")
+ return Component.literal(" - ")
.white()
- .append(Text.literal("[").aqua())
- .append(Text.translatable("firmament.download", modName)
- .styled { it.withClickEvent(ClickEvent.OpenUrl(URI (modrinthLink(slug)))) }
+ .append(Component.literal("[").aqua())
+ .append(Component.translatable("firmament.download", modName)
+ .withStyle { it.withClickEvent(ClickEvent.OpenUrl(URI (modrinthLink(slug)))) }
.yellow()
.also {
if (alreadyDownloaded)
- it.append(Text.translatable("firmament.download.already", modName)
+ it.append(Component.translatable("firmament.download.already", modName)
.lime())
})
- .append(Text.literal("]").aqua())
+ .append(Component.literal("]").aqua())
}
@Subscribe
@@ -60,11 +60,11 @@ object REIDependencyWarner {
delay(2.seconds)
// TODO: should we offer an automatic install that actually downloads the JARs and places them into the mod folder?
MC.sendChat(
- Text.translatable("firmament.reiwarning").red().bold().append("\n")
+ Component.translatable("firmament.reiwarning").red().bold().append("\n")
.append(downloadButton("RoughlyEnoughItems", reiModId, "rei")).append("\n")
.append(downloadButton("Architectury API", "architectury", "architectury-api")).append("\n")
.append(downloadButton("Cloth Config API", "cloth-config", "cloth-config")).append("\n")
- .append(Text.translatable("firmament.reiwarning.disable")
+ .append(Component.translatable("firmament.reiwarning.disable")
.clickCommand("/firm disablereiwarning")
.grey())
)
@@ -78,7 +78,7 @@ object REIDependencyWarner {
thenExecute {
RepoManager.TConfig.warnForMissingItemListMod = false
RepoManager.TConfig.markDirty()
- MC.sendChat(Text.translatable("firmament.reiwarning.disabled").yellow())
+ MC.sendChat(Component.translatable("firmament.reiwarning.disabled").yellow())
}
}
}
diff --git a/src/main/kotlin/features/inventory/SaveCursorPosition.kt b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
index c523661..c492a75 100644
--- a/src/main/kotlin/features/inventory/SaveCursorPosition.kt
+++ b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
@@ -3,7 +3,7 @@ package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
import kotlin.math.absoluteValue
import kotlin.time.Duration.Companion.milliseconds
-import net.minecraft.client.util.InputUtil
+import com.mojang.blaze3d.platform.InputConstants
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TimeMark
import moe.nea.firmament.util.assertNotNullOr
@@ -43,9 +43,9 @@ object SaveCursorPosition {
(lastPosition.middle.first - middleX).absoluteValue < 1 &&
(lastPosition.middle.second - middleY).absoluteValue < 1
) {
- InputUtil.setCursorParameters(
+ InputConstants.grabOrReleaseMouse(
MC.window,
- InputUtil.GLFW_CURSOR_NORMAL,
+ InputConstants.CURSOR_NORMAL,
lastPosition.cursor.first,
lastPosition.cursor.second
)
diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt
index 10c58cb..09afe80 100644
--- a/src/main/kotlin/features/inventory/SlotLocking.kt
+++ b/src/main/kotlin/features/inventory/SlotLocking.kt
@@ -16,17 +16,17 @@ import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.int
import kotlinx.serialization.serializer
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.gui.screen.ingame.InventoryScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.ItemStack
-import net.minecraft.screen.GenericContainerScreenHandler
-import net.minecraft.screen.PlayerScreenHandler
-import net.minecraft.screen.slot.Slot
-import net.minecraft.screen.slot.SlotActionType
-import net.minecraft.util.Identifier
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.gui.screens.inventory.InventoryScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.inventory.ChestMenu
+import net.minecraft.world.inventory.InventoryMenu
+import net.minecraft.world.inventory.Slot
+import net.minecraft.world.inventory.ClickType
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ClientInitEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
@@ -157,12 +157,12 @@ object SlotLocking {
val allowDroppingInDungeons by toggle("drop-in-dungeons") { true }
}
- enum class SlotRenderLinesMode : StringIdentifiable {
+ enum class SlotRenderLinesMode : StringRepresentable {
EVERYTHING,
ONLY_BOXES,
NOTHING;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -175,25 +175,25 @@ object SlotLocking {
val lockedSlots
get() = currentWorldData?.lockedSlots
- fun isSalvageScreen(screen: HandledScreen<*>?): Boolean {
+ fun isSalvageScreen(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
return screen.title.unformattedString.contains("Salvage Item")
}
- fun isTradeScreen(screen: HandledScreen<*>?): Boolean {
+ fun isTradeScreen(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return false
- if (handler.inventory.size() < 9) return false
- val middlePane = handler.inventory.getStack(handler.inventory.size() - 5)
+ val handler = screen.menu as? ChestMenu ?: return false
+ if (handler.container.containerSize < 9) return false
+ val middlePane = handler.container.getItem(handler.container.containerSize - 5)
if (middlePane == null) return false
return middlePane.displayNameAccordingToNbt?.unformattedString == "⇦ Your stuff"
}
- fun isNpcShop(screen: HandledScreen<*>?): Boolean {
+ fun isNpcShop(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return false
- if (handler.inventory.size() < 9) return false
- val sellItem = handler.inventory.getStack(handler.inventory.size() - 5)
+ val handler = screen.menu as? ChestMenu ?: return false
+ if (handler.container.containerSize < 9) return false
+ val sellItem = handler.container.getItem(handler.container.containerSize - 5)
if (sellItem == null) return false
if (sellItem.displayNameAccordingToNbt.unformattedString == "Sell Item") return true
val lore = sellItem.loreAccordingToNbt
@@ -203,15 +203,15 @@ object SlotLocking {
@Subscribe
fun onSalvageProtect(event: IsSlotProtectedEvent) {
if (event.slot == null) return
- if (!event.slot.hasStack()) return
- if (event.slot.stack.displayNameAccordingToNbt.unformattedString != "Salvage Items") return
- val inv = event.slot.inventory
+ if (!event.slot.hasItem()) return
+ if (event.slot.item.displayNameAccordingToNbt.unformattedString != "Salvage Items") return
+ val inv = event.slot.container
var anyBlocked = false
- for (i in 0 until event.slot.index) {
- val stack = inv.getStack(i)
+ for (i in 0 until event.slot.containerSlot) {
+ val stack = inv.getItem(i)
if (IsSlotProtectedEvent.shouldBlockInteraction(
null,
- SlotActionType.THROW,
+ ClickType.THROW,
IsSlotProtectedEvent.MoveOrigin.SALVAGE,
stack
)
@@ -225,15 +225,15 @@ object SlotLocking {
@Subscribe
fun onProtectUuidItems(event: IsSlotProtectedEvent) {
- val doesNotDeleteItem = event.actionType == SlotActionType.SWAP
- || event.actionType == SlotActionType.PICKUP
- || event.actionType == SlotActionType.QUICK_MOVE
- || event.actionType == SlotActionType.QUICK_CRAFT
- || event.actionType == SlotActionType.CLONE
- || event.actionType == SlotActionType.PICKUP_ALL
+ val doesNotDeleteItem = event.actionType == ClickType.SWAP
+ || event.actionType == ClickType.PICKUP
+ || event.actionType == ClickType.QUICK_MOVE
+ || event.actionType == ClickType.QUICK_CRAFT
+ || event.actionType == ClickType.CLONE
+ || event.actionType == ClickType.PICKUP_ALL
val isSellOrTradeScreen =
isNpcShop(MC.handledScreen) || isTradeScreen(MC.handledScreen) || isSalvageScreen(MC.handledScreen)
- if ((!isSellOrTradeScreen || event.slot?.inventory !is PlayerInventory)
+ if ((!isSellOrTradeScreen || event.slot?.container !is Inventory)
&& doesNotDeleteItem
) return
val stack = event.itemStack ?: return
@@ -253,7 +253,7 @@ object SlotLocking {
@Subscribe
fun onProtectSlot(it: IsSlotProtectedEvent) {
- if (it.slot != null && it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())) {
+ if (it.slot != null && it.slot.container is Inventory && it.slot.containerSlot in (lockedSlots ?: setOf())) {
it.protect()
}
}
@@ -275,14 +275,14 @@ object SlotLocking {
fun onQuickMoveBoundSlot(it: IsSlotProtectedEvent) {
val boundSlots = currentWorldData?.boundSlots ?: BoundSlots()
val isValidAction =
- it.actionType == SlotActionType.QUICK_MOVE || (it.actionType == SlotActionType.PICKUP && !TConfig.slotBindRequireShift)
+ it.actionType == ClickType.QUICK_MOVE || (it.actionType == ClickType.PICKUP && !TConfig.slotBindRequireShift)
if (!isValidAction) return
- val handler = MC.handledScreen?.screenHandler ?: return
- if (TConfig.slotBindOnlyInInv && handler !is PlayerScreenHandler)
+ val handler = MC.handledScreen?.menu ?: return
+ if (TConfig.slotBindOnlyInInv && handler !is InventoryMenu)
return
val slot = it.slot
- if (slot != null && it.slot.inventory is PlayerInventory) {
- val matchingSlots = boundSlots.findMatchingSlots(slot.index)
+ if (slot != null && it.slot.container is Inventory) {
+ val matchingSlots = boundSlots.findMatchingSlots(slot.containerSlot)
if (matchingSlots.isEmpty()) return
it.protectSilent()
val boundSlot = matchingSlots.singleOrNull() ?: return
@@ -298,7 +298,7 @@ object SlotLocking {
inventory as AccessorHandledScreen
val slot = inventory.focusedSlot_Firmament ?: return
- val stack = slot.stack ?: return
+ val stack = slot.item ?: return
if (stack.isHuntingBox()) {
MC.sendChat(
tr(
@@ -339,10 +339,10 @@ object SlotLocking {
val hotBarSlot = if (slot.isHotbar()) slot else storedSlot
val invSlot = if (slot.isHotbar()) storedSlot else slot
val boundSlots = currentWorldData?.boundSlots ?: return
- lockedSlots?.remove(hotBarSlot.index)
- lockedSlots?.remove(invSlot.index)
- boundSlots.removeDuplicateForInventory(invSlot.index)
- boundSlots.insert(hotBarSlot.index, invSlot.index)
+ lockedSlots?.remove(hotBarSlot.containerSlot)
+ lockedSlots?.remove(invSlot.containerSlot)
+ boundSlots.removeDuplicateForInventory(invSlot.containerSlot)
+ boundSlots.insert(hotBarSlot.containerSlot, invSlot.containerSlot)
DConfig.markDirty()
CommonSoundEffects.playSuccess()
return
@@ -356,7 +356,7 @@ object SlotLocking {
storedLockingSlot = null
val boundSlots = currentWorldData?.boundSlots ?: return
if (slot != null)
- boundSlots.removeAllInvolving(slot.index)
+ boundSlots.removeAllInvolving(slot.containerSlot)
}
}
@@ -393,12 +393,12 @@ object SlotLocking {
hotX + sx, hotY + sy,
color(anyHovered)
)
- event.context.drawStrokedRectangle(
+ event.context.submitOutline(
hotbarSlot.x + sx,
hotbarSlot.y + sy,
16, 16, color(hotbarSlot in highlitSlots).color
)
- event.context.drawStrokedRectangle( // TODO: 1.21.10
+ event.context.submitOutline( // TODO: 1.21.10
inventorySlot.x + sx,
inventorySlot.y + sy,
16, 16, color(inventorySlot in highlitSlots).color
@@ -411,12 +411,12 @@ object SlotLocking {
val draggingSlot = storedLockingSlot ?: return
val accScreen = event.screen as AccessorHandledScreen
val hoveredSlot = accScreen.focusedSlot_Firmament
- ?.takeIf { it.inventory is PlayerInventory }
+ ?.takeIf { it.container is Inventory }
?.takeIf { it == draggingSlot || it.isHotbar() != draggingSlot.isHotbar() }
val sx = accScreen.x_Firmament
val sy = accScreen.y_Firmament
val (borderX, borderY) = draggingSlot.lineCenter()
- event.context.drawStrokedRectangle(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) // TODO: 1.21.10
+ event.context.submitOutline(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) // TODO: 1.21.10
if (hoveredSlot == null) {
event.context.drawLine(
borderX + sx, borderY + sy,
@@ -430,7 +430,7 @@ object SlotLocking {
hovX + sx, hovY + sy,
me.shedaniel.math.Color.ofOpaque(0x00FF00)
)
- event.context.drawStrokedRectangle(
+ event.context.submitOutline(
hoveredSlot.x + sx,
hoveredSlot.y + sy,
16, 16, 0xFF00FF00u.toInt()
@@ -448,7 +448,7 @@ object SlotLocking {
fun Slot.isHotbar(): Boolean {
- return index < 9
+ return containerSlot < 9
}
@Subscribe
@@ -461,13 +461,13 @@ object SlotLocking {
fun toggleSlotLock(slot: Slot) {
val lockedSlots = lockedSlots ?: return
val boundSlots = currentWorldData?.boundSlots ?: BoundSlots()
- if (slot.inventory is PlayerInventory) {
- if (boundSlots.removeAllInvolving(slot.index)) {
+ if (slot.container is Inventory) {
+ if (boundSlots.removeAllInvolving(slot.containerSlot)) {
// intentionally do nothing
- } else if (slot.index in lockedSlots) {
- lockedSlots.remove(slot.index)
+ } else if (slot.containerSlot in lockedSlots) {
+ lockedSlots.remove(slot.containerSlot)
} else {
- lockedSlots.add(slot.index)
+ lockedSlots.add(slot.containerSlot)
}
DConfig.markDirty()
CommonSoundEffects.playSuccess()
@@ -480,7 +480,7 @@ object SlotLocking {
inventory as AccessorHandledScreen
val slot = inventory.focusedSlot_Firmament ?: return
- if (slot.inventory !is PlayerInventory) return
+ if (slot.container !is Inventory) return
if (it.matches(TConfig.slotBind)) {
storedLockingSlot = storedLockingSlot ?: slot
return
@@ -493,17 +493,17 @@ object SlotLocking {
@Subscribe
fun onRenderSlotOverlay(it: SlotRenderEvents.After) {
- val isSlotLocked = it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())
- val isUUIDLocked = (it.slot.stack?.skyblockUUID) in (lockedUUIDs ?: setOf())
+ val isSlotLocked = it.slot.container is Inventory && it.slot.containerSlot in (lockedSlots ?: setOf())
+ val isUUIDLocked = (it.slot.item?.skyblockUUID) in (lockedUUIDs ?: setOf())
if (isSlotLocked || isUUIDLocked) {
- it.context.drawGuiTexture(
+ it.context.blitSprite(
RenderPipelines.GUI_TEXTURED,
when {
isSlotLocked ->
- (Identifier.of("firmament:slot_locked"))
+ (ResourceLocation.parse("firmament:slot_locked"))
isUUIDLocked ->
- (Identifier.of("firmament:uuid_locked"))
+ (ResourceLocation.parse("firmament:uuid_locked"))
else ->
error("unreachable")
diff --git a/src/main/kotlin/features/inventory/TimerInLore.kt b/src/main/kotlin/features/inventory/TimerInLore.kt
index d8eebda..9bb78c9 100644
--- a/src/main/kotlin/features/inventory/TimerInLore.kt
+++ b/src/main/kotlin/features/inventory/TimerInLore.kt
@@ -7,8 +7,8 @@ import java.time.format.DateTimeFormatterBuilder
import java.time.format.FormatStyle
import java.time.format.TextStyle
import java.time.temporal.ChronoField
-import net.minecraft.text.Text
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.network.chat.Component
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.util.SBData
@@ -29,7 +29,7 @@ object TimerInLore {
val timerFormat by choice("format") { TimerFormat.SOCIALIST }
}
- enum class TimerFormat(val formatter: DateTimeFormatter) : StringIdentifiable {
+ enum class TimerFormat(val formatter: DateTimeFormatter) : StringRepresentable {
RFC(DateTimeFormatter.RFC_1123_DATE_TIME),
LOCAL(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)),
SOCIALIST(
@@ -57,7 +57,7 @@ object TimerInLore {
constructor(format: String) : this(DateTimeFormatter.ofPattern(format))
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -142,9 +142,9 @@ object TimerInLore {
// TODO: install approximate time stabilization algorithm
event.lines.add(
i + 1,
- Text.literal("${countdownType.label}: ")
+ Component.literal("${countdownType.label}: ")
.grey()
- .append(Text.literal(TConfig.timerFormat.formatter.format(localTimer)).aqua())
+ .append(Component.literal(TConfig.timerFormat.formatter.format(localTimer)).aqua())
)
}
}
diff --git a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
index cdd646e..b3d4bfd 100644
--- a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
+++ b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
-import net.minecraft.item.Items
+import net.minecraft.world.item.Items
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.util.MC
@@ -41,16 +41,16 @@ object WardrobeKeybinds {
) {
event.cancel()
- val handler = event.screen.screenHandler
+ val handler = event.screen.menu
val previousSlot = handler.getSlot(45)
val nextSlot = handler.getSlot(53)
val backPressed = event.matches(TConfig.changePageKeybind) || event.matches(TConfig.previousPage)
val nextPressed = event.matches(TConfig.changePageKeybind) || event.matches(TConfig.nextPage)
- if (backPressed && previousSlot.stack.item == Items.ARROW) {
+ if (backPressed && previousSlot.item.item == Items.ARROW) {
previousSlot.clickLeftMouseButton(handler)
- } else if (nextPressed && nextSlot.stack.item == Items.ARROW) {
+ } else if (nextPressed && nextSlot.item.item == Items.ARROW) {
nextSlot.clickLeftMouseButton(handler)
}
}
@@ -63,10 +63,10 @@ object WardrobeKeybinds {
event.cancel()
- val handler = event.screen.screenHandler
+ val handler = event.screen.menu
val invSlot = handler.getSlot(slot)
- val itemStack = invSlot.stack
+ val itemStack = invSlot.item
val isSelected = itemStack.item == Items.LIME_DYE
val isSelectable = itemStack.item == Items.PINK_DYE
if (!isSelectable && !isSelected) return
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButton.kt b/src/main/kotlin/features/inventory/buttons/InventoryButton.kt
index e31f4a0..0cb51ca 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButton.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButton.kt
@@ -5,14 +5,14 @@ import me.shedaniel.math.Dimension
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.command.CommandRegistryAccess
-import net.minecraft.command.argument.ItemStackArgumentType
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.resource.featuretoggle.FeatureFlags
-import net.minecraft.util.Identifier
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.commands.CommandBuildContext
+import net.minecraft.commands.arguments.item.ItemArgument
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.world.flag.FeatureFlags
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.ItemCache.isBroken
@@ -40,10 +40,10 @@ data class InventoryButton(
companion object {
val itemStackParser by lazy {
- ItemStackArgumentType.itemStack(
- CommandRegistryAccess.of(
+ ItemArgument.item(
+ CommandBuildContext.simple(
MC.defaultRegistries,
- FeatureFlags.VANILLA_FEATURES
+ FeatureFlags.VANILLA_SET
)
)
}
@@ -71,7 +71,7 @@ data class InventoryButton(
else icon
val componentItem =
runCatching {
- itemStackParser.parse(StringReader(giveSyntaxItem)).createStack(1, false)
+ itemStackParser.parse(StringReader(giveSyntaxItem)).createItemStack(1, false)
}.getOrNull()
if (componentItem != null)
itemStack = componentItem
@@ -84,23 +84,23 @@ data class InventoryButton(
}
}
- fun render(context: DrawContext) {
- context.drawGuiTexture(
+ fun render(context: GuiGraphics) {
+ context.blitSprite(
RenderPipelines.GUI_TEXTURED,
- Identifier.of("firmament:inventory_button_background"),
+ ResourceLocation.parse("firmament:inventory_button_background"),
0,
0,
myDimension.width,
myDimension.height,
)
if (isGigantic) {
- context.matrices.pushMatrix()
- context.matrices.translate(myDimension.width / 2F, myDimension.height / 2F)
- context.matrices.scale(2F)
- context.drawItem(getItem(), -8, -8)
- context.matrices.popMatrix()
+ context.pose().pushMatrix()
+ context.pose().translate(myDimension.width / 2F, myDimension.height / 2F)
+ context.pose().scale(2F)
+ context.renderItem(getItem(), -8, -8)
+ context.pose().popMatrix()
} else {
- context.drawItem(getItem(), 1, 1)
+ context.renderItem(getItem(), 1, 1)
}
}
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
index d5d291c..6b6a2d6 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
@@ -8,17 +8,17 @@ import io.github.notenoughupdates.moulconfig.xml.Bind
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
import org.lwjgl.glfw.GLFW
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.widget.ButtonWidget
-import net.minecraft.client.gui.widget.MultilineTextWidget
-import net.minecraft.client.gui.widget.TextWidget
-import net.minecraft.client.input.KeyInput
-import net.minecraft.client.util.InputUtil
-import net.minecraft.text.Text
-import net.minecraft.util.math.MathHelper
-import net.minecraft.util.math.Vec2f
+import net.minecraft.client.Minecraft
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.components.Button
+import net.minecraft.client.gui.components.MultiLineTextWidget
+import net.minecraft.client.gui.components.StringWidget
+import net.minecraft.client.input.KeyEvent
+import com.mojang.blaze3d.platform.InputConstants
+import net.minecraft.network.chat.Component
+import net.minecraft.util.Mth
+import net.minecraft.world.phys.Vec2
import moe.nea.firmament.util.ClipboardUtils
import moe.nea.firmament.util.FragmentGuiScreen
import moe.nea.firmament.util.MC
@@ -60,69 +60,69 @@ class InventoryButtonEditor(
var buttons: MutableList<InventoryButton> =
InventoryButtons.DConfig.data.buttons.map { it.copy() }.toMutableList()
- override fun close() {
+ override fun onClose() {
InventoryButtons.DConfig.data.buttons = buttons
InventoryButtons.DConfig.markDirty()
- super.close()
+ super.onClose()
}
- override fun resize(client: MinecraftClient, width: Int, height: Int) {
+ override fun resize(client: Minecraft, width: Int, height: Int) {
lastGuiRect.move(
- MC.window.scaledWidth / 2 - lastGuiRect.width / 2,
- MC.window.scaledHeight / 2 - lastGuiRect.height / 2
+ MC.window.guiScaledWidth / 2 - lastGuiRect.width / 2,
+ MC.window.guiScaledHeight / 2 - lastGuiRect.height / 2
)
super.resize(client, width, height)
}
override fun init() {
super.init()
- addDrawableChild(
- MultilineTextWidget(
+ addRenderableWidget(
+ MultiLineTextWidget(
lastGuiRect.minX,
25,
- Text.translatable("firmament.inventory-buttons.delete"),
+ Component.translatable("firmament.inventory-buttons.delete"),
MC.font
).setCentered(true).setMaxWidth(lastGuiRect.width)
)
- addDrawableChild(
- MultilineTextWidget(
+ addRenderableWidget(
+ MultiLineTextWidget(
lastGuiRect.minX,
40,
- Text.translatable("firmament.inventory-buttons.info"),
+ Component.translatable("firmament.inventory-buttons.info"),
MC.font
).setCentered(true).setMaxWidth(lastGuiRect.width)
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.reset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.reset")) {
val newButtons = InventoryButtonTemplates.loadTemplate("TkVVQlVUVE9OUy9bXQ==")
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 10)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 10)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.load-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.load-preset")) {
val t = ClipboardUtils.getTextContents()
val newButtons = InventoryButtonTemplates.loadTemplate(t)
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 35)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 35)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.save-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.save-preset")) {
ClipboardUtils.setTextContent(InventoryButtonTemplates.saveTemplate(buttons))
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 60)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 60)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.simple-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.simple-preset")) {
// Preset from NEU
// Credit: https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/9b1fcfebc646e9fb69f99006327faa3e734e5f51/src/main/resources/assets/notenoughupdates/invbuttons/presets.json#L900-L1348
val newButtons = InventoryButtonTemplates.loadTemplate(
@@ -131,12 +131,12 @@ class InventoryButtonEditor(
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 85)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 85)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.all-warps-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.all-warps-preset")) {
// Preset from NEU
// Credit: https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/9b1fcfebc646e9fb69f99006327faa3e734e5f51/src/main/resources/assets/notenoughupdates/invbuttons/presets.json#L1817-L2276
val newButtons = InventoryButtonTemplates.loadTemplate(
@@ -145,7 +145,7 @@ class InventoryButtonEditor(
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 110)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 110)
.width(lastGuiRect.width - 20)
.build()
)
@@ -195,42 +195,42 @@ class InventoryButtonEditor(
return newButtons
}
- override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
- context.matrices.pushMatrix()
+ override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
+ context.pose().pushMatrix()
PanelComponent.DefaultBackgroundRenderer.VANILLA
.render(
MoulConfigRenderContext(context),
lastGuiRect.minX, lastGuiRect.minY,
lastGuiRect.width, lastGuiRect.height,
)
- context.matrices.popMatrix()
+ context.pose().popMatrix()
super.render(context, mouseX, mouseY, delta)
for (button in buttons) {
val buttonPosition = button.getBounds(lastGuiRect)
- context.matrices.pushMatrix()
- context.matrices.translate(buttonPosition.minX.toFloat(), buttonPosition.minY.toFloat())
+ context.pose().pushMatrix()
+ context.pose().translate(buttonPosition.minX.toFloat(), buttonPosition.minY.toFloat())
button.render(context)
- context.matrices.popMatrix()
+ context.pose().popMatrix()
}
renderPopup(context, mouseX, mouseY, delta)
}
- override fun keyPressed(input: KeyInput): Boolean {
+ override fun keyPressed(input: KeyEvent): Boolean {
if (super.keyPressed(input)) return true
- if (input.keycode == GLFW.GLFW_KEY_ESCAPE) {
- close()
+ if (input.input() == GLFW.GLFW_KEY_ESCAPE) {
+ onClose()
return true
}
return false
}
- override fun mouseReleased(click: Click): Boolean {
+ override fun mouseReleased(click: MouseButtonEvent): Boolean {
if (super.mouseReleased(click)) return true
val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(click.x, click.y)) }
if (clickedButton != null && !justPerformedAClickAction) {
- if (InputUtil.isKeyPressed(
+ if (InputConstants.isKeyDown(
MC.window,
- InputUtil.GLFW_KEY_LEFT_CONTROL
+ InputConstants.KEY_LCONTROL
)
) Editor(clickedButton).delete()
else createPopup(
@@ -244,11 +244,11 @@ class InventoryButtonEditor(
return false
}
- override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ override fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
if (super.mouseDragged(click, offsetX, offsetY)) return true
- if (initialDragMousePosition.distanceSquared(Vec2f(click.x.toFloat(), click.y.toFloat())) >= 4 * 4) {
- initialDragMousePosition = Vec2f(-10F, -10F)
+ if (initialDragMousePosition.distanceToSqr(Vec2(click.x.toFloat(), click.y.toFloat())) >= 4 * 4) {
+ initialDragMousePosition = Vec2(-10F, -10F)
lastDraggedButton?.let { dragging ->
justPerformedAClickAction = true
val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(click.x.toInt(), click.y.toInt())
@@ -272,7 +272,7 @@ class InventoryButtonEditor(
var lastDraggedButton: InventoryButton? = null
var justPerformedAClickAction = false
- var initialDragMousePosition = Vec2f(-10F, -10F)
+ var initialDragMousePosition = Vec2(-10F, -10F)
data class AnchoredCoords(
val anchorRight: Boolean,
@@ -286,9 +286,9 @@ class InventoryButtonEditor(
val anchorBottom = my > lastGuiRect.maxY
var offsetX = mx - if (anchorRight) lastGuiRect.maxX else lastGuiRect.minX
var offsetY = my - if (anchorBottom) lastGuiRect.maxY else lastGuiRect.minY
- if (InputUtil.isKeyPressed(MC.window, InputUtil.GLFW_KEY_LEFT_SHIFT)) {
- offsetX = MathHelper.floor(offsetX / 20F) * 20
- offsetY = MathHelper.floor(offsetY / 20F) * 20
+ if (InputConstants.isKeyDown(MC.window, InputConstants.KEY_LSHIFT)) {
+ offsetX = Mth.floor(offsetX / 20F) * 20
+ offsetY = Mth.floor(offsetY / 20F) * 20
}
val rect = InventoryButton(offsetX, offsetY, anchorRight, anchorBottom).getBounds(lastGuiRect)
if (rect.intersects(lastGuiRect)) return null
@@ -296,12 +296,12 @@ class InventoryButtonEditor(
return anchoredCoords
}
- override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClicked(click: MouseButtonEvent, doubled: Boolean): Boolean {
if (super.mouseClicked(click, doubled)) return true
val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(click.x, click.y) }
if (clickedButton != null) {
lastDraggedButton = clickedButton
- initialDragMousePosition = Vec2f(click.y.toFloat(), click.y.toFloat())
+ initialDragMousePosition = Vec2(click.y.toFloat(), click.y.toFloat())
return true
}
val mx = click.x.toInt()
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
index 082673e..c6ad14d 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.features.inventory.buttons
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.MC
@@ -17,7 +17,7 @@ object InventoryButtonTemplates {
ErrorUtil.catch<InventoryButton?>("Could not import button") {
Firmament.json.decodeFromString<InventoryButton>(it).also {
if (it.icon?.startsWith("extra:") == true) {
- MC.sendChat(Text.translatable("firmament.inventory-buttons.import-failed"))
+ MC.sendChat(Component.translatable("firmament.inventory-buttons.import-failed"))
}
}
}.or {
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
index 47fdbe9..fa376bc 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
@@ -4,9 +4,9 @@ import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.gui.screen.ingame.InventoryScreen
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.gui.screens.inventory.InventoryScreen
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenClickEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
@@ -14,7 +14,7 @@ import moe.nea.firmament.events.HandledScreenPushREIEvent
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.TimeMark
-import moe.nea.firmament.util.accessors.getRectangle
+import moe.nea.firmament.util.accessors.getProperRectangle
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.DataHolder
import moe.nea.firmament.util.data.ManagedConfig
@@ -39,7 +39,7 @@ object InventoryButtons {
var buttons: MutableList<InventoryButton> = mutableListOf()
)
- fun getValidButtons(screen: HandledScreen<*>): Sequence<InventoryButton> {
+ fun getValidButtons(screen: AbstractContainerScreen<*>): Sequence<InventoryButton> {
return DConfig.data.buttons.asSequence().filter { button ->
button.isValid() && (!TConfig.onlyInv || screen is InventoryScreen)
}
@@ -48,7 +48,7 @@ object InventoryButtons {
@Subscribe
fun onRectangles(it: HandledScreenPushREIEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
it.block(buttonBounds)
@@ -57,7 +57,7 @@ object InventoryButtons {
@Subscribe
fun onClickScreen(it: HandledScreenClickEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
if (buttonBounds.contains(it.mouseX, it.mouseY)) {
@@ -72,22 +72,22 @@ object InventoryButtons {
@Subscribe
fun onRenderForeground(it: HandledScreenForegroundEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
var hoveredComponent: InventoryButton? = null
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
- it.context.matrices.pushMatrix()
- it.context.matrices.translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
+ it.context.pose().pushMatrix()
+ it.context.pose().translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
button.render(it.context)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
if (buttonBounds.contains(it.mouseX, it.mouseY) && TConfig.hoverText && hoveredComponent == null) {
hoveredComponent = button
if (lastMouseMove.passedTime() > 0.6.seconds && lastHoveredComponent === button) {
- it.context.drawTooltip(
+ it.context.setComponentTooltipForNextFrame(
MC.font,
- listOf(Text.literal(button.command).gold()),
+ listOf(Component.literal(button.command).gold()),
buttonBounds.minX - 15,
buttonBounds.maxY + 20,
)
@@ -105,8 +105,8 @@ object InventoryButtons {
ScreenUtil.setScreenLater(
InventoryButtonEditor(
lastRectangle ?: Rectangle(
- MC.window.scaledWidth / 2 - 88,
- MC.window.scaledHeight / 2 - 83,
+ MC.window.guiScaledWidth / 2 - 88,
+ MC.window.guiScaledHeight / 2 - 83,
176, 166,
)
)
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt
index d7346c2..964f415 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt
@@ -4,9 +4,9 @@ package moe.nea.firmament.features.inventory.storageoverlay
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.screen.GenericContainerScreenHandler
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.world.inventory.ChestMenu
import moe.nea.firmament.util.ifMatches
import moe.nea.firmament.util.unformattedString
@@ -16,19 +16,19 @@ import moe.nea.firmament.util.unformattedString
sealed interface StorageBackingHandle {
sealed interface HasBackingScreen {
- val handler: GenericContainerScreenHandler
+ val handler: ChestMenu
}
/**
* The main storage overview is open. Clicking on a slot will open that page. This page is accessible via `/storage`
*/
- data class Overview(override val handler: GenericContainerScreenHandler) : StorageBackingHandle, HasBackingScreen
+ data class Overview(override val handler: ChestMenu) : StorageBackingHandle, HasBackingScreen
/**
* An individual storage page is open. This may be a backpack or an enderchest page. This page is accessible via
* the [Overview] or via `/ec <index + 1>` for enderchest pages.
*/
- data class Page(override val handler: GenericContainerScreenHandler, val storagePageSlot: StoragePageSlot) :
+ data class Page(override val handler: ChestMenu, val storagePageSlot: StoragePageSlot) :
StorageBackingHandle, HasBackingScreen
companion object {
@@ -46,13 +46,13 @@ sealed interface StorageBackingHandle {
returnsNotNull() implies (screen != null)
}
if (screen == null) return null
- if (screen !is GenericContainerScreen) return null
+ if (screen !is ContainerScreen) return null
val title = screen.title.unformattedString
- if (title == "Storage") return Overview(screen.screenHandler)
+ if (title == "Storage") return Overview(screen.menu)
return title.ifMatches(enderChestName) {
- Page(screen.screenHandler, StoragePageSlot.ofEnderChestPage(it.groupValues[1].toInt()))
+ Page(screen.menu, StoragePageSlot.ofEnderChestPage(it.groupValues[1].toInt()))
} ?: title.ifMatches(backPackName) {
- Page(screen.screenHandler, StoragePageSlot.ofBackPackPage(it.groupValues[1].toInt()))
+ Page(screen.menu, StoragePageSlot.ofBackPackPage(it.groupValues[1].toInt()))
}
}
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
index 7dbb02a..7f96637 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
@@ -3,12 +3,12 @@ package moe.nea.firmament.features.inventory.storageoverlay
import io.github.notenoughupdates.moulconfig.ChromaColour
import java.util.SortedMap
import kotlinx.serialization.serializer
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.Items
-import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.Items
+import net.minecraft.network.protocol.game.ServerboundContainerClosePacket
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ChestInventoryUpdateEvent
import moe.nea.firmament.events.ScreenChangeEvent
@@ -71,7 +71,7 @@ object StorageOverlay {
(MC.screen as? StorageOverlayScreen)
?: (MC.handledScreen?.customGui as? StorageOverlayCustom)?.overview
?: return
- val stack = event.slot.stack ?: return
+ val stack = event.slot.item ?: return
val search = storageOverlayScreen.searchText.get().takeIf { it.isNotBlank() } ?: return
if (storageOverlayScreen.matchesSearch(stack, search)) {
event.context.fill(
@@ -100,7 +100,7 @@ object StorageOverlay {
@Subscribe
fun onClick(event: SlotClickEvent) {
- if (lastStorageOverlay != null && event.slot.inventory !is PlayerInventory && event.slot.index < 9
+ if (lastStorageOverlay != null && event.slot.container !is Inventory && event.slot.containerSlot < 9
&& event.stack.item != Items.BLACK_STAINED_GLASS_PANE
) {
skipNextStorageOverlayBackflip = true
@@ -111,18 +111,18 @@ object StorageOverlay {
fun onScreenChange(it: ScreenChangeEvent) {
if (it.old == null && it.new == null) return
val storageOverlayScreen = it.old as? StorageOverlayScreen
- ?: ((it.old as? HandledScreen<*>)?.customGui as? StorageOverlayCustom)?.overview
+ ?: ((it.old as? AbstractContainerScreen<*>)?.customGui as? StorageOverlayCustom)?.overview
var storageOverviewScreen = it.old as? StorageOverviewScreen
- val screen = it.new as? GenericContainerScreen
+ val screen = it.new as? ContainerScreen
rememberContent(currentHandler)
val oldHandler = currentHandler
currentHandler = StorageBackingHandle.fromScreen(screen)
if (storageOverviewScreen != null && oldHandler is StorageBackingHandle.HasBackingScreen) {
val player = MC.player
assert(player != null)
- player?.networkHandler?.sendPacket(CloseHandledScreenC2SPacket(oldHandler.handler.syncId))
- if (player?.currentScreenHandler === oldHandler.handler) {
- player.currentScreenHandler = player.playerScreenHandler
+ player?.connection?.send(ServerboundContainerClosePacket(oldHandler.handler.containerId))
+ if (player?.containerMenu === oldHandler.handler) {
+ player.containerMenu = player.inventoryMenu
}
}
storageOverviewScreen = storageOverviewScreen ?: lastStorageOverlay
@@ -164,7 +164,7 @@ object StorageOverlay {
handler: StorageBackingHandle.Overview,
data: SortedMap<StoragePageSlot, StorageData.StorageInventory>
) {
- for ((index, stack) in handler.handler.stacks.withIndex()) {
+ for ((index, stack) in handler.handler.items.withIndex()) { // TODO: replace with slot iteration
// Ignore unloaded item stacks
if (stack.isEmpty) continue
val slot = StoragePageSlot.fromOverviewSlotIndex(index) ?: continue
@@ -186,7 +186,7 @@ object StorageOverlay {
data: SortedMap<StoragePageSlot, StorageData.StorageInventory>
) {
val newStacks =
- VirtualInventory(handler.handler.stacks.take(handler.handler.rows * 9).drop(9).map { it.copy() })
+ VirtualInventory(handler.handler.items.take(handler.handler.rowCount * 9).drop(9).map { it.copy() })
data.compute(handler.storagePageSlot) { slot, existingInventory ->
(existingInventory ?: StorageData.StorageInventory(
slot.defaultName(),
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
index a4199c9..f291dba 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
@@ -2,22 +2,22 @@ package moe.nea.firmament.features.inventory.storageoverlay
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.client.input.CharInput
-import net.minecraft.client.input.KeyInput
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.screen.slot.Slot
+import net.minecraft.client.Minecraft
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.client.input.CharacterEvent
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.inventory.Slot
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.customgui.CustomGui
import moe.nea.firmament.util.focusedItemStack
class StorageOverlayCustom(
- val handler: StorageBackingHandle,
- val screen: GenericContainerScreen,
- val overview: StorageOverlayScreen,
+ val handler: StorageBackingHandle,
+ val screen: ContainerScreen,
+ val overview: StorageOverlayScreen,
) : CustomGui() {
override fun onVoluntaryExit(): Boolean {
overview.isExiting = true
@@ -29,18 +29,18 @@ class StorageOverlayCustom(
return overview.getBounds()
}
- override fun afterSlotRender(context: DrawContext, slot: Slot) {
- if (slot.inventory !is PlayerInventory)
+ override fun afterSlotRender(context: GuiGraphics, slot: Slot) {
+ if (slot.container !is Inventory)
context.disableScissor()
}
- override fun beforeSlotRender(context: DrawContext, slot: Slot) {
- if (slot.inventory !is PlayerInventory)
+ override fun beforeSlotRender(context: GuiGraphics, slot: Slot) {
+ if (slot.container !is Inventory)
overview.createScissors(context)
}
override fun onInit() {
- overview.init(MinecraftClient.getInstance(), screen.width, screen.height)
+ overview.init(Minecraft.getInstance(), screen.width, screen.height)
overview.init()
screen as AccessorHandledScreen
screen.x_Firmament = overview.measurements.x
@@ -52,7 +52,7 @@ class StorageOverlayCustom(
override fun isPointOverSlot(slot: Slot, xOffset: Int, yOffset: Int, pointX: Double, pointY: Double): Boolean {
if (!super.isPointOverSlot(slot, xOffset, yOffset, pointX, pointY))
return false
- if (slot.inventory !is PlayerInventory) {
+ if (slot.container !is Inventory) {
if (!overview.getScrollPanelInner().contains(pointX, pointY))
return false
}
@@ -63,31 +63,31 @@ class StorageOverlayCustom(
return false
}
- override fun mouseReleased(click: Click): Boolean {
+ override fun mouseReleased(click: MouseButtonEvent): Boolean {
return overview.mouseReleased(click)
}
- override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ override fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
return overview.mouseDragged(click, offsetX, offsetY)
}
- override fun keyReleased(input: KeyInput): Boolean {
+ override fun keyReleased(input: KeyEvent): Boolean {
return overview.keyReleased(input)
}
- override fun keyPressed(input: KeyInput): Boolean {
+ override fun keyPressed(input: KeyEvent): Boolean {
return overview.keyPressed(input)
}
- override fun charTyped(input: CharInput): Boolean {
+ override fun charTyped(input: CharacterEvent): Boolean {
return overview.charTyped(input)
}
- override fun mouseClick(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClick(click: MouseButtonEvent, doubled: Boolean): Boolean {
return overview.mouseClicked(click, doubled, (handler as? StorageBackingHandle.Page)?.storagePageSlot)
}
- override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) {
+ override fun render(drawContext: GuiGraphics, delta: Float, mouseX: Int, mouseY: Int) {
overview.drawBackgrounds(drawContext)
overview.drawPages(
drawContext,
@@ -95,7 +95,7 @@ class StorageOverlayCustom(
mouseY,
delta,
(handler as? StorageBackingHandle.Page)?.storagePageSlot,
- screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9),
+ screen.menu.slots.take(screen.menu.rowCount * 9).drop(9),
Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament)
)
overview.drawScrollBar(drawContext)
@@ -103,7 +103,7 @@ class StorageOverlayCustom(
}
override fun moveSlot(slot: Slot) {
- val index = slot.index
+ val index = slot.containerSlot
if (index in 0..<36) {
val (x, y) = overview.getPlayerInventorySlotPosition(index)
slot.x = x - (screen as AccessorHandledScreen).x_Firmament
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
index d2fff9c..3e0bb4b 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
@@ -13,17 +13,17 @@ import io.github.notenoughupdates.moulconfig.observer.Property
import java.util.TreeSet
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.input.CharInput
-import net.minecraft.client.input.KeyInput
-import net.minecraft.item.ItemStack
-import net.minecraft.screen.slot.Slot
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.Identifier
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.input.CharacterEvent
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.inventory.Slot
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.events.SlotRenderEvents
import moe.nea.firmament.gui.EmptyComponent
import moe.nea.firmament.gui.FirmButtonComponent
@@ -43,7 +43,7 @@ import moe.nea.firmament.util.render.enableScissorWithoutTranslation
import moe.nea.firmament.util.tr
import moe.nea.firmament.util.unformattedString
-class StorageOverlayScreen : Screen(Text.literal("")) {
+class StorageOverlayScreen : Screen(Component.literal("")) {
companion object {
val PLAYER_WIDTH = 184
@@ -122,20 +122,20 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
fun getMaxScroll() = lastRenderedInnerHeight.toFloat() - getScrollPanelInner().height
- val playerInventorySprite = Identifier.of("firmament:storageoverlay/player_inventory")
- val upperBackgroundSprite = Identifier.of("firmament:storageoverlay/upper_background")
- val slotRowSprite = Identifier.of("firmament:storageoverlay/storage_row")
- val scrollbarBackground = Identifier.of("firmament:storageoverlay/scroll_bar_background")
- val scrollbarKnob = Identifier.of("firmament:storageoverlay/scroll_bar_knob")
- val controllerBackground = Identifier.of("firmament:storageoverlay/storage_controls")
+ val playerInventorySprite = ResourceLocation.parse("firmament:storageoverlay/player_inventory")
+ val upperBackgroundSprite = ResourceLocation.parse("firmament:storageoverlay/upper_background")
+ val slotRowSprite = ResourceLocation.parse("firmament:storageoverlay/storage_row")
+ val scrollbarBackground = ResourceLocation.parse("firmament:storageoverlay/scroll_bar_background")
+ val scrollbarKnob = ResourceLocation.parse("firmament:storageoverlay/scroll_bar_knob")
+ val controllerBackground = ResourceLocation.parse("firmament:storageoverlay/storage_controls")
- override fun close() {
+ override fun onClose() {
isExiting = true
resetScroll()
- super.close()
+ super.onClose()
}
- override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
+ override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
super.render(context, mouseX, mouseY, delta)
drawBackgrounds(context)
drawPages(context, mouseX, mouseY, delta, null, null, Point())
@@ -148,7 +148,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return scroll / getMaxScroll()
}
- fun drawScrollBar(context: DrawContext) {
+ fun drawScrollBar(context: GuiGraphics) {
val sbRect = getScrollBarRect()
context.drawGuiTexture(
scrollbarBackground,
@@ -164,8 +164,8 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
fun editPages() {
isExiting = true
- MC.instance.send {
- val hs = MC.screen as? HandledScreen<*>
+ MC.instance.schedule {
+ val hs = MC.screen as? AbstractContainerScreen<*>
if (StorageBackingHandle.fromScreen(hs) is StorageBackingHandle.Overview) {
hs.customGui = null
hs.init(MC.instance, width, height)
@@ -204,7 +204,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
guiContext.adopt(controlComponent)
}
- fun drawControls(context: DrawContext, mouseX: Int, mouseY: Int) {
+ fun drawControls(context: GuiGraphics, mouseX: Int, mouseY: Int) {
context.drawGuiTexture(
controllerBackground,
measurements.controlX,
@@ -219,7 +219,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
)
}
- fun drawBackgrounds(context: DrawContext) {
+ fun drawBackgrounds(context: GuiGraphics) {
context.drawGuiTexture(
upperBackgroundSprite,
measurements.x,
@@ -246,12 +246,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
)
}
- fun drawPlayerInventory(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
- val items = MC.player?.inventory?.mainStacks ?: return
+ fun drawPlayerInventory(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
+ val items = MC.player?.inventory?.nonEquipmentItems ?: return
items.withIndex().forEach { (index, item) ->
val (x, y) = getPlayerInventorySlotPosition(index)
- context.drawItem(item, x, y, 0)
- context.drawStackOverlay(textRenderer, item, x, y)
+ context.renderItem(item, x, y, 0)
+ context.renderItemDecorations(font, item, x, y)
}
}
@@ -273,7 +273,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
)
}
- fun createScissors(context: DrawContext) {
+ fun createScissors(context: GuiGraphics) {
val rect = getScrollPanelInner()
context.enableScissorWithoutTranslation(
rect.minX.toFloat(), rect.minY.toFloat(),
@@ -282,10 +282,10 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
}
fun drawPages(
- context: DrawContext, mouseX: Int, mouseY: Int, delta: Float,
- excluding: StoragePageSlot?,
- slots: List<Slot>?,
- slotOffset: Point
+ context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float,
+ excluding: StoragePageSlot?,
+ slots: List<Slot>?,
+ slotOffset: Point
) {
createScissors(context)
val data = StorageOverlay.Data.data ?: StorageData()
@@ -310,11 +310,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
get() = guiContext.focusedElement == knobStub
set(value) = knobStub.setFocus(value)
- override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClicked(click: MouseButtonEvent, doubled: Boolean): Boolean {
return mouseClicked(click, doubled, null)
}
- override fun mouseReleased(click: Click): Boolean {
+ override fun mouseReleased(click: MouseButtonEvent): Boolean {
if (knobGrabbed) {
knobGrabbed = false
return true
@@ -330,7 +330,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return super.mouseReleased(click)
}
- override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ override fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
if (knobGrabbed) {
val sbRect = getScrollBarRect()
val percentage = (click.x - sbRect.getY()) / sbRect.getHeight()
@@ -341,7 +341,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return super.mouseDragged(click, offsetX, offsetY)
}
- fun mouseClicked(click: Click, doubled: Boolean, activePage: StoragePageSlot?): Boolean {
+ fun mouseClicked(click: MouseButtonEvent, doubled: Boolean, activePage: StoragePageSlot?): Boolean {
guiContext.setFocusedElement(null) // Blur all elements. They will be refocused by clickMCComponentInPlace if in doubt, and we don't have any double click components.
val mouseX = click.x
val mouseY = click.y
@@ -374,12 +374,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return false
}
- override fun charTyped(input: CharInput): Boolean {
+ override fun charTyped(input: CharacterEvent): Boolean {
if (typeMCComponentInPlace(
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.CharTyped(input.asString().first()) // TODO: i dont like this .first()
+ KeyboardEvent.CharTyped(input.codepointAsString().first()) // TODO: i dont like this .first()
)
) {
return true
@@ -387,12 +387,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return super.charTyped(input)
}
- override fun keyReleased(input: KeyInput): Boolean {
+ override fun keyReleased(input: KeyEvent): Boolean {
if (typeMCComponentInPlace(
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.KeyPressed(input.keycode, input.scancode, false)
+ KeyboardEvent.KeyPressed(input.input(), input.scancode, false)
)
) {
return true
@@ -404,12 +404,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return this === MC.screen // Fixes this UI closing the handled screen on Escape press.
}
- override fun keyPressed(input: KeyInput): Boolean {
+ override fun keyPressed(input: KeyEvent): Boolean {
if (typeMCComponentInPlace(
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.KeyPressed(input.keycode, input.scancode, true)
+ KeyboardEvent.KeyPressed(input.input(), input.scancode, true)
)
) {
return true
@@ -463,7 +463,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
val filter = getFilteredPages()
for ((page, inventory) in data.storageInventories.entries) {
if (page !in filter) continue
- val currentHeight = inventory.inventory?.let { it.rows * SLOT_SIZE + 6 + textRenderer.fontHeight }
+ val currentHeight = inventory.inventory?.let { it.rows * SLOT_SIZE + 6 + font.lineHeight }
?: 18
maxHeight = maxOf(maxHeight, currentHeight)
val rect = Rectangle(
@@ -484,22 +484,22 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
}
fun drawPage(
- context: DrawContext,
- x: Int,
- y: Int,
- page: StoragePageSlot,
- inventory: StorageData.StorageInventory,
- slots: List<Slot>?,
- slotOffset: Point,
- mouseX: Int,
- mouseY: Int,
+ context: GuiGraphics,
+ x: Int,
+ y: Int,
+ page: StoragePageSlot,
+ inventory: StorageData.StorageInventory,
+ slots: List<Slot>?,
+ slotOffset: Point,
+ mouseX: Int,
+ mouseY: Int,
): Int {
val inv = inventory.inventory
if (inv == null) {
context.drawGuiTexture(upperBackgroundSprite, x, y, PAGE_WIDTH, 18)
- context.drawText(
- textRenderer,
- Text.literal("TODO: open this page"),
+ context.drawString(
+ font,
+ Component.literal("TODO: open this page"),
x + 4,
y + 4,
-1,
@@ -509,34 +509,34 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
}
assertTrueOr(slots == null || slots.size == inv.stacks.size) { return 0 }
val name = inventory.title
- val pageHeight = inv.rows * SLOT_SIZE + 8 + textRenderer.fontHeight
+ val pageHeight = inv.rows * SLOT_SIZE + 8 + font.lineHeight
if (slots != null && StorageOverlay.TConfig.outlineActiveStoragePage)
- context.drawStrokedRectangle(
+ context.submitOutline(
x,
- y + 3 + textRenderer.fontHeight,
+ y + 3 + font.lineHeight,
PAGE_WIDTH,
inv.rows * SLOT_SIZE + 4,
StorageOverlay.TConfig.outlineActiveStoragePageColour.getEffectiveColourRGB()
)
- context.drawText(
- textRenderer, Text.literal(name), x + 6, y + 3,
+ context.drawString(
+ font, Component.literal(name), x + 6, y + 3,
if (slots == null) 0xFFFFFFFF.toInt() else 0xFFFFFF00.toInt(), true
)
context.drawGuiTexture(
slotRowSprite,
x + 2,
- y + 5 + textRenderer.fontHeight,
+ y + 5 + font.lineHeight,
PAGE_SLOTS_WIDTH,
inv.rows * SLOT_SIZE
)
inv.stacks.forEachIndexed { index, stack ->
val slotX = (index % 9) * SLOT_SIZE + x + 3
- val slotY = (index / 9) * SLOT_SIZE + y + 5 + textRenderer.fontHeight + 1
+ val slotY = (index / 9) * SLOT_SIZE + y + 5 + font.lineHeight + 1
if (slots == null) {
val fakeSlot = FakeSlot(stack, slotX, slotY)
SlotRenderEvents.Before.publish(SlotRenderEvents.Before(context, fakeSlot))
- context.drawItem(stack, slotX, slotY)
- context.drawStackOverlay(textRenderer, stack, slotX, slotY)
+ context.renderItem(stack, slotX, slotY)
+ context.renderItemDecorations(font, stack, slotX, slotY)
SlotRenderEvents.After.publish(SlotRenderEvents.After(context, fakeSlot))
val rect = getScrollPanelInner()
if (StorageOverlay.TConfig.showInactivePageTooltips && !stack.isEmpty &&
@@ -544,11 +544,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
mouseX <= slotX + 16 && mouseY <= slotY + 16 &&
mouseY >= rect.minY && mouseY <= rect.maxY) {
try {
- context.drawItemTooltip(textRenderer, stack, mouseX, mouseY)
+ context.setTooltipForNextFrame(font, stack, mouseX, mouseY)
} catch (e: IllegalStateException) {
- context.drawTooltip(textRenderer, listOf(Text.of(Formatting.RED.toString() +
- "Error Getting Tooltip!"), Text.of(Formatting.YELLOW.toString() +
- "Open page to fix" + Formatting.RESET)), mouseX, mouseY)
+ context.setComponentTooltipForNextFrame(font, listOf(Component.nullToEmpty(ChatFormatting.RED.toString() +
+ "Error Getting Tooltip!"), Component.nullToEmpty(ChatFormatting.YELLOW.toString() +
+ "Open page to fix" + ChatFormatting.RESET)), mouseX, mouseY)
}
}
} else {
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
index a55b5ac..3c40fc6 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
@@ -4,19 +4,19 @@ package moe.nea.firmament.features.inventory.storageoverlay
import org.lwjgl.glfw.GLFW
import kotlin.math.max
-import net.minecraft.block.Blocks
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.input.KeyInput
-import net.minecraft.item.Item
-import net.minecraft.item.Items
-import net.minecraft.text.Text
-import net.minecraft.util.DyeColor
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.Items
+import net.minecraft.network.chat.Component
+import net.minecraft.world.item.DyeColor
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.toShedaniel
-class StorageOverviewScreen() : Screen(Text.empty()) {
+class StorageOverviewScreen() : Screen(Component.empty()) {
companion object {
val emptyStorageSlotItems = listOf<Item>(
Blocks.RED_STAINED_GLASS_PANE.asItem(),
@@ -37,19 +37,19 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
scroll = scroll.coerceAtMost(getMaxScroll()).coerceAtLeast(0)
}
- override fun close() {
+ override fun onClose() {
if (!StorageOverlay.TConfig.retainScroll) scroll = 0
- super.close()
+ super.onClose()
}
- override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
+ override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
super.render(context, mouseX, mouseY, delta)
context.fill(0, 0, width, height, 0x90000000.toInt())
layoutedForEach { (key, value), offsetX, offsetY ->
- context.matrices.pushMatrix()
- context.matrices.translate(offsetX.toFloat(), offsetY.toFloat())
+ context.pose().pushMatrix()
+ context.pose().translate(offsetX.toFloat(), offsetY.toFloat())
renderStoragePage(context, value, mouseX - offsetX, mouseY - offsetY)
- context.matrices.popMatrix()
+ context.pose().popMatrix()
}
}
@@ -74,12 +74,12 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
lastRenderedHeight = totalHeight + currentMaxHeight
}
- override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClicked(click: MouseButtonEvent, doubled: Boolean): Boolean {
layoutedForEach { (k, p), x, y ->
val rx = click.x - x
val ry = click.y - y
if (rx in (0.0..pageWidth.toDouble()) && ry in (0.0..getStorePageHeight(p).toDouble())) {
- close()
+ onClose()
StorageOverlay.lastStorageOverlay = this
k.navigateTo()
return true
@@ -89,7 +89,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
}
fun getStorePageHeight(page: StorageData.StorageInventory): Int {
- return page.inventory?.rows?.let { it * 19 + MC.font.fontHeight + 2 } ?: 60
+ return page.inventory?.rows?.let { it * 19 + MC.font.lineHeight + 2 } ?: 60
}
override fun mouseScrolled(
@@ -106,31 +106,31 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
private fun getMaxScroll() = lastRenderedHeight - height + 2 * StorageOverlay.TConfig.margin
- private fun renderStoragePage(context: DrawContext, page: StorageData.StorageInventory, mouseX: Int, mouseY: Int) {
- context.drawText(MC.font, page.title, 2, 2, -1, true)
+ private fun renderStoragePage(context: GuiGraphics, page: StorageData.StorageInventory, mouseX: Int, mouseY: Int) {
+ context.drawString(MC.font, page.title, 2, 2, -1, true)
val inventory = page.inventory
if (inventory == null) {
// TODO: Missing texture
context.fill(0, 0, pageWidth, 60, DyeColor.RED.toShedaniel().darker(4.0).color)
- context.drawCenteredTextWithShadow(MC.font, Text.literal("Not loaded yet"), pageWidth / 2, 30, -1)
+ context.drawCenteredString(MC.font, Component.literal("Not loaded yet"), pageWidth / 2, 30, -1)
return
}
for ((index, stack) in inventory.stacks.withIndex()) {
val x = (index % 9) * 19
- val y = (index / 9) * 19 + MC.font.fontHeight + 2
+ val y = (index / 9) * 19 + MC.font.lineHeight + 2
if (((mouseX - x) in 0 until 18) && ((mouseY - y) in 0 until 18)) {
context.fill(x, y, x + 18, y + 18, 0x80808080.toInt())
} else {
context.fill(x, y, x + 18, y + 18, 0x40808080.toInt())
}
- context.drawItem(stack, x + 1, y + 1)
- context.drawStackOverlay(MC.font, stack, x + 1, y + 1)
+ context.renderItem(stack, x + 1, y + 1)
+ context.renderItemDecorations(MC.font, stack, x + 1, y + 1)
}
}
- override fun keyPressed(input: KeyInput): Boolean {
- if (input.keycode == GLFW.GLFW_KEY_ESCAPE)
+ override fun keyPressed(input: KeyEvent): Boolean {
+ if (input.input() == GLFW.GLFW_KEY_ESCAPE)
isClosing = true
return super.keyPressed(input)
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt b/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
index fddc189..69d686f 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
@@ -13,12 +13,12 @@ import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NbtCompound
+import net.minecraft.world.item.ItemStack
+import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.NbtIo
-import net.minecraft.nbt.NbtList
+import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.nbt.NbtSizeTracker
+import net.minecraft.nbt.NbtAccounter
import moe.nea.firmament.Firmament
import moe.nea.firmament.features.inventory.storageoverlay.VirtualInventory.Serializer.writeToByteArray
import moe.nea.firmament.util.Base64Util
@@ -44,21 +44,21 @@ data class VirtualInventory(
object Serializer : KSerializer<VirtualInventory> {
fun writeToByteArray(value: VirtualInventory): ByteArray {
- val list = NbtList()
+ val list = ListTag()
val ops = getOps()
value.stacks.forEach {
- if (it.isEmpty) list.add(NbtCompound())
+ if (it.isEmpty) list.add(CompoundTag())
else list.add(ErrorUtil.catch("Could not serialize item") {
ItemStack.CODEC.encode(
it,
ops,
- NbtCompound()
+ CompoundTag()
).orThrow
}
- .or { NbtCompound() })
+ .or { CompoundTag() })
}
val baos = ByteArrayOutputStream()
- NbtIo.writeCompressed(NbtCompound().also { it.put(INVENTORY, list) }, baos)
+ NbtIo.writeCompressed(CompoundTag().also { it.put(INVENTORY, list) }, baos)
return baos.toByteArray()
}
@@ -68,11 +68,11 @@ data class VirtualInventory(
override fun deserialize(decoder: Decoder): VirtualInventory {
val s = decoder.decodeString()
- val n = NbtIo.readCompressed(ByteArrayInputStream(Base64Util.decodeBytes(s)), NbtSizeTracker.of(100_000_000))
+ val n = NbtIo.readCompressed(ByteArrayInputStream(Base64Util.decodeBytes(s)), NbtAccounter.create(100_000_000))
val items = n.getList(INVENTORY).getOrNull()
val ops = getOps()
return VirtualInventory(items?.map {
- it as NbtCompound
+ it as CompoundTag
if (it.isEmpty) ItemStack.EMPTY
else ErrorUtil.catch("Could not deserialize item") {
ItemStack.CODEC.parse(ops, it).orThrow
diff --git a/src/main/kotlin/features/items/BlockZapperOverlay.kt b/src/main/kotlin/features/items/BlockZapperOverlay.kt
index a853012..cc58f8a 100644
--- a/src/main/kotlin/features/items/BlockZapperOverlay.kt
+++ b/src/main/kotlin/features/items/BlockZapperOverlay.kt
@@ -2,12 +2,12 @@ package moe.nea.firmament.features.items
import io.github.notenoughupdates.moulconfig.ChromaColour
import java.util.LinkedList
-import net.minecraft.block.Block
-import net.minecraft.block.BlockState
-import net.minecraft.block.Blocks
-import net.minecraft.util.hit.BlockHitResult
-import net.minecraft.util.hit.HitResult
-import net.minecraft.util.math.BlockPos
+import net.minecraft.world.level.block.Block
+import net.minecraft.world.level.block.state.BlockState
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.world.phys.BlockHitResult
+import net.minecraft.world.phys.HitResult
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.WorldKeyboardEvent
import moe.nea.firmament.events.WorldRenderLastEvent
@@ -64,10 +64,10 @@ object BlockZapperOverlay {
fun renderBlockZapperOverlay(event: WorldRenderLastEvent) {
if (!TConfig.blockZapperOverlay) return
val player = MC.player ?: return
- val world = player.world ?: return
+ val world = player.level ?: return
val heldItem = MC.stackInHand
if (heldItem.skyBlockId != SkyBlockItems.BLOCK_ZAPPER) return
- val hitResult = MC.instance.crosshairTarget ?: return
+ val hitResult = MC.instance.hitResult ?: return
val zapperBlocks: HashSet<BlockPos> = HashSet()
val returnablePositions = LinkedList<BlockPos>()
@@ -77,7 +77,7 @@ object BlockZapperOverlay {
val firstBlockState: BlockState = world.getBlockState(pos)
val block = firstBlockState.block
- val initialAboveBlock = world.getBlockState(pos.up()).block
+ val initialAboveBlock = world.getBlockState(pos.above()).block
if (!bannedZapper.contains(initialAboveBlock) && !bannedZapper.contains(block)) {
var i = 0
while (i < 164) {
@@ -87,13 +87,13 @@ object BlockZapperOverlay {
val availableNeighbors: MutableList<BlockPos> = ArrayList()
for (offset in zapperOffsets) {
- val newPos = pos.add(offset)
+ val newPos = pos.offset(offset)
if (zapperBlocks.contains(newPos)) continue
val state: BlockState? = world.getBlockState(newPos)
if (state != null && state.block === block) {
- val above = newPos.up()
+ val above = newPos.above()
val aboveBlock = world.getBlockState(above).block
if (!bannedZapper.contains(aboveBlock)) {
availableNeighbors.add(newPos)
@@ -118,7 +118,7 @@ object BlockZapperOverlay {
}
RenderInWorldContext.renderInWorld(event) {
- if (MC.player?.isSneaking ?: false) {
+ if (MC.player?.isShiftKeyDown ?: false) {
zapperBlocks.forEach {
block(it, TConfig.color.getEffectiveColourRGB())
}
diff --git a/src/main/kotlin/features/items/BonemerangOverlay.kt b/src/main/kotlin/features/items/BonemerangOverlay.kt
index 1310154..3f16922 100644
--- a/src/main/kotlin/features/items/BonemerangOverlay.kt
+++ b/src/main/kotlin/features/items/BonemerangOverlay.kt
@@ -2,11 +2,11 @@ package moe.nea.firmament.features.items
import me.shedaniel.math.Color
import org.joml.Vector2i
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.decoration.ArmorStandEntity
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.util.Formatting
-import net.minecraft.util.math.Box
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.decoration.ArmorStand
+import net.minecraft.world.entity.player.Player
+import net.minecraft.ChatFormatting
+import net.minecraft.world.phys.AABB
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityRenderTintEvent
import moe.nea.firmament.events.HudRenderEvent
@@ -31,18 +31,18 @@ object BonemerangOverlay {
fun getEntities(): MutableSet<LivingEntity> {
val entities = mutableSetOf<LivingEntity>()
- val camera = MC.camera as? PlayerEntity ?: return entities
+ val camera = MC.camera as? Player ?: return entities
val player = MC.player ?: return entities
- val world = player.world ?: return entities
+ val world = player.level ?: return entities
- val cameraPos = camera.eyePos
- val rayDirection = camera.rotationVector.normalize()
- val endPos = cameraPos.add(rayDirection.multiply(15.0))
- val foundEntities = world.getOtherEntities(camera, Box(cameraPos, endPos).expand(1.0))
+ val cameraPos = camera.eyePosition
+ val rayDirection = camera.lookAngle.normalize()
+ val endPos = cameraPos.add(rayDirection.scale(15.0))
+ val foundEntities = world.getEntities(camera, AABB(cameraPos, endPos).inflate(1.0))
for (entity in foundEntities) {
- if (entity !is LivingEntity || entity is ArmorStandEntity || entity.isInvisible) continue
- val hitResult = entity.boundingBox.expand(0.35).raycast(cameraPos, endPos).orElse(null)
+ if (entity !is LivingEntity || entity is ArmorStand || entity.isInvisible) continue
+ val hitResult = entity.boundingBox.inflate(0.35).clip(cameraPos, endPos).orElse(null)
if (hitResult != null) entities.add(entity)
}
@@ -66,7 +66,7 @@ object BonemerangOverlay {
if (event.entity !in entities) return
val tintOverlay by lazy {
- TintedOverlayTexture().setColor(Color.ofOpaque(Formatting.BLUE.colorValue!!))
+ TintedOverlayTexture().setColor(Color.ofOpaque(ChatFormatting.BLUE.color!!))
}
event.renderState.overlayTexture_firmament = tintOverlay
@@ -80,15 +80,15 @@ object BonemerangOverlay {
val entities = getEntities()
- it.context.matrices.pushMatrix()
- TConfig.bonemerangOverlayHud.applyTransformations(it.context.matrices)
- it.context.drawText(
+ it.context.pose().pushMatrix()
+ TConfig.bonemerangOverlayHud.applyTransformations(it.context.pose())
+ it.context.drawString(
MC.font, String.format(
tr(
"firmament.bonemerang-overlay.bonemerang-overlay.display", "Bonemerang Targets: %s"
).string, entities.size
), 0, 0, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
}
diff --git a/src/main/kotlin/features/items/EtherwarpOverlay.kt b/src/main/kotlin/features/items/EtherwarpOverlay.kt
index 5f32a96..a59fcbd 100644
--- a/src/main/kotlin/features/items/EtherwarpOverlay.kt
+++ b/src/main/kotlin/features/items/EtherwarpOverlay.kt
@@ -1,17 +1,17 @@
package moe.nea.firmament.features.items
import io.github.notenoughupdates.moulconfig.ChromaColour
-import net.minecraft.block.Blocks
-import net.minecraft.registry.entry.RegistryEntry
-import net.minecraft.registry.tag.BlockTags
-import net.minecraft.registry.tag.TagKey
-import net.minecraft.text.Text
-import net.minecraft.util.hit.BlockHitResult
-import net.minecraft.util.hit.HitResult
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.Vec3d
-import net.minecraft.util.shape.VoxelShapes
-import net.minecraft.world.BlockView
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.core.Holder
+import net.minecraft.tags.BlockTags
+import net.minecraft.tags.TagKey
+import net.minecraft.network.chat.Component
+import net.minecraft.world.phys.BlockHitResult
+import net.minecraft.world.phys.HitResult
+import net.minecraft.core.BlockPos
+import net.minecraft.world.phys.Vec3
+import net.minecraft.world.phys.shapes.Shapes
+import net.minecraft.world.level.BlockGetter
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.WorldRenderLastEvent
import moe.nea.firmament.util.MC
@@ -41,7 +41,7 @@ object EtherwarpOverlay {
var failureText by toggle("failure-text") { false }
}
- enum class EtherwarpResult(val label: Text?, val color: () -> ChromaColour) {
+ enum class EtherwarpResult(val label: Component?, val color: () -> ChromaColour) {
SUCCESS(null, TConfig::cubeColour),
INTERACTION_BLOCKED(
tr("firmament.etherwarp.fail.tooclosetointeractable", "Too close to interactable"),
@@ -76,10 +76,10 @@ object EtherwarpOverlay {
)
data class Checker<T>(
- val direct: Set<T>,
- val byTag: Set<TagKey<T>>,
+ val direct: Set<T>,
+ val byTag: Set<TagKey<T>>,
) {
- fun matches(entry: RegistryEntry<T>): Boolean {
+ fun matches(entry: Holder<T>): Boolean {
return entry.value() in direct || checkTags(entry, byTag)
}
}
@@ -123,34 +123,34 @@ object EtherwarpOverlay {
)
- fun <T> checkTags(holder: RegistryEntry<out T>, set: Set<TagKey<out T>>) =
- holder.streamTags()
+ fun <T> checkTags(holder: Holder<out T>, set: Set<TagKey<out T>>) =
+ holder.tags()
.anyMatch(set::contains)
- fun isEtherwarpTransparent(world: BlockView, blockPos: BlockPos): Boolean {
+ fun isEtherwarpTransparent(world: BlockGetter, blockPos: BlockPos): Boolean {
val blockState = world.getBlockState(blockPos)
val block = blockState.block
- if (etherwarpConsidersFat.matches(blockState.registryEntry))
+ if (etherwarpConsidersFat.matches(blockState.blockHolder))
return false
- if (block.defaultState.getCollisionShape(world, blockPos).isEmpty)
+ if (block.defaultBlockState().getCollisionShape(world, blockPos).isEmpty)
return true
- if (etherwarpHallpasses.matches(blockState.registryEntry))
+ if (etherwarpHallpasses.matches(blockState.blockHolder))
return true
return false
}
sealed interface EtherwarpBlockHit {
- data class BlockHit(val blockPos: BlockPos, val accuratePos: Vec3d?) : EtherwarpBlockHit
+ data class BlockHit(val blockPos: BlockPos, val accuratePos: Vec3?) : EtherwarpBlockHit
data object Miss : EtherwarpBlockHit
}
- fun raycastWithEtherwarpTransparency(world: BlockView, start: Vec3d, end: Vec3d): EtherwarpBlockHit {
- return BlockView.raycast<EtherwarpBlockHit, Unit>(
+ fun raycastWithEtherwarpTransparency(world: BlockGetter, start: Vec3, end: Vec3): EtherwarpBlockHit {
+ return BlockGetter.traverseBlocks<EtherwarpBlockHit, Unit>(
start, end, Unit,
{ _, blockPos ->
if (isEtherwarpTransparent(world, blockPos)) {
- return@raycast null
+ return@traverseBlocks null
}
// val defaultedState = world.getBlockState(blockPos).block.defaultState
// val hitShape = defaultedState.getCollisionShape(
@@ -161,8 +161,8 @@ object EtherwarpOverlay {
// if (world.raycastBlock(start, end, blockPos, hitShape, defaultedState) == null) {
// return@raycast null
// }
- val partialResult = world.raycastBlock(start, end, blockPos, VoxelShapes.fullCube(), world.getBlockState(blockPos).block.defaultState)
- return@raycast EtherwarpBlockHit.BlockHit(blockPos, partialResult?.pos)
+ val partialResult = world.clipWithInteractionOverride(start, end, blockPos, Shapes.block(), world.getBlockState(blockPos).block.defaultBlockState())
+ return@traverseBlocks EtherwarpBlockHit.BlockHit(blockPos, partialResult?.location)
},
{ EtherwarpBlockHit.Miss })
}
@@ -176,8 +176,8 @@ object EtherwarpOverlay {
fun renderEtherwarpOverlay(event: WorldRenderLastEvent) {
if (!TConfig.etherwarpOverlay) return
val player = MC.player ?: return
- if (TConfig.onlyShowWhileSneaking && !player.isSneaking) return
- val world = player.world
+ if (TConfig.onlyShowWhileSneaking && !player.isShiftKeyDown) return
+ val world = player.level
val heldItem = MC.stackInHand
val etherwarpTyp = run {
if (heldItem.extraAttributes.contains("ethermerge"))
@@ -188,12 +188,12 @@ object EtherwarpOverlay {
return
}
val playerEyeHeight = // Sneaking: 1.27 (1.21) 1.54 (1.8.9) / Upright: 1.62 (1.8.9,1.21)
- if (player.isSneaking || etherwarpTyp == EtherwarpItemKind.MERGED)
+ if (player.isShiftKeyDown || etherwarpTyp == EtherwarpItemKind.MERGED)
(if (SBData.skyblockLocation?.isModernServer ?: false) 1.27 else 1.54)
else 1.62
- val playerEyePos = player.pos.add(0.0, playerEyeHeight, 0.0)
+ val playerEyePos = player.position.add(0.0, playerEyeHeight, 0.0)
val start = playerEyePos
- val end = player.getRotationVec(0F).multiply(160.0).add(playerEyePos)
+ val end = player.getViewVector(0F).scale(160.0).add(playerEyePos)
val hitResult = raycastWithEtherwarpTransparency(
world,
start,
@@ -202,15 +202,15 @@ object EtherwarpOverlay {
if (hitResult !is EtherwarpBlockHit.BlockHit) return
val blockPos = hitResult.blockPos
val success = run {
- if (!isEtherwarpTransparent(world, blockPos.up()))
+ if (!isEtherwarpTransparent(world, blockPos.above()))
EtherwarpResult.OCCUPIED
- else if (!isEtherwarpTransparent(world, blockPos.up(2)))
+ else if (!isEtherwarpTransparent(world, blockPos.above(2)))
EtherwarpResult.OCCUPIED
- else if (playerEyePos.squaredDistanceTo(hitResult.accuratePos ?: blockPos.toCenterPos()) > 61 * 61)
+ else if (playerEyePos.distanceToSqr(hitResult.accuratePos ?: blockPos.center) > 61 * 61)
EtherwarpResult.TOO_DISTANT
- else if ((MC.instance.crosshairTarget as? BlockHitResult)
+ else if ((MC.instance.hitResult as? BlockHitResult)
?.takeIf { it.type == HitResult.Type.BLOCK }
- ?.let { interactionBlocked.matches(world.getBlockState(it.blockPos).registryEntry) }
+ ?.let { interactionBlocked.matches(world.getBlockState(it.blockPos).blockHolder) }
?: false
)
EtherwarpResult.INTERACTION_BLOCKED
@@ -225,7 +225,7 @@ object EtherwarpOverlay {
)
if (TConfig.wireframe) wireframeCube(blockPos, 10f)
if (TConfig.failureText && success.label != null) {
- withFacingThePlayer(blockPos.toCenterPos()) {
+ withFacingThePlayer(blockPos.center) {
text(success.label)
}
}
diff --git a/src/main/kotlin/features/macros/ComboProcessor.kt b/src/main/kotlin/features/macros/ComboProcessor.kt
index a01f8b7..9dadb80 100644
--- a/src/main/kotlin/features/macros/ComboProcessor.kt
+++ b/src/main/kotlin/features/macros/ComboProcessor.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.macros
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.TickEvent
@@ -46,14 +46,14 @@ object ComboProcessor {
fun onRender(event: HudRenderEvent) {
if (!isInputting) return
if (!event.isRenderingHud) return
- event.context.matrices.pushMatrix()
+ event.context.pose().pushMatrix()
val width = 120
- event.context.matrices.translate(
- (MC.window.scaledWidth - width) / 2F,
- (MC.window.scaledHeight) / 2F + 8
+ event.context.pose().translate(
+ (MC.window.guiScaledWidth - width) / 2F,
+ (MC.window.guiScaledHeight) / 2F + 8
)
val breadCrumbText = breadCrumbs.joinToString(" > ")
- event.context.drawText(
+ event.context.drawString(
MC.font,
tr("firmament.combo.active", "Current Combo: ").append(breadCrumbText),
0,
@@ -61,19 +61,19 @@ object ComboProcessor {
-1,
true
)
- event.context.matrices.translate(0F, MC.font.fontHeight + 2F)
+ event.context.pose().translate(0F, MC.font.lineHeight + 2F)
for ((key, value) in activeTrie.nodes) {
- event.context.drawText(
+ event.context.drawString(
MC.font,
- Text.literal("$breadCrumbText > $key: ").append(value.label),
+ Component.literal("$breadCrumbText > $key: ").append(value.label),
0,
0,
-1,
true
)
- event.context.matrices.translate(0F, MC.font.fontHeight + 1F)
+ event.context.pose().translate(0F, MC.font.lineHeight + 1F)
}
- event.context.matrices.popMatrix()
+ event.context.pose().popMatrix()
}
@Subscribe
diff --git a/src/main/kotlin/features/macros/HotkeyAction.kt b/src/main/kotlin/features/macros/HotkeyAction.kt
index 011f797..18c95bc 100644
--- a/src/main/kotlin/features/macros/HotkeyAction.kt
+++ b/src/main/kotlin/features/macros/HotkeyAction.kt
@@ -2,21 +2,21 @@ package moe.nea.firmament.features.macros
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.MC
@Serializable
sealed interface HotkeyAction {
// TODO: execute
- val label: Text
+ val label: Component
fun execute()
}
@Serializable
@SerialName("command")
data class CommandAction(val command: String) : HotkeyAction {
- override val label: Text
- get() = Text.literal("/$command")
+ override val label: Component
+ get() = Component.literal("/$command")
override fun execute() {
MC.sendCommand(command)
diff --git a/src/main/kotlin/features/macros/KeyComboTrie.kt b/src/main/kotlin/features/macros/KeyComboTrie.kt
index 1983b2e..2701ac1 100644
--- a/src/main/kotlin/features/macros/KeyComboTrie.kt
+++ b/src/main/kotlin/features/macros/KeyComboTrie.kt
@@ -1,12 +1,12 @@
package moe.nea.firmament.features.macros
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.keybindings.SavedKeyBinding
import moe.nea.firmament.util.ErrorUtil
sealed interface KeyComboTrie {
- val label: Text
+ val label: Component
companion object {
fun fromComboList(
@@ -57,7 +57,7 @@ data class ComboKeyAction(
)
data class Leaf(val action: HotkeyAction) : KeyComboTrie {
- override val label: Text
+ override val label: Component
get() = action.label
fun execute() {
@@ -68,6 +68,6 @@ data class Leaf(val action: HotkeyAction) : KeyComboTrie {
data class Branch(
val nodes: Map<SavedKeyBinding, KeyComboTrie>
) : KeyComboTrie {
- override val label: Text
- get() = Text.literal("...") // TODO: better labels
+ override val label: Component
+ get() = Component.literal("...") // TODO: better labels
}
diff --git a/src/main/kotlin/features/macros/MacroUI.kt b/src/main/kotlin/features/macros/MacroUI.kt
index 869466d..e73f076 100644
--- a/src/main/kotlin/features/macros/MacroUI.kt
+++ b/src/main/kotlin/features/macros/MacroUI.kt
@@ -55,7 +55,7 @@ class MacroUI {
fun discard() {
dontSave = true
- MC.screen?.close()
+ MC.screen?.onClose()
}
class Command(
@@ -102,7 +102,7 @@ class MacroUI {
@Bind
fun back() {
- MC.screen?.close()
+ MC.screen?.onClose()
}
@Bind
@@ -169,7 +169,7 @@ class MacroUI {
fun saveAndClose() {
save()
- MC.screen?.close()
+ MC.screen?.onClose()
}
inner class Combos {
@@ -268,7 +268,7 @@ class MacroUI {
@Bind
fun back() {
- MC.screen?.close()
+ MC.screen?.onClose()
}
@Bind
diff --git a/src/main/kotlin/features/macros/RadialMenu.kt b/src/main/kotlin/features/macros/RadialMenu.kt
index 43e65a7..2519123 100644
--- a/src/main/kotlin/features/macros/RadialMenu.kt
+++ b/src/main/kotlin/features/macros/RadialMenu.kt
@@ -7,7 +7,7 @@ import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
-import net.minecraft.client.gui.DrawContext
+import net.minecraft.client.gui.GuiGraphics
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.TickEvent
@@ -32,7 +32,7 @@ object RadialMenuViewer {
interface RadialMenuOption {
val isEnabled: Boolean
fun resolve()
- fun renderSlice(drawContext: DrawContext)
+ fun renderSlice(drawContext: GuiGraphics)
}
var activeMenu: RadialMenu? = null
@@ -63,11 +63,11 @@ object RadialMenuViewer {
@Subscribe
fun onRender(event: HudRenderEvent) {
val menu = activeMenu ?: return
- val mat = event.context.matrices
+ val mat = event.context.pose()
mat.pushMatrix()
mat.translate(
- (MC.window.scaledWidth) / 2F,
- (MC.window.scaledHeight) / 2F,
+ (MC.window.guiScaledWidth) / 2F,
+ (MC.window.guiScaledHeight) / 2F,
)
val sliceWidth = (τ / menu.options.size).toFloat()
var selectedAngle = wrapAngle(atan2(delta.y, delta.x))
@@ -137,8 +137,8 @@ object RadialMacros {
action.execute()
}
- override fun renderSlice(drawContext: DrawContext) {
- drawContext.drawCenteredTextWithShadow(MC.font, action.label, 0, 0, -1)
+ override fun renderSlice(drawContext: GuiGraphics) {
+ drawContext.drawCenteredString(MC.font, action.label, 0, 0, -1)
}
}
RadialMenuViewer.activeMenu = object : RadialMenu {
diff --git a/src/main/kotlin/features/mining/CommissionFeatures.kt b/src/main/kotlin/features/mining/CommissionFeatures.kt
index 1041ae5..bfc635a 100644
--- a/src/main/kotlin/features/mining/CommissionFeatures.kt
+++ b/src/main/kotlin/features/mining/CommissionFeatures.kt
@@ -20,7 +20,7 @@ object CommissionFeatures {
fun onSlotRender(event: SlotRenderEvents.Before) {
if (!TConfig.highlightCompletedCommissions) return
if (MC.screenName != "Commissions") return
- val stack = event.slot.stack
+ val stack = event.slot.item
if (stack.loreAccordingToNbt.any { it.unformattedString == "COMPLETED" }) {
event.highlight(Firmament.identifier("completed_commission_background"))
}
diff --git a/src/main/kotlin/features/mining/HotmPresets.kt b/src/main/kotlin/features/mining/HotmPresets.kt
index 97c9a7c..5316211 100644
--- a/src/main/kotlin/features/mining/HotmPresets.kt
+++ b/src/main/kotlin/features/mining/HotmPresets.kt
@@ -3,15 +3,15 @@ package moe.nea.firmament.features.mining
import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.block.Blocks
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.Items
-import net.minecraft.screen.GenericContainerScreenHandler
-import net.minecraft.screen.slot.Slot
-import net.minecraft.text.Text
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.Items
+import net.minecraft.world.inventory.ChestMenu
+import net.minecraft.world.inventory.Slot
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
@@ -51,8 +51,8 @@ object HotmPresets {
fun onScreenOpen(event: ScreenChangeEvent) {
val title = event.new?.title?.unformattedString
if (title != hotmInventoryName) return
- val screen = event.new as? HandledScreen<*> ?: return
- val oldHandler = (event.old as? HandledScreen<*>)?.customGui
+ val screen = event.new as? AbstractContainerScreen<*> ?: return
+ val oldHandler = (event.old as? AbstractContainerScreen<*>)?.customGui
if (oldHandler is HotmScrollPrompt) {
event.new.customGui = oldHandler
oldHandler.setNewScreen(screen)
@@ -63,32 +63,32 @@ object HotmPresets {
screen.customGui = HotmScrollPrompt(screen)
}
- class HotmScrollPrompt(var screen: HandledScreen<*>) : CustomGui() {
+ class HotmScrollPrompt(var screen: AbstractContainerScreen<*>) : CustomGui() {
var bounds = Rectangle(
0, 0, 0, 0
)
- fun setNewScreen(screen: HandledScreen<*>) {
+ fun setNewScreen(screen: AbstractContainerScreen<*>) {
this.screen = screen
onInit()
hasScrolled = false
}
- override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) {
+ override fun render(drawContext: GuiGraphics, delta: Float, mouseX: Int, mouseY: Int) {
drawContext.drawGuiTexture(
CommonTextures.genericWidget(),
bounds.x, bounds.y,
bounds.width,
bounds.height,
)
- drawContext.drawCenteredTextWithShadow(
+ drawContext.drawCenteredString(
MC.font,
if (hasAll) {
- Text.translatable("firmament.hotmpreset.copied")
+ Component.translatable("firmament.hotmpreset.copied")
} else if (!hasScrolled) {
- Text.translatable("firmament.hotmpreset.scrollprompt")
+ Component.translatable("firmament.hotmpreset.scrollprompt")
} else {
- Text.translatable("firmament.hotmpreset.scrolled")
+ Component.translatable("firmament.hotmpreset.scrolled")
},
bounds.centerX,
bounds.centerY - 5,
@@ -100,11 +100,11 @@ object HotmPresets {
var hasScrolled = false
var hasAll = false
- override fun mouseClick(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClick(click: MouseButtonEvent, doubled: Boolean): Boolean {
if (!hasScrolled) {
- val slot = screen.screenHandler.getSlot(8)
- println("Clicking ${slot.stack}")
- slot.clickRightMouseButton(screen.screenHandler)
+ val slot = screen.menu.getSlot(8)
+ println("Clicking ${slot.item}")
+ slot.clickRightMouseButton(screen.menu)
}
hasScrolled = true
return super.mouseClick(click, doubled)
@@ -140,10 +140,10 @@ object HotmPresets {
val allRows = (1..10).toSet()
fun onNewItems(event: ChestInventoryUpdateEvent) {
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return
+ val handler = screen.menu as? ChestMenu ?: return
for (it in handler.slots) {
- if (it.inventory is PlayerInventory) continue
- val stack = it.stack
+ if (it.container is Inventory) continue
+ val stack = it.item
val name = stack.displayNameAccordingToNbt.unformattedString
tierRegex.useMatch(name) {
coveredRows.add(group("tier").toInt())
@@ -169,7 +169,7 @@ object HotmPresets {
@Subscribe
fun onSlotUpdates(event: ChestInventoryUpdateEvent) {
- val customGui = (event.inventory as? HandledScreen<*>)?.customGui
+ val customGui = (event.inventory as? AbstractContainerScreen<*>)?.customGui
if (customGui is HotmScrollPrompt) {
customGui.onNewItems(event)
}
@@ -185,7 +185,7 @@ object HotmPresets {
@Subscribe
fun onSlotRender(event: SlotRenderEvents.Before) {
if (hotmInventoryName == MC.screenName
- && event.slot.stack.displayNameAccordingToNbt.unformattedString in highlightedPerks
+ && event.slot.item.displayNameAccordingToNbt.unformattedString in highlightedPerks
) {
event.highlight((Firmament.identifier("hotm_perk_preset")))
}
@@ -197,7 +197,7 @@ object HotmPresets {
thenExecute {
hotmCommandSent = TimeMark.now()
MC.sendCommand("hotm")
- source.sendFeedback(Text.translatable("firmament.hotmpreset.openinghotm"))
+ source.sendFeedback(Component.translatable("firmament.hotmpreset.openinghotm"))
}
}
event.subcommand("importhotm") {
@@ -205,10 +205,10 @@ object HotmPresets {
val template =
TemplateUtil.maybeDecodeTemplate<HotmPreset>(SHARE_PREFIX, ClipboardUtils.getTextContents())
if (template == null) {
- source.sendFeedback(Text.translatable("firmament.hotmpreset.failedimport"))
+ source.sendFeedback(Component.translatable("firmament.hotmpreset.failedimport"))
} else {
highlightedPerks = template.perks.mapTo(mutableSetOf()) { it.perkName }
- source.sendFeedback(Text.translatable("firmament.hotmpreset.okayimport"))
+ source.sendFeedback(Component.translatable("firmament.hotmpreset.okayimport"))
MC.sendCommand("hotm")
}
}
diff --git a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
index f4def44..6c50665 100644
--- a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
+++ b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
@@ -3,8 +3,8 @@ package moe.nea.firmament.features.mining
import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import io.github.notenoughupdates.moulconfig.xml.Bind
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.item.ItemStack
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.world.item.ItemStack
import moe.nea.firmament.repo.MiningRepoData
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MoulConfigUtils
diff --git a/src/main/kotlin/features/mining/PickaxeAbility.kt b/src/main/kotlin/features/mining/PickaxeAbility.kt
index 862d979..23b55e5 100644
--- a/src/main/kotlin/features/mining/PickaxeAbility.kt
+++ b/src/main/kotlin/features/mining/PickaxeAbility.kt
@@ -5,13 +5,13 @@ import java.util.regex.Pattern
import kotlin.jvm.optionals.getOrNull
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.toast.SystemToast
-import net.minecraft.item.ItemStack
-import net.minecraft.util.DyeColor
-import net.minecraft.util.Hand
-import net.minecraft.util.Identifier
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.components.toasts.SystemToast
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.DyeColor
+import net.minecraft.world.InteractionHand
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -48,13 +48,13 @@ object PickaxeAbility {
val identifier: String
get() = "pickaxe-info"
- enum class ShowOnTools(val label: String, val items: Set<ItemType>) : StringIdentifiable {
+ enum class ShowOnTools(val label: String, val items: Set<ItemType>) : StringRepresentable {
ALL("all", ItemType.DRILL, ItemType.PICKAXE, ItemType.SHOVEL, ItemType.AXE),
PICKAXES_AND_DRILLS("pick-and-drill", ItemType.PICKAXE, ItemType.DRILL),
DRILLS("drills", ItemType.DRILL),
;
- override fun asString(): String? {
+ override fun getSerializedName(): String? {
return label
}
@@ -79,12 +79,12 @@ object PickaxeAbility {
}
}
- enum class BlockPickaxeAbility : StringIdentifiable {
+ enum class BlockPickaxeAbility : StringRepresentable {
NEVER,
ALWAYS,
ONLY_DESTRUCTIVE;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -195,11 +195,11 @@ object PickaxeAbility {
val ability = group("name")
lastUsage[ability] = TimeMark.farPast()
if (!TConfig.cooldownReadyToast) return
- val mc: MinecraftClient = MinecraftClient.getInstance()
- mc.toastManager.add(
- SystemToast.create(
+ val mc: Minecraft = Minecraft.getInstance()
+ mc.toastManager.addToast(
+ SystemToast.multiline(
mc,
- SystemToast.Type.NARRATOR_TOGGLE,
+ SystemToast.SystemToastId.NARRATOR_TOGGLE,
tr("firmament.pickaxe.ability-ready", "Pickaxe Cooldown"),
tr("firmament.pickaxe.ability-ready.desc", "Pickaxe ability is ready!")
)
@@ -248,7 +248,7 @@ object PickaxeAbility {
if (!TConfig.cooldownEnabled) return
if (TConfig.disableInDungeons && DungeonUtil.isInDungeonIsland) return
if (!event.isRenderingCursor) return
- val stack = MC.player?.getStackInHand(Hand.MAIN_HAND) ?: return
+ val stack = MC.player?.getItemInHand(InteractionHand.MAIN_HAND) ?: return
if (!TConfig.showOnTools.matches(ItemType.fromItemStack(stack) ?: ItemType.NIL))
return
var ability = getCooldownFromLore(stack)?.also { ability ->
@@ -258,15 +258,15 @@ object PickaxeAbility {
if (ability == null || (ao != ability.name && ao != null)) {
ability = PickaxeAbilityData(ao ?: return, defaultAbilityDurations[ao] ?: 120.seconds)
}
- event.context.matrices.pushMatrix()
- event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F)
- event.context.matrices.scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat())
+ event.context.pose().pushMatrix()
+ event.context.pose().translate(MC.window.guiScaledWidth / 2F, MC.window.guiScaledHeight / 2F)
+ event.context.pose().scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat())
RenderCircleProgress.renderCircle(
- event.context, Identifier.of("firmament", "textures/gui/circle.png"),
+ event.context, ResourceLocation.fromNamespaceAndPath("firmament", "textures/gui/circle.png"),
getCooldownPercentage(ability.name, ability.cooldown).toFloat(),
0f, 1f, 0f, 1f,
color = TConfig.cooldownColour.getEffectiveColourRGB()
)
- event.context.matrices.popMatrix()
+ event.context.pose().popMatrix()
}
}
diff --git a/src/main/kotlin/features/mining/PristineProfitTracker.kt b/src/main/kotlin/features/mining/PristineProfitTracker.kt
index ad864c1..0470702 100644
--- a/src/main/kotlin/features/mining/PristineProfitTracker.kt
+++ b/src/main/kotlin/features/mining/PristineProfitTracker.kt
@@ -5,7 +5,7 @@ import org.joml.Vector2i
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.gui.hud.MoulConfigHud
@@ -105,11 +105,11 @@ object PristineProfitTracker {
val moneyPerSecond = moneyHistogram.averagePer({ it }, 1.seconds)
if (collectionPerSecond == null || moneyPerSecond == null) return
ProfitHud.collectionCurrent = collectionPerSecond
- ProfitHud.collectionText = Text.stringifiedTranslatable("firmament.pristine-profit.collection",
+ ProfitHud.collectionText = Component.translatableEscape("firmament.pristine-profit.collection",
formatCommas(collectionPerSecond * SECONDS_PER_HOUR,
1)).formattedString()
ProfitHud.moneyCurrent = moneyPerSecond
- ProfitHud.moneyText = Text.stringifiedTranslatable("firmament.pristine-profit.money",
+ ProfitHud.moneyText = Component.translatableEscape("firmament.pristine-profit.money",
formatCommas(moneyPerSecond * SECONDS_PER_HOUR, 1))
.formattedString()
val data = DConfig.data
diff --git a/src/main/kotlin/features/misc/CustomCapes.kt b/src/main/kotlin/features/misc/CustomCapes.kt
index d66e6a3..8aa19d3 100644
--- a/src/main/kotlin/features/misc/CustomCapes.kt
+++ b/src/main/kotlin/features/misc/CustomCapes.kt
@@ -3,15 +3,15 @@ package moe.nea.firmament.features.misc
import util.render.CustomRenderPipelines
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.network.AbstractClientPlayerEntity
-import net.minecraft.client.render.RenderLayer
-import net.minecraft.client.render.VertexConsumer
-import net.minecraft.client.render.VertexConsumerProvider
-import net.minecraft.client.render.entity.state.PlayerEntityRenderState
-import net.minecraft.client.util.math.MatrixStack
-import net.minecraft.entity.player.SkinTextures
-import net.minecraft.util.AssetInfo
-import net.minecraft.util.Identifier
+import net.minecraft.client.player.AbstractClientPlayer
+import net.minecraft.client.renderer.RenderType
+import com.mojang.blaze3d.vertex.VertexConsumer
+import net.minecraft.client.renderer.MultiBufferSource
+import net.minecraft.client.renderer.entity.state.AvatarRenderState
+import com.mojang.blaze3d.vertex.PoseStack
+import net.minecraft.world.entity.player.PlayerSkin
+import net.minecraft.core.ClientAsset
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TimeMark
@@ -30,44 +30,44 @@ object CustomCapes {
interface CustomCapeRenderer {
fun replaceRender(
- renderLayer: RenderLayer,
- vertexConsumerProvider: VertexConsumerProvider,
- matrixStack: MatrixStack,
- model: (VertexConsumer) -> Unit
+ renderLayer: RenderType,
+ vertexConsumerProvider: MultiBufferSource,
+ matrixStack: PoseStack,
+ model: (VertexConsumer) -> Unit
)
}
data class TexturedCapeRenderer(
- val location: Identifier
+ val location: ResourceLocation
) : CustomCapeRenderer {
override fun replaceRender(
- renderLayer: RenderLayer,
- vertexConsumerProvider: VertexConsumerProvider,
- matrixStack: MatrixStack,
- model: (VertexConsumer) -> Unit
+ renderLayer: RenderType,
+ vertexConsumerProvider: MultiBufferSource,
+ matrixStack: PoseStack,
+ model: (VertexConsumer) -> Unit
) {
- model(vertexConsumerProvider.getBuffer(RenderLayer.getEntitySolid(location)))
+ model(vertexConsumerProvider.getBuffer(RenderType.entitySolid(location)))
}
}
data class ParallaxedHighlightCapeRenderer(
- val template: Identifier,
- val background: Identifier,
- val overlay: Identifier,
- val animationSpeed: Duration,
+ val template: ResourceLocation,
+ val background: ResourceLocation,
+ val overlay: ResourceLocation,
+ val animationSpeed: Duration,
) : CustomCapeRenderer {
override fun replaceRender(
- renderLayer: RenderLayer,
- vertexConsumerProvider: VertexConsumerProvider,
- matrixStack: MatrixStack,
- model: (VertexConsumer) -> Unit
+ renderLayer: RenderType,
+ vertexConsumerProvider: MultiBufferSource,
+ matrixStack: PoseStack,
+ model: (VertexConsumer) -> Unit
) {
val animationValue = (startTime.passedTime() / animationSpeed).mod(1F)
CustomRenderPassHelper(
{ "Firmament Cape Renderer" },
- renderLayer.drawMode,
- renderLayer.vertexFormat,
- MC.instance.framebuffer,
+ renderLayer.mode(),
+ renderLayer.format(),
+ MC.instance.mainRenderTarget,
true,
).use { renderPass ->
renderPass.setPipeline(CustomRenderPipelines.PARALLAX_CAPE_SHADER)
@@ -87,7 +87,7 @@ object CustomCapes {
interface CapeStorage {
companion object {
@JvmStatic
- fun cast(playerEntityRenderState: PlayerEntityRenderState) =
+ fun cast(playerEntityRenderState: AvatarRenderState) =
playerEntityRenderState as CapeStorage
}
@@ -146,8 +146,8 @@ object CustomCapes {
@JvmStatic
fun addCapeData(
- player: AbstractClientPlayerEntity,
- playerEntityRenderState: PlayerEntityRenderState
+ player: AbstractClientPlayer,
+ playerEntityRenderState: AvatarRenderState
) {
if (true) return // TODO: see capefeaturerenderer mixin
val cape = if (TConfig.showCapes) byUuid[player.uuid] else null
@@ -156,14 +156,14 @@ object CustomCapes {
capeStorage.cape_firmament = null
} else {
capeStorage.cape_firmament = cape
- playerEntityRenderState.skinTextures = SkinTextures(
- playerEntityRenderState.skinTextures.body,
- AssetInfo.TextureAssetInfo(Firmament.identifier("placeholder/fake_cape"), Firmament.identifier("placeholder/fake_cape")),
- playerEntityRenderState.skinTextures.elytra,
- playerEntityRenderState.skinTextures.model,
- playerEntityRenderState.skinTextures.secure,
+ playerEntityRenderState.skin = PlayerSkin(
+ playerEntityRenderState.skin.body,
+ ClientAsset.ResourceTexture(Firmament.identifier("placeholder/fake_cape"), Firmament.identifier("placeholder/fake_cape")),
+ playerEntityRenderState.skin.elytra,
+ playerEntityRenderState.skin.model,
+ playerEntityRenderState.skin.secure,
)
- playerEntityRenderState.capeVisible = true
+ playerEntityRenderState.showCape = true
}
}
diff --git a/src/main/kotlin/features/misc/Hud.kt b/src/main/kotlin/features/misc/Hud.kt
index fb7c6cd..bbe8044 100644
--- a/src/main/kotlin/features/misc/Hud.kt
+++ b/src/main/kotlin/features/misc/Hud.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.misc
import org.joml.Vector2i
-import net.minecraft.client.network.PlayerListEntry
-import net.minecraft.text.Text
+import net.minecraft.client.multiplayer.PlayerInfo
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.util.MC
@@ -27,49 +27,49 @@ object Hud {
@Subscribe
fun onRenderHud(it: HudRenderEvent) {
if (TConfig.dayCount) {
- it.context.matrices.pushMatrix()
- TConfig.dayCountHud.applyTransformations(it.context.matrices)
- val day = (MC.world?.timeOfDay ?: 0L) / 24000
- it.context.drawText(
+ it.context.pose().pushMatrix()
+ TConfig.dayCountHud.applyTransformations(it.context.pose())
+ val day = (MC.world?.dayTime ?: 0L) / 24000
+ it.context.drawString(
MC.font,
- Text.literal(String.format(tr("firmament.config.hud.day-count-hud.display", "Day: %s").string, day)),
+ Component.literal(String.format(tr("firmament.config.hud.day-count-hud.display", "Day: %s").string, day)),
36,
- MC.font.fontHeight,
+ MC.font.lineHeight,
-1,
true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
if (TConfig.fpsCount) {
- it.context.matrices.pushMatrix()
- TConfig.fpsCountHud.applyTransformations(it.context.matrices)
- it.context.drawText(
- MC.font, Text.literal(
+ it.context.pose().pushMatrix()
+ TConfig.fpsCountHud.applyTransformations(it.context.pose())
+ it.context.drawString(
+ MC.font, Component.literal(
String.format(
- tr("firmament.config.hud.fps-count-hud.display", "FPS: %s").string, MC.instance.currentFps
+ tr("firmament.config.hud.fps-count-hud.display", "FPS: %s").string, MC.instance.fps
)
- ), 36, MC.font.fontHeight, -1, true
+ ), 36, MC.font.lineHeight, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
if (TConfig.pingCount) {
- it.context.matrices.pushMatrix()
- TConfig.pingCountHud.applyTransformations(it.context.matrices)
+ it.context.pose().pushMatrix()
+ TConfig.pingCountHud.applyTransformations(it.context.pose())
val ping = MC.player?.let {
- val entry: PlayerListEntry? = MC.networkHandler?.getPlayerListEntry(it.uuid)
+ val entry: PlayerInfo? = MC.networkHandler?.getPlayerInfo(it.uuid)
entry?.latency ?: -1
} ?: -1
- it.context.drawText(
- MC.font, Text.literal(
+ it.context.drawString(
+ MC.font, Component.literal(
String.format(
tr("firmament.config.hud.ping-count-hud.display", "Ping: %s ms").string, ping
)
- ), 36, MC.font.fontHeight, -1, true
+ ), 36, MC.font.lineHeight, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
}
}
diff --git a/src/main/kotlin/features/misc/LicenseViewer.kt b/src/main/kotlin/features/misc/LicenseViewer.kt
index 7a43554..26bec80 100644
--- a/src/main/kotlin/features/misc/LicenseViewer.kt
+++ b/src/main/kotlin/features/misc/LicenseViewer.kt
@@ -6,7 +6,7 @@ import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.json.decodeFromStream
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
@@ -31,7 +31,7 @@ object LicenseViewer {
fun hasWebPresence() = webPresence != null
@Bind
- fun webPresence() = Text.literal(webPresence ?: "<no web presence>")
+ fun webPresence() = Component.literal(webPresence ?: "<no web presence>")
@Bind
fun open() {
@@ -39,10 +39,10 @@ object LicenseViewer {
}
@Bind
- fun projectName() = Text.literal(projectName)
+ fun projectName() = Component.literal(projectName)
@Bind
- fun projectDescription() = Text.literal(projectDescription ?: "<no project description>")
+ fun projectDescription() = Component.literal(projectDescription ?: "<no project description>")
@get:Bind("developers")
@Transient
@@ -60,7 +60,7 @@ object LicenseViewer {
) {
@Bind("name")
- fun nameT() = Text.literal(name)
+ fun nameT() = Component.literal(name)
@Bind
fun open() {
@@ -71,7 +71,7 @@ object LicenseViewer {
fun hasWebPresence() = webPresence != null
@Bind
- fun webPresence() = Text.literal(webPresence ?: "<no web presence>")
+ fun webPresence() = Component.literal(webPresence ?: "<no web presence>")
}
@Serializable
@@ -80,7 +80,7 @@ object LicenseViewer {
val licenseUrl: String? = null
) {
@Bind("name")
- fun nameG() = Text.literal(licenseName)
+ fun nameG() = Component.literal(licenseName)
@Bind
fun open() {
@@ -91,7 +91,7 @@ object LicenseViewer {
fun hasUrl() = licenseUrl != null
@Bind
- fun url() = Text.literal(licenseUrl ?: "<no link to license text>")
+ fun url() = Component.literal(licenseUrl ?: "<no link to license text>")
}
data class LicenseList(
diff --git a/src/main/kotlin/features/misc/ModAnnouncer.kt b/src/main/kotlin/features/misc/ModAnnouncer.kt
index 1047353..c2aa013 100644
--- a/src/main/kotlin/features/misc/ModAnnouncer.kt
+++ b/src/main/kotlin/features/misc/ModAnnouncer.kt
@@ -4,10 +4,10 @@ import io.netty.buffer.ByteBuf
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry
import net.fabricmc.loader.api.FabricLoader
-import net.minecraft.network.codec.PacketCodec
-import net.minecraft.network.codec.PacketCodecs
-import net.minecraft.network.packet.CustomPayload
-import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket
+import net.minecraft.network.codec.StreamCodec
+import net.minecraft.network.codec.ByteBufCodecs
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload
+import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.JoinServerEvent
@@ -37,9 +37,9 @@ object ModAnnouncer {
val modVersion: String,
) {
companion object {
- val CODEC: PacketCodec<ByteBuf, ModEntry> = PacketCodec.tuple(
- PacketCodecs.STRING, ModEntry::modid,
- PacketCodecs.STRING, ModEntry::modVersion,
+ val CODEC: StreamCodec<ByteBuf, ModEntry> = StreamCodec.composite(
+ ByteBufCodecs.STRING_UTF8, ModEntry::modid,
+ ByteBufCodecs.STRING_UTF8, ModEntry::modVersion,
::ModEntry
)
}
@@ -47,15 +47,15 @@ object ModAnnouncer {
data class ModPacket(
val mods: List<ModEntry>,
- ) : CustomPayload {
- override fun getId(): CustomPayload.Id<out ModPacket> {
+ ) : CustomPacketPayload {
+ override fun type(): CustomPacketPayload.Type<out ModPacket> {
return ID
}
companion object {
- val ID = CustomPayload.Id<ModPacket>(Firmament.identifier("mod_list"))
- val CODEC: PacketCodec<ByteBuf, ModPacket> = ModEntry.CODEC.collect(PacketCodecs.toList())
- .xmap(::ModPacket, ModPacket::mods)
+ val ID = CustomPacketPayload.Type<ModPacket>(Firmament.identifier("mod_list"))
+ val CODEC: StreamCodec<ByteBuf, ModPacket> = ModEntry.CODEC.apply(ByteBufCodecs.list())
+ .map(::ModPacket, ModPacket::mods)
}
}
@@ -68,10 +68,10 @@ object ModAnnouncer {
.map { ModEntry(it.metadata.id, it.metadata.version.friendlyString) })
val pbb = PacketByteBufs.create()
ModPacket.CODEC.encode(pbb, packet)
- if (pbb.writerIndex() > CustomPayloadC2SPacket.MAX_PAYLOAD_SIZE)
+ if (pbb.writerIndex() > ServerboundCustomPayloadPacket.MAX_PAYLOAD_SIZE)
return
- event.networkHandler.sendPacket(event.packetSender.createPacket(packet))
+ event.networkHandler.send(event.packetSender.createPacket(packet))
}
init {
diff --git a/src/main/kotlin/features/world/ColeWeightCompat.kt b/src/main/kotlin/features/world/ColeWeightCompat.kt
index f7f1317..3597d6d 100644
--- a/src/main/kotlin/features/world/ColeWeightCompat.kt
+++ b/src/main/kotlin/features/world/ColeWeightCompat.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.world
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.DefaultSource
@@ -44,9 +44,9 @@ object ColeWeightCompat {
}
fun copyAndInform(
- source: DefaultSource,
- origin: BlockPos,
- positiveFeedback: (Int) -> Text,
+ source: DefaultSource,
+ origin: BlockPos,
+ positiveFeedback: (Int) -> Component,
) {
val waypoints = Waypoints.useNonEmptyWaypoints()
?.let { fromFirm(it, origin) }
@@ -61,12 +61,12 @@ object ColeWeightCompat {
}
fun importAndInform(
- source: DefaultSource,
- pos: BlockPos?,
- positiveFeedback: (Int) -> Text
+ source: DefaultSource,
+ pos: BlockPos?,
+ positiveFeedback: (Int) -> Component
) {
val text = ClipboardUtils.getTextContents()
- val wr = tryParse(text).map { intoFirm(it, pos ?: BlockPos.ORIGIN) }
+ val wr = tryParse(text).map { intoFirm(it, pos ?: BlockPos.ZERO) }
val waypoints = wr.getOrElse {
source.sendError(
tr("firmament.command.waypoint.import.cw.error",
@@ -84,7 +84,7 @@ object ColeWeightCompat {
event.subcommand(Waypoints.WAYPOINTS_SUBCOMMAND) {
thenLiteral("exportcw") {
thenExecute {
- copyAndInform(source, BlockPos.ORIGIN) {
+ copyAndInform(source, BlockPos.ZERO) {
tr("firmament.command.waypoint.export.cw",
"Copied $it waypoints to clipboard in ColeWeight format.")
}
@@ -92,7 +92,7 @@ object ColeWeightCompat {
}
thenLiteral("exportrelativecw") {
thenExecute {
- copyAndInform(source, MC.player?.blockPos ?: BlockPos.ORIGIN) {
+ copyAndInform(source, MC.player?.blockPosition() ?: BlockPos.ZERO) {
tr("firmament.command.waypoint.export.cw.relative",
"Copied $it relative waypoints to clipboard in ColeWeight format. Make sure to stand in the same position when importing.")
}
@@ -108,7 +108,7 @@ object ColeWeightCompat {
}
thenLiteral("importrelativecw") {
thenExecute {
- importAndInform(source, MC.player!!.blockPos) {
+ importAndInform(source, MC.player!!.blockPosition()) {
tr("firmament.command.waypoint.import.cw.relative",
"Imported $it relative waypoints from clipboard. Make sure you stand in the same position as when you exported these waypoints for them to line up correctly.")
}
diff --git a/src/main/kotlin/features/world/FairySouls.kt b/src/main/kotlin/features/world/FairySouls.kt
index 9191a80..b073726 100644
--- a/src/main/kotlin/features/world/FairySouls.kt
+++ b/src/main/kotlin/features/world/FairySouls.kt
@@ -67,12 +67,12 @@ object FairySouls {
fun findNearestClickableSoul(): Coordinate? {
val player = MC.player ?: return null
- val pos = player.pos
+ val pos = player.position
val location = SBData.skyblockLocation ?: return null
val soulLocations: List<Coordinate> =
RepoManager.neuRepo.constants.fairySouls.soulLocations[location.locrawMode] ?: return null
return soulLocations
- .map { it to it.blockPos.getSquaredDistance(pos) }
+ .map { it to it.blockPos.distToCenterSqr(pos) }
.filter { it.second < playerReachSquared }
.minByOrNull { it.second }
?.first
diff --git a/src/main/kotlin/features/world/FirmWaypointManager.kt b/src/main/kotlin/features/world/FirmWaypointManager.kt
index 41c3007..c6e2610 100644
--- a/src/main/kotlin/features/world/FirmWaypointManager.kt
+++ b/src/main/kotlin/features/world/FirmWaypointManager.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.features.world
import com.mojang.brigadier.arguments.StringArgumentType
import kotlinx.serialization.serializer
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.DefaultSource
import moe.nea.firmament.commands.RestArgumentType
@@ -46,10 +46,10 @@ object FirmWaypointManager {
return copy
}
- fun loadWaypoints(waypoints: FirmWaypoints, sendFeedback: (Text) -> Unit) {
+ fun loadWaypoints(waypoints: FirmWaypoints, sendFeedback: (Component) -> Unit) {
val copy = waypoints.deepCopy()
if (copy.isRelativeTo != null) {
- val origin = MC.player!!.blockPos
+ val origin = MC.player!!.blockPosition()
copy.waypoints.replaceAll {
it.copy(
x = it.x + origin.x,
@@ -57,7 +57,7 @@ object FirmWaypointManager {
z = it.z + origin.z,
)
}
- copy.lastRelativeImport = origin.toImmutable()
+ copy.lastRelativeImport = origin.immutable()
sendFeedback(tr("firmament.command.waypoint.import.ordered.success",
"Imported ${copy.size} relative waypoints. Make sure you stand in the correct spot while loading the waypoints: ${copy.isRelativeTo}."))
} else {
@@ -70,7 +70,7 @@ object FirmWaypointManager {
fun setOrigin(source: DefaultSource, text: String?) {
val waypoints = Waypoints.useEditableWaypoints()
waypoints.isRelativeTo = text ?: waypoints.isRelativeTo ?: ""
- val pos = MC.player!!.blockPos
+ val pos = MC.player!!.blockPosition()
waypoints.lastRelativeImport = pos
source.sendFeedback(tr("firmament.command.waypoint.originset",
"Set the origin of waypoints to ${FirmFormatters.formatPosition(pos)}. Run /firm waypoints export to save the waypoints relative to this position."))
diff --git a/src/main/kotlin/features/world/FirmWaypoints.kt b/src/main/kotlin/features/world/FirmWaypoints.kt
index d0cd55a..0b018cb 100644
--- a/src/main/kotlin/features/world/FirmWaypoints.kt
+++ b/src/main/kotlin/features/world/FirmWaypoints.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.features.world
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
@Serializable
data class FirmWaypoints(
diff --git a/src/main/kotlin/features/world/NavigableWaypoint.kt b/src/main/kotlin/features/world/NavigableWaypoint.kt
index 28a517f..653fd87 100644
--- a/src/main/kotlin/features/world/NavigableWaypoint.kt
+++ b/src/main/kotlin/features/world/NavigableWaypoint.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.world
import io.github.moulberry.repo.data.NEUItem
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
import moe.nea.firmament.util.SkyBlockIsland
abstract class NavigableWaypoint {
diff --git a/src/main/kotlin/features/world/NavigationHelper.kt b/src/main/kotlin/features/world/NavigationHelper.kt
index acdfb86..ea886bf 100644
--- a/src/main/kotlin/features/world/NavigationHelper.kt
+++ b/src/main/kotlin/features/world/NavigationHelper.kt
@@ -1,10 +1,10 @@
package moe.nea.firmament.features.world
import io.github.moulberry.repo.constants.Islands
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.Position
-import net.minecraft.util.math.Vec3i
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
+import net.minecraft.core.Position
+import net.minecraft.core.Vec3i
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SkyblockServerUpdateEvent
import moe.nea.firmament.events.TickEvent
@@ -72,7 +72,7 @@ object NavigationHelper {
fun onMovement(event: TickEvent) { // TODO: add a movement tick event maybe?
val tp = targetWaypoint ?: return
val p = MC.player ?: return
- if (p.squaredDistanceTo(tp.position.toCenterPos()) < 5 * 5) {
+ if (p.distanceToSqr(tp.position.center) < 5 * 5) {
targetWaypoint = null
}
}
@@ -84,11 +84,11 @@ object NavigationHelper {
RenderInWorldContext.renderInWorld(event) {
if (nt != null) {
waypoint(nt.blockPos,
- Text.literal("Teleporter to " + nt.toIsland.userFriendlyName),
- Text.literal("(towards " + tp.name + "§f)"))
+ Component.literal("Teleporter to " + nt.toIsland.userFriendlyName),
+ Component.literal("(towards " + tp.name + "§f)"))
} else if (tp.island == SBData.skyblockLocation) {
waypoint(tp.position,
- Text.literal(tp.name))
+ Component.literal(tp.name))
}
}
}
@@ -96,7 +96,7 @@ object NavigationHelper {
fun tryWarpNear() {
val tp = targetWaypoint
if (tp == null) {
- MC.sendChat(Text.literal("Could not find a waypoint to warp you to. Select one first."))
+ MC.sendChat(Component.literal("Could not find a waypoint to warp you to. Select one first."))
return
}
WarpUtil.teleportToNearestWarp(tp.island, tp.position.asPositionView())
@@ -106,15 +106,15 @@ object NavigationHelper {
fun Vec3i.asPositionView(): Position {
return object : Position {
- override fun getX(): Double {
+ override fun x(): Double {
return this@asPositionView.x.toDouble()
}
- override fun getY(): Double {
+ override fun y(): Double {
return this@asPositionView.y.toDouble()
}
- override fun getZ(): Double {
+ override fun z(): Double {
return this@asPositionView.z.toDouble()
}
}
diff --git a/src/main/kotlin/features/world/NpcWaypointGui.kt b/src/main/kotlin/features/world/NpcWaypointGui.kt
index b6db7eb..3bae3e8 100644
--- a/src/main/kotlin/features/world/NpcWaypointGui.kt
+++ b/src/main/kotlin/features/world/NpcWaypointGui.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.features.world
import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.xml.Bind
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.features.events.anniversity.AnniversaryFeatures.atOnce
import moe.nea.firmament.keybindings.SavedKeyBinding
@@ -12,7 +12,7 @@ class NpcWaypointGui(
data class NavigableWaypointW(val waypoint: NavigableWaypoint) {
@Bind
- fun name() = Text.literal(waypoint.name)
+ fun name() = Component.literal(waypoint.name)
@Bind
fun isSelected() = NavigationHelper.targetWaypoint == waypoint
diff --git a/src/main/kotlin/features/world/TemporaryWaypoints.kt b/src/main/kotlin/features/world/TemporaryWaypoints.kt
index 14a9f74..ac1600e 100644
--- a/src/main/kotlin/features/world/TemporaryWaypoints.kt
+++ b/src/main/kotlin/features/world/TemporaryWaypoints.kt
@@ -2,8 +2,8 @@ package moe.nea.firmament.features.world
import me.shedaniel.math.Color
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.events.WorldReadyEvent
@@ -15,8 +15,8 @@ import moe.nea.firmament.util.render.RenderInWorldContext
object TemporaryWaypoints {
data class TemporaryWaypoint(
- val pos: BlockPos,
- val postedAt: TimeMark,
+ val pos: BlockPos,
+ val postedAt: TimeMark,
)
val temporaryPlayerWaypointList = mutableMapOf<String, TemporaryWaypoint>()
val temporaryPlayerWaypointMatcher = "(?i)x: (-?[0-9]+),? y: (-?[0-9]+),? z: (-?[0-9]+)".toPattern()
@@ -41,9 +41,9 @@ object TemporaryWaypoints {
}
temporaryPlayerWaypointList.forEach { (player, waypoint) ->
val skin =
- MC.networkHandler?.listedPlayerListEntries?.find { it.profile.name == player }?.skinTextures?.body
- withFacingThePlayer(waypoint.pos.toCenterPos()) {
- waypoint(waypoint.pos, Text.stringifiedTranslatable("firmament.waypoint.temporary", player))
+ MC.networkHandler?.listedOnlinePlayers?.find { it.profile.name == player }?.skin?.body
+ withFacingThePlayer(waypoint.pos.center) {
+ waypoint(waypoint.pos, Component.translatableEscape("firmament.waypoint.temporary", player))
if (skin != null) {
matrixStack.translate(0F, -20F, 0F)
// Head front
diff --git a/src/main/kotlin/features/world/Waypoints.kt b/src/main/kotlin/features/world/Waypoints.kt
index 318b6c2..9097d3a 100644
--- a/src/main/kotlin/features/world/Waypoints.kt
+++ b/src/main/kotlin/features/world/Waypoints.kt
@@ -4,9 +4,9 @@ import com.mojang.brigadier.arguments.IntegerArgumentType
import me.shedaniel.math.Color
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.command.argument.BlockPosArgumentType
-import net.minecraft.text.Text
-import net.minecraft.util.math.Vec3d
+import net.minecraft.commands.arguments.coordinates.BlockPosArgument
+import net.minecraft.network.chat.Component
+import net.minecraft.world.phys.Vec3
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.thenArgument
@@ -46,14 +46,14 @@ object Waypoints {
if (!w.isOrdered) {
w.waypoints.withIndex().forEach {
block(it.value.blockPos, Color.ofRGBA(0, 80, 160, 128).color)
- if (TConfig.showIndex) withFacingThePlayer(it.value.blockPos.toCenterPos()) {
- text(Text.literal(it.index.toString()))
+ if (TConfig.showIndex) withFacingThePlayer(it.value.blockPos.center) {
+ text(Component.literal(it.index.toString()))
}
}
} else {
orderedIndex %= w.waypoints.size
val firstColor = Color.ofRGBA(0, 200, 40, 180)
- tracer(w.waypoints[orderedIndex].blockPos.toCenterPos(), color = firstColor.color, lineWidth = 3f)
+ tracer(w.waypoints[orderedIndex].blockPos.center, color = firstColor.color, lineWidth = 3f)
w.waypoints.withIndex().toList().wrappingWindow(orderedIndex, 3).zip(
listOf(
firstColor,
@@ -63,8 +63,8 @@ object Waypoints {
).reversed().forEach { (waypoint, col) ->
val (index, pos) = waypoint
block(pos.blockPos, col.color)
- if (TConfig.showIndex) withFacingThePlayer(pos.blockPos.toCenterPos()) {
- text(Text.literal(index.toString()))
+ if (TConfig.showIndex) withFacingThePlayer(pos.blockPos.center) {
+ text(Component.literal(index.toString()))
}
}
}
@@ -76,13 +76,13 @@ object Waypoints {
val w = useNonEmptyWaypoints() ?: return
if (!w.isOrdered) return
orderedIndex %= w.waypoints.size
- val p = MC.player?.pos ?: return
+ val p = MC.player?.position ?: return
if (TConfig.skipToNearest) {
orderedIndex =
- (w.waypoints.withIndex().minBy { it.value.blockPos.getSquaredDistance(p) }.index + 1) % w.waypoints.size
+ (w.waypoints.withIndex().minBy { it.value.blockPos.distToCenterSqr(p) }.index + 1) % w.waypoints.size
} else {
- if (w.waypoints[orderedIndex].blockPos.isWithinDistance(p, 3.0)) {
+ if (w.waypoints[orderedIndex].blockPos.closerToCenterThan(p, 3.0)) {
orderedIndex = (orderedIndex + 1) % w.waypoints.size
}
}
@@ -117,14 +117,14 @@ object Waypoints {
@Subscribe
fun onCommand(event: CommandEvent.SubCommand) {
event.subcommand("waypoint") {
- thenArgument("pos", BlockPosArgumentType.blockPos()) { pos ->
+ thenArgument("pos", BlockPosArgument.blockPos()) { pos ->
thenExecute {
source
- val position = pos.get(this).toAbsoluteBlockPos(source.asFakeServer())
+ val position = pos.get(this).getBlockPos(source.asFakeServer())
val w = useEditableWaypoints()
w.waypoints.add(FirmWaypoints.Waypoint.from(position))
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.command.waypoint.added",
position.x,
position.y,
@@ -180,7 +180,7 @@ object Waypoints {
thenLiteral("clear") {
thenExecute {
waypoints = null
- source.sendFeedback(Text.translatable("firmament.command.waypoint.clear"))
+ source.sendFeedback(Component.translatable("firmament.command.waypoint.clear"))
}
}
thenLiteral("toggleordered") {
@@ -188,11 +188,11 @@ object Waypoints {
val w = useEditableWaypoints()
w.isOrdered = !w.isOrdered
if (w.isOrdered) {
- val p = MC.player?.pos ?: Vec3d.ZERO
+ val p = MC.player?.position ?: Vec3.ZERO
orderedIndex = // TODO: this should be extracted to a utility method
- w.waypoints.withIndex().minByOrNull { it.value.blockPos.getSquaredDistance(p) }?.index ?: 0
+ w.waypoints.withIndex().minByOrNull { it.value.blockPos.distToCenterSqr(p) }?.index ?: 0
}
- source.sendFeedback(Text.translatable("firmament.command.waypoint.ordered.toggle.${w.isOrdered}"))
+ source.sendFeedback(Component.translatable("firmament.command.waypoint.ordered.toggle.${w.isOrdered}"))
}
}
thenLiteral("skip") {
@@ -200,9 +200,9 @@ object Waypoints {
val w = useNonEmptyWaypoints()
if (w != null && w.isOrdered) {
orderedIndex = (orderedIndex + 1) % w.size
- source.sendFeedback(Text.translatable("firmament.command.waypoint.skip"))
+ source.sendFeedback(Component.translatable("firmament.command.waypoint.skip"))
} else {
- source.sendError(Text.translatable("firmament.command.waypoint.skip.error"))
+ source.sendError(Component.translatable("firmament.command.waypoint.skip.error"))
}
}
}
@@ -214,13 +214,13 @@ object Waypoints {
if (w != null && index in w.waypoints.indices) {
w.waypoints.removeAt(index)
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.command.waypoint.remove",
index
)
)
} else {
- source.sendError(Text.stringifiedTranslatable("firmament.command.waypoint.remove.error"))
+ source.sendError(Component.translatableEscape("firmament.command.waypoint.remove.error"))
}
}
}
@@ -234,7 +234,7 @@ object Waypoints {
"Invalid index $index provided."
)
- fun textNothingToExport(): Text =
+ fun textNothingToExport(): Component =
tr(
"firmament.command.waypoint.export.nowaypoints",
"No waypoints to export found. Add some with /firm waypoint ~ ~ ~."