Jump to content

[1.12] Register ItemBlock model/texture [Solved]


IceMetalPunk
 Share

Recommended Posts

I've added a new block to the game, which is fully functional. It has its own block model and textures, which also works fine. But now, I'm trying to give its ItemBlock a model, and it's just not working.

I've noticed that quite a few things about item and block registration have changed in Forge for 1.12; how would I properly register an item model?

Currently, I'm simply creating an ItemBlock from my block class and registering it with the GameRegistry.findRegistry(Item.class) registry. Then I have a JSON file in my assets/<mod>/models/item folder (using the actual mod ID, not literally "<mod>") which simply defines the model parent to be the block model that already works.

But the item isn't showing up; it's just the standard purple-and-black "not found" texture instead. So then I tried adding a call, after registering the item with FML, to ModelBakery.registerItemVariants passing only one registry name to it, in hopes that would work out; it didn't change anything. No errors, just also no item model.

I'm probably missing a step or two; what am I missing?

Edited by IceMetalPunk
Solved

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

Hey, I hope this will help you :

 

@SideOnly(Side.CLIENT)
public static void initClient(ItemModelMesher mesher) {
	
	Item item = Item.getItemFromBlock(YOUR_BLOCK);
	ModelResourceLocation model = new ModelResourceLocation("modName:" + "blockName", "inventory");
	ModelLoader.registerItemVariants(item, model);
	mesher.register(item, 0, model);
}

 

Note : this needs to be called from your ClientProxy class, from the FMLInitializationEvent event.

Link to comment
Share on other sites

Why are you using the ModelMesher?

If you're going to do it this way (and not the Registry events) then you should be using ModelLoader.setCustomModelResourceLocation

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

2 minutes ago, Draco18s said:

Why are you using the ModelMesher?

If you're going to do it this way (and not the Registry events) then you should be using ModelLoader.setCustomModelResourceLocation

Well, I made it this way and it worked so I didn't look further, but it's probably better using the events anyway, you are right.

Link to comment
Share on other sites

2 minutes ago, Draco18s said:

Why are you using the ModelMesher?

If you're going to do it this way (and not the Registry events) then you should be using ModelLoader.setCustomModelResourceLocation

Dylem's solution seems to work just fine; when I tried switching the code to ModelLoader.setCustomModelResourceLocation(this.itemBlock, 0, model) [this.itemBlock is of course the ItemBlock instance], it doesn't work, it just shows the purple-and-black undefined model instead again...

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

Just now, IceMetalPunk said:

Dylem's solution seems to work just fine; when I tried switching the code to ModelLoader.setCustomModelResourceLocation(this.itemBlock, 0, model) [this.itemBlock is of course the ItemBlock instance], it doesn't work, it just shows the purple-and-black undefined model instead again...

ModelLoader needs to be called during PreInit, not Init.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

2 minutes ago, Draco18s said:

ModelLoader needs to be called during PreInit, not Init.

