aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/repo
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-08-27 01:38:49 +0200
committernea <romangraef@gmail.com>2022-08-27 01:38:49 +0200
commit973c13e84f8e091a6a920779103d96559dcd32a8 (patch)
tree95741faaa85509216a3a5130a3d8cd48b1b415fd /src/main/kotlin/moe/nea/notenoughupdates/repo
parent4c7bd601c4df4d03536e97e18e4b88d858330ad9 (diff)
downloadfirmament-973c13e84f8e091a6a920779103d96559dcd32a8.tar.gz
firmament-973c13e84f8e091a6a920779103d96559dcd32a8.tar.bz2
firmament-973c13e84f8e091a6a920779103d96559dcd32a8.zip
Switch to yarn mappings
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt38
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt14
2 files changed, 26 insertions, 26 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
index 9255867..1cf6efc 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
@@ -10,36 +10,36 @@ import kotlinx.coroutines.launch
import moe.nea.notenoughupdates.NotEnoughUpdates
import moe.nea.notenoughupdates.util.LegacyTagParser
import moe.nea.notenoughupdates.util.appendLore
-import net.minecraft.nbt.CompoundTag
+import net.minecraft.datafixer.Schemas
+import net.minecraft.datafixer.TypeReferences
+import net.minecraft.item.ItemStack
+import net.minecraft.item.Items
+import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtOps
-import net.minecraft.network.chat.Component
-import net.minecraft.resources.ResourceLocation
-import net.minecraft.util.datafix.DataFixers
-import net.minecraft.util.datafix.fixes.References
-import net.minecraft.world.item.ItemStack
-import net.minecraft.world.item.Items
+import net.minecraft.text.Text
+import net.minecraft.util.Identifier
import java.util.concurrent.ConcurrentHashMap
object ItemCache : IReloadable {
val cache: MutableMap<String, ItemStack> = ConcurrentHashMap()
- val df = DataFixers.getDataFixer()
+ val df = Schemas.getFixer()
var isFlawless = true
- private fun NEUItem.get10809CompoundTag(): CompoundTag = CompoundTag().apply {
+ private fun NEUItem.get10809CompoundTag(): NbtCompound = NbtCompound().apply {
put("tag", LegacyTagParser.parse(nbttag))
putString("id", minecraftItemId)
putByte("Count", 1)
putShort("Damage", damage.toShort())
}
- private fun CompoundTag.transformFrom10809ToModern(): CompoundTag? =
+ private fun NbtCompound.transformFrom10809ToModern(): NbtCompound? =
try {
df.update(
- References.ITEM_STACK,
+ TypeReferences.ITEM_STACK,
Dynamic(NbtOps.INSTANCE, this),
-1,
2975
- ).value as CompoundTag
+ ).value as NbtCompound
} catch (e: Exception) {
NotEnoughUpdates.logger.error("Failed to datafixer an item", e)
isFlawless = false
@@ -50,12 +50,12 @@ object ItemCache : IReloadable {
val oldItemTag = get10809CompoundTag()
val modernItemTag = oldItemTag.transformFrom10809ToModern()
?: return ItemStack(Items.PAINTING).apply {
- hoverName = Component.literal(this@asItemStackNow.displayName)
- appendLore(listOf(Component.literal("Exception rendering item: $skyblockItemId")))
+ setCustomName(Text.literal(this@asItemStackNow.displayName))
+ appendLore(listOf(Text.literal("Exception rendering item: $skyblockItemId")))
}
- val itemInstance = ItemStack.of(modernItemTag)
- if (itemInstance.tag?.contains("Enchantments") == true) {
- itemInstance.enchantmentTags.add(CompoundTag())
+ val itemInstance = ItemStack.fromNbt(modernItemTag)
+ if (itemInstance.nbt?.contains("Enchantments") == true) {
+ itemInstance.enchantments.add(NbtCompound())
}
return itemInstance
}
@@ -69,8 +69,8 @@ object ItemCache : IReloadable {
return s
}
- fun NEUItem.getResourceLocation() =
- ResourceLocation("skyblockitem", skyblockItemId.lowercase().replace(";", "__"))
+ fun NEUItem.getIdentifier() =
+ Identifier("skyblockitem", skyblockItemId.lowercase().replace(";", "__"))
var job: Job? = null
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
index 2c0b4ec..ac595ca 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
@@ -11,9 +11,9 @@ import moe.nea.notenoughupdates.NotEnoughUpdates.logger
import moe.nea.notenoughupdates.hud.ProgressBar
import moe.nea.notenoughupdates.util.ConfigHolder
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
-import net.minecraft.client.Minecraft
-import net.minecraft.network.chat.Component
-import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket
+import net.minecraft.client.MinecraftClient
+import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket
+import net.minecraft.text.Text
object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Config) {
@Serializable
@@ -43,8 +43,8 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co
}
private fun trySendClientboundUpdateRecipesPacket(): Boolean {
- return Minecraft.getInstance().level != null && Minecraft.getInstance().connection?.handleUpdateRecipes(
- ClientboundUpdateRecipesPacket(mutableListOf())
+ return MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().networkHandler?.onSynchronizeRecipes(
+ SynchronizeRecipesS2CPacket(mutableListOf())
) != null
}
@@ -71,8 +71,8 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co
CottonHud.add(progressBar)
neuRepo.reload()
} catch (exc: NEURepositoryException) {
- Minecraft.getInstance().player?.sendSystemMessage(
- Component.literal("Failed to reload repository. This will result in some mod features not working.")
+ MinecraftClient.getInstance().player?.sendMessage(
+ Text.literal("Failed to reload repository. This will result in some mod features not working.")
)
CottonHud.remove(progressBar)
exc.printStackTrace()