Search in sources :

Example 1 with SoundEventAccessor

use of me.basiqueevangelist.pingspam.mixin.SoundEventAccessor in project pingspam by BasiqueEvangelist.

the class PingSoundCommand method setPingSound.

private static int setPingSound(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
    ServerCommandSource src = ctx.getSource();
    ServerPlayerEntity player = src.getPlayer();
    Identifier soundId = IdentifierArgumentType.getIdentifier(ctx, "sound");
    SoundEvent event = Registry.SOUND_EVENT.getOrEmpty(soundId).orElseThrow(INVALID_SOUND::create);
    PlayerUtils.setPingSound(player, event);
    src.sendFeedback(new LiteralText("Set ping sound to ").formatted(Formatting.GREEN).append(new LiteralText(((SoundEventAccessor) PlayerUtils.getPingSound(player)).pingspam$getId().toString()).formatted(Formatting.YELLOW)).append(new LiteralText(".")), false);
    return 0;
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) Identifier(net.minecraft.util.Identifier) SoundEventAccessor(me.basiqueevangelist.pingspam.mixin.SoundEventAccessor) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LiteralText(net.minecraft.text.LiteralText)

Example 2 with SoundEventAccessor

use of me.basiqueevangelist.pingspam.mixin.SoundEventAccessor in project pingspam by BasiqueEvangelist.

the class PingSoundCommand method getPingSound.

private static int getPingSound(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
    ServerCommandSource src = ctx.getSource();
    ServerPlayerEntity player = src.getPlayer();
    if (PlayerUtils.getPingSound(player) != null) {
        src.sendFeedback(new LiteralText("Your current ping sound is ").formatted(Formatting.GREEN).append(new LiteralText(((SoundEventAccessor) PlayerUtils.getPingSound(player)).pingspam$getId().toString()).formatted(Formatting.YELLOW)).append(new LiteralText(".")), false);
    } else {
        src.sendFeedback(new LiteralText("You have disabled ping sounds.").formatted(Formatting.GREEN), false);
    }
    return 0;
}
Also used : SoundEventAccessor(me.basiqueevangelist.pingspam.mixin.SoundEventAccessor) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LiteralText(net.minecraft.text.LiteralText)

Aggregations

SoundEventAccessor (me.basiqueevangelist.pingspam.mixin.SoundEventAccessor)2 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 LiteralText (net.minecraft.text.LiteralText)2 SoundEvent (net.minecraft.sound.SoundEvent)1 Identifier (net.minecraft.util.Identifier)1