use of net.mine_diver.unsafeevents.listener.EventListener in project StationAPI by ModificationStation.
the class LevelRegistryRemapper method saveProperties.
@EventListener(priority = ListenerPriority.HIGH)
private static void saveProperties(LevelPropertiesEvent.Save event) {
CompoundTag registriesTag = new CompoundTag();
LevelSerialRegistry.saveAll(registriesTag);
event.tag.put(of(MODID, "level_serial_registries").toString(), registriesTag);
}
use of net.mine_diver.unsafeevents.listener.EventListener in project StationAPI by ModificationStation.
the class ItemListener method registerItems.
@EventListener
public void registerItems(ItemRegistryEvent event) {
// 8475
testItem = new ModdedItem(of(MODID, "test_item")).setTranslationKey(MODID, "testItem");
testMaterial = ToolMaterialFactory.create("testMaterial", 3, Integer.MAX_VALUE, Float.MAX_VALUE, Integer.MAX_VALUE - 2);
// 8476
testPickaxe = new ModdedPickaxe(of(MODID, "test_pickaxe"), testMaterial).setTranslationKey(MODID, "testPickaxe");
// 8477
testNBTItem = new NBTItem(of(MODID, "nbt_item")).setTranslationKey(MODID, "nbt_item");
testModelItem = new ModelItem(of(MODID, "model_item")).setMaxStackSize(1).setTranslationKey(MODID, "idkSomething");
ironOre = new TemplateItemBase(Identifier.of(MODID, "ironOre")).setTranslationKey(MODID, "ironOre");
TagRegistry.INSTANCE.register(Identifier.of("blocks/ores/iron"), new ItemInstance(ironOre), e -> ironOre.id == e.itemId);
TagRegistry.INSTANCE.register(Identifier.of("items/tools/pickaxes/testpickaxe"), new ItemInstance(testPickaxe), (e) -> e.itemId == testPickaxe.id);
}
use of net.mine_diver.unsafeevents.listener.EventListener in project StationAPI by ModificationStation.
the class TextureListener method registerTextures.
@EventListener
public void registerTextures(TextureRegisterEvent event) {
ExpandableAtlas terrain = Atlases.getTerrain();
TEST_BLOCK.get().texture = terrain.addTexture(of(MODID, "blocks/testBlock")).index;
TEST_ANIMATED_BLOCK.get().texture = terrain.addTexture(of(MODID, "blocks/testAnimatedBlock")).index;
FREEZER.get().texture = terrain.addTexture(of(MODID, "blocks/FreezerTop")).index;
FREEZER.get(BlockFreezer.class).sideTexture = terrain.addTexture(of(MODID, "blocks/FreezerSide")).index;
altarTextures[Direction.DOWN.ordinal()] = terrain.addTexture(of(MODID, "blocks/altar_bottom")).index;
altarTextures[Direction.UP.ordinal()] = terrain.addTexture(of(MODID, "blocks/altar_top")).index;
altarTextures[Direction.EAST.ordinal()] = terrain.addTexture(of(MODID, "blocks/altar_east")).index;
altarTextures[Direction.WEST.ordinal()] = terrain.addTexture(of(MODID, "blocks/altar_west")).index;
altarTextures[Direction.NORTH.ordinal()] = terrain.addTexture(of(MODID, "blocks/altar_north")).index;
altarTextures[Direction.SOUTH.ordinal()] = terrain.addTexture(of(MODID, "blocks/altar_south")).index;
ItemListener.testNBTItem.setTexture(of(MODID, "items/nbtItem"));
ItemListener.testItem.setTexture(of(MODID, "items/highres"));
// ItemListener.testPickaxe.setAnimationBinder("/assets/sltest/stationapi/textures/items/testPickaxe.png", 1, of(MODID, "items/testItem"));
ItemListener.testPickaxe.setTexture(of(MODID, "items/testPickaxe"));
// SquareAtlas.GUI_ITEMS.addAnimationBinder("/assets/sltest/textures/items/testPickaxe.png", 1, 0);
TEST_ATLAS = new ExpandableAtlas(of(SLTest.MODID, "test_atlas"));
TEST_ATLAS.addTexture(of(MODID, "items/testItem"));
TEST_ATLAS.addTexture(of(MODID, "blocks/testBlock"));
TEST_ATLAS.addTexture(of(MODID, "blocks/testAnimatedBlock"));
TEST_ATLAS.addTexture(of(MODID, "items/testPickaxe"));
TEST_ATLAS.addTexture(of(MODID, "items/nbtItem"));
TEST_ATLAS.addTexture(of(MODID, "blocks/FreezerTop"));
TEST_ATLAS.addTexture(of(MODID, "blocks/FreezerSide"));
// farlandsBlockModel = JsonUnbakedModel.get(of(MODID, "farlandsBlock"));
// testItemModel = JsonUnbakedModel.get(of(MODID, "item/testItem"));
}
use of net.mine_diver.unsafeevents.listener.EventListener in project StationAPI by ModificationStation.
the class MainTest method onInitialize.
@EventListener
public void onInitialize(TagRegisterEvent event) {
SLTest.LOGGER.info("==================================================================================================");
Identifier oreDictToTest = Identifier.of("items/tools/pickaxes/");
SLTest.LOGGER.info(oreDictToTest);
Optional<Map<Identifier, List<TagEntry>>> predicates = TagRegistry.INSTANCE.getWithIdentifiers(oreDictToTest);
if (predicates.isPresent()) {
for (Identifier oreDictEntryObject : predicates.get().keySet()) {
SLTest.LOGGER.info(oreDictEntryObject);
}
} else {
throw new RuntimeException("Predicates are empty for " + oreDictToTest);
}
SLTest.LOGGER.info("==================================================================================================");
// block.mineableByTool("pickaxe*", 0);
}
use of net.mine_diver.unsafeevents.listener.EventListener 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