-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
PatchFMLCommonHandler.java
76 lines (68 loc) · 2.34 KB
/
PatchFMLCommonHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package me.nallar.patched;
import java.util.EnumSet;
import java.util.List;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IScheduledTickHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.profiler.Profiler;
public abstract class PatchFMLCommonHandler extends FMLCommonHandler {
public Profiler theProfiler = null;
@Override
public void rescheduleTicks(Side side) {
List<IScheduledTickHandler> scheduledTicks = side.isClient() ? scheduledClientTicks : scheduledServerTicks;
synchronized (scheduledTicks) {
TickRegistry.updateTickQueue(scheduledTicks, side);
}
}
@Override
public void tickStart(EnumSet<TickType> ticks, Side side, Object... data) {
if (theProfiler == null) {
theProfiler = getMinecraftServerInstance().theProfiler;
}
final List<IScheduledTickHandler> scheduledTicks = side.isClient() ? scheduledClientTicks : scheduledServerTicks;
synchronized (scheduledTicks) {
if (scheduledTicks.isEmpty()) {
return;
}
for (IScheduledTickHandler ticker : scheduledTicks) {
EnumSet<TickType> ticksToRun = ticker.ticks();
if (ticksToRun == null) {
ticksToRun = EnumSet.noneOf(TickType.class);
} else {
ticksToRun = EnumSet.copyOf(ticksToRun);
}
ticksToRun.retainAll(ticks);
if (!ticksToRun.isEmpty()) {
theProfiler.startSection(ticker.getClass().toString());
ticker.tickStart(ticksToRun, data);
theProfiler.endSection();
}
}
}
}
@Override
public void tickEnd(EnumSet<TickType> ticks, Side side, Object... data) {
final List<IScheduledTickHandler> scheduledTicks = side.isClient() ? scheduledClientTicks : scheduledServerTicks;
synchronized (scheduledTicks) {
if (scheduledTicks.isEmpty()) {
return;
}
for (IScheduledTickHandler ticker : scheduledTicks) {
EnumSet<TickType> ticksToRun = ticker.ticks();
if (ticksToRun == null) {
ticksToRun = EnumSet.noneOf(TickType.class);
} else {
ticksToRun = EnumSet.copyOf(ticksToRun);
}
ticksToRun.retainAll(ticks);
if (!ticksToRun.isEmpty()) {
theProfiler.startSection(ticker.getClass().toString());
ticker.tickEnd(ticksToRun, data);
theProfiler.endSection();
}
}
}
}
}