Added timer functions.

ticks(int id):
Gets the remaining ticks in the timer that matches this id.

setTicks(int id, int ticks):
Sets the remaining ticks in the timer that matches this id.

maxTicks(int id):
Gets the maximum ticks that must elapse for the timer that matches this id to finish.

setMaxTicks(int id, int ticks):
Sets the maximum ticks that must elapse for the timer that matches this id to finish.

repeats(int id):
Returns true if the timer with the given id is set to repeat, false otherwise.

setRepeats(int id, bool repeat):
Sets whether the timer with the given id should repeat. If true, the timer will repeat, and not repeat otherwise.
This commit is contained in:
luisc committed 2022-02-27 23:08:24 -06:00
1 parent 22b622d46c
commit 403738262c
2 files changed
+46

No files matched your search

@@ -55,6 +55,40 @@ public class DataTimers implements ITimers {
}
}
public int ticks(int id){
return this.timers.get(Integer.valueOf(id)).ticks;
}
public void setTicks(int id, int ticks){
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
if(ticks < 0)
ticks = 0;
if(ticks > timer.timerTicks)
ticks = timer.timerTicks;
timer.ticks = ticks;
}
public int maxTicks(int id){
return this.timers.get(Integer.valueOf(id)).timerTicks;
}
public void setMaxTicks(int id, int maxTicks){
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
if(maxTicks < 0)
maxTicks = 0;
timer.timerTicks = maxTicks;
}
public boolean repeats(int id){
return this.timers.get(Integer.valueOf(id)).repeat;
}
public void setRepeats(int id, boolean repeat){
this.timers.get(Integer.valueOf(id)).repeat = repeat;
}
public void writeToNBT(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
Iterator var3 = this.timers.values().iterator();
@@ -18,5 +18,17 @@ public interface ITimers {
void clear();
int ticks(int id);
void setTicks(int id, int ticks);
int maxTicks(int id);
void setMaxTicks(int id, int maxTicks);
boolean repeats(int id);
void setRepeats(int id, boolean repeat);
int size();
}