Jump to content

[1.12.2] Custom bed without TileEntity-based rendering?


Kinniken
 Share

Recommended Posts

Hi all,

 

I am adding custom beds to my mod, that unlike the regular ones will display as low-lying blocks, think half-slab or a little smaller (this is intended to represent beds like Japanese futons or simple hay beds etc).

 

I could try and copy vanilla and have beds using tile entity rendering, but that seems unnecessarily complex and CPU-intensive for my purpose when block-based rendering is more than fine.

 

I tried extending BlockBed, extending TileEntityBed, and declaring an empty TileEntitySpecialRenderer for my custom TileEntity, but it stills overrides the block-based rendering - my bed is not displayed at all.

 

Any way around that? I know some blocks with tile entities still use normal rendering (like furnaces).

 

My bed block:

 

public class BlockMillBed extends BlockBed {
	public BlockMillBed(final String blockName) {
		super();

		setCreativeTab(MillBlocks.tabMillenaire);
		setUnlocalizedName(Mill.MODID + "." + blockName);
		setRegistryName(blockName);
	}

	@Override
	public TileEntity createNewTileEntity(final World worldIn, final int meta) {
		return new TileEntityMillBed();
	}

	@Override
	public boolean isBed(final IBlockState state, final IBlockAccess world, final BlockPos pos, @Nullable final Entity player) {
		return true;
	}
}

 

My empty tile entity:

 

public class TileEntityMillBed extends TileEntityBed {

}

 

Empty renderer:

 

public class TileEntityMillBedRenderer extends TileEntitySpecialRenderer<TileEntityMillBed> {

}

 

Block and TE registration:

 

event.getRegistry().register(new BlockMillBed(MillBlockNames.BED_THATCH));
		GameRegistry.registerTileEntity(TileEntityMillBed.class, Mill.MODID + ":" + MillBlockNames.BED_THATCH);

 

And renderer registration:

 

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMillBed.class, new TileEntityMillBedRenderer());

 

Oh and I've of course added a block state, bed_thatch.json:

{
    "multipart": [
        {   "apply": { "model": "millenaire:bed_thatch" }}
    ]
}

 

And a block model:

{
    "parent": "block/half_slab",
    "textures": {
        "bottom": "millenaire:blocks/thatch",
        "top": "millenaire:blocks/thatch",
        "side": "millenaire:blocks/thatch",
        "particle" : "millenaire:blocks/thatch"
    }
}

 

Any ideas? Thanks!

Link to comment
Share on other sites

If you do not want a TESR then don't register it. An empty TESR still has it's render method called even if it doesn't do anything. You can have a TE without a TESR.

As for your issue - override Block#getRenderType and make it return EnumBlockRenderType.MODEL. BlockBed overrides that to return something else.

  • Thanks 1
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
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.

 Share



×
×
  • Create New...

Important Information

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