use of com.redlimerl.speedrunigt.timer.running.RunCategory in project SpeedRunIGT by RedLime.
the class TimerPacketHandler method receiveInitC2S.
public static void receiveInitC2S(MinecraftServer server, PacketByteBuf buffer) {
try {
long startTime = buffer.readLong();
RunCategory category = RunCategory.getCategory(buffer.readString());
sendInitS2C(server.getPlayerManager().getPlayerList(), startTime, category);
SpeedRunIGT.debug("server received init: " + startTime + " / " + category.getID());
} catch (Exception e) {
SpeedRunIGT.error("Failed read packets, probably SpeedRunIGT version different between players");
}
}
use of com.redlimerl.speedrunigt.timer.running.RunCategory in project SpeedRunIGT by RedLime.
the class TimerPacketHandler method receiveInitS2C.
public static void receiveInitS2C(PacketByteBuf buffer) {
try {
if (!SpeedRunOption.getOption(SpeedRunOptions.AUTOMATIC_COOP_MODE))
return;
long startTime = buffer.readLong();
RunCategory category = RunCategory.getCategory(buffer.readString());
if (InGameTimer.getInstance().startTime != startTime) {
InGameTimer.start("");
InGameTimer.getInstance().startTime = startTime;
InGameTimer.getInstance().setCategory(category);
}
InGameTimer.getInstance().isCoop = true;
InGameTimer.getInstance().isServerIntegrated = MinecraftClient.getInstance().isIntegratedServerRunning();
InGameTimer.getInstance().setPause(false, "co-op setup");
SpeedRunIGT.debug("client received init: " + startTime + " / " + category.getID());
} catch (Exception e) {
SpeedRunIGT.error("Failed read packets, probably SpeedRunIGT version different between players");
}
}
use of com.redlimerl.speedrunigt.timer.running.RunCategory in project SpeedRunIGT by RedLime.
the class SpeedRunIGT method onInitializeClient.
@Override
public void onInitializeClient() {
MOD_VERSION = (FabricLoader.getInstance().getModContainer(SpeedRunIGT.MOD_ID).isPresent() ? FabricLoader.getInstance().getModContainer(SpeedRunIGT.MOD_ID).get().getMetadata().getVersion().getFriendlyString() : "Unknown+Unknown");
// init default option buttons
SpeedRunOption.addOptionButtonFactories(new OptionButtonsImpl().createOptionButtons().toArray(new OptionButtonFactory[0]));
// init default categories
new CategoryRegistryImpl().registerCategories().forEach(RunCategory::registerCategory);
// Registry API's
for (EntrypointContainer<SpeedRunIGTApi> entryPoint : FabricLoader.getInstance().getEntrypointContainers("speedrunigt", SpeedRunIGTApi.class)) {
SpeedRunIGTApi api = entryPoint.getEntrypoint();
// Registry single option button
OptionButtonFactory singleFactory = api.createOptionButton();
if (singleFactory != null)
SpeedRunOption.addOptionButtonFactories(singleFactory);
// Registry multiple option buttons
Collection<OptionButtonFactory> multipleFactory = api.createOptionButtons();
if (multipleFactory != null)
SpeedRunOption.addOptionButtonFactories(multipleFactory.toArray(new OptionButtonFactory[0]));
// Registry single category
RunCategory singleCategory = api.registerCategory();
if (singleCategory != null)
RunCategory.registerCategory(singleCategory);
// Registry multiple categories
Collection<RunCategory> multipleCategories = api.registerCategories();
if (multipleCategories != null)
multipleCategories.forEach(RunCategory::registerCategory);
API_PROVIDERS.add(entryPoint.getProvider());
}
// Options initialize
SpeedRunOption.init();
// Translate initialize
try {
TranslateHelper.init();
} catch (Throwable e) {
e.printStackTrace();
}
// Key Bindings initialize
timerResetKeyBinding = KeyBindingRegistry.registerKeyBinding(new KeyBinding("speedrunigt.controls.start_timer", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_U, "speedrunigt.title.options"));
timerStopKeyBinding = KeyBindingRegistry.registerKeyBinding(new KeyBinding("speedrunigt.controls.stop_timer", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_I, "speedrunigt.title.options"));
// End initializing
isInitialized = true;
// Update checking
SpeedRunIGTInfoScreen.checkUpdate();
// Add default fonts
FontUtils.copyDefaultFonts();
}
Aggregations