Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Handle new Pumpkin Carve sound & handle new StopSound packet
Dieser Commit ist enthalten in:
Ursprung
195b89f24c
Commit
ff5bb8acc6
@ -11,6 +11,7 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.EntityPackets;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets;
|
||||
@ -285,8 +286,25 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
registerOutgoing(State.PLAY, 0x46, 0x48);
|
||||
registerOutgoing(State.PLAY, 0x47, 0x49);
|
||||
registerOutgoing(State.PLAY, 0x48, 0x4A);
|
||||
// New packet 0x4A - Stop sound (TODO: Migrate from Plugin Messages)
|
||||
registerOutgoing(State.PLAY, 0x49, 0x4C);
|
||||
|
||||
// Sound Effect packet
|
||||
registerOutgoing(State.PLAY, 0x49, 0x4C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Sound ID
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int soundId = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
// Handle new 'Pumpkin Carve' sound
|
||||
if (soundId >= 86)
|
||||
wrapper.set(Type.VAR_INT, 0, soundId + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x4A, 0x4D);
|
||||
registerOutgoing(State.PLAY, 0x4B, 0x4E);
|
||||
registerOutgoing(State.PLAY, 0x4C, 0x4F);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2;
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
@ -0,0 +1,30 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SoundSource {
|
||||
MASTER("master", 0),
|
||||
MUSIC("music", 1),
|
||||
RECORD("record", 2),
|
||||
WEATHER("weather", 3),
|
||||
BLOCK("block", 4),
|
||||
HOSTILE("hostile", 5),
|
||||
NEUTRAL("neutral", 6),
|
||||
PLAYER("player", 7),
|
||||
AMBIENT("ambient", 8),
|
||||
VOICE("voice", 9);
|
||||
|
||||
private final String name;
|
||||
private final int id;
|
||||
|
||||
public static Optional<SoundSource> findBySource(String source) {
|
||||
for (SoundSource item : SoundSource.values())
|
||||
if (item.getName().equalsIgnoreCase(source))
|
||||
return Optional.of(item);
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.google.common.base.Optional;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
@ -9,7 +10,8 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.SoundSource;
|
||||
|
||||
public class InventoryPackets {
|
||||
private static String NBT_TAG_NAME;
|
||||
@ -67,8 +69,37 @@ public class InventoryPackets {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// TODO: StopSound?
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
String channel = wrapper.get(Type.STRING, 0);
|
||||
// Handle stopsound change
|
||||
if (channel.equalsIgnoreCase("MC|StopSound")) {
|
||||
String originalSource = wrapper.read(Type.STRING);
|
||||
String originalSound = wrapper.read(Type.STRING);
|
||||
|
||||
// Reset the packet
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(0x4B);
|
||||
|
||||
byte flags = 0;
|
||||
wrapper.write(Type.BYTE, flags); // Placeholder
|
||||
if (!originalSource.isEmpty()) {
|
||||
flags |= 1;
|
||||
Optional<SoundSource> finalSource = SoundSource.findBySource(originalSource);
|
||||
if (!finalSource.isPresent()) {
|
||||
System.out.println("Could not handle unknown sound source " + originalSource + " falling back to default: master");
|
||||
finalSource = Optional.of(SoundSource.MASTER);
|
||||
}
|
||||
|
||||
System.out.println(finalSource.get());
|
||||
wrapper.write(Type.VAR_INT, finalSource.get().getId());
|
||||
}
|
||||
if (!originalSound.isEmpty()) {
|
||||
flags |= 2;
|
||||
wrapper.write(Type.STRING, originalSound);
|
||||
}
|
||||
|
||||
wrapper.set(Type.BYTE, 0, flags); // Update flags
|
||||
}
|
||||
if (channel.equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
|
@ -15,7 +15,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren