3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-27 08:30:10 +01:00

Read proper sound event type in 1.20.5->1.20.3

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-06-13 18:33:43 +02:00
Ursprung 0b38dc18a5
Commit 65d829065a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F

Datei anzeigen

@ -27,7 +27,9 @@ import com.viaversion.viabackwards.api.rewriters.StructuredEnchantmentRewriter;
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Holder;
import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.SoundEvent;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer; import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
@ -142,16 +144,17 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem
protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_5.PARTICLE, Types1_20_3.PARTICLE); // Small explosion particle protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_5.PARTICLE, Types1_20_3.PARTICLE); // Small explosion particle
protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_5.PARTICLE, Types1_20_3.PARTICLE); // Large explosion particle protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_5.PARTICLE, Types1_20_3.PARTICLE); // Large explosion particle
int soundId = wrapper.read(Types.VAR_INT) - 1; final Holder<SoundEvent> soundEventHolder = wrapper.read(Types.SOUND_EVENT);
if (soundId == -1) { if (soundEventHolder.isDirect()) {
// Already followed by the resource location final SoundEvent soundEvent = soundEventHolder.value();
return; wrapper.write(Types.STRING, soundEvent.identifier());
} wrapper.write(Types.OPTIONAL_FLOAT, soundEvent.fixedRange());
} else {
soundId = protocol.getMappingData().getSoundMappings().getNewId(soundId); final int soundId = protocol.getMappingData().getSoundMappings().getNewId(soundEventHolder.id());
final String soundKey = Protocol1_20_3To1_20_5.MAPPINGS.soundName(soundId); final String soundKey = Protocol1_20_3To1_20_5.MAPPINGS.soundName(soundId);
wrapper.write(Types.STRING, soundKey != null ? soundKey : "minecraft:entity.generic.explode"); wrapper.write(Types.STRING, soundKey != null ? soundKey : "minecraft:entity.generic.explode");
wrapper.write(Types.OPTIONAL_FLOAT, null); // Fixed range wrapper.write(Types.OPTIONAL_FLOAT, null); // Fixed range
}
}); });
protocol.registerClientbound(ClientboundPackets1_20_5.MERCHANT_OFFERS, wrapper -> { protocol.registerClientbound(ClientboundPackets1_20_5.MERCHANT_OFFERS, wrapper -> {