Add nms for 1.21.2 & 1.21.3

updated nms for 1.21R1
version up to 1.6.7
This commit is contained in:
alexcrea 2024-10-26 16:24:56 +02:00
parent 50f8a37d8b
commit e231f0ad7b
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
7 changed files with 83 additions and 3 deletions

View file

@ -15,7 +15,7 @@ plugins {
} }
group = "xyz.alexcrea" group = "xyz.alexcrea"
version = "1.6.6" version = "1.6.7"
repositories { repositories {
// EcoEnchants // EcoEnchants
@ -57,6 +57,7 @@ dependencies {
implementation(project(":nms:v1_20R3", configuration = "reobf")) implementation(project(":nms:v1_20R3", configuration = "reobf"))
implementation(project(":nms:v1_20R4", configuration = "reobf")) implementation(project(":nms:v1_20R4", configuration = "reobf"))
implementation(project(":nms:v1_21R1", configuration = "reobf")) implementation(project(":nms:v1_21R1", configuration = "reobf"))
implementation(project(":nms:v1_21R2", configuration = "reobf"))
// include kotlin for the offline jar // include kotlin for the offline jar
implementation(kotlin("stdlib")) implementation(kotlin("stdlib"))

View file

@ -11,7 +11,7 @@ dependencies {
implementation(project(":nms:nms-common")) implementation(project(":nms:nms-common"))
// Used for nms // Used for nms
paperweight.paperDevBundle("1.21-R0.1-SNAPSHOT") // 1.21.1 userdev did not release yet but still use R1 paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT")
} }
repositories { repositories {

View file

@ -8,7 +8,7 @@ class v1_21R1_ExternGuiTester: ExternGuiTester {
override val wesjdAnvilGuiName = "Wrapper1_21_R1" override val wesjdAnvilGuiName = "Wrapper1_21_R1"
override fun getContainerClass(view: InventoryView): Class<Any>? { override fun getContainerClass(view: InventoryView): Class<Any>? {
if(view !is CraftInventoryView<*>) return null if(view !is CraftInventoryView<*, *>) return null
val container = view.handle val container = view.handle
return container.javaClass return container.javaClass

View file

@ -0,0 +1,43 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.21.3-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// minecraft 1.21 java version is 21.
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "21"
targetCompatibility = "21"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_21)
}
}

View file

@ -0,0 +1,33 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_21R2_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -34,3 +34,5 @@ include("nms:v1_20R4")
findProject(":nms:v1_20R4")?.name = "v1_20R4" findProject(":nms:v1_20R4")?.name = "v1_20R4"
include("nms:v1_21R1") include("nms:v1_21R1")
findProject(":nms:v1_21R1")?.name = "v1_21R1" findProject(":nms:v1_21R1")?.name = "v1_21R1"
include("nms:v1_21R2")
findProject(":nms:v1_21R2")?.name = "v1_21R2"

View file

@ -55,6 +55,7 @@ object PacketManagerSelector {
21 -> when (versionParts[2]) { 21 -> when (versionParts[2]) {
0, 1 -> V1_21R1_PacketManager() 0, 1 -> V1_21R1_PacketManager()
2, 3 -> V1_21R2_PacketManager()
else -> null else -> null
} }