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.

Featured Replies

Posted

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

 

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.

  • Author

Indeed, I had completely missed the getRenderType() override in BlockContainer, thanks!

 

For the record, if we use Block instead of BlockContainer as a parent class, there's also breakBlock() to override as it removes the TileEntity.

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.