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

声音重构

This commit is contained in:
XiaoMoMi
2025-04-09 20:30:31 +08:00
parent 7f84de0862
commit b9e0658035
2 changed files with 13 additions and 17 deletions

View File

@@ -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<Object> 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<Integer> 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<NetWorkUser, NMSPacketEvent, Object> RENAME_ITEM = (user, event, packet) -> {

View File

@@ -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