在這個教學中,我會教你如何創建最重要的基本檔案,這個基本檔案是你在做任何事之前都必須要有的。
第一步你需要在Minecraft >
src的大資料夾中創建一個package(簡單來說是一個資料夾)。
首先對src資料夾按右鍵,然後選擇New,再選擇Package。
然後再對著你創建的package按右鍵,選擇New > Class:
創建後,一開始你應該會有以下的字元:
package Tutorial;
public class Tutorial {
}
(第一個Tutorial取決於你的package名字,第二個Tutorial取決於你的class名字)
第一樣你要做的事,就是在package
Tutorial和public class
Tutorial之間加這句:
然後你應該在那行的左邊會發現一個錯誤,
那是因為這個檔案沒有讀取到「@Mod」這個方法,這時候按Ctrl+Shift+O,
(當然你也可以按圖直接打上去)
第二樣你要加這行:
這句會讓有這個模組的玩家可以進入沒有這個模組的伺服器,
如果沒有這行,玩家嘗試進入伺服器時會崩潰。
同樣你也需要使用Ctrl+Shift+O來import這句:
import cpw.mods.fml.common.network.NetworkMod;
然後你需要在public class
Tutorial的兩個大括號內增加這句:
public void load(FMLInitializationEvent event)
{
}
這邊這句的內部是用作註冊方塊、弄合成表等等的東西,所以是十分重要的。
同樣import你需要的東西。
這邊就完成了基本工作了,這是整個檔案的編碼:
package Tutorial;
package Tutorial;
import cpw.mods.fml.common.Mod;
import
cpw.mods.fml.common.Mod.Init;
import
cpw.mods.fml.common.event.FMLInitializationEvent;
import
cpw.mods.fml.common.network.NetworkMod;
@Mod(modid = "Seer_TutorialMod",
name = "TutorialMod", version = "1.0.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Tutorial {
@Init
{
}
}
You can download the source code from this tutorial right here.
When you are done you should go back to the tutorials list here.







ROBLOX is driven by a growing community of more than 300,000 creators who produce an infinite variety of highly immersive experiences.
BeantwoordenVerwijderenThese experiences range from 3D games and competitions, to interactive adventures where friends can take on new identities exploring what it's like to be a dinosaur, a miner working a mine or an astronaut out in space.