From e4196cf5592c0932a7f1915ad691ccaa2b712c7e Mon Sep 17 00:00:00 2001 From: jhqwqmc <2110242767@qq.com> Date: Thu, 5 Jun 2025 22:22:19 +0800 Subject: [PATCH] =?UTF-8?q?perf(entity):=20=E6=9C=80=E7=BB=88=E7=9A=84?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 已测试 1.20.1 1.20.4 1.21.4 --- .../entity/furniture/BukkitFurniture.java | 6 +- .../plugin/network/PacketConsumers.java | 58 +++++++++---------- .../reflection/minecraft/CoreReflections.java | 4 ++ .../minecraft/NetworkReflections.java | 36 +++++++++--- 4 files changed, 63 insertions(+), 41 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/furniture/BukkitFurniture.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/furniture/BukkitFurniture.java index 8bd6ccf01..8f4df2e9c 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/furniture/BukkitFurniture.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/furniture/BukkitFurniture.java @@ -366,8 +366,8 @@ public class BukkitFurniture implements Furniture { try { Object trackedEntity = FastNMS.INSTANCE.field$Entity$trackedEntity(nmsEntity); Object serverEntity = FastNMS.INSTANCE.filed$ChunkMap$TrackedEntity$serverEntity(trackedEntity); - CoreReflections.handle$ServerEntity$broadcastSetter.invoke(serverEntity, Handlers.DO_NOTHING); - CoreReflections.handle$ServerEntity$updateIntervalSetter.invoke(serverEntity, Integer.MAX_VALUE); + CoreReflections.handle$ServerEntity$broadcastSetter.invokeExact(serverEntity, Handlers.DO_NOTHING); + CoreReflections.handle$ServerEntity$updateIntervalSetter.invokeExact(serverEntity, Integer.MAX_VALUE); } catch (Throwable e) { CraftEngine.instance().logger().warn("Failed to inject collider", e); } @@ -375,7 +375,7 @@ public class BukkitFurniture implements Furniture { @FunctionalInterface public interface Handlers extends Consumer { - Handlers DO_NOTHING = doNothing(); + Consumer DO_NOTHING = doNothing(); static Handlers doNothing() { return (packet) -> {}; diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/network/PacketConsumers.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/network/PacketConsumers.java index 0bf9daee7..a11ce2e94 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/network/PacketConsumers.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/network/PacketConsumers.java @@ -1169,14 +1169,14 @@ public class PacketConsumers { public static final TriConsumer HELLO_C2S = (user, event, packet) -> { try { BukkitServerPlayer player = (BukkitServerPlayer) user; - String name = (String) NetworkReflections.handle$ServerboundHelloPacket$nameGetter.invoke(packet); + String name = (String) NetworkReflections.handle$ServerboundHelloPacket$nameGetter.invokeExact(packet); player.setName(name); if (VersionHelper.isOrAbove1_20_2()) { - UUID uuid = (UUID) NetworkReflections.handle$ServerboundHelloPacket$uuidGetter.invoke(packet); + UUID uuid = (UUID) NetworkReflections.handle$ServerboundHelloPacket$uuidGetter.invokeExact(packet); player.setUUID(uuid); } else { @SuppressWarnings("unchecked") - Optional uuid = (Optional) NetworkReflections.handle$ServerboundHelloPacket$uuidGetter.invoke(packet); + Optional uuid = (Optional) NetworkReflections.handle$ServerboundHelloPacket$uuidGetter.invokeExact(packet); if (uuid.isPresent()) { player.setUUID(uuid.get()); } else { @@ -1220,10 +1220,10 @@ public class PacketConsumers { player.clearView(); Object dimensionKey; if (!VersionHelper.isOrAbove1_20_2()) { - dimensionKey = NetworkReflections.handle$ClientboundRespawnPacket$dimensionGetter.invoke(packet); + dimensionKey = NetworkReflections.handle$ClientboundRespawnPacket$dimensionGetter.invokeExact(packet); } else { - Object commonInfo = NetworkReflections.handle$ClientboundRespawnPacket$commonPlayerSpawnInfoGetter.invoke(packet); - dimensionKey = NetworkReflections.handle$CommonPlayerSpawnInfo$dimensionGetter.invoke(commonInfo); + Object commonInfo = NetworkReflections.handle$ClientboundRespawnPacket$commonPlayerSpawnInfoGetter.invokeExact(packet); + dimensionKey = NetworkReflections.handle$CommonPlayerSpawnInfo$dimensionGetter.invokeExact(commonInfo); } Object location = FastNMS.INSTANCE.field$ResourceKey$location(dimensionKey); World world = Bukkit.getWorld(Objects.requireNonNull(NamespacedKey.fromString(location.toString()))); @@ -1248,10 +1248,10 @@ public class PacketConsumers { if (BukkitNetworkManager.hasViaVersion()) { user.setProtocolVersion(CraftEngine.instance().compatibilityManager().getPlayerProtocolVersion(player.uuid())); } - dimensionKey = NetworkReflections.handle$ClientboundLoginPacket$dimensionGetter.invoke(packet); + dimensionKey = NetworkReflections.handle$ClientboundLoginPacket$dimensionGetter.invokeExact(packet); } else { - Object commonInfo = NetworkReflections.handle$ClientboundLoginPacket$commonPlayerSpawnInfoGetter.invoke(packet); - dimensionKey = NetworkReflections.handle$CommonPlayerSpawnInfo$dimensionGetter.invoke(commonInfo); + Object commonInfo = NetworkReflections.handle$ClientboundLoginPacket$commonPlayerSpawnInfoGetter.invokeExact(packet); + dimensionKey = NetworkReflections.handle$CommonPlayerSpawnInfo$dimensionGetter.invokeExact(commonInfo); } Object location = FastNMS.INSTANCE.field$ResourceKey$location(dimensionKey); World world = Bukkit.getWorld(Objects.requireNonNull(NamespacedKey.fromString(location.toString()))); @@ -1295,9 +1295,9 @@ public class PacketConsumers { Player bukkitPlayer = player.platformPlayer(); if (bukkitPlayer == null) return; if (bukkitPlayer.getGameMode() != GameMode.CREATIVE) return; - int slot = (int) NetworkReflections.handle$ServerboundSetCreativeModeSlotPacket$slotNumGetter.invoke(packet); + int slot = VersionHelper.isOrAbove1_20_5() ? (short) NetworkReflections.handle$ServerboundSetCreativeModeSlotPacket$slotNumGetter.invokeExact(packet) : (int) NetworkReflections.handle$ServerboundSetCreativeModeSlotPacket$slotNumGetter.invokeExact(packet); if (slot < 36 || slot > 44) return; - ItemStack item = FastNMS.INSTANCE.method$CraftItemStack$asCraftMirror(NetworkReflections.handle$ServerboundSetCreativeModeSlotPacket$itemStackGetter.invoke(packet)); + ItemStack item = FastNMS.INSTANCE.method$CraftItemStack$asCraftMirror(NetworkReflections.handle$ServerboundSetCreativeModeSlotPacket$itemStackGetter.invokeExact(packet)); if (ItemUtils.isEmpty(item)) return; if (slot - 36 != bukkitPlayer.getInventory().getHeldItemSlot()) { return; @@ -1370,7 +1370,7 @@ public class PacketConsumers { if (!user.isOnline()) return; Player player = (Player) user.platformPlayer(); if (player == null) return; - Object pos = NetworkReflections.handle$ServerboundPickItemFromBlockPacket$posGetter.invoke(packet); + Object pos = NetworkReflections.handle$ServerboundPickItemFromBlockPacket$posGetter.invokeExact(packet); if (VersionHelper.isFolia()) { int x = FastNMS.INSTANCE.field$Vec3i$x(pos); int z = FastNMS.INSTANCE.field$Vec3i$z(pos); @@ -1408,7 +1408,7 @@ public class PacketConsumers { // 1.21.4+ public static final TriConsumer PICK_ITEM_FROM_ENTITY = (user, event, packet) -> { try { - int entityId = (int) NetworkReflections.handle$ServerboundPickItemFromEntityPacket$idGetter.invoke(packet); + int entityId = (int) NetworkReflections.handle$ServerboundPickItemFromEntityPacket$idGetter.invokeExact(packet); BukkitFurniture furniture = BukkitFurnitureManager.instance().loadedFurnitureByEntityId(entityId); if (furniture == null) return; Player player = (Player) user.platformPlayer(); @@ -1450,11 +1450,11 @@ public class PacketConsumers { assert CoreReflections.method$ServerGamePacketListenerImpl$tryPickItem != null; if (VersionHelper.isOrAbove1_21_5()) { CoreReflections.method$ServerGamePacketListenerImpl$tryPickItem.invoke( - CoreReflections.handle$ServerPlayer$connectionGetter.invoke(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)), + CoreReflections.handle$ServerPlayer$connectionGetter.invokeExact(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)), FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(itemStack), blockPos, entity, true); } else { CoreReflections.method$ServerGamePacketListenerImpl$tryPickItem.invoke( - CoreReflections.handle$ServerPlayer$connectionGetter.invoke(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)), FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(itemStack)); + CoreReflections.handle$ServerPlayer$connectionGetter.invokeExact(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)), FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(itemStack)); } } @@ -1519,7 +1519,7 @@ public class PacketConsumers { } BukkitFurniture furniture = BukkitFurnitureManager.instance().loadedFurnitureByEntityId(entityId); if (furniture == null) return; - Object action = NetworkReflections.handle$ServerboundInteractPacket$actionGetter.invoke(packet); + Object action = NetworkReflections.handle$ServerboundInteractPacket$actionGetter.invokeExact(packet); Object actionType = NetworkReflections.method$ServerboundInteractPacket$Action$getType.invoke(action); if (actionType == null) return; Location location = furniture.baseEntity().getLocation(); @@ -1552,9 +1552,9 @@ public class PacketConsumers { InteractionHand hand; Location interactionPoint; try { - Object interactionHand = NetworkReflections.handle$ServerboundInteractPacket$InteractionAtLocationAction$handGetter.invoke(action); + Object interactionHand = NetworkReflections.handle$ServerboundInteractPacket$InteractionAtLocationAction$handGetter.invokeExact(action); hand = interactionHand == CoreReflections.instance$InteractionHand$MAIN_HAND ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; - Object vec3 = NetworkReflections.handle$ServerboundInteractPacket$InteractionAtLocationAction$locationGetter.invoke(action); + Object vec3 = NetworkReflections.handle$ServerboundInteractPacket$InteractionAtLocationAction$locationGetter.invokeExact(action); double x = FastNMS.INSTANCE.field$Vec3$x(vec3); double y = FastNMS.INSTANCE.field$Vec3$y(vec3); @@ -1696,14 +1696,14 @@ public class PacketConsumers { if (((BukkitServerPlayer) user).hasPermission(FontManager.BYPASS_ANVIL)) { return; } - String message = (String) NetworkReflections.handle$ServerboundRenameItemPacket$nameGetter.invoke(packet); + String message = (String) NetworkReflections.handle$ServerboundRenameItemPacket$nameGetter.invokeExact(packet); if (message != null && !message.isEmpty()) { // check bypass FontManager manager = CraftEngine.instance().fontManager(); IllegalCharacterProcessResult result = manager.processIllegalCharacters(message); if (result.has()) { try { - NetworkReflections.handle$ServerboundRenameItemPacket$nameSetter.invoke(packet, result.text()); + NetworkReflections.handle$ServerboundRenameItemPacket$nameSetter.invokeExact(packet, result.text()); } catch (ReflectiveOperationException e) { CraftEngine.instance().logger().warn("Failed to replace chat", e); } @@ -1722,7 +1722,7 @@ public class PacketConsumers { if (((BukkitServerPlayer) user).hasPermission(FontManager.BYPASS_SIGN)) { return; } - String[] lines = (String[]) NetworkReflections.handle$ServerboundSignUpdatePacket$linesGetter.invoke(packet); + String[] lines = (String[]) NetworkReflections.handle$ServerboundSignUpdatePacket$linesGetter.invokeExact(packet); FontManager manager = CraftEngine.instance().fontManager(); if (!manager.isDefaultFontInUse()) return; for (int i = 0; i < lines.length; i++) { @@ -1753,9 +1753,9 @@ public class PacketConsumers { boolean changed = false; - List pages = (List) NetworkReflections.handleServerboundEditBookPacket$pagesGetter.invoke(packet); + List pages = (List) NetworkReflections.handleServerboundEditBookPacket$pagesGetter.invokeExact(packet); List newPages = new ArrayList<>(pages.size()); - Optional title = (Optional) NetworkReflections.handle$ServerboundEditBookPacket$titleGetter.invoke(packet); + Optional title = (Optional) NetworkReflections.handle$ServerboundEditBookPacket$titleGetter.invokeExact(packet); Optional newTitle; if (title.isPresent()) { @@ -1779,7 +1779,7 @@ public class PacketConsumers { if (changed) { Object newPacket = NetworkReflections.constructor$ServerboundEditBookPacket.newInstance( - NetworkReflections.handle$ServerboundEditBookPacket$slotGetter.invoke(packet), + (int) NetworkReflections.handle$ServerboundEditBookPacket$slotGetter.invokeExact(packet), newPages, newTitle ); @@ -1812,7 +1812,7 @@ public class PacketConsumers { public static final TriConsumer CUSTOM_PAYLOAD = (user, event, packet) -> { try { if (!VersionHelper.isOrAbove1_20_5()) return; - Object payload = NetworkReflections.handle$ServerboundCustomPayloadPacket$payloadGetter.invoke(packet); + Object payload = NetworkReflections.handle$ServerboundCustomPayloadPacket$payloadGetter.invokeExact(packet); if (NetworkReflections.clazz$DiscardedPayload.isInstance(payload)) { Payload discardedPayload = DiscardedPayload.from(payload); if (discardedPayload == null || !discardedPayload.channel().equals(NetworkManager.MOD_CHANNEL_KEY)) @@ -2231,7 +2231,7 @@ public class PacketConsumers { public static final TriConsumer HANDSHAKE_C2S = (user, event, packet) -> { try { if (BukkitNetworkManager.hasViaVersion()) return; - int protocolVersion = (int) NetworkReflections.handle$ClientIntentionPacket$protocolVersionGetter.invoke(packet); + int protocolVersion = (int) NetworkReflections.handle$ClientIntentionPacket$protocolVersionGetter.invokeExact(packet); user.setProtocolVersion(protocolVersion); } catch (Throwable e) { CraftEngine.instance().logger().warn("Failed to handle ClientIntentionPacket", e); @@ -2251,7 +2251,7 @@ public class PacketConsumers { public static final TriConsumer RESOURCE_PACK_RESPONSE = (user, event, packet) -> { try { if (user.sentResourcePack() || !Config.sendPackOnJoin() || !Config.kickOnDeclined()) return; - Object action = NetworkReflections.handle$ServerboundResourcePackPacket$actionGetter.invoke(packet); + Object action = NetworkReflections.handle$ServerboundResourcePackPacket$actionGetter.invokeExact(packet); if (action == null) return; if (action == NetworkReflections.instance$ServerboundResourcePackPacket$Action$DECLINED || action == NetworkReflections.instance$ServerboundResourcePackPacket$Action$FAILED_DOWNLOAD) { @@ -2273,9 +2273,9 @@ public class PacketConsumers { try { Object player = user.serverPlayer(); if (player == null) return; - int entityId = (int) NetworkReflections.handle$ClientboundEntityEventPacket$entityIdGetter.invoke(packet); + int entityId = (int) NetworkReflections.handle$ClientboundEntityEventPacket$entityIdGetter.invokeExact(packet); if (entityId != FastNMS.INSTANCE.method$Entity$getId(player)) return; - byte eventId = (byte) NetworkReflections.handle$ClientboundEntityEventPacket$eventIdGetter.invoke(packet); + byte eventId = (byte) NetworkReflections.handle$ClientboundEntityEventPacket$eventIdGetter.invokeExact(packet); if (eventId >= 24 && eventId <= 28) { CraftEngine.instance().fontManager().refreshEmojiSuggestions(user.uuid()); } diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/CoreReflections.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/CoreReflections.java index 6bfc980cb..986c58c50 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/CoreReflections.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/CoreReflections.java @@ -12,6 +12,7 @@ import net.momirealms.craftengine.core.util.VersionHelper; import java.io.BufferedReader; import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodType; import java.lang.invoke.VarHandle; import java.lang.reflect.*; import java.util.*; @@ -3275,13 +3276,16 @@ public final class CoreReflections { public static final MethodHandle handle$ServerEntity$broadcastSetter = requireNonNull( ReflectionUtils.unreflectSetter(field$ServerEntity$broadcast) + .asType(MethodType.methodType(void.class, Object.class, Consumer.class)) ); public static final MethodHandle handle$ServerEntity$updateIntervalSetter = requireNonNull( ReflectionUtils.unreflectSetter(field$ServerEntity$updateInterval) + .asType(MethodType.methodType(void.class, Object.class, int.class)) ); public static final MethodHandle handle$ServerPlayer$connectionGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerPlayer$connection) + .asType(MethodType.methodType(Object.class, Object.class)) ); } diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/NetworkReflections.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/NetworkReflections.java index c2dc38105..83ff087e5 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/NetworkReflections.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/reflection/minecraft/NetworkReflections.java @@ -6,6 +6,7 @@ import net.momirealms.craftengine.core.util.ReflectionUtils; import net.momirealms.craftengine.core.util.VersionHelper; import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodType; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -969,7 +970,7 @@ public final class NetworkReflections { ); public static final Field field$ServerboundEditBookPacket$slot = requireNonNull( - ReflectionUtils.getDeclaredField(clazz$ServerboundEditBookPacket, int.class, 0) + ReflectionUtils.getDeclaredField(clazz$ServerboundEditBookPacket, int.class, VersionHelper.isOrAbove1_20_5() ? 0 : 4) ); public static final Field field$ServerboundEditBookPacket$pages = requireNonNull( @@ -1297,102 +1298,119 @@ public final class NetworkReflections { public static final MethodHandle handle$ServerboundRenameItemPacket$nameGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundRenameItemPacket$name) + .asType(MethodType.methodType(String.class, Object.class)) ); public static final MethodHandle handle$ServerboundRenameItemPacket$nameSetter = requireNonNull( ReflectionUtils.unreflectSetter(field$ServerboundRenameItemPacket$name) + .asType(MethodType.methodType(void.class, Object.class, String.class)) ); public static final MethodHandle handle$ServerboundHelloPacket$nameGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundHelloPacket$name) + .asType(MethodType.methodType(String.class, Object.class)) ); public static final MethodHandle handle$ServerboundHelloPacket$uuidGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundHelloPacket$uuid) + .asType(MethodType.methodType(VersionHelper.isOrAbove1_20_2() ? UUID.class : Optional.class, Object.class)) ); public static final MethodHandle handle$ClientboundRespawnPacket$dimensionGetter = Optional.ofNullable(field$ClientboundRespawnPacket$dimension) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(Object.class, Object.class))) .orElse(null); public static final MethodHandle handle$ClientboundRespawnPacket$commonPlayerSpawnInfoGetter = Optional.ofNullable(field$ClientboundRespawnPacket$commonPlayerSpawnInfo) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(Object.class, Object.class))) .orElse(null); public static final MethodHandle handle$CommonPlayerSpawnInfo$dimensionGetter = Optional.ofNullable(field$CommonPlayerSpawnInfo$dimension) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(Object.class, Object.class))) .orElse(null); public static final MethodHandle handle$ClientboundLoginPacket$dimensionGetter = Optional.ofNullable(field$ClientboundLoginPacket$dimension) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(Object.class, Object.class))) .orElse(null); public static final MethodHandle handle$ClientboundLoginPacket$commonPlayerSpawnInfoGetter = Optional.ofNullable(field$ClientboundLoginPacket$commonPlayerSpawnInfo) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(Object.class, Object.class))) .orElse(null); public static final MethodHandle handle$ServerboundSetCreativeModeSlotPacket$itemStackGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundSetCreativeModeSlotPacket$itemStack) + .asType(MethodType.methodType(Object.class, Object.class)) ); public static final MethodHandle handle$ServerboundSetCreativeModeSlotPacket$slotNumGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundSetCreativeModeSlotPacket$slotNum) + .asType(MethodType.methodType(VersionHelper.isOrAbove1_20_5() ? short.class : int.class, Object.class)) ); public static final MethodHandle handle$ServerboundPickItemFromBlockPacket$posGetter = Optional.ofNullable(field$ServerboundPickItemFromBlockPacket$pos) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(Object.class, Object.class))) .orElse(null); public static final MethodHandle handle$ServerboundPickItemFromEntityPacket$idGetter = Optional.ofNullable(field$ServerboundPickItemFromEntityPacket$id) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(int.class, Object.class))) .orElse(null); public static final MethodHandle handle$ServerboundInteractPacket$actionGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundInteractPacket$action) + .asType(MethodType.methodType(Object.class, Object.class)) ); public static final MethodHandle handle$ServerboundInteractPacket$InteractionAtLocationAction$handGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundInteractPacket$InteractionAtLocationAction$hand) + .asType(MethodType.methodType(Object.class, Object.class)) ); public static final MethodHandle handle$ServerboundInteractPacket$InteractionAtLocationAction$locationGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundInteractPacket$InteractionAtLocationAction$location) + .asType(MethodType.methodType(Object.class, Object.class)) ); public static final MethodHandle handle$ServerboundSignUpdatePacket$linesGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundSignUpdatePacket$lines) + .asType(MethodType.methodType(String[].class, Object.class)) ); public static final MethodHandle handleServerboundEditBookPacket$pagesGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundEditBookPacket$pages) + .asType(MethodType.methodType(List.class, Object.class)) ); public static final MethodHandle handle$ServerboundEditBookPacket$titleGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundEditBookPacket$title) + .asType(MethodType.methodType(Optional.class, Object.class)) ); public static final MethodHandle handle$ServerboundEditBookPacket$slotGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundEditBookPacket$slot) + .asType(MethodType.methodType(int.class, Object.class)) ); public static final MethodHandle handle$ServerboundCustomPayloadPacket$payloadGetter = Optional.ofNullable(field$ServerboundCustomPayloadPacket$payload) - .map(ReflectionUtils::unreflectGetter) + .map(it -> ReflectionUtils.unreflectGetter(it).asType(MethodType.methodType(Object.class, Object.class))) .orElse(null); public static final MethodHandle handle$ServerboundResourcePackPacket$actionGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ServerboundResourcePackPacket$action) + .asType(MethodType.methodType(Object.class, Object.class)) ); public static final MethodHandle handle$ClientboundEntityEventPacket$entityIdGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ClientboundEntityEventPacket$entityId) + .asType(MethodType.methodType(int.class, Object.class)) ); public static final MethodHandle handle$ClientboundEntityEventPacket$eventIdGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ClientboundEntityEventPacket$eventId) + .asType(MethodType.methodType(byte.class, Object.class)) ); public static final MethodHandle handle$ClientIntentionPacket$protocolVersionGetter = requireNonNull( ReflectionUtils.unreflectGetter(field$ClientIntentionPacket$protocolVersion) + .asType(MethodType.methodType(int.class, Object.class)) ); }