简体   繁体   English

Minecraft Forge 1.16.5 自 1.16.4 起更改 - 编译错误

[英]Minecraft Forge 1.16.5 changes since 1.16.4 - compiling error

I am trying to learn Minecraft modding, and while following a tutorial for version 1.16.4, I found that their code did not work, and I presume this is a change to the API, since I am using 1.16.5.我正在尝试学习 Minecraft 改装,在遵循 1.16.4 版本的教程时,我发现他们的代码不起作用,我认为这是对 API 的更改,因为我使用的是 1.16.5。

I have looked at both official and unofficial API docs, but these did not provide me any insight.我查看了官方和非官方 API 文档,但这些并没有为我提供任何见解。 Could anyone point me to a better API reference, or better yet, to a VSCode extension that autocompletes for the most recent Forge API.谁能给我指出一个更好的 API 参考,或者更好的是一个 VSCode 扩展,它可以自动完成最新的 Forge API。

Here is the compile error when I ran ./gradlew.bat build with my minimal reproducible example (sorry about the code highlighting, I don't know how to fix it):这是我使用最小的可重现示例运行./gradlew.bat build时出现的编译错误(抱歉代码突出显示,我不知道如何修复它):

C:\Users\eric\Desktop\Programming\Java\Minecraft Mod 1\src\main\java\com\ericl5445\testmod1\core\init\ItemInit.java:1: error: package net.minecraftforge.item does not exist
import net.minecraftforge.item.Item;
                              ^
C:\Users\eric\Desktop\Programming\Java\Minecraft Mod 1\src\main\java\com\ericl5445\testmod1\core\init\ItemInit.java:2: error: package net.minecraftforge.item does not exist
import net.minecraftforge.item.ItemGroup;
                              ^

Here is my full code: TestMod1.java ItemInit.java这是我的完整代码: TestMod1.java ItemInit.java

Any help would really be appreciated!任何帮助将不胜感激!

I do not have an api reference, however I have found that the ItemGroup class is not under net.minecraftforge.item .我没有 api 参考,但是我发现 ItemGroup class 不在net.minecraftforge.item下。 It is under the package net.minecraft.item .它在 package net.minecraft.item下。

Your IDE, usually Intellij Idea or Eclipse, should be able to tell you where these classes are located via a search functionality.您的 IDE,通常是 Intellij Idea 或 Eclipse,应该能够通过搜索功能告诉您这些类的位置。 In Eclipse, you can press Control/Command + Shift + T to bring up a search box with a list of all the classes in your workspace.在 Eclipse 中,您可以按 Control/Command + Shift + T 来打开一个搜索框,其中包含工作区中所有类的列表。

The Package You Need To import is net.minecraft.item.Item and net.minecraft.itemGroup, Not net.minecraftforge.item.Item and net.minecraftforge.itemGroup您需要导入的 Package 是 net.minecraft.item.Item 和 net.minecraft.itemGroup,而不是 net.minecraftforge.item.Item 和 net.minecraftforge.itemGroup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM