Jump to content

Recommended Posts

Posted

Hey Everyone,

 

Got some help last week, was great help, was able to do 90% of the things the guy told me to do, besides the new Registry System, and I am entirely not sure what I am doing wrong.

I read through some other threads, and even have my custom Biome working perfectly fine with the new Registry System, however it seems I can't get this simple block to register

correctly, I've tried multiple rendering techniques, all failing with a NPE on the "RENDER" part.

 

If anyone can give me a slight push, I am not entirely sure what I am not getting.

 

package com.demonly.netherexpansion.blocks;

import com.demonly.netherexpansion.blocks.Molten_Obsidian.Molten_Obsidian;
import com.demonly.netherexpansion.blocks.Skull_Block.Skull_block;
import com.demonly.netherexpansion.util.Reference;

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

public class BlocksRegistry {
public static Skull_block testBlock;
public static Molten_Obsidian MoltenObsidian;

public static void preInitCommon() {

	//Registering Test_block - Old Method
	//testBlock = (Skull_block) (new Skull_block().setUnlocalizedName("test_block"));
	//GameRegistry.registerBlock(testBlock, "test_block").getUnlocalizedName().substring(5);

	//Registering MoltenObsidian - Old Method
	//MoltenObsidian = (Molten_Obsidian) (new Molten_Obsidian().setUnlocalizedName("Molten_Obsidian"));
	//GameRegistry.registerBlock(MoltenObsidian, "Molten_Obsidian").getUnlocalizedName().substring(5);

	//Testing new Method
	MoltenObsidian = new Molten_Obsidian();
	MoltenObsidian.setUnlocalizedName("Molten_Obsidian");
	MoltenObsidian.setRegistryName(MoltenObsidian.getUnlocalizedName());
	GameRegistry.register(MoltenObsidian);

}

public static void initCommon() {
}

public static void postInitCommon() {
}

public static void registerRenders() {

	//Registering the Render of the Item of testBlock
	registerBlockRender(MoltenObsidian);
	//registerBlockRender(testBlock);

}

public static void registerBlockRender(Block block) {

	MoltenObsidian = new Molten_Obsidian();

	Item render = Item.getItemFromBlock(block);

	//New Model Loader
	ModelLoader.setCustomModelResourceLocation(render, 0, (ModelResourceLocation) render.getRegistryName());

	//Old Model Loader
	//Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
	//.register(render, 0, new ModelResourceLocation(Reference.MOD_ID 
    //+ ":" + render.getUnlocalizedName().substring(5), "inventory"));

}

}

Posted

- Don't use the unlocalized name as the registry name. If anything do it the other way around.

- You never registered an ItemBlock for your Block, hence it cannot exist in the inventory or any other ItemStack based form.

 

Thank you,

 

Got it working. Much appreciation, can't believe I was missing the ItemBlock. xD

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.