/* * This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package de.florianmichael.viaforge; import de.florianmichael.viaforge.common.platform.VFPlatform; import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher; import net.minecraft.SharedConstants; import net.minecraft.client.Minecraft; import net.minecraft.client.User; import net.minecraftforge.fml.common.Mod; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; import java.io.File; import java.util.function.Supplier; @Mod("viaforge") public class ViaForge119 implements VFPlatform { public static final ViaForge119 PLATFORM = new ViaForge119(); @Override public int getGameVersion() { return SharedConstants.getProtocolVersion(); } @Override public Supplier isSingleplayer() { return () -> Minecraft.getInstance().isSingleplayer(); } @Override public File getLeadingDirectory() { return Minecraft.getInstance().gameDirectory; } @Override public void joinServer(String serverId) throws Throwable { final User session = Minecraft.getInstance().getUser(); Minecraft.getInstance().getMinecraftSessionService().joinServer(session.getGameProfile(), session.getAccessToken(), serverId); } @Override public GameProfileFetcher getGameProfileFetcher() { return new ViaForgeGameProfileFetcher(); } }