Jump to content

Recommended Posts

Posted

Hey guys, so I'm working on some new trees, and now I have a problem. I'm adding trees as subblocks, and I can't get the .json files to work.

 

Here's my code

 

Here's my Block Register Class

public class EadoreBlocks
{
//Trees
public static Block block_log;
public static Block block_leaves;

public static void init()
{
	//Trees
	block_log = new EadoreLog().setUnlocalizedName("log").setCreativeTab(CreativeTabs.tabBlock);
	block_leaves = new EadoreLeaves().setUnlocalizedName("leaves").setCreativeTab(CreativeTabs.tabDecorations);

}

public static void register()
{
	//Trees
	GameRegistry.registerBlock(block_log, ItemEadoreLog.class, block_log.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(block_leaves, ItemEadoreLeaves.class, block_leaves.getUnlocalizedName().substring(5));

}

public static void registerRenders()
{
	//Trees
	registerRender(block_log);
	registerRender(block_leaves);

}

public static void registerRender(Block block)
{
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new net.minecraft.client.renderer.block.model.ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}

 

Here's my custom log class

public class EadoreLog extends BlockLog
{
public static final String[] logs = new String[] {"maple", "poplar"};

public void getSubBlocks (Item item, CreativeTabs tabs, List list)
{
	for(int i = 0; i < logs.length; i++)
	{
		list.add(new ItemStack(item, 1, i));
	}
}
}

 

Here's my custom item log class

public class ItemEadoreLog extends ItemBlock
{

public ItemEadoreLog(Block block)
{
	super(block);
	this.setHasSubtypes(true);
}

public String getUnlocalizedName(ItemStack itemstack)
{
	int i = itemstack.getItemDamage();
	if(i < 0 || i >= EadoreLog.logs.length)
	{
		i = 0;
	}

	return super.getUnlocalizedName() + "_" + EadoreLog.logs[i];
}

public int getMetaData(int meta)
{
	return meta;
}
}

 

 

My main problem is that the logs look for a .json file with the name log.json. Whereas I want the maple log to look for either maple_log.json or log_maple.json, and the poplar log to look for either poplar_log.json or log_poplar.json. I don't know how to use .json files with subBlocks/metadata, but I want to learn, that's why I haven't just added two new blocks instead of subBlocks/metadata.

 

I hope someone here with better understanding of .json files or subBlocks/metadata can help me out.

Posted

1. You should have to understand the current blockstate system.

2. There is ModelRegistry.registerCustomStateMapper exactly for the use.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

1. You should have to understand the current blockstate system.

2. There is ModelRegistry.registerCustomStateMapper exactly for the use.

 

I have a hard time understanding blockstate fully, without trying it ☺️

I will try your suggestion, when I get home from work

Posted

1. You should have to understand the current blockstate system.

2. There is ModelRegistry.registerCustomStateMapper exactly for the use.

 

I feel stupid, but I can't get this to work. Could you maybe give me an example of this in use?

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.