Skip to content

Commit

Permalink
Modify some mod compat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jul 16, 2024
1 parent e5792df commit e7eb829
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
10 changes: 9 additions & 1 deletion src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,17 @@ public static String getModVersion(String modId) {
//#endif
}

public static boolean isModLoaded(String modId) {
//#if FABRIC
return FabricLoader.getInstance().isModLoaded(modId);
//#else
//$$ return ModList.get().isLoaded(modId);
//#endif
}

public static int getMenuLines(boolean isPause, OnlineStatusLocation side) {
//#if FABRIC
if (!FabricLoader.getInstance().isModLoaded("isxander-main-menu-credits")) {
if (!isModLoaded("isxander-main-menu-credits")) {
return 0;
}
final var baseConfig = MainMenuCredits.getInstance().getConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,17 @@
import java.util.Map;
import java.util.UUID;

//#if MC >= 1.20.4
import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
//#endif

//#if MC >= 1.20.0
import net.minecraft.client.gui.GuiGraphics;
//#else
//$$ import com.mojang.blaze3d.vertex.PoseStack;
//#endif

//#if MC >= 1.20.4 && FABRIC
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
import net.fabricmc.loader.api.FabricLoader;
//#if MC >= 1.20.1
import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
//#else
//$$ import de.florianmichael.viafabricplus.screen.impl.base.ProtocolSelectionScreen;
//#endif
//#endif

//#if MC >= 1.19.4
import java.util.Arrays;
import net.minecraft.client.gui.components.Tooltip;
Expand Down Expand Up @@ -141,14 +136,14 @@ protected void init() {

updateButtonActivationStates();

//#if MC >= 1.20.4 && FABRIC
if (FabricLoader.getInstance().isModLoaded("viafabricplus")) {
//#if MC >= 1.20.4
if (WorldHost.isModLoaded("viafabricplus")) {
vfpInit();
}
//#endif
}

//#if MC >= 1.20.4 && FABRIC
//#if MC >= 1.20.4
// Based on https://github.com/ViaVersion/ViaFabricPlus/blob/main/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerScreen.java
private void vfpInit() {
Button.Builder builder = Button.builder(
Expand Down

0 comments on commit e7eb829

Please sign in to comment.