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.

Rendering custom block render in inventory?

Featured Replies

Posted

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

}

 

 

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.

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.