39 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.resources.sounds;
 | |
| 
 | |
| import net.fabricmc.api.EnvType;
 | |
| import net.fabricmc.api.Environment;
 | |
| import net.minecraft.sounds.SoundEvent;
 | |
| import net.minecraft.sounds.SoundSource;
 | |
| import net.minecraft.util.RandomSource;
 | |
| import net.minecraft.world.entity.Entity;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class EntityBoundSoundInstance extends AbstractTickableSoundInstance {
 | |
| 	private final Entity entity;
 | |
| 
 | |
| 	public EntityBoundSoundInstance(SoundEvent soundEvent, SoundSource source, float volume, float pitch, Entity entity, long seed) {
 | |
| 		super(soundEvent, source, RandomSource.create(seed));
 | |
| 		this.volume = volume;
 | |
| 		this.pitch = pitch;
 | |
| 		this.entity = entity;
 | |
| 		this.x = (float)this.entity.getX();
 | |
| 		this.y = (float)this.entity.getY();
 | |
| 		this.z = (float)this.entity.getZ();
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public boolean canPlaySound() {
 | |
| 		return !this.entity.isSilent();
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void tick() {
 | |
| 		if (this.entity.isRemoved()) {
 | |
| 			this.stop();
 | |
| 		} else {
 | |
| 			this.x = (float)this.entity.getX();
 | |
| 			this.y = (float)this.entity.getY();
 | |
| 			this.z = (float)this.entity.getZ();
 | |
| 		}
 | |
| 	}
 | |
| }
 |