我不得不使用 Minecraft Forge 更改 Minecraft 的主菜单。我设法更改了基本代码以将保存文件复制到 Saves 文件夹,然后加载该保存。但是当我编译它时它不起作用。我猜这是因为它是我编辑过的基类并且它没有包含在编译中。我也明白我不应该编辑基类,但它不会干扰任何东西,所以应该没问题。无论如何编译已编辑的基类,或者可能是另一种编辑主菜单的方式。我读过关于中断 GUI 的负载并用我自己的替换它,但我还没有找到任何好的方法来做到这一点。
下面是代码,稍微精简一下:net.minecraft.client.gui.GuiMainMenu.java
private void addSingleplayerMultiplayerButtons(int p_73969_1_, int p_73969_2_)
{
this.buttonList.add(new GuiButton(15, this.width / 2 - 100, p_73969_1_, I18n.format("Quickplay", new Object[0])));
}
protected void actionPerformed(GuiButton p_146284_1_)
{
if (p_146284_1_.id == 15)
{
// Clone and create new map
File srcFolder = new File(System.getProperty("user.dir") + "\\quickMap");
File destFolder = new File(System.getProperty("user.dir") + "\\saves\\tempQuickMap");
//make sure source exists
if(!srcFolder.exists()){
//System.out.println("Directory does not exist.");
//just exit
//System.exit(0);
}else{
try{
copyFolder(srcFolder,destFolder);
}catch(IOException e){
e.printStackTrace();
//error, just exit
//System.exit(0);
}
}
//System.out.println("Done");
// Cloning done
if (this.mc.getSaveLoader().canLoadWorld("tempQuickMap"))
{
FMLClientHandler.instance().tryLoadExistingWorldMainMenu(this, "tempQuickMap", "Quickplay map");
}
}
}