@@ -28,6 +28,7 @@ public class TemperatureCapability implements ITemperatureCapability
2828{
2929 private int temperature = 12 ;
3030 private int ticktimer = 0 ;
31+ private int damagecounter = 0 ;
3132
3233 private Map <String , TemporaryModifier > temporaryModifiers = new HashMap <String , TemporaryModifier >();
3334
@@ -51,6 +52,12 @@ public int getTemperatureTickTimer()
5152 {
5253 return ticktimer ;
5354 }
55+
56+ @ Override
57+ public int getTemperatureDamageCounter ()
58+ {
59+ return damagecounter ;
60+ }
5461
5562 @ Override
5663 public void setTemperatureLevel (int temperature )
@@ -63,6 +70,12 @@ public void setTemperatureTickTimer(int ticktimer)
6370 {
6471 this .ticktimer =ticktimer ;
6572 }
73+
74+ @ Override
75+ public void setTemperatureDamageCounter (int damagecounter )
76+ {
77+ this .damagecounter = damagecounter ;
78+ }
6679
6780 @ Override
6881 public void addTemperatureLevel (int temperature )
@@ -75,6 +88,12 @@ public void addTemperatureTickTimer(int ticktimer)
7588 {
7689 this .setTemperatureTickTimer (this .getTemperatureTickTimer () + ticktimer );
7790 }
91+
92+ @ Override
93+ public void addTemperatureDamageCounter (int damagecounter )
94+ {
95+ this .setTemperatureDamageCounter (this .getTemperatureDamageCounter () + damagecounter );
96+ }
7897
7998 @ Override
8099 public void tickUpdate (EntityPlayer player , World world , TickEvent .Phase phase )
@@ -128,6 +147,8 @@ public void tickUpdate(EntityPlayer player, World world, TickEvent.Phase phase)
128147
129148 //Effects
130149
150+ boolean appliedEffect = false ;
151+
131152 TemperatureEnum tempEnum = getTemperatureEnum ();
132153 if (tempEnum ==TemperatureEnum .BURNING )
133154 {
@@ -136,6 +157,7 @@ public void tickUpdate(EntityPlayer player, World world, TickEvent.Phase phase)
136157 //Hyperthermia
137158 player .removePotionEffect (SDPotions .hyperthermia );
138159 player .addPotionEffect (new PotionEffect (SDPotions .hyperthermia , 450 , 0 ));
160+ appliedEffect = true ;
139161 }
140162 }
141163 else if (tempEnum ==TemperatureEnum .FREEZING )
@@ -145,6 +167,22 @@ else if(tempEnum==TemperatureEnum.FREEZING)
145167 //Hypothermia
146168 player .removePotionEffect (SDPotions .hypothermia );
147169 player .addPotionEffect (new PotionEffect (SDPotions .hypothermia , 450 , 0 ));
170+ appliedEffect = true ;
171+ }
172+ }
173+
174+ if (!appliedEffect )
175+ {
176+ if (this .getTemperatureDamageCounter () != 0 )
177+ {
178+ //Test whether to reset the temperature damage counter
179+ boolean hasHypothermia = player .isPotionActive (SDPotions .hypothermia );
180+ boolean hasHyperthermia = player .isPotionActive (SDPotions .hyperthermia );
181+ if (!hasHypothermia && !hasHyperthermia )
182+ {
183+ //Reset the temperature damage counter
184+ this .setTemperatureDamageCounter (0 );
185+ }
148186 }
149187 }
150188 }
0 commit comments