Jump to content

[1.8] Frustrating Missing Textures


1Poseidon3

Recommended Posts

Hey guys. This is more or less directed at Choonster since I used his framework from his test mod as the framework for rendering my models and there are some things I can't figure out and I'm hoping someone can help. Basically, none of the item or block textures are rendering in my inventory or when I hold them in my hand. Though, when I place the block the texture shows up on the block in the world. Why is this happening? It also cannot find the textures for the test liquid I created. I'll post all relevant file code below. Like I said, this looks a lot like Choonsters way of mod creation which I am borrowing to create my own mod. If you don't want me to use your mod framework then I can just start over. If I am allowed to use it, I'll credit you for the framework. Just thought I'd toss that in as a side note.

 

 

TMModelManager.java

 

 


package com.poseidon.testmod.client.model;


import com.poseidon.testmod.init.TMBlocks;
import com.poseidon.testmod.init.TMFluids;
import com.poseidon.testmod.init.TMItems;
import com.poseidon.testmod.util.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCommandBlock;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;


import java.util.HashSet;
import java.util.Set;


public class TMModelManager {
public static final TMModelManager INSTANCE = new TMModelManager();


private static final String FLUID_MODEL_PATH = Constants.RESOURCE_PREFIX + "fluid";


private TMModelManager() {}


public void registerAllModels() {
	registerFluidModels();
	//registerBucketModels();


	registerBlockModels();


	registerItemVariants();
	registerItemModels();
}


private void registerFluidModels() {
	TMFluids.fluidBlocks.forEach(this::registerFluidModel);
}


private void registerFluidModel(IFluidBlock fluidBlock) {
	Item item = Item.getItemFromBlock((Block) fluidBlock);


	ModelBakery.addVariantName(item);


	ModelResourceLocation modelResourceLocation = new ModelResourceLocation(FLUID_MODEL_PATH, fluidBlock.getFluid().getName());


	ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> modelResourceLocation));


	ModelLoader.setCustomStateMapper((Block) fluidBlock, new StateMapperBase() {
		@Override
		protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_) {
			return modelResourceLocation;
		}
	});
}


private void registerBlockModels() {
	registerBlockItemModel(TMBlocks.test_block, "tm:test_block");


	TMBlocks.blocks.forEach(this::registerBlockItemModel);
}


private void registerBlockItemModel(Block block) {
	registerItemModel(Item.getItemFromBlock(block));
}


private void registerBlockItemModel(Block block, String modelLocation) {
	registerItemModel(Item.getItemFromBlock(block), modelLocation);
}


private void registerItemVariants() {
	for (int stage = 0; stage < 3; stage++) { // Add a variant for each stage's model


	}
}


private Set<Item> itemsRegistered = new HashSet<>();


private void registerItemModels() {
	registerItemModel(TMItems.icon);
	registerItemModel(TMItems.test_item);


	TMItems.items.forEach(this::registerItemModel);
}


private void registerItemModel(Item item) {
	registerItemModel(item, Item.itemRegistry.getNameForObject(item).toString());
}


private void registerItemModel(Item item, String modelLocation) {
	if (!itemsRegistered.contains(item)) {
		itemsRegistered.add(item);


		final ModelResourceLocation fullModelLocation = new ModelResourceLocation(modelLocation, "inventory");
		ModelBakery.addVariantName(item, modelLocation);


		ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> fullModelLocation));
	}
}
}

 

 

 

 

TMItems.java

 

 


package com.poseidon.testmod.init;


import net.minecraft.item.*;
import net.minecraftforge.fml.common.registry.GameRegistry;


import java.util.HashSet;
import java.util.Set;


import com.poseidon.testmod.item.Icon;
import com.poseidon.testmod.item.TestItem;


