-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathSLTest.java
More file actions
102 lines (90 loc) · 3.98 KB
/
SLTest.java
File metadata and controls
102 lines (90 loc) · 3.98 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package net.modificationstation.sltest;
import lombok.experimental.SuperBuilder;
import net.mine_diver.unsafeevents.Event;
import net.mine_diver.unsafeevents.EventBus;
import net.mine_diver.unsafeevents.listener.EventListener;
import net.mine_diver.unsafeevents.listener.ListenerPriority;
import net.modificationstation.stationapi.api.event.mod.InitEvent;
import net.modificationstation.stationapi.api.util.Namespace;
import org.apache.logging.log4j.Logger;
public class SLTest {
public static final Namespace NAMESPACE = Namespace.of("sltest");
public static final Logger LOGGER = NAMESPACE.getLogger();
@EventListener
public void init(InitEvent event) {
SLTest.LOGGER.info(NAMESPACE.toString());
EventBus eventBus = new EventBus();
eventBus.register(this::onTestEvent, ListenerPriority.LOWEST.numPriority);
eventBus.register(this::onTestEventbutCOOLER, ListenerPriority.HIGH.numPriority);
eventBus.register(this::onTestEventButNo);
// eventBus.register(this::lol);
eventBus.post(TestEvent.builder().build());
// TextureAtlas atlas = new TextureAtlas(true, null, null, 0);
// try {
// int firstTexture = atlas.addTexture("/assets/sltest/textures/blocks/FreezerSide.png");
// int secondTexture = atlas.addTexture("/assets/sltest/textures/blocks/FreezerTop.png");
// int thirdTexture = atlas.addTexture("/assets/sltest/textures/blocks/testBlock.png");
// System.out.println(firstTexture + " " + secondTexture + " " + thirdTexture);
// File spritesheet = new File(FabricLoader.getInstance().getGameDir().toFile(), "spritesheet.png");
// if (!spritesheet.exists())
// spritesheet.createNewFile();
// ImageIO.write(atlas.getSpritesheet(), "png", spritesheet);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
{
// int tests = 1000;
// int listeners = 1;
// int dispatches = 1000000;
// long total = 0;
// long min = Long.MAX_VALUE;
// long max = Long.MIN_VALUE;
// for (int i = 0; i < tests; i++) {
// EventBus bmBus = new EventBus();
// for (int j = 0; j < listeners; j++)
// bmBus.register(Listener.class);
// long startTS = System.nanoTime();
// for (int j = 0; j < dispatches; j++)
// bmBus.post(new TestEvent());
// long stopTS = System.nanoTime();
// long result = stopTS - startTS;
// System.out.println("Took: " + result + "ns");
// total += result;
// if (result < min)
// min = result;
// if (result > max)
// max = result;
// }
// System.out.println("Tests: " + tests);
// System.out.println("Listeners: " + listeners);
// System.out.println("Dispatches: " + dispatches);
// System.out.println("Average: " + total / tests + "ns");
// System.out.println("Min: " + min + "ns");
// System.out.println("Max: " + max + "ns");
}
}
public static class Listener {
@EventListener
public static void benchmark1(TestEvent event2) { }
//
// @EventListener
// public static void benchmark2(TestEvent event2) { }
//
// @EventListener
// public static void benchmark3(TestEvent event2) { }
}
public void onTestEvent(TestEvent event) {
SLTest.LOGGER.info("oh wow, a test event");
}
public void onTestEventbutCOOLER(TestEvent event) {
SLTest.LOGGER.info("am cooler that the thing that's gonna execute after me");
}
public void onTestEventButNo(TestEvent event) {
SLTest.LOGGER.info("no, not me");
}
// public void lol(Event event) {
// System.out.println("lol");
// }
@SuperBuilder
public static class TestEvent extends Event {}
}