Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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"));

}

}

  • Author

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.