Skip to content

Commit 0b616a8

Browse files
authored
Merge pull request #559 from EmptyIrony/dev/6.2.3
#558 和ItemBuilder的catch
2 parents c432a59 + 6aa76ba commit 0b616a8

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

module/bukkit/bukkit-ui/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ dependencies {
1212
compileOnly("ink.ptms.core:v11600:11600-minimize")
1313
compileOnly("ink.ptms.core:v11200:11200-minimize")
1414
compileOnly("ink.ptms.core:v10900:10900")
15+
// 降低依赖权重 避免编译报错
16+
compileOnly("ink.ptms.core:v12104:12104-minimize:mapped")
1517
// 版本实现
1618
compileOnly(project(":module:bukkit:bukkit-ui:bukkit-ui-12100"))
1719
compileOnly(project(":module:bukkit:bukkit-ui:bukkit-ui-legacy"))

module/bukkit/bukkit-ui/src/main/kotlin/taboolib/module/ui/virtual/InventoryHandlerImpl.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,11 @@ class InventoryHandlerImpl : InventoryHandler() {
217217
}
218218

219219
override fun sendCarriedChange(itemStack: ItemStack) {
220-
sendSlotChange(-1, itemStack)
220+
if (MinecraftVersion.versionId >= 12104) {
221+
viewer.sendPacket(NMSPacketPlayOutSetCursorItem(Craft19ItemStack.asNMSCopy(itemStack)))
222+
} else {
223+
sendSlotChange(-1, itemStack)
224+
}
221225
}
222226

223227
fun sendDataChange(slot: Int, state: Int) {
@@ -438,6 +442,8 @@ private typealias NMSPacketPlayOutWindowItems = net.minecraft.network.protocol.g
438442

439443
private typealias NMSPacketPlayOutSetSlot = net.minecraft.network.protocol.game.PacketPlayOutSetSlot
440444

445+
private typealias NMSPacketPlayOutSetCursorItem = net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket
446+
441447
private typealias NMSPacketPlayOutWindowData = net.minecraft.network.protocol.game.PacketPlayOutWindowData
442448

443449
private typealias NMSPacketPlayOutCloseWindow = net.minecraft.network.protocol.game.PacketPlayOutCloseWindow

module/bukkit/bukkit-util/src/main/kotlin/taboolib/platform/util/ItemBuilder.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ open class ItemBuilder {
304304
// Tooltip Style
305305
try {
306306
itemMeta.tooltipStyle = tooltipStyle
307-
} catch (_: NoSuchMethodException) {
307+
} catch (_: NoSuchMethodError) {
308308
}
309309
// ItemModel
310310
try {
311311
itemMeta.itemModel = itemModel
312-
} catch (_: NoSuchMethodException) {
312+
} catch (_: NoSuchMethodError) {
313313
}
314314
// 唯一化
315315
try {
@@ -413,17 +413,17 @@ open class ItemBuilder {
413413
} else {
414414
modelData?.getProperty<Any>("handle")?.getProperty<List<Float>>("floats")?.firstOrNull()?.cint ?: -1
415415
}
416-
} catch (ignored: NoSuchFieldException) {
416+
} catch (ignored: NoSuchMethodError) {
417417
}
418418
// Tooltip Style
419419
try {
420420
tooltipStyle = itemMeta.tooltipStyle
421-
} catch (ignored: NoSuchFieldException) {
421+
} catch (ignored: NoSuchMethodError) {
422422
}
423423
// ItemModel
424424
try {
425425
itemModel = itemMeta.itemModel
426-
} catch (ignored: NoSuchFieldException) {
426+
} catch (ignored: NoSuchMethodError) {
427427
}
428428
}
429429
}

0 commit comments

Comments
 (0)