Play sound when totem is used

This commit is contained in:
Redned 2021-09-04 13:52:02 -05:00 committed by RednedEpic
parent 9f77d47f14
commit c1e66f306c

View file

@ -39,6 +39,8 @@ import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import java.util.concurrent.ThreadLocalRandom;
@Translator(packet = ServerEntityStatusPacket.class) @Translator(packet = ServerEntityStatusPacket.class)
public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntityStatusPacket> { public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntityStatusPacket> {
@ -158,6 +160,13 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
break; break;
case TOTEM_OF_UNDYING_MAKE_SOUND: case TOTEM_OF_UNDYING_MAKE_SOUND:
entityEventPacket.setType(EntityEventType.CONSUME_TOTEM); entityEventPacket.setType(EntityEventType.CONSUME_TOTEM);
PlaySoundPacket playSoundPacket = new PlaySoundPacket();
playSoundPacket.setSound("random.totem");
playSoundPacket.setPosition(entity.getPosition());
playSoundPacket.setVolume(1.0F);
playSoundPacket.setPitch(1.0F + (ThreadLocalRandom.current().nextFloat() * 0.1F) - 0.05F);
session.sendUpstreamPacket(playSoundPacket);
break; break;
case SHEEP_GRAZE_OR_TNT_CART_EXPLODE: case SHEEP_GRAZE_OR_TNT_CART_EXPLODE:
if (entity.getEntityType() == EntityType.SHEEP) { if (entity.getEntityType() == EntityType.SHEEP) {