我不得不用“我的世界”改变主菜单。我设法更改了基本代码,将保存文件复制到“保存”文件夹中,然后加载该保存。但是,当我编译它时,它不起作用。我猜这是因为它是我编辑过的一个基本类,它没有包含在编译中。我也明白,我不应该编辑基线,但它不会干扰任何事情,所以它应该是可以的。是否有编译已编辑的基类,或者可能是编辑主菜单的另一种方法。我读过关于中断GUI负载并将其替换为自己的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");
}
}
}发布于 2016-07-02 12:12:48
您可以在1.7.x中使用ASM,但是对于您的目的来说,它是复杂的和不必要的。订阅GuiOpenEvent,检查gui是否是主菜单,如果是,则调用event.setGui方法将其设置为GUI。
https://stackoverflow.com/questions/31149823
复制相似问题