TickThrottler .java

net.minecraft.util.TickThrottler (class, 27 lines): members: isUnderThreshold, incrementStep, increment, threshold, count, tick.

net.minecraft.utilclass27 linescommon538 B

API Surface (3)

void increment()
void tick()
boolean isUnderThreshold()

Fields & Constants (3)

incrementStep
threshold
count

Full Source

TickThrottler.java27 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util;
2
3
public class TickThrottler {
4
	private final int incrementStep;
5
	private final int threshold;
6
	private int count;
7
8
	public TickThrottler(final int incrementStep, final int threshold) {
9
		this.incrementStep = incrementStep;
10
		this.threshold = threshold;
11
	}
12
13
	public void increment() {
14
		this.count = this.count + this.incrementStep;
15
	}
16
17
	public void tick() {
18
		if (this.count > 0) {
19
			this.count--;
20
		}
21
	}
22
23
	public boolean isUnderThreshold() {
24
		return this.threshold <= 0 || this.count < this.threshold;
25
	}
26
}
27

Decompiled Minecraft 26.3 source of TickThrottler (net/minecraft/util/TickThrottler.java) with Mojang official mappings, stored verbatim on the site.