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

 

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.

  • Author

But why does it give me this: Caused by: java.io.FileNotFoundException: txsmod:models/item/BlockTable.json

  • Author

Resource files must be all lowercase.

But the json file is in models\block, not items\block. Why is it looking for items\block?

  • Author

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

 

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

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.