TextureCompass .java

net.minecraft.client.renderer.texture.TextureCompass (class, 99 lines): members: locationSprite, updateCompass, currentAngle, angleDelta, updateAnimation.

net.minecraft.client.renderer.textureclass99 linesclientextends TextureAtlasSprite3.1 KB

API Surface (2)

void updateAnimation()
void updateCompass(World worldIn, double p_94241_2_, double p_94241_4_, double p_94241_6_, boolean p_94241_8_, boolean p_94241_9_)

Fields & Constants (3)

currentAngle
angleDelta
locationSprite

Code Graph: Dependencies (6)

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

Full Source

TextureCompass.java99 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer.texture;
2
3
import net.minecraft.client.Minecraft;
4
import net.minecraft.util.BlockPos;
5
import net.minecraft.util.MathHelper;
6
import net.minecraft.world.World;
7
8
public class TextureCompass extends TextureAtlasSprite
9
{
10
    /** Current compass heading in radians */
11
    public double currentAngle;
12
13
    /** Speed and direction of compass rotation */
14
    public double angleDelta;
15
    public static String locationSprite;
16
17
    public TextureCompass(String iconName)
18
    {
19
        super(iconName);
20
        locationSprite = iconName;
21
    }
22
23
    public void updateAnimation()
24
    {
25
        Minecraft minecraft = Minecraft.getMinecraft();
26
27
        if (minecraft.theWorld != null && minecraft.thePlayer != null)
28
        {
29
            this.updateCompass(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ, (double)minecraft.thePlayer.rotationYaw, false, false);
30
        }
31
        else
32
        {
33
            this.updateCompass((World)null, 0.0D, 0.0D, 0.0D, true, false);
34
        }
35
    }
36
37
    /**
38
     * Updates the compass based on the given x,z coords and camera direction
39
     */
40
    public void updateCompass(World worldIn, double p_94241_2_, double p_94241_4_, double p_94241_6_, boolean p_94241_8_, boolean p_94241_9_)
41
    {
42
        if (!this.framesTextureData.isEmpty())
43
        {
44
            double d0 = 0.0D;
45
46
            if (worldIn != null && !p_94241_8_)
47
            {
48
                BlockPos blockpos = worldIn.getSpawnPoint();
49
                double d1 = (double)blockpos.getX() - p_94241_2_;
50
                double d2 = (double)blockpos.getZ() - p_94241_4_;
51
                p_94241_6_ = p_94241_6_ % 360.0D;
52
                d0 = -((p_94241_6_ - 90.0D) * Math.PI / 180.0D - Math.atan2(d2, d1));
53
54
                if (!worldIn.provider.isSurfaceWorld())
55
                {
56
                    d0 = Math.random() * Math.PI * 2.0D;
57
                }
58
            }
59
60
            if (p_94241_9_)
61
            {
62
                this.currentAngle = d0;
63
            }
64
            else
65
            {
66
                double d3;
67
68
                for (d3 = d0 - this.currentAngle; d3 < -Math.PI; d3 += (Math.PI * 2D))
69
                {
70
                    ;
71
                }
72
73
                while (d3 >= Math.PI)
74
                {
75
                    d3 -= (Math.PI * 2D);
76
                }
77
78
                d3 = MathHelper.clamp_double(d3, -1.0D, 1.0D);
79
                this.angleDelta += d3 * 0.1D;
80
                this.angleDelta *= 0.8D;
81
                this.currentAngle += this.angleDelta;
82
            }
83
84
            int i;
85
86
            for (i = (int)((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double)this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size())
87
            {
88
                ;
89
            }
90
91
            if (i != this.frameCounter)
92
            {
93
                this.frameCounter = i;
94
                TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
95
            }
96
        }
97
    }
98
}
99

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