Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I recently started using nbt data to hold item variants. However, when using ModelLoader.setCustomMeshDefinition and ModelBakery.registerItemVariants, the textures do not render whatsoever. The text that says "modid:location#inventory" does not appear on the not rendered item either. Any help is much appreciated.

 

Render register class:

package com.championash5357.tabletop.event;

import com.championash5357.tabletop.client.Namespace;
import com.championash5357.tabletop.init.Items;
import com.championash5357.tabletop.init.Items.ItemRegistration;
import com.championash5357.tabletop.registry.CardType;
import com.championash5357.tabletop.util.CardUtil;

import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod.EventBusSubscriber(modid = Namespace.ID)
public class Events {

	@SubscribeEvent
	public static void registerModels(final ModelRegistryEvent event) {
		final NonNullList<Item> items = NonNullList.<Item>create();
		items.addAll(ItemRegistration.ITEMS);
		
		for(Item item : items)
			ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
		
		ModelLoader.setCustomMeshDefinition(Items.CARD, new ItemMeshDefinition() {

			@Override
			public ModelResourceLocation getModelLocation(ItemStack stack) {
				String name = CardUtil.getRegistryNameFromNBT(stack);
				return new ModelResourceLocation(stack.getItem().getRegistryName() + "_" + name.split("\\.")[1], "inventory");
			}
			
		});
	}
	
	@SubscribeEvent
	public static void registerVariants(final ModelBakeEvent event) {
		for(CardType card : GameRegistry.findRegistry(CardType.class).getValuesCollection())
			ModelBakery.registerItemVariants(Items.CARD, new ResourceLocation(Namespace.ID, "card_" + card.getRegistryName().getResourcePath().split("\\.")[1]));
	}
}

 

Edited by ChampionAsh5357

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.