Jump to content

[1.10.2] ItemBlock textures not found


Manu4021

Recommended Posts

Hello,

 

yesterday I started to work at a new mod, this time 1.10.2 instead of 1.7 so I discovered that there are a lot of changes to the texture system.

So I tried to work out the new system and tried to figure out what I have to do. Now everything works fine, except for the ItemBlock textures.

 

What I see ingame:

k3rgx2.png

 

So, here's my code, I removed everything what has nothing to do with the block registering.

 

Mod class:

 

package de.mc.mssystems;

import de.mc.mssystems.blocks.MSBlocks;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@Mod(modid = "matterstoragesystems", name = "MatterStorageSystems", version = "0")
public class MatterSystems
{
@Instance
public static MatterSystems instance;

@SidedProxy(clientSide = "de.mc.mssystems.ClientProxy", serverSide = "de.mc.mssystems.CommonProxy")
public static CommonProxy proxy;

public static CreativeTabs tabMSSystems = new CreativeTabs("tabMSSystems")
{
	@Override
	@SideOnly(Side.CLIENT)
	public Item getTabIconItem()
	{
		return Item.getItemFromBlock(Blocks.DIAMOND_BLOCK);
	}
};

@EventHandler
public void preInit(FMLPreInitializationEvent e)
{
	MSBlocks.registerBlocks();
}

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

 

Proxies:

 

package de.mc.mssystems;

public class CommonProxy
{
public void registerRenders() {}
}

package de.mc.mssystems;

import de.mc.mssystems.blocks.MSBlocks;
import de.mc.mssystems.items.MSItems;

public class ClientProxy extends CommonProxy
{
@Override
public void registerRenders()
{
	MSBlocks.registerRenderers();
	MSItems.registerRenderers();
}
}

 

MSBlocks:

 

package de.mc.mssystems.blocks;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MSBlocks
{
public static Block oreCerium;

public static void registerBlocks()
{
	register(oreCerium = new BlockOreCerium());
}

public static void registerRenderers()
{
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(oreCerium), 0, new ModelResourceLocation(oreCerium.getRegistryName(), "inventory"));
}

private static void register(Block block)
{
	GameRegistry.register(block);
	GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()).setUnlocalizedName(block.getRegistryName().getResourcePath()));
}
}

 

BlockOreCerium:

 

package de.mc.mssystems.blocks;

import de.mc.mssystems.MatterSystems;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.ResourceLocation;

public class BlockOreCerium extends Block
{
public BlockOreCerium()
{
	super(Material.ROCK);

	setRegistryName("matterstoragesystems:BlockOreCerium");
	setUnlocalizedName("oreCerium");
	setCreativeTab(MatterSystems.tabMSSystems);
	setHardness(2);
}
}

 

So much for the code. Now here the JSon files:

 

assets.matterstoragesystems.blockstates.BlockOreCerium.json:

 

{
    "variants": {
        "normal": { "model": "matterstoragesystems:BlockOreCerium" }
    }
}

 

assets.matterstoragesystems.models.block.BlockOreCerium.json:

 

{
  "parent": "block/cube_all",
  "textures": {
    "all": "matterstoragesystems:blocks/oreCerium"
  }
}

 

assets.matterstoragesystems.models.items.BlockOreCerium.json (The console threw an error so I expect that this is necessary - I looked up how minecraft handles that and oriented on the file for diamond ore)

 

{
    "parent": "block/diamond_ore"
}

 

And of course my texture, which lies in assets.matterstoragesystems.textures.blocks, named oreCerium.png. It obviously loads because the block has a texture when it's placed in the world.

 

I have absolutely no idea why the texture isn't showing up in my inventory. I've tried this instead as my model.item json file but this also has absolutely no effect on the outcome of things.

 

{
    "parent": "matterstoragesystems:block/BlockOreCerium"
}

 

I hope that anybody got an answer for me, google didn't find anything on that topic.

Thanks for your help,

 

Manu

Link to comment
Share on other sites

setRegistryName("matterstoragesystems:BlockOreCerium");

 

setRegistryName already prefixes your MOD ID you don't need to do it again.

 

Also don't put your model registration code in a common location, it must be in the client proxy or it will crash the dedicated server: ModelLoader extends a client-side-only class.

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

Thanks for the information, didn't know that.

 

The registerRenderers in my MSBlocks class is called by the client prox when the mod is being initialized, only if this is a client.

 

JVM:

Loading class MSBlocks.

Hmm, it has a reference to ModelLoader in it, must make sure I can fetch that class when that method gets called

Server has crashed: ClassNotFoundException

 

It's not about whether or not it gets called, the fact that it exists is the problem: the JVM can't validate the MSBlocks class as valid java code.

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

First of all, thank you Draco18s, if you put it that way it makes sense. I moved the code directly into the client proxy, now there shouldn't be any errors of java complaining about wroing imports.

 

The registerRenders is called by the Mod class in the FML Initialization Event with a call on proxy.registerRenders. It's being called, I've tested it and the console showed my debug

Link to comment
Share on other sites

First of all, thank you Draco18s, if you put it that way it makes sense. I moved the code directly into the client proxy, now there shouldn't be any errors of java complaining about wroing imports.

 

The only reason people are likely not currently seeing the issue is because ModelLoader itself is not marked as Client-side (and doesn't get loaded, only validated to exist) which might change.

 

Also, you might be interested in how I set things up.

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/EasyRegistry.java

 

Those being effectively proxy classes, but with some static methods to allow child mods to use it.

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 think the problem was that I registered the model on the init part and the block itself with the ItemBlock in the preinit. Either that or the fact that the unlocalized name differed from the registry name, which shouldn't be a problem.

 

Thanks for the help, somehow by looking at your code I managed to get this thing to display my sweat sweat cerium ore, thanks! :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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