简体   繁体   English

纹理不在我的世界mod中出现

[英]Textures not appearing in minecraft mod

I am trying to mod minecraft 1.11.2 in eclipse and I put all the texure files in the right place but they just won't load. 我正在尝试在Eclipse中修改Minecraft 1.11.2,并将所有texure文件放在正确的位置,但它们不会加载。 I tried rewriting some of the java to see if I had made a mistake but nothing changed. 我尝试重写某些Java,以查看是否犯了错误,但没有任何更改。 This is my error code: 这是我的错误代码:

[11:22:57] [Client thread/INFO]: Created: 16x16 textures-atlas
[11:23:00] [Client thread/ERROR] [FML]: Exception loading model for variant wowkcraft:itemobsidianingot#inventory for item "wowkcraft:itemobsidianingot", normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model wowkcraft:item/itemobsidianingot with loader VanillaLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:323) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:153) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.io.FileNotFoundException: wowkcraft:models/item/itemobsidianingot.json
    at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:69) ~[FallbackResourceManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.access$1600(ModelLoader.java:124) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:923) ~[ModelLoader$VanillaLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 20 more
[11:23:00] [Client thread/ERROR] [FML]: Exception loading model for variant wowkcraft:itemobsidianingot#inventory for item "wowkcraft:itemobsidianingot", blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model wowkcraft:itemobsidianingot#inventory with loader VariantLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:331) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:153) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1239) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 20 more

Caused by: java.io.FileNotFoundException: wowkcraft:models/item/itemobsidianingot.json 造成原因:java.io.FileNotFoundException:wowkcraft:models / item / itemobsidianingot.json

You're missing an Item Model json. 您缺少项目模型json。 The error is buried a little deeply, as there are several possible errors that lead to a model being unable to load, so the initial error ("failed to load model") is on top of the underlying error (in this case, "file not found"). 该错误被深深地掩盖了,因为有几种可能的错误导致无法加载模型,因此初始错误(“无法加载模型”)位于基础错误(在本例中为“文件”)之上未找到”)。

Taken from the Documentation entries I wrote on the subject, with some minor alterations and updates: 摘自我在该主题上撰写的文档条目,其中进行了一些较小的更改和更新:

As with blocks, items need models too. 与积木一样,物品也需要模型。

{
    "parent": "item/generated",
    "textures": {
        "layer0": "example:items/basic"
    }
}

That's pretty much all that's needed for it to work once the item is registered. 注册该项目后,它几乎可以正常工作。 The only important thing is that the filename match the registry name used to register the block and should be in all lowercase (1.11+ file names are required to be lowercase, prior to that it is just case sensitive). 唯一重要的是文件名必须与用于注册该块的注册表名称匹配,并且应全部使用小写字母(1.11+文件名必须小写,然后再区分大小写)。

Name the model JSON file matching the registry name and save it at src\\main\\resources\\assets\\example\\models\\item\\ (where example is the mod ID specified in the @Mod annotation of your main mod class). 命名与注册表名称匹配的模型JSON文件,并将其保存在src\\main\\resources\\assets\\example\\models\\item\\ (其中example是在主mod类的@Mod批注中指定的mod ID)。

Additionally create a texture for your item, name it basic.png and save it to src\\main\\resources\\assets\\example\\textures\\items\\ (The file is referenced by the model via "layer0": "example:items/basic" which says "find a .png file named 'basic' inside the items folder of the resource location example ") 此外,为您的商品创建一个纹理,将其命名为basic.png并将其保存到src\\main\\resources\\assets\\example\\textures\\items\\ (模型通过"layer0": "example:items/basic"引用该文件"layer0": "example:items/basic"表示“在资源位置exampleitems文件夹中找到名为'basic'的.png文件”)

The item model here uses a parent of item/generated , which means that the single supplied texture will be used (as with most non-block items) and will be held in the player's hand in a default orientation. 此处的物品模型使用item/generated Generated的父对象,这意味着将使用单个提供的纹理(与大多数非方块物品一样),并将其以默认方向握在玩家的手中。 There is also item/handheld which specifies different display orientations (for tools). 还有用于指定不同显示方向(用于工具)的item/handheld Items may also supply their own "display" attribute, overriding those from the parent, but is not needed in 99.9% of uses. 项也可以提供自己的“显示”属性,以覆盖父项中的属性,但在99.9%的使用中不需要。

Registering the item: 注册项目:

Item item = new CustomItem();
string registryname = "my_item";
item.setRegistryName(registryname);
item.setUnlocalizedName(item.getRegistryName().toString());
GameRegistry.register(item);

There is an important reason to use item.setUnlocalizedName(item.getRegistryName().toString()); 使用item.setUnlocalizedName(item.getRegistryName().toString());是一个重要原因item.setUnlocalizedName(item.getRegistryName().toString()); as well! 以及! It insures that your item's unlocalized name contains your mod ID to avoid language file conflicts between mods. 它可以确保项目的未本地化名称包含您的mod ID,以避免mod之间的语言文件冲突。 It is unlikely, but entirely avoidable. 这不太可能,但完全可以避免。

Registering the item model: 注册项目模型:

final ModelResourceLocation fullModelLocation = new ModelResourceLocation(item.getRegistryName().toString(), "inventory");
ModelBakery.registerItemVariants(item, fullModelLocation);
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
    {
        public ModelResourceLocation getModelLocation(ItemStack stack)
        {
            return fullModelLocation;
        }
    });

