9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 12:29:15 +00:00

一些改进

This commit is contained in:
XiaoMoMi
2025-06-13 16:47:25 +08:00
parent d775349b8b
commit f2ad6f2ba1
4 changed files with 8 additions and 5 deletions

View File

@@ -64,7 +64,8 @@ public class LegacyNetworkItemHandler implements NetworkItemHandler<ItemStack> {
return new OtherItem(wrapped, false).process();
} else {
BukkitCustomItem customItem = (BukkitCustomItem) optionalCustomItem.get();
boolean hasDifferentMaterial = FastNMS.INSTANCE.method$ItemStack$getItem(wrapped.getLiteralObject()) != customItem.clientItem();
Object serverItem = FastNMS.INSTANCE.method$ItemStack$getItem(wrapped.getLiteralObject());
boolean hasDifferentMaterial = serverItem == customItem.item() && serverItem != customItem.clientItem();
if (hasDifferentMaterial) {
wrapped = wrapped.unsafeTransmuteCopy(customItem.clientItem(), wrapped.count());
}

View File

@@ -66,7 +66,8 @@ public final class ModernNetworkItemHandler implements NetworkItemHandler<ItemSt
return new OtherItem(wrapped, false).process();
} else {
BukkitCustomItem customItem = (BukkitCustomItem) optionalCustomItem.get();
boolean hasDifferentMaterial = FastNMS.INSTANCE.method$ItemStack$getItem(wrapped.getLiteralObject()) != customItem.clientItem();
Object serverItem = FastNMS.INSTANCE.method$ItemStack$getItem(wrapped.getLiteralObject());
boolean hasDifferentMaterial = serverItem == customItem.item() && serverItem != customItem.clientItem();
if (hasDifferentMaterial) {
wrapped = wrapped.unsafeTransmuteCopy(customItem.clientItem(), wrapped.count());
}