Jump to content

Block not registering.


Teraxus

Recommended Posts

 

BlockState file.

{
    "variants": {
        "normal": { "model": "txsmod:BlockTable" }
    }
}

 

 

Reference class.

package com.teraxus.mod;

public class Ref {
public final static String MODID = "txsmod";
public static final String VERSION = "1.0.0";
public final static String NAME = "TeraxusMod";
public static final String ACCEPTED_VERSIONS = "[1.10]";

public static final String CLIENT_PROXY_CLASS = "com.teraxus.mod.proxy.ClientProxy";
public static final String SERVER_PROXY_CLASS = "com.teraxus.mod.proxy.ServerProxy";

public static enum TeraxusItems
{
	CARAMEL("caramel", "ItemCaramel"),
	DIAMOND_NUGGET("diamond nugget", "ItemDiamondNugget");

	private String unlocalizedName;
	private String registryName;

	TeraxusItems(String unlocalizedName, String registryName)
	{
		this.unlocalizedName = unlocalizedName;
		this.registryName = registryName;
	}

	public String getUnlocalizedName()
	{
		return unlocalizedName;
	}
	public String getRegistryName()
	{
		return registryName;
	}
}

public static enum TeraxusBlocks
{
	TABLE("table", "BlockTable");

	private String unlocalizedName;
	private String registryName;

	TeraxusBlocks(String unlocalizedName, String registryName)
	{
		this.unlocalizedName = unlocalizedName;
		this.registryName = registryName;
	}

	public String getUnlocalizedName()
	{
		return unlocalizedName;
	}
	public String getRegistryName()
	{
		return registryName;
	}
}
}

 

 

Main class.

package com.teraxus.mod;

import com.teraxus.mod.init.CraftingRecepies;
import com.teraxus.mod.init.ModBlocks;
import com.teraxus.mod.init.ModItems;
import com.teraxus.mod.proxy.CommonProxy;

import net.minecraft.init.Blocks;
import net.minecraft.network.ServerStatusResponse.Players;
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.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Ref.MODID, version = Ref.VERSION, name = Ref.NAME, acceptedMinecraftVersions = Ref.ACCEPTED_VERSIONS)
public class ExampleMod {

@Instance
public static ExampleMod instance;

@SidedProxy(clientSide = Ref.CLIENT_PROXY_CLASS, serverSide = Ref.SERVER_PROXY_CLASS)
public static CommonProxy proxy;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) 
{
	System.out.println(Ref.NAME + " is preinitializing!");
	ModItems.init();
	ModItems.register();
	ModBlocks.init();
	ModBlocks.register();
}

@Mod.EventHandler
public void init(FMLInitializationEvent event) 
{
	System.out.println(Ref.NAME + " is initializing!");
	proxy.init();

	CraftingRecepies.register();
}

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) 
{
	System.out.println(Ref.NAME + " is postinitializing!");
}
}

 

 

Modblocks class. (Registration and intialization class)

package com.teraxus.mod.init;

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.fml.common.registry.GameRegistry;

public class ModBlocks {

public static Block table;

public static void init()
{
	table = new BlockTable();
}
public static void register()
{
	GameRegistry.register(table);
}
public static void registerRenders()
{
	registerRender(table);
}
private static void registerRender(Block block)
{
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
}

 

 

Block class.

package com.teraxus.mod.init;

import com.teraxus.mod.Ref;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;

public class BlockTable extends Block {

public BlockTable() {
	super(Material.WOOD);
	setUnlocalizedName(Ref.TeraxusBlocks.TABLE.getUnlocalizedName());
	setRegistryName(Ref.TeraxusBlocks.TABLE.getRegistryName());
	setCreativeTab(CreativeTabs.DECORATIONS);
}

}

 

 

The block is not in the creative inventory and I cant get it by doing /give. I am a total beginner at the Forge API.

Link to comment
Share on other sites

GameRegistry.register(new ItemBlock(block))

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Post the full log and your code.

Log: http://pastebin.com/wmfU6tsE

The class that registers the block:

 

package com.teraxus.mod.init;

import com.teraxus.mod.Ref;

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.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModBlocks {

public static Block table;

public static void init()
{
	table = new BlockTable();
}
public static void register()
{
	GameRegistry.register(table);
	GameRegistry.register(new ItemBlock(table).setRegistryName(Ref.TeraxusBlocks.TABLE.getRegistryName()));
}
public static void registerRenders()
{
	registerRender(table);
}
private static void registerRender(Block block)
{
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
}

 

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.



×
×
  • Create New...

Important Information

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