Note that this section must be located client-side only (ie the client proxy) as many of the referenced classes do not exist on the dedicated server. 请注意,此部分只能位于客户端(即客户端代理),因为专用服务器上不存在许多引用的类。

Registering items with variants eg Saplings, has to be done a different way, using ModelLoader.setCustomModelResourceLocation(item, metadata, resourceLocation) although it lets us use a Blockstate file to specify our variants (which is much preferred to the alternative). 使用ModelLoader.setCustomModelResourceLocation(item, metadata, resourceLocation)注册带有变体(例如ModelLoader.setCustomModelResourceLocation(item, metadata, resourceLocation)必须以不同的方式完成ModelLoader.setCustomModelResourceLocation(item, metadata, resourceLocation)尽管它允许我们使用Blockstate文件来指定我们的变体(这是替代方法的首选)。

For 1.12+ modders: 对于1.12+修改器:

This also works in 1.11, but is required in 1.12 and forward 这在1.11中也有效,但在1.12及更高版本中是必需的

GameRegistry.register() is now private . GameRegistry.register()现在是private Instead you must register things in the RegistryEvent.Register<T> event through an event handler. 相反,您必须通过事件处理程序在RegistryEvent.Register<T>事件中注册事物。 Simply subscribe to the RegistryEvent.Register<Item> or RegistryEvent.Register<Block> event (as well as others: an event is fired for each registry type) in order to register items and blocks. 只需订阅RegistryEvent.Register<Item>RegistryEvent.Register<Block>事件(以及其他事件:每个注册表类型都会触发一个事件)以注册项目和块。 Simply call event.getRegistry().add(...) or event.getRegistry().addAll(...) for every object that needs to be registered. 只需为每个需要注册的对象调用event.getRegistry().add(...)event.getRegistry().addAll(...) addAll will accept an array or list. addAll将接受数组或列表。 You can see an example of this here . 您可以在这里看到一个示例。

For models, you do the same thing as above, but in the ModelRegistryEvent instead. 对于模型,您执行与上述相同的操作,但是在ModelRegistryEvent You can see an example of this here although heavily modified to allow for additional variations in models not discussed here (supporting custom MeshDefinitions and StateMappers). 您可以在此处看到一个示例,尽管对其进行了重大修改以允许此处未讨论的模型有其他变化(支持自定义MeshDefinitions和StateMappers)。

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

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