public class TMItems {

public static final Set<Item> items = new HashSet<>();

public static Item icon;
public static Item test_item;

public static void registerItems()
{
	icon = registerItem(new Icon());
	test_item = registerItem(new TestItem());

}

private static <T extends Item> T registerItem(T item) {
	return registerItem(item, item.getUnlocalizedName());
}


private static <T extends Item> T registerItem(T item, String name) {
	GameRegistry.registerItem(item, name);
	items.add(item);
	return item;
}
}

 

 

 

 

TMBlocks.java

 

 


package com.poseidon.testmod.init;


import com.poseidon.testmod.Reference;
import com.poseidon.testmod.block.TestBlock;


import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.common.registry.GameRegistry;


import java.util.HashSet;
import java.util.Set;


public class TMBlocks {

public static final Set<Block> blocks = new HashSet<>();

public static Block test_block;

public static void registerBlocks()
{

	test_block = registerBlock(new TestBlock());
}

/**
 * Register a Block with the default ItemBlock class.
 *
 * @param block The Block instance
 * @param <T>   The Block type
 * @return The Block instance
 */
private static <T extends Block> T registerBlock(T block) {
	GameRegistry.registerBlock(block, block.getUnlocalizedName().replaceFirst("tile.", ""));
	blocks.add(block);
	return block;
}


/**
 * Register a Block with a custom ItemBlock class.
 *
 * @param block           The Block instance
 * @param itemClass       The ItemBlock class
 * @param constructorArgs Arguments to pass to the ItemBlock constructor
 * @param <T>             The Block type
 * @return The Block instance
 */
private static <T extends Block> T registerBlock(T block, Class<? extends ItemBlock> itemClass, Object... constructorArgs) {
	GameRegistry.registerBlock(block, itemClass, block.getUnlocalizedName(), constructorArgs);
	blocks.add(block);
	return block;
}


public static void registerTileEntities() {
	//registerTileEntity(HydrogenBlock.class, "hydrogen_block");
	//registerTileEntity(TileEntityFluidTank.class, "fluidTank");
}


private static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id) {
	GameRegistry.registerTileEntity(tileEntityClass, Reference.MOD_ID + ":" + id);
}
}

 

 

 

 

TestMod.java

 

 


package com.poseidon.testmod;


import com.poseidon.testmod.init.TMBlocks;
import com.poseidon.testmod.init.TMFluids;
import com.poseidon.testmod.init.TMItems;
import com.poseidon.testmod.proxy.CommonProxy;


import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.common.registry.GameRegistry;


@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class TestMod
{

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;

public static final TMTab tab = new TMTab("tab");

@Mod.Instance(Reference.MOD_ID)
public static TestMod instance;


public static SimpleNetworkWrapper network;

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	TMItems.registerItems();
	TMBlocks.registerBlocks();
	TMFluids.registerFluids();
	proxy.preInit();
} 

@EventHandler
public void init(FMLInitializationEvent event)
{
	proxy.init();
}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
	proxy.postInit();
}
}

 

 

 

 

ClientProxy.java

 

 


package com.poseidon.testmod.proxy;


import com.poseidon.testmod.client.model.TMModelManager;
import com.poseidon.testmod.init.TMBlocks;
import com.poseidon.testmod.init.TMItems;


import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;


public class ClientProxy extends CommonProxy {

private final Minecraft minecraft = Minecraft.getMinecraft();

@Override
public void preInit() {
	super.preInit();

	TMModelManager.INSTANCE.registerAllModels();
}

@Override
public void doClientRightClick() {
	super.doClientRightClick();

	KeyBinding.onTick(minecraft.gameSettings.keyBindUseItem.getKeyCode());
}

@Override
public EntityPlayer getClientPlayer() {
	return minecraft.thePlayer;
}
}

 

 

 

 

I feel like those are all of the relevant files. I don't think there's anything wrong with the textures or .json files. If anyone could help out that would be awesome. Thanks!

egg

Link to comment
Share on other sites

Have you used log output or the debugger to verify that methods like getNameForObject(item).toString() give output that matches labels used in json files and meshing?

 

And where are your json files? Have you validated them in jsonlint?  Those json files are very fragile and prone to frustrating, hard to see errors. Capitalization, pluralization and even underscores can ruin your day.

 

