提供: Minecraft Modding Wiki
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
1行目: | 1行目: | ||
− | {{前提MOD|reqmod=" | + | {{前提MOD|reqmod="MinecraftForge3.3.7以降"}} |
==解説== | ==解説== | ||
20行目: | 20行目: | ||
;必要ファイルのインポート | ;必要ファイルのインポート | ||
<source lang="java">import net.minecraft.client.Minecraft; | <source lang="java">import net.minecraft.client.Minecraft; | ||
+ | import cpw.mods.fml.common.FMLCommonHandler; | ||
</source> | </source> | ||
− | :クラス宣言の上部に上記の文を追加し、Minecraft.class をインポートします。 | + | :クラス宣言の上部に上記の文を追加し、Minecraft.class と FMLCommonHandler.class をインポートします。 |
;インスタンスの取得 | ;インスタンスの取得 | ||
− | <source lang="java">Minecraft minecraft = | + | <source lang="java">Minecraft minecraft = (Minecraft)FMLCommonHandler.instance().getMinecraftInstance(); |
</source> | </source> | ||
− | :メッセージを表示したいメソッドで、Minecraft型のメンバ minecraft | + | :メッセージを表示したいメソッドで、Minecraft型のメンバ minecraft を宣言し、Minecraft型にキャストしたインスタンス取得します。 |
44行目: | 45行目: | ||
import net.minecraft.client.Minecraft; | import net.minecraft.client.Minecraft; | ||
+ | import cpw.mods.fml.common.FMLCommonHandler; | ||
public class DebugLibrary | public class DebugLibrary | ||
51行目: | 53行目: | ||
public DebugLibrary() | public DebugLibrary() | ||
{ | { | ||
− | minecraft = | + | minecraft = (Minecraft)FMLCommonHandler.instance().getMinecraftInstance(); |
} | } | ||