Skip to content

Commit

Permalink
NeoForge 1.20.6 runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed May 9, 2024
1 parent 2f55a32 commit cc45187
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@
//$$ import net.minecraftforge.fml.ModLoadingContext;
//$$ import net.minecraftforge.fml.common.Mod;
//$$ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
//$$ import net.minecraftforge.fml.loading.FMLPaths;
//#else
//$$ import net.neoforged.api.distmarker.Dist;
//$$ import net.neoforged.bus.api.SubscribeEvent;
//$$ import net.neoforged.fml.ModList;
//$$ import net.neoforged.fml.ModLoadingContext;
//$$ import net.neoforged.fml.common.Mod;
//$$ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
//$$ import net.neoforged.fml.loading.FMLPaths;
//#endif
//$$ import java.util.function.BiFunction;
//#if MC >= 1.20.5
Expand Down Expand Up @@ -173,13 +175,13 @@ public class WorldHost
300 * 20
};

public static final File GAME_DIR = Minecraft.getInstance().gameDirectory;
public static final File CACHE_DIR = new File(GAME_DIR, ".world-host-cache");
public static final Path GAME_DIR = getGameDir();
public static final Path CACHE_DIR = GAME_DIR.resolve(".world-host-cache");

public static final File CONFIG_DIR = new File(GAME_DIR, "config");
public static final Path CONFIG_FILE = new File(CONFIG_DIR, "world-host.json5").toPath();
public static final Path FRIENDS_FILE = new File(CONFIG_DIR, "world-host-friends.json").toPath();
public static final Path OLD_CONFIG_FILE = new File(CONFIG_DIR, "world-host.json").toPath();
public static final Path CONFIG_DIR = GAME_DIR.resolve("config");
public static final Path CONFIG_FILE = CONFIG_DIR.resolve("world-host.json5");
public static final Path FRIENDS_FILE = CONFIG_DIR.resolve("world-host-friends.json");
public static final Path OLD_CONFIG_FILE = CONFIG_DIR.resolve("world-host.json");
public static final WorldHostConfig CONFIG = new WorldHostConfig();

private static List<String> wordsForCid;
Expand Down Expand Up @@ -245,17 +247,20 @@ private static void init() {

loadConfig();

//noinspection ResultOfMethodCallIgnored
CACHE_DIR.mkdirs();
try {
Files.createDirectories(CACHE_DIR);
} catch (IOException e) {
LOGGER.error("Failed to create cache directory", e);
}
//#if MC >= 1.19.2
profileCache = Services.create(
((MinecraftAccessor)Minecraft.getInstance()).getAuthenticationService(),
CACHE_DIR
CACHE_DIR.toFile()
).profileCache();
//#else
//$$ profileCache = new GameProfileCache(
//$$ new YggdrasilAuthenticationService(Minecraft.getInstance().getProxy()).createProfileRepository(),
//$$ new File(CACHE_DIR, "usercache.json")
//$$ CACHE_DIR.resolve("usercache.json").toFile()
//$$ );
//#endif
profileCache.setExecutor(Util.backgroundExecutor());
Expand Down Expand Up @@ -840,6 +845,14 @@ public static CompletableFuture<Optional<String>> checkForUpdates() {
});
}

private static Path getGameDir() {
//#if FABRIC
return FabricLoader.getInstance().getGameDir();
//#else
//$$ return FMLPaths.GAMEDIR.get();
//#endif
}

//#if FORGELIKE
//#if MC >= 1.20.5
//$$ @EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
//$$ import java.util.concurrent.CompletableFuture;
//#endif

//#if MC >= 1.20.5
import net.minecraft.client.multiplayer.TransferState;
//#endif

@Mixin(targets = "net.minecraft.client.gui.screens.ConnectScreen$1")
public class MixinConnectScreen_1 {
@Unique
Expand All @@ -32,6 +36,9 @@ private void initRefs(
//#elseif MC > 1.18.2
//$$ CompletableFuture<?> completableFuture,
//#endif
//#if MC >= 1.20.5
TransferState transferState,
//#endif
CallbackInfo ci
) {
wh$parent = connectScreen;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/world-host.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"MixinWorldSelectionList_WorldListEntry",
"PlainTextButtonAccessor",
"ServerStatusPingerAccessor",
//#if FABRIC
"modmenu.MixinModMenuEventHandler"
//#endif
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit cc45187

Please sign in to comment.