Finally, I don't see an item model mesher in an init method in your client proxy  :(  IIRC, You can't texture items without item models, and you can't mesh item models before TheMinecraft instance is constructed during the init phase (Your static call to getMinecraft() is probably premature and should return null).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

I believe the issue might be registering the items with getUnlocalizedName since that is, by default, going to return whatever name you specified for the item, plus .name

 

Try changing that to a literal string, or use .substring(0,getUnlocalizedName().length()-".name".length()), or something of the sorts.

Link to comment
Share on other sites

....you mean like length() - 5?

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

Finally, I don't see an item model mesher in an init method in your client proxy  :(  IIRC, You can't texture items without item models, and you can't mesh item models before TheMinecraft instance is constructed during the init phase (Your static call to getMinecraft() is probably premature and should return null).

 

ModelLoader.setCustomModelResourceLocation

and

ModelLoader.setCustomMeshDefinition

can be called during preInit to do the same thing as calling

ItemModelMesher#register

in init.

 

The

Minecraft

instance is created and stored before mod loading starts, though the

ItemModelMesher

instance is only created between preInit and init.

 

1Poseidon3: You're free to use my code within the terms of the MIT License (basically you can do what you want with it as long as you credit me). I don't really mind if you include the credit in every file or just include a line in your license/readme.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Thanks for all the help guys. I'll try out all of the suggestions now that I have the chance and report back! Also, thanks for the information Choonster. I'll be sure to credit you.  :D

 

 

EDIT: I forgot to include this in the original post. Here's an error type thing I saw on startup in the console.

 

 

Error

 

 

[19:43:21] [Client thread/ERROR] [FML]: Model definition for location tm:fluid#test_fluid not found
[19:43:21] [Client thread/ERROR] [FML]: Model definition for location tm:item.icon#inventory not found
[19:43:21] [Client thread/ERROR] [FML]: Model definition for location tm:item.test_item#inventory not found
[19:43:21] [Client thread/ERROR] [FML]: Model definition for location tm:test_block#inventory not found

 

 

