use of net.mine_diver.unsafeevents.EventBus in project StationAPI by ModificationStation.
the class SLTest method init.
@EventListener
public void init(InitEvent event) {
SLTest.LOGGER.info(MODID.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(new TestEvent());
// 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");
}
}
Aggregations