001 package net.minecraft.src;
002
003 import cpw.mods.fml.common.Side;
004 import cpw.mods.fml.common.asm.SideOnly;
005
006 @SideOnly(Side.CLIENT)
007 public class SoundUpdaterMinecart implements IUpdatePlayerListBox
008 {
009 private final SoundManager field_82477_a;
010 private final EntityMinecart field_82475_b;
011 private final EntityPlayerSP field_82476_c;
012 private boolean field_82473_d = false;
013 private boolean field_82474_e = false;
014 private boolean field_82471_f = false;
015 private boolean field_82472_g = false;
016 private float field_82480_h = 0.0F;
017 private float field_82481_i = 0.0F;
018 private float field_82478_j = 0.0F;
019 private double field_82479_k = 0.0D;
020
021 public SoundUpdaterMinecart(SoundManager par1SoundManager, EntityMinecart par2EntityMinecart, EntityPlayerSP par3EntityPlayerSP)
022 {
023 this.field_82477_a = par1SoundManager;
024 this.field_82475_b = par2EntityMinecart;
025 this.field_82476_c = par3EntityPlayerSP;
026 }
027
028 /**
029 * Updates the JList with a new model.
030 */
031 public void update()
032 {
033 boolean var1 = false;
034 boolean var2 = this.field_82473_d;
035 boolean var3 = this.field_82474_e;
036 boolean var4 = this.field_82471_f;
037 float var5 = this.field_82481_i;
038 float var6 = this.field_82480_h;
039 float var7 = this.field_82478_j;
040 double var8 = this.field_82479_k;
041 this.field_82473_d = this.field_82476_c != null && this.field_82475_b.riddenByEntity == this.field_82476_c;
042 this.field_82474_e = this.field_82475_b.isDead;
043 this.field_82479_k = (double)MathHelper.sqrt_double(this.field_82475_b.motionX * this.field_82475_b.motionX + this.field_82475_b.motionZ * this.field_82475_b.motionZ);
044 this.field_82471_f = this.field_82479_k >= 0.01D;
045
046 if (var2 && !this.field_82473_d)
047 {
048 this.field_82477_a.func_82469_c(this.field_82476_c);
049 }
050
051 if (this.field_82474_e || !this.field_82472_g && this.field_82481_i == 0.0F && this.field_82478_j == 0.0F)
052 {
053 if (!var3)
054 {
055 this.field_82477_a.func_82469_c(this.field_82475_b);
056
057 if (var2 || this.field_82473_d)
058 {
059 this.field_82477_a.func_82469_c(this.field_82476_c);
060 }
061 }
062
063 this.field_82472_g = true;
064
065 if (this.field_82474_e)
066 {
067 return;
068 }
069 }
070
071 if (!this.field_82477_a.func_82465_b(this.field_82475_b) && this.field_82481_i > 0.0F)
072 {
073 this.field_82477_a.func_82467_a("minecart.base", this.field_82475_b, this.field_82481_i, this.field_82480_h, false);
074 this.field_82472_g = false;
075 var1 = true;
076 }
077
078 if (this.field_82473_d && !this.field_82477_a.func_82465_b(this.field_82476_c) && this.field_82478_j > 0.0F)
079 {
080 this.field_82477_a.func_82467_a("minecart.inside", this.field_82476_c, this.field_82478_j, 1.0F, true);
081 this.field_82472_g = false;
082 var1 = true;
083 }
084
085 if (this.field_82471_f)
086 {
087 if (this.field_82480_h < 1.0F)
088 {
089 this.field_82480_h += 0.0025F;
090 }
091
092 if (this.field_82480_h > 1.0F)
093 {
094 this.field_82480_h = 1.0F;
095 }
096
097 float var10 = MathHelper.clamp_float((float)this.field_82479_k, 0.0F, 4.0F) / 4.0F;
098 this.field_82478_j = 0.0F + var10 * 0.75F;
099 var10 = MathHelper.clamp_float(var10 * 2.0F, 0.0F, 1.0F);
100 this.field_82481_i = 0.0F + var10 * 0.7F;
101 }
102 else if (var4)
103 {
104 this.field_82481_i = 0.0F;
105 this.field_82480_h = 0.0F;
106 this.field_82478_j = 0.0F;
107 }
108
109 if (!this.field_82472_g)
110 {
111 if (this.field_82480_h != var6)
112 {
113 this.field_82477_a.func_82463_b(this.field_82475_b, this.field_82480_h);
114 }
115
116 if (this.field_82481_i != var5)
117 {
118 this.field_82477_a.func_82468_a(this.field_82475_b, this.field_82481_i);
119 }
120
121 if (this.field_82478_j != var7)
122 {
123 this.field_82477_a.func_82468_a(this.field_82476_c, this.field_82478_j);
124 }
125 }
126
127 if (!var1)
128 {
129 this.field_82477_a.func_82460_a(this.field_82475_b);
130
131 if (this.field_82473_d)
132 {
133 this.field_82477_a.func_82462_a(this.field_82476_c, this.field_82475_b);
134 }
135 }
136 }
137 }