From b9e0658035ae8a6cf7dd0073f66491e6b7322151 Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Wed, 9 Apr 2025 20:30:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A3=B0=E9=9F=B3=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/network/PacketConsumers.java | 26 ++++++++----------- gradle.properties | 4 +-- 2 files changed, 13 insertions(+), 17 deletions(-) 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 9e8efae00..6a37a7f87 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 @@ -1585,7 +1585,7 @@ public class PacketConsumers { event.setChanged(true); buf.clear(); buf.writeVarInt(event.packetID()); - buf.writeVarInt(id); + buf.writeVarInt(0); buf.writeKey(mapped); if (range != null) { buf.writeBoolean(true); @@ -1604,8 +1604,8 @@ public class PacketConsumers { } else { Optional optionalSound = FastNMS.INSTANCE.method$BuiltInRegistries$byId(Reflections.instance$BuiltInRegistries$SOUND_EVENT, id - 1); if (optionalSound.isEmpty()) return; - Object sound = optionalSound.get(); - Key soundId = Key.of(FastNMS.INSTANCE.method$SoundEvent$location(sound)); + Object soundEvent = optionalSound.get(); + Key soundId = Key.of(FastNMS.INSTANCE.method$SoundEvent$location(soundEvent)); int source = buf.readVarInt(); int x = buf.readInt(); int y = buf.readInt(); @@ -1615,20 +1615,15 @@ public class PacketConsumers { long seed = buf.readLong(); Key mapped = BukkitBlockManager.instance().replaceSoundIfExist(soundId); if (mapped != null) { - Optional mappedId = FastNMS.INSTANCE.method$BuiltInRegistries$getId( - Reflections.instance$BuiltInRegistries$SOUND_EVENT, - FastNMS.INSTANCE.method$SoundEvent$createVariableRangeEvent(KeyUtils.toResourceLocation(mapped)) - ); event.setChanged(true); buf.clear(); buf.writeVarInt(event.packetID()); - if (mappedId.isPresent()) { - buf.writeVarInt(mappedId.get() + 1); - } else { - buf.writeVarInt(0); - buf.writeKey(mapped); - buf.writeBoolean(false); - } + buf.writeVarInt(0); + Object newId = KeyUtils.toResourceLocation(mapped); + Object newSoundEvent = VersionHelper.isVersionNewerThan1_21_2() ? + Reflections.constructor$SoundEvent.newInstance(newId, Reflections.field$SoundEvent$fixedRange.get(soundEvent)) : + Reflections.constructor$SoundEvent.newInstance(newId, Reflections.field$SoundEvent$range.get(soundEvent), Reflections.field$SoundEvent$newSystem.get(soundEvent)); + FastNMS.INSTANCE.method$SoundEvent$directEncode(buf, newSoundEvent); buf.writeVarInt(source); buf.writeInt(x); buf.writeInt(y); @@ -1640,7 +1635,8 @@ public class PacketConsumers { } } catch (Exception e) { CraftEngine.instance().logger().warn("Failed to handle ClientboundSoundPacket", e); - }}; + } + }; // we handle it on packet level to prevent it from being captured by plugins public static final TriConsumer RENAME_ITEM = (user, event, packet) -> { diff --git a/gradle.properties b/gradle.properties index a0e502d0a..be12a461e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G # Project settings # Rule: [major update].[feature update].[bug fix] -project_version=0.0.46.1 +project_version=0.0.46.2 config_version=23 lang_version=4 project_group=net.momirealms @@ -51,7 +51,7 @@ byte_buddy_version=1.17.5 ahocorasick_version=0.6.3 snake_yaml_version=2.4 anti_grief_version=0.13 -nms_helper_version=0.51 +nms_helper_version=0.52 # Ignite Dependencies mixinextras_version=0.4.1 mixin_version=0.15.2+mixin.0.8.7