Jump to content

[1.8] Block Textures


impavelow

Recommended Posts

Okay, so i am having troubles with adding in a texture for my block.

This is the code i have for the block:

package com.pavelow.main;

import com.pavelow.lib.RefStrings;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class PavelowOre extends Block {

public PavelowOre (Material material) 
    {
            super(material);
            setUnlocalizedName("PavelowOre");
            setHardness(4.0f);
            setStepSound(Block.soundTypeStone);
            setCreativeTab(CreativeTabs.tabBlock);
            setHarvestLevel("pickaxe",3);
    }

And that works i guess but i think the problem comes down to the main file:

@Mod(modid = RefStrings.MODID , name = RefStrings.NAME, version = RefStrings.VERSION)
public class mainRegistry {
@SidedProxy(clientSide = RefStrings.CLIENTSiDE , serverSide = RefStrings.SERVERSIDE) 
public static ServerProxy proxy;
public final static Block PavelowOre = new PavelowOre(Material.rock);
@EventHandler
public static void PreLoad(FMLPreInitializationEvent PreEvent) {
	proxy.registerRenderInfo();
	GameRegistry.registerBlock(PavelowOre, "PavelowOre");
}

@EventHandler
public static void Load(FMLInitializationEvent event) {
	if(event.getSide() == Side.CLIENT)
    	{
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(PavelowOre), 0, new ModelResourceLocation(RefStrings.MODID + ":" + PavelowOre.getUnlocalizedName().substring(5), "inventory"));
    	}

I have the json files all in the right place and have the right things in it, but i again i think the problem lies in the main files.

Link to comment
Share on other sites

1. Make use of proxies! Don't EVER do this: if(event.getSide() == Side.CLIENT)

2.

proxy.registerRenderInfo();
GameRegistry.registerBlock(PavelowOre, "PavelowOre");

You can't be registering renderers before you register item/block. Also - adding renderers should happen in init().

 

http://www.minecraftforge.net/forum/index.php/topic,26267.0.html

Have look here.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Okay so i added the rendering thing to ClientProxy:

public class ClientProxy extends ServerProxy{
public void registerRenderInfo() {
	Item PavelowOre = GameRegistry.findItem("pavelow", "PavelowOre");
	ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation("pavelow:PavelowOre", "inventory");
    final int DEFAULT_ITEM_SUBTYPE = 0;
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(PavelowOre, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation);
}
}

And add proxy.registerRenderInfo() to Init but i still get an error when i start up Minecraft.

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

Announcements



×
×
  • Create New...

Important Information

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