MovingSoundMinecart .java

net.minecraft.client.audio.MovingSoundMinecart (class): members: distance, minecart, update. strings: "minecraft:minecart.base". imports: EntityMinecart.

net.minecraft.client.audioclass49 linesclientextends MovingSound1.4 KB

API Surface (1)

void update()

Fields & Constants (2)

minecart
distance

String literals (1)

"minecraft:minecart.base"

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

MovingSoundMinecart.java49 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.audio;
2
3
import net.minecraft.entity.item.EntityMinecart;
4
import net.minecraft.util.MathHelper;
5
import net.minecraft.util.ResourceLocation;
6
7
public class MovingSoundMinecart extends MovingSound
8
{
9
    private final EntityMinecart minecart;
10
    private float distance = 0.0F;
11
12
    public MovingSoundMinecart(EntityMinecart minecartIn)
13
    {
14
        super(new ResourceLocation("minecraft:minecart.base"));
15
        this.minecart = minecartIn;
16
        this.repeat = true;
17
        this.repeatDelay = 0;
18
    }
19
20
    /**
21
     * Like the old updateEntity(), except more generic.
22
     */
23
    public void update()
24
    {
25
        if (this.minecart.isDead)
26
        {
27
            this.donePlaying = true;
28
        }
29
        else
30
        {
31
            this.xPosF = (float)this.minecart.posX;
32
            this.yPosF = (float)this.minecart.posY;
33
            this.zPosF = (float)this.minecart.posZ;
34
            float f = MathHelper.sqrt_double(this.minecart.motionX * this.minecart.motionX + this.minecart.motionZ * this.minecart.motionZ);
35
36
            if ((double)f >= 0.01D)
37
            {
38
                this.distance = MathHelper.clamp_float(this.distance + 0.0025F, 0.0F, 1.0F);
39
                this.volume = 0.0F + MathHelper.clamp_float(f, 0.0F, 0.5F) * 0.7F;
40
            }
41
            else
42
            {
43
                this.distance = 0.0F;
44
                this.volume = 0.0F;
45
            }
46
        }
47
    }
48
}
49

Deobfuscated MCP 1.8.9 source of MovingSoundMinecart from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/audio/MovingSoundMinecart.java), stored verbatim.