egg

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, I have built a new ai model that can create any minecraft texture 16X16 pixels from a text prompt. I've deployed this model on a server with a standard http request.  I want to build a mod where the player can enter text through the chat/text box and load the created texture from the ai model to a simple block. Any ideas for where to start?, I think the most challenging part is loading texture to an object dynamically, do you know any similar projects?
    • If donation/download revenue won't cut it I may also be willing to make arrangements to pay for at least an assistant that can deal with Networking(Pipe Logic & Packets), and ANYTHING rendering related that is not adding basic block models(Anything to do with OpenGL, especially in minecraft, makes my head spin and I just can't wrap my mind around it). We can discuss amounts through messages if it comes to this.
    • Hello, I installed minecraft 1.16.2, then i downloaded forge 1.16.2-33.0.20 and it just won t open...no error message...
    • [29may2023 23:10:06.337] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, Fabu10th, --version, 1.19.3-forge-44.1.23, --gameDir, C:\Users\fabuo\AppData\Roaming\.minecraft, --assetsDir, C:\Users\fabuo\AppData\Roaming\.minecraft\assets, --assetIndex, 2, --uuid, 1f7b7b2f9e814cf4b23dfa2f0ccb79a1, --accessToken, ????????, --clientId, N2EyZmZhMTUtYjA0OC00N2RkLTg2NTgtZDM2YTUwNTZlODFj, --xuid, 2535425619212215, --userType, msa, --versionType, release, --launchTarget, forgeclient, --fml.forgeVersion, 44.1.23, --fml.mcVersion, 1.19.3, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20221207.122022] [29may2023 23:10:06.341] [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 [29may2023 23:10:07.130] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.onLoad [29may2023 23:10:07.131] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/fabuo/AppData/Roaming/.minecraft/mods/OptiFine_1.19.3_HD_U_I3.jar%23265!/ [29may2023 23:10:07.138] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\fabuo\AppData\Roaming\.minecraft\mods\OptiFine_1.19.3_HD_U_I3.jar [29may2023 23:10:07.140] [main/INFO] [optifine.OptiFineTransformer/]: Target.PRE_CLASS is available [29may2023 23:10:07.185] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/fabuo/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2398!/ Service=ModLauncher Env=CLIENT [29may2023 23:10:07.190] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.initialize [29may2023 23:10:07.783] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.19.3-44.1.23\fmlcore-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.787] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.19.3-44.1.23\javafmllanguage-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.791] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.19.3-44.1.23\lowcodelanguage-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.794] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.19.3-44.1.23\mclanguage-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.935] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 8 dependencies adding them to mods collection [29may2023 23:10:08.445] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.transformers [29may2023 23:10:08.451] [main/INFO] [optifine.OptiFineTransformer/]: Targets: 395 [29may2023 23:10:09.288] [main/INFO] [optifine.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] [29may2023 23:10:10.427] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [29may2023 23:10:10.610] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [ca.spottedleaf.starlight.mixin.MixinConnector] [29may2023 23:10:10.610] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.19.3-forge-44.1.23, --gameDir, C:\Users\fabuo\AppData\Roaming\.minecraft, --assetsDir, C:\Users\fabuo\AppData\Roaming\.minecraft\assets, --uuid, 1f7b7b2f9e814cf4b23dfa2f0ccb79a1, --username, Fabu10th, --assetIndex, 2, --accessToken, ????????, --clientId, N2EyZmZhMTUtYjA0OC00N2RkLTg2NTgtZDM2YTUwNTZlODFj, --xuid, 2535425619212215, --userType, msa, --versionType, release] [29may2023 23:10:10.650] [main/INFO] [Rubidium/]: Loaded configuration file for Rubidium: 30 options available, 0 override(s) found [29may2023 23:10:10.684] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.686] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras_forge.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.703] [main/WARN] [mixin/]: Reference map 'xlpackets.refmap.json' for xlpackets.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.718] [main/WARN] [mixin/]: Reference map 'configured.refmap.json' for configured.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.728] [main/WARN] [mixin/]: Reference map 'simplyswords-common-refmap.json' for simplyswords-common.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.729] [main/WARN] [mixin/]: Reference map 'simplyswords-forge-refmap.json' for simplyswords.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.767] [main/WARN] [mixin/]: Reference map 'apexcore.refmap.json' for apexcore.mixins.json could not be read. If this is a development environment you can ignore this message
    • I'm looking for someone who for the most part would be taking over my mods main development. With work I just can't give it the time it deserves but I think it will be a good mod to fill the void of BuildCraft while still having its own unique twist. It is currently still only on 1.16.5 only because I just haven't had the time to try and get an update plus there were features I was working on that I had wanted to hammer out first. Not to mention I'm just not very good at Java or Programming in general. I can get things done and they mostly work but I am just not skilled enough to keep my brain child alive and honestly optimized. My only real requirement is that if I choose to come back I want to be able to jump back in and do so(Not take over per say just add to it again from time to time). I have a basic outline of how I want things to work in general for the things not added yet that were planned features and I also have some started but not yet finished ideas in. I'm currently working on getting a repo up on github that has my most current code so that way its easier for everyone involved to contribute. I'm sure the best first step would be to update to the newest version of forge first before doing this to give the next person a good head start but I'm sure alot of my stuff needs rewritten anyways so I figured I'd do this now as it sits.  Any other questions or details can be worked out through messages but if you are interested please drop a reply. Here is the link to the curseforge page which you can use to get to the github repo: https://www.curseforge.com/minecraft/mc-mods/mechanicraft For anyone who is interested please leave a reply. You will be added to the curseforge as a member and since I will be contributing less 80% of anything that is earned/donated because of this mod will be kicked your way(Can be controlled through curseforge, they have a way to split the earning).
  • Topics

×
×
  • Create New...

Important Information

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