Ah! And now it works! :D So what's the main benefit to using ModelLoader rather than ItemModelMesher? They seem to work equally well, just with registration occurring at different times. Is there a benefit under the hood I'm not aware of?

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! When I'm trying to get items by tag during the recipe serialization, I'm getting an empty list. I have a guess that item tags're not loaded by the time minecraft loads my recipes. Here's my code: Class that saves information about ingredient's count Recipe serializer with some aux methods: Registry: Example of the json recipe file:  
    • I tried to install client forge on my linux desktop. But after "installation" it's missing forge[version].jar file in .minecraft/versions. I tried java 11 and 8 environment with same result. Here link to log file from installation: https://drive.google.com/file/d/1vtg9NT-WX5ilb1aNUvZlOv54gKWJuaT1/view?usp=share_link. I don't know what to do. I give for every directory permissions that I don't think that is issue. I will try check older versions if universal file work. Debian 11 (kernel 5.10)
    • I recently got error 1 in the launcher, so I restarted the .minecraft. After restarting it, I can't get the Forge 1.19.2 - 43.1.1 installer to run, I tried other versions and I get the same result, it opens a black box that closes instantly and nothing happens. I already tried to restart my pc, minecraft, update and reinstall java, run vanilla 1.19.2 and more recent versions of the game, disable Windows Firewall and antivirus and I still haven't solved it. Many times I installed forge and never ran into this problem. If I could receive assistance I would be very grateful.  
    • Here's the default loot table for gravel block: { "type": "minecraft:block", "pools": [ { "rolls": 1.0, "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:match_tool", "predicate": { "enchantments": [ { "enchantment": "minecraft:silk_touch", "levels": { "min": 1 } } ] } } ], "name": "minecraft:gravel" }, { "type": "minecraft:alternatives", "conditions": [ { "condition": "minecraft:survives_explosion" } ], "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:table_bonus", "enchantment": "minecraft:fortune", "chances": [ 0.1, 0.14285715, 0.25, 1.0 ] } ], "name": "minecraft:flint" }, { "type": "minecraft:item", "name": "minecraft:gravel" } ] } ] } ] } ] } This is a finicky loot table. If I add anything to it, nothing drops. I've added pools, entries, children ... you name it. Does anyone know the particulars about this table? I mean, periodically gravel drops flint instead of a gravel block. I understand the condition that could drop flint if the block survives an explosion. Otherwise, it drops the gravel block itself. I would like to further understand why the use of `children` and the set of `chance` values given in the explosion child entry. What I do understand is that `"type" : "minecraft:alternatives"` means that if this child/entry is successful, then it stops generating loot for this entry/pool. How often does the flint drop and is that taken care of in another location? Is that in a `"condition" : "minecraft:table_bonus"` loot table? Hmmm... I'll have to go take a look and see if there is something called table_bonus.json.
    • No mod is working. Im trying to create a pack for some friends but cant get past this. I reinstalled Forge and I got a complete install pop up like normal   [29Jan2023 14:17:58.884] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, Oddie23110, --version, 1.19.3-forge-44.1.8, --gameDir, C:\Users\Oddie\AppData\Roaming\.minecraft, --assetsDir, C:\Users\Oddie\AppData\Roaming\.minecraft\assets, --assetIndex, 2, --uuid, d7db39d1b1f940ac841852e76fe1844c, --accessToken, ????????, --clientId, M2JmY2FlYTktNzE1OC00NzYwLThlMzUtNGIxYzA1MzcwNTli, --xuid, 2535431288182209, --userType, msa, --versionType, release, --width, 1600, --height, 900, --launchTarget, forgeclient, --fml.forgeVersion, 44.1.8, --fml.mcVersion, 1.19.3, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20221207.122022] [29Jan2023 14:17:58.889] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 17.0.3 by Microsoft; OS Windows 10 arch amd64 version 10.0 [29Jan2023 14:17:59.094] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/Oddie/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2392!/ Service=ModLauncher Env=CLIENT [29Jan2023 14:17:59.498] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.19.3-44.1.8\fmlcore-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.503] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.19.3-44.1.8\javafmllanguage-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.507] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.19.3-44.1.8\lowcodelanguage-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.513] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.19.3-44.1.8\mclanguage-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.653] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: flywheel. Using Mod File: C:\Users\Oddie\AppData\Roaming\.minecraft\mods\flywheel-forge-1.19.2-0.6.8.a.jar [29Jan2023 14:17:59.654] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 1 dependencies adding them to mods collection [29Jan2023 14:18:00.624] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [29Jan2023 14:18:00.629] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.19.3-forge-44.1.8, --gameDir, C:\Users\Oddie\AppData\Roaming\.minecraft, --assetsDir, C:\Users\Oddie\AppData\Roaming\.minecraft\assets, --uuid, d7db39d1b1f940ac841852e76fe1844c, --username, Oddie23110, --assetIndex, 2, --accessToken, ????????, --clientId, M2JmY2FlYTktNzE1OC00NzYwLThlMzUtNGIxYzA1MzcwNTli, --xuid, 2535431288182209, --userType, msa, --versionType, release, --width, 1600, --height, 900] [29Jan2023 14:18:00.827] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/texture/TextureAtlas$Preparations (java.lang.ClassNotFoundException: net.minecraft.client.renderer.texture.TextureAtlas$Preparations) [29Jan2023 14:18:00.827] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.renderer.texture.TextureAtlas$Preparations was not found flywheel.mixins.json:atlas.SheetDataAccessor [29Jan2023 14:18:00.840] [main/WARN] [mixin/]: Error loading class: me/jellysquid/mods/sodium/client/render/chunk/data/ChunkRenderData$Builder (java.lang.ClassNotFoundException: me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData$Builder) [29Jan2023 14:18:00.840] [main/WARN] [mixin/]: @Mixin target me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData$Builder was not found flywheel.mixins.json:instancemanage.SodiumChunkRenderDataMixin [29Jan2023 14:18:00.853] [main/WARN] [mixin/]: Error loading class: com/mojang/math/Matrix3f (java.lang.ClassNotFoundException: com.mojang.math.Matrix3f) [29Jan2023 14:18:00.854] [main/WARN] [mixin/]: @Mixin target com.mojang.math.Matrix3f was not found flywheel.mixins.json:matrix.Matrix3fMixin [29Jan2023 14:18:00.855] [main/WARN] [mixin/]: Error loading class: com/mojang/math/Matrix4f (java.lang.ClassNotFoundException: com.mojang.math.Matrix4f) [29Jan2023 14:18:00.856] [main/WARN] [mixin/]: @Mixin target com.mojang.math.Matrix4f was not found flywheel.mixins.json:matrix.Matrix4fMixin [29Jan2023 14:18:00.974] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/texture/TextureAtlas$Preparations (java.lang.ClassNotFoundException: net.minecraft.client.renderer.texture.TextureAtlas$Preparations) [29Jan2023 14:18:03.993] [pool-3-thread-1/INFO] [net.minecraft.util.datafix.DataFixers/]: Building unoptimized datafixer [29Jan2023 14:18:05.173] [Render thread/WARN] [mixin/]: Error loading class: com/mojang/math/Quaternion (java.lang.ClassNotFoundException: com.mojang.math.Quaternion) [29Jan2023 14:18:05.175] [Render thread/FATAL] [mixin/]: Mixin apply failed flywheel.mixins.json:matrix.PoseStackMixin -> com.mojang.blaze3d.vertex.PoseStack: org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException Unexpecteded ClassMetadataNotFoundException whilst transforming the mixin class: [MAIN Applicator Phase -> flywheel.mixins.json:matrix.PoseStackMixin -> Apply Methods -> (Lcom/mojang/math/Quaternion;)Lcom/jozufozu/flywheel/util/transform/TransformStack;:multiply -> Transform LVT -> var=quaternion -> desc=Lcom/mojang/math/Quaternion;] org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException: Unexpecteded ClassMetadataNotFoundException whilst transforming the mixin class: [MAIN Applicator Phase -> flywheel.mixins.json:matrix.PoseStackMixin -> Apply Methods -> (Lcom/mojang/math/Quaternion;)Lcom/jozufozu/flywheel/util/transform/TransformStack;:multiply -> Transform LVT -> var=quaternion -> desc=Lcom/mojang/math/Quaternion;]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethod(MixinTargetContext.java:491) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyNormalMethod(MixinApplicatorStandard.java:532) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMethods(MixinApplicatorStandard.java:518) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:386) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:325) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:383) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:365) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:250) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.processClass(MixinTransformationHandler.java:131) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156) ~[modlauncher-10.0.8.jar:10.0.8+10.0.8+main.0ef7e830]     at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:113) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) ~[securejarhandler-2.1.6.jar:?]     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]     at com.mojang.blaze3d.systems.RenderSystem.<clinit>(RenderSystem.java:83) ~[1.19.3-forge-44.1.8.jar:?]     at net.minecraft.client.main.Main.m_239872_(Main.java:174) ~[1.19.3-forge-44.1.8.jar:?]     at net.minecraft.client.main.Main.main(Main.java:51) ~[1.19.3-forge-44.1.8.jar:?]     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:27) ~[fmlloader-1.19.3-44.1.8.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: com.mojang.math.Quaternion     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformSingleDescriptor(MixinTargetContext.java:983) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformSingleDescriptor(MixinTargetContext.java:943) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformLVT(MixinTargetContext.java:544) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethod(MixinTargetContext.java:450) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     ... 36 more  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.