Jump to content

[1.10.2] Is there special rendering requirements for TileEntities?


LemADEC

Recommended Posts

I've been able to update my mod from 1.7.10 to 1.10.2 with rendering for non-TileEntity blocks, but for some reason all TileEntity blocks are fully transparent, even through they render fine in inventory.

Is there some additional code needed when using BlockContainers?

 

Here's my block reduce to it's simplest form reproducing the issue:

1- blockstates/air_generator.json

{
"variants": {
	"normal"     : { "model": "warpdrive:air_generator" }
}
}

2- models/block/air_generator.json

{
"parent": "block/cube_all",
"textures": {
	"all" : "minecraft:blocks/log_birch_top"
}
}

3- models/item/air_generator.json

{
    "parent": "warpdrive:block/air_generator",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

4- Block code without tile entity

public class BlockAirGenerator extends Block {

public BlockAirGenerator(final String dummy) {
	super(Material.IRON);
	String registryName = "air_generator";
	setUnlocalizedName("xxx");
	// setCreativeTab(xxx);
	setRegistryName(registryName);
	GameRegistry.register(this);
	ItemBlock itemBlock = new ItemBlock(this);
	itemBlock.setRegistryName(registryName);
	GameRegistry.register(itemBlock);
}
}

=> in this case, the block renders properly in the world, on my player and in my inventory

 

5- Block with a tile entity

public class BlockAirGenerator extends BlockContainer {

public BlockAirGenerator(final String dummy) {
	super(Material.IRON);
	String registryName = "air_generator";
	setUnlocalizedName("xxx");
	// setCreativeTab(xxx);
	setRegistryName(registryName);
	GameRegistry.register(this);
	ItemBlock itemBlock = new ItemBlock(this);
	itemBlock.setRegistryName(registryName);
	GameRegistry.register(itemBlock);
	GameRegistry.registerTileEntity(TileEntityAirGenerator.class, "xxx");
}

@Nonnull
public TileEntity createNewTileEntity(@Nonnull World world, int metadata) {
	return new TileEntityAirGenerator();
}
}

public class TileEntityAirGenerator extends TileEntity {

public TileEntityAirGenerator() {
	super();
}
}

=> in this case, the block is fully transparent in the world (I can even see through it) but it renders fine on my player and in my inventory

 

Link to comment
Share on other sites

BlockContainer

overrides

Block#getRenderType

to return

EnumBlockRenderType.INVISIBLE

, which prevents the block from being rendered via the model system. This is because vanilla renders a lot of its

TileEntity

blocks with a

TileEntitySpecialRenderer

.

 

You could override this to return

EnumBlockRenderType.MODEL

, but there's no reason to extend

BlockContainer

at all. Instead, override

Block#hasTileEntity(IBlockState)

to return

true

and override

Block#createTileEntity

to create and return an instance of your

TileEntity

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.