If you are reading this article you probably already know Minecraft. We use Forge to manipulate the game Minecraft to make it do what we want. This could be anything, ranging from new cool creatures to entire new systems in the game.
如果您正在阅读本文,您可能已经知道Minecraft。 我们使用Forge来操纵Minecraft游戏,使其达到我们想要的效果。 可以是任何东西,从新的酷动物到游戏中的整个新系统。
Forge is a modding API. Minecraft Forge (or Forge for short) is a layer between our code and Minecraft itself.
Forge是改装API。 Minecraft Forge(或简称为Forge)是我们的代码与Minecraft本身之间的一层。
We cannot directly ask Minecraft to add items and do special cool things. That’s why we need an API (application programming interface) to handle our logic and make Minecraft recognise it.
我们不能直接要求Minecraft添加物品并做特别酷的事情。 这就是为什么我们需要一个API(应用程序编程接口)来处理我们的逻辑并使Minecraft识别它的原因。
A Minecraft account which can be bought from their official website. (https://minecraft.net/en-us/store/)
可以从其官方网站上购买的Minecraft帐户。 ( https://minecraft.net/zh-cn/store/ )
After installing/acquiring these pieces of software, download your desired Forge version at https://files.minecraftforge.net/.
安装/获取这些软件后,请从https://files.minecraftforge.net/下载所需的Forge版本。
Tip: Hover over the information button and press direct download to avoid an Adfly virus!
提示 :将鼠标悬停在信息按钮上,然后按直接下载以避免Adfly病毒!
Once you have downloaded this ZIP you’ll be able to unzip it. Do so and cd (cmd/command) into the directory with all of the Forge files. Run gradlew setupDecompWorkspace
.
下载此ZIP文件后,您就可以将其解压缩。 这样做,然后将cd(cmd / command)与所有Forge文件一起放入目录。 运行gradlew setupDecompWorkspace
。
Next up is picking your IDE (integrated development environment).
下一步是选择您的IDE(集成开发环境)。
Eclipse? gradlew eclipse
.
蚀? gradlew eclipse
。
Hold your horses. There’s much more to it. You’ll have to texture an item of course, add code and so much more! In this article we’ll only look at some simple sample code which I also use for my own mods. Here it is!
稍安毋躁。 还有更多的东西。 您当然必须构造一个项目,添加代码等等! 在本文中,我们将只看一些简单的示例代码,这些代码也用于我自己的mod。 这里是!
`@Mod.EventBusSubscriber @Mod(modid = Version.MODID, name = Version.MODNAME, version = Version.VERSION) public class TheMod {
`@Mod.EventBusSubscriber @Mod(modid = Version.MOD ID,名称= Version.MOD NAME,版本= Version.VERSION)公共类TheMod {
public static ModMetadata metadata;
public static File baseDir;
public static Configuration config;
@SidedProxy(clientSide="com.ciphry.client.ClientProxy", serverSide="com.ciphry.common.CommonProxy")
public static CommonProxy proxy;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
baseDir = new File(event.getModConfigurationDirectory(), MOD_ID);
config = new Configuration(event.getSuggestedConfigurationFile());
if (!baseDir.exists())
baseDir.mkdir();
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
proxy.init(event);
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);
}
Use this code as you please. Just make sure you edit, for instance, the proxy strings and more. This should give you a basic overview of what a basic mod class looks like.
您可以随意使用此代码。 只需确保编辑例如代理字符串等即可。 这应该为您提供基本的mod类的基本概述。
翻译自: https://www.freecodecamp.org/news/minecraft-forge-how-to-download-install-and-use-forge/