Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update KQL to Minecraft 1.21 and Kotlin 2.0.0 #98

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ atomic = "0.23.2"
coroutines = "1.8.0"
datetime = "0.5.0"
dokka = "1.9.10"
kotlin = "1.9.23"
minecraft = "1.20.4"
kotlin = "2.0.0"
minecraft = "1.21"
qsl = "8.0.0-alpha.10+1.20.4"
quilt_loader = "0.24.0"
quilt_mappings = "1.20.4+build.3"
quilt_loader = "0.26.4-beta.1"
quilt_mappings = "1.21+build.12"
serialization = "1.6.3"
serialization_plugin = "1.9.23" # usually same as kotlin but can lag behind
binary_compat_plugin = "0.14.0"
Expand All @@ -33,7 +33,7 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
git_hooks = { id = "com.github.jakemarsden.git-hooks", version = "0.0.2" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
licenser = { id = "dev.yumi.gradle.licenser", version = "1.1.1" }
quilt_loom = { id = "org.quiltmc.loom", version = "1.4.2" }
quilt_loom = { id = "org.quiltmc.loom", version = "1.7.4" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialization_plugin" }
binary_compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary_compat_plugin" }
minotaur = { id = "com.modrinth.minotaur", version = "2.8.7" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Comment on lines 1 to 7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Expand Down
12 changes: 6 additions & 6 deletions library/api/library.api
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public final class org/quiltmc/qkl/library/brigadier/argument/ArgumentsKt {
public static final fun team (Ljava/lang/String;)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
public static final fun testClass (Ljava/lang/String;)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
public static final fun testFunction (Ljava/lang/String;)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
public static final fun text (Ljava/lang/String;)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
public static final fun text (Lnet/minecraft/command/CommandBuildContext;Ljava/lang/String;)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
public static final fun time (Ljava/lang/String;I)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
public static synthetic fun time$default (Ljava/lang/String;IILjava/lang/Object;)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
public static final fun uuid (Ljava/lang/String;)Lorg/quiltmc/qkl/library/brigadier/ArgumentConstructor;
Expand Down Expand Up @@ -1178,10 +1178,10 @@ public final class org/quiltmc/qkl/library/text/HoverEvents {
public static final field INSTANCE Lorg/quiltmc/qkl/library/text/HoverEvents;
public final fun showEntity (Lnet/minecraft/entity/EntityType;Ljava/util/UUID;Lnet/minecraft/text/Text;)Lnet/minecraft/text/HoverEvent;
public static synthetic fun showEntity$default (Lorg/quiltmc/qkl/library/text/HoverEvents;Lnet/minecraft/entity/EntityType;Ljava/util/UUID;Lnet/minecraft/text/Text;ILjava/lang/Object;)Lnet/minecraft/text/HoverEvent;
public final fun showItem (Lnet/minecraft/item/Item;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/text/HoverEvent;
public final fun showItem (Lnet/minecraft/item/Item;Lnet/minecraft/component/DataComponentMap;)Lnet/minecraft/text/HoverEvent;
public final fun showItem (Lnet/minecraft/item/ItemStack;)Lnet/minecraft/text/HoverEvent;
public final fun showItem (Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/text/HoverEvent;
public static synthetic fun showItem$default (Lorg/quiltmc/qkl/library/text/HoverEvents;Lnet/minecraft/item/Item;Lnet/minecraft/nbt/NbtCompound;ILjava/lang/Object;)Lnet/minecraft/text/HoverEvent;
public final fun showItem (Lnet/minecraft/registry/HolderLookup$Provider;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/text/HoverEvent;
public static synthetic fun showItem$default (Lorg/quiltmc/qkl/library/text/HoverEvents;Lnet/minecraft/item/Item;Lnet/minecraft/component/DataComponentMap;ILjava/lang/Object;)Lnet/minecraft/text/HoverEvent;
public final fun showText (Lnet/minecraft/text/Text;)Lnet/minecraft/text/HoverEvent;
}

Expand Down Expand Up @@ -1250,7 +1250,7 @@ public final class org/quiltmc/qkl/library/text/TextDslKt {
public static synthetic fun italic$default (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
public static final fun keyBind (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/String;)V
public static final fun literal (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/String;)V
public static final fun nbt (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/String;ZLjava/util/Optional;Lnet/minecraft/text/data/TextData;)V
public static final fun nbt (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/String;ZLjava/util/Optional;Lnet/minecraft/text/data/TextDataSource;)V
public static final fun obfuscated (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;)V
public static synthetic fun obfuscated$default (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
public static final fun scoreboard (Lorg/quiltmc/qkl/library/text/TextBuilder;Ljava/lang/String;Ljava/lang/String;)V
Expand All @@ -1267,6 +1267,6 @@ public final class org/quiltmc/qkl/library/text/TextDslKt {
}

public final class org/quiltmc/qkl/library/worlds/DimensionExtensionsKt {
public static final fun teleportGeneral (Lnet/minecraft/entity/Entity;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/TeleportTarget;)Lnet/minecraft/entity/Entity;
public static final fun teleportGeneral (Lnet/minecraft/entity/Entity;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/DimensionTransition;)Lnet/minecraft/entity/Entity;
}

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public fun commandBuildContext(
featureFlags: FeatureFlagBitSet,
action: CommandBuildContext.() -> Unit
): CommandBuildContext {
val context = CommandBuildContext.createConfigurable(dynamicRegistryManager, featureFlags)
val context = CommandBuildContext.createSimple(dynamicRegistryManager, featureFlags)
context.apply(action)
return context
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import net.minecraft.loot.condition.LootCondition
import net.minecraft.loot.function.LootFunction
import net.minecraft.recipe.RecipeHolder
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.unmapped.C_jjjbxeeq
import net.minecraft.util.Identifier
import org.quiltmc.qkl.library.brigadier.*

Expand Down Expand Up @@ -81,7 +82,7 @@ public fun ArgumentReader<
IdentifierArgumentType
>
>.asPredicate(): LootCondition {
return IdentifierArgumentType.getPredicateArgument(context, name)
return C_jjjbxeeq.method_58488(context, name).value()
}

/**
Expand All @@ -100,7 +101,7 @@ public fun ArgumentReader<
IdentifierArgumentType
>
>.asItemModifier(): LootFunction {
return IdentifierArgumentType.getItemModifierArgument(context, name)
return C_jjjbxeeq.method_58485(context, name).value()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package org.quiltmc.qkl.library.brigadier.argument


import net.minecraft.command.CommandBuildContext
import net.minecraft.command.argument.ColorArgumentType
import net.minecraft.command.argument.MessageArgumentType
import net.minecraft.command.argument.TextArgumentType
Expand Down Expand Up @@ -132,7 +133,8 @@ public fun <S> color(
*/
@BrigadierDsl
public fun <S> text(
context: CommandBuildContext,
name: String
): DefaultArgumentConstructor<S, TextArgumentType> {
return argument(name, TextArgumentType.text())
return argument(name, TextArgumentType.text(context))
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.quiltmc.qkl.library.client.tooltip

import net.minecraft.client.gui.tooltip.TooltipComponent
import net.minecraft.client.item.TooltipContext
import net.minecraft.client.item.TooltipConfig
import net.minecraft.client.item.TooltipData
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemStack
Expand All @@ -33,7 +33,7 @@ import org.quiltmc.qsl.tooltip.api.client.TooltipComponentCallback
public typealias TooltipCallback = (
stack: ItemStack,
player: PlayerEntity?,
ctx: TooltipContext,
ctx: TooltipConfig,
lines: List<Text>
) -> Unit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package org.quiltmc.qkl.library.networking

import net.minecraft.entity.Entity
import net.minecraft.network.ServerConfigurationPacketHandler
import net.minecraft.network.packet.payload.CustomPayload
import net.minecraft.network.packet.s2c.login.payload.CustomQueryPayload
import net.minecraft.server.MinecraftServer
import net.minecraft.server.network.ServerConfigurationNetworkHandler
import net.minecraft.server.network.ServerLoginNetworkHandler
import net.minecraft.server.network.ServerPlayNetworkHandler
import net.minecraft.server.network.ServerPlayerEntity
Expand Down Expand Up @@ -74,11 +74,11 @@ public fun EventRegistration.onLoginDisconnect(callback: GenericLoginCallback) {
//endregion

//region: Server configuration events
public typealias ServerConfigurationCallback = ServerConfigurationPacketHandler.(
public typealias ServerConfigurationCallback = ServerConfigurationNetworkHandler.(
server: MinecraftServer
) -> Unit

public typealias ServerConfigurationReadyCallback = ServerConfigurationPacketHandler.(
public typealias ServerConfigurationReadyCallback = ServerConfigurationNetworkHandler.(
sender: PacketSender<CustomPayload>,
server: MinecraftServer
) -> Unit
Expand Down Expand Up @@ -121,7 +121,7 @@ public fun EventRegistration.onConfigurationAddTasks(callback: ServerConfigurati
//endregion

//region: S2C configuration channel events
public typealias S2CConfigurationChannelCallback = ServerConfigurationPacketHandler.(
public typealias S2CConfigurationChannelCallback = ServerConfigurationNetworkHandler.(
packetSender: PacketSender<CustomPayload>,
server: MinecraftServer,
channels: List<Identifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import net.minecraft.item.Item
import net.minecraft.item.ItemConvertible
import net.minecraft.item.ItemStack
import net.minecraft.recipe.*
import net.minecraft.registry.RegistryKeys
import net.minecraft.registry.tag.TagKey
import net.minecraft.util.Identifier
import net.minecraft.registry.RegistryKeys
import org.quiltmc.qsl.recipe.api.RecipeManagerHelper
import org.quiltmc.qsl.recipe.api.builder.ShapedRecipeBuilder
import org.quiltmc.qsl.recipe.api.builder.ShapelessRecipeBuilder
Expand Down Expand Up @@ -179,9 +179,9 @@ public fun foodCookingRecipe(
smokerCookTime: Int = cookTime / 2,
campfireCookTime: Int = cookTime * 3
): Array<RecipeHolder<out AbstractCookingRecipe>> {
val smeltingId = Identifier(baseId.namespace, "${baseId.path}_smelting")
val smokingId = Identifier(baseId.namespace, "${baseId.path}_smoking")
val campfireId = Identifier(baseId.namespace, "${baseId.path}_campfire")
val smeltingId = Identifier.of(baseId.namespace, "${baseId.path}_smelting")
val smokingId = Identifier.of(baseId.namespace, "${baseId.path}_smoking")
val campfireId = Identifier.of(baseId.namespace, "${baseId.path}_campfire")

val ingredient = coerceIngredient(input)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package org.quiltmc.qkl.library.registry

import net.minecraft.util.Identifier
import net.minecraft.registry.Registry
import net.minecraft.util.Identifier

/**
* Marks functions as part of QKL Registry DSL.
Expand Down Expand Up @@ -46,7 +46,7 @@ public data class RegistryObject<T>(val modid: String, val path: String, val t:
* */
@RegistryDsl
public infix fun toRegistry(registry: Registry<in T>): T {
return Registry.register(registry, Identifier(modid, path), t)
return Registry.register(registry, Identifier.of(modid, path), t)
}
}

Expand Down Expand Up @@ -85,9 +85,9 @@ public data class RegistryAction<T>(val modid: String?, val registry: Registry<T
@RegistryDsl
public infix fun <R : T> R.withId(id: String): R {
val identifier = if (':' in id || modid == null) {
Identifier(id)
Identifier.parse(id)
} else {
Identifier(modid, id)
Identifier.of(modid, id)
}
return Registry.register(registry, identifier, this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal tailrec fun <T : Any> DynamicOps<T>.getExtendedWithDefault(): ExtendedD
}

internal fun <R> DataResult<R>.unwrap(): R {
return getOrThrow(false) {}
return getOrThrow()
}

internal fun <R> DataResult<R>.orNull(): R? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
package org.quiltmc.qkl.library.serialization.options

import com.mojang.serialization.Codec
import com.mojang.serialization.DataResult.PartialResult
import kotlinx.serialization.Polymorphic
import kotlinx.serialization.Contextual
import kotlinx.serialization.Polymorphic
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.modules.SerializersModule
import net.minecraft.registry.Registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
package org.quiltmc.qkl.library.text

import net.minecraft.text.*
import net.minecraft.text.data.TextData
import net.minecraft.text.data.TextDataSource
import net.minecraft.util.Identifier
import org.quiltmc.qkl.library.*
import org.quiltmc.qkl.library.isBoldRaw
import org.quiltmc.qkl.library.isItalicRaw
import org.quiltmc.qkl.library.isStrikethroughRaw
import org.quiltmc.qkl.library.isUnderlinedRaw
import java.util.*

/**
Expand Down Expand Up @@ -152,7 +148,7 @@ public fun TextBuilder.nbt(
pathPattern: String,
interpreting: Boolean,
separator: Optional<Text>,
nbt: TextData
nbt: TextDataSource
) {
styleAndAppend(
Text.nbt(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

package org.quiltmc.qkl.library.text

import net.minecraft.component.DataComponentMap
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityType
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.registry.HolderLookup
import net.minecraft.text.ClickEvent
import net.minecraft.text.HoverEvent
import net.minecraft.text.Text
Expand Down Expand Up @@ -119,8 +121,8 @@ public object HoverEvents {
*
* @author NoComment1105
*/
public fun showItem(nbt: NbtCompound): HoverEvent {
return showItem(ItemStack.fromNbt(nbt))
public fun showItem(lookupProvider: HolderLookup.Provider, nbt: NbtCompound): HoverEvent {
return showItem(ItemStack.fromNbt(lookupProvider, nbt))
}

/**
Expand All @@ -131,8 +133,8 @@ public object HoverEvents {
*
* @author NoComment1105
*/
public fun showItem(item: Item, nbt: NbtCompound? = null): HoverEvent {
return showItem(item.defaultStack.also { it.nbt = nbt })
public fun showItem(item: Item, components: DataComponentMap = DataComponentMap.EMPTY): HoverEvent {
return showItem(item.defaultStack.also { it.applyComponents(components) })
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package org.quiltmc.qkl.library.worlds

import net.minecraft.entity.Entity
import net.minecraft.server.world.ServerWorld
import net.minecraft.world.TeleportTarget
import net.minecraft.world.DimensionTransition
import org.quiltmc.qsl.worldgen.dimension.api.QuiltDimensions

/**
Expand All @@ -37,7 +37,7 @@ import org.quiltmc.qsl.worldgen.dimension.api.QuiltDimensions
*/
public inline fun <reified E : Entity> E.teleport(
targetWorld: ServerWorld,
location: TeleportTarget
location: DimensionTransition
): E? = when (val teleported = QuiltDimensions.teleport<Entity>(this, targetWorld, location)) {
null -> null
is E -> teleported
Expand All @@ -53,5 +53,5 @@ public inline fun <reified E : Entity> E.teleport(
*/
public fun Entity.teleportGeneral(
targetWorld: ServerWorld,
location: TeleportTarget
location: DimensionTransition
): Entity? = QuiltDimensions.teleport(this, targetWorld, location)
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private object RegistryDslSamples {

fun sampleRegisterWithRegistry() {
val item: TestItem = stub()
val identifier = Identifier("my", "item1")
val identifier = Identifier.of("my", "item1")

Registries.ITEM("my") {
item withId identifier // Goes under `my:item1`
Expand All @@ -64,7 +64,7 @@ private object RegistryDslSamples {

fun sampleRegisterWithScope() {
val item: TestItem = stub()
val identifier = Identifier("my", "item1")
val identifier = Identifier.of("my", "item1")

registryScope("my") {
Registries.ITEM {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ private object MapSerializationTests {
require(
encodesToJson(
codecCodec,
mapOf(Identifier("foo:bar") to "baz"),
mapOf(Identifier.parse("foo:bar") to "baz"),
"""{"foo:bar": "baz"}"""
)
)

require(
encodesToJson(
inlineCodecCodec,
mapOf(AllowedCodecInline(Identifier("foo:bar")) to "baz"),
mapOf(AllowedCodecInline(Identifier.parse("foo:bar")) to "baz"),
"""{"foo:bar": "baz"}"""
)
)
Expand All @@ -113,7 +113,7 @@ private object MapSerializationTests {
require(
decodesFromJson(
codecCodec,
mapOf(Identifier("foo:bar") to "baz"),
mapOf(Identifier.parse("foo:bar") to "baz"),
"""{"foo:bar": "baz"}"""
)
)
Expand All @@ -123,7 +123,7 @@ private object MapSerializationTests {
require(
decodesFromJson(
inlineCodecCodec,
mapOf(AllowedCodecInline(Identifier("foo:bar")) to "baz"),
mapOf(AllowedCodecInline(Identifier.parse("foo:bar")) to "baz"),
"""{"foo:bar": "baz"}"""
)
)
Expand Down
Loading