Jump to content

Rendering custom block render in inventory?


jordan30001

Recommended Posts

I have a Custom block render model and I am wondering how I would Render the same model in the inventory rather than a "flat" texture

 

I also have the ModelSmith/RenderSmith/TileEntitySmith if needed just ask

BlockSmith

 

package jordan30001.testMod.common.blocks.smith;

import java.util.List;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

import cpw.mods.fml.relauncher.*;
import jordan30001.testMod.common.Main;
import jordan30001.testMod.utils.Utils;


public class BlockSmith extends BlockContainer
{
private Class	thisClass;

public BlockSmith(int ID, int texID, Material m, Class c)
{
	super(ID, texID, m);
	thisClass = c;
	setBlockName("jordan30001BlockSmith");
	setTextureFile("/testModGFX/Blocks.png"); //The texture file used
	this.blockIndexInTexture = texID;
}
public boolean isOpaqueCube()
{
	return false;
}

public boolean renderAsNormalBlock()
{
	return false;
}

public int getRenderType()
{
	return -1;
}

@Override
public TileEntity createNewTileEntity(World var1)
{
	return new TileEntitySmith();
}

public TileEntity getBlockEntity()
{
	try
	{
		return (TileEntity) TileEntitySmith.class.newInstance();
	}
	catch (Exception exception)
	{
		throw new RuntimeException(exception);
	}
}

}

 

 

Link to comment
Share on other sites

This is not an answer for custom BLOCK renderer, but for custom TILEENTITY renderer. You can't (or rather you shouldn't) use this approach for blocks that are naturally ocuring. Even for blocks that are not it's not the best solution. Yes, it works, but there's a performance cost - tile entity saves itself, ticks, synchronizes and so on. This should be done via ISimpleBlockRenderingHandler.

 

sample code (not nicest, some things like dependency on TileEntityRenderer's mappings need refactoring, but it's functional):

https://github.com/mnn/jaffas/blob/b05d038e7c30c3c3fc9ea0783c640bdd76129a09/src/minecraft/monnef/jaffas/power/client/BlockRenderingHandler.java (you can browse the repo to view other classes)

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.