/* * Copyright (c) Forge Development LLC and contributors * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.event; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.Holder; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Objects; /** * PlayLevelSoundEvent is fired when a sound is played on a {@link Level}. * This event is fired from {@link Level#playSound}, {@link Level#playSeededSound}, and {@link LocalPlayer#playSound}. *
* {@link #getLevel()} contains the level the sound is being played in. * {@link #getSound()} contains the sound event to be played. * {@link #getOriginalVolume()} contains the original volume for the sound to be played at. * {@link #getOriginalPitch()} contains the original pitch for the sound to be played at. * {@link #getNewVolume()} contains the volume the sound will be played at. * {@link #getNewPitch()} contains the pitch the sound will be played at. *
* This event is {@link Cancelable cancelable}. * If this event is canceled, the sound is not played. *
* This event does not have a result. *
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/
@Cancelable
public class PlayLevelSoundEvent extends Event
{
private final Level level;
private final float originalVolume;
private final float originalPitch;
private Holder
* This event is {@link Cancelable cancelable}.
* If this event is canceled, the sound is not played.
*
* This event does not have a result.
*
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/
public static class AtEntity extends PlayLevelSoundEvent
{
private final Entity entity;
public AtEntity(Entity entity, Holder
* This event is {@link Cancelable cancelable}.
* If this event is canceled, the sound is not played.
*
* This event does not have a result.
*
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/
public static class AtPosition extends PlayLevelSoundEvent
{
private final Vec3 position;
public AtPosition(Level level, Vec3 position, Holder