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:
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