Chinese 1.4.7 Modding Tutorials: 第二章:基本檔案

第二章:基本檔案
在這個教學中,我會教你如何創建最重要的基本檔案,這個基本檔案是你在做任何事之前都必須要有的。

第一步你需要在Minecraft > src的大資料夾中創建一個package(簡單來說是一個資料夾)。
首先對src資料夾按右鍵,然後選擇New,再選擇Package
然後會跳出以下的頁面,圖片說明:
然後再對著你創建的package按右鍵,選擇New > Class

創建後,一開始你應該會有以下的字元:

package Tutorial;

public class Tutorial {

}


(第一個Tutorial取決於你的package名字,第二個Tutorial取決於你的class名字)

第一樣你要做的事,就是在package Tutorialpublic class Tutorial之間加這句:


@Mod(modid = 你的名字_模組名字, name = 模組名字, version = 版本號)

(那些中文請該成相應的英文或數字)
然後你應該在那行的左邊會發現一個錯誤,
那是因為這個檔案沒有讀取到「@Mod」這個方法,這時候按Ctrl+Shift+O
Eclipse就會自動幫你import(讀取)在其他位置的檔案,就不會有錯誤了。
(當然你也可以按圖直接打上去)
第二樣你要加這行:


@NetworkMod(clientSideRequired = true, serverSideRequired = false)

這句會讓有這個模組的玩家可以進入沒有這個模組的伺服器,
如果沒有這行,玩家嘗試進入伺服器時會崩潰。
同樣你也需要使用Ctrl+Shift+Oimport這句:

import cpw.mods.fml.common.network.NetworkMod;


然後你需要在public class Tutorial的兩個大括號內增加這句:


@Init
public void load(FMLInitializationEvent event)
{
        
}


這邊這句的內部是用作註冊方塊、弄合成表等等的東西,所以是十分重要的。
同樣import你需要的東西。


這邊就完成了基本工作了,這是整個檔案的編碼:

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
       public void load(FMLInitializationEvent event)
       {
        
       }
}


You can download the source code from this tutorial right here.

When you are done you should go back to the tutorials list here.

1 opmerking:

  1. ROBLOX is driven by a growing community of more than 300,000 creators who produce an infinite variety of highly immersive experiences.

    These 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.

    BeantwoordenVerwijderen