Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.17.1] How to make block transparency


samjviana
 Share

Recommended Posts

How can i make the transparency of an block work just like the SlimeBlock, as shown in the image:
Vir9cqZ.png

By now i'm setting the RenderLayer of the block to RenderType.translucent() and also extending the HalfTransparentBlock in my block.

Edited by samjviana
more info
Link to comment
Share on other sites

9 minutes ago, Luis_ST said:

show your Block class and your Registration

Block class: 

Spoiler
public class ColoredSlimeBlock extends SlimeBlock {
	public ColoredSlimeBlock(Properties properties) {
		super(properties);
	}
	
	@Override
	public boolean isStickyBlock(BlockState state) {
		return true;
	}
}

The registration:

Spoiler
@OnlyIn(Dist.CLIENT)
public static Object clientOnlySetup() {
	for (RegistryObject<Block> regBlock : ModBlocks.BLOCKS.getEntries()) {
		if (regBlock.get() instanceof ColoredSlimeBlock) {
			ItemBlockRenderTypes.setRenderLayer(regBlock.get(), RenderType.translucent());
		}
	}
	
  	...
      
	return null;
}

 

 

Link to comment
Share on other sites

1 hour ago, Luis_ST said:

show your Block Registration

and do never use @OnlyIn it's only for vanilla

    @SubscribeEvent
    public static void onRegisterItem(final RegistryEvent.Register<Item> event) {
        final IForgeRegistry<Item> registry = event.getRegistry();

		ModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach((block) -> {
			final Item.Properties properties;
			if (shouldHide(block)) {
				return;
			}
			else if (isBlockItem(block)) {
				properties = new Item.Properties().tab(ModCreativeTab.ITEMS);
			}
			else {
				properties = new Item.Properties().tab(ModCreativeTab.BLOCKS);
			}
			final BlockItem blockItem = new BlockItem(block, properties);

			blockItem.setRegistryName(block.getRegistryName());
			registry.register(blockItem);
		});
    }

Did'n know about the OnlyIn thing, thanks

Link to comment
Share on other sites

4 minutes ago, Luis_ST said:

you need to register the Block itself and the BlockItem for it

@SubscribeEvent
public static void onRegisterBlock(final RegistryEvent.Register<Block> event) {
	final IForgeRegistry<Block> registry = event.getRegistry();

	ModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach((block) -> {
		registry.register(block);
	});
}

just did the block registration, but the block transparency remains the same.

Link to comment
Share on other sites

4 minutes ago, Luis_ST said:

show the Registry Entry of your ColoredSlimeBlock

public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, BunchOfThings.MODID);
public static final RegistryObject<Block> BLACK_SLIME_BLOCK = BLOCKS.register("black_slime_block", () -> { 
	return new ColoredSlimeBlock(BlockBehaviour.Properties.of(Material.CLAY).friction(0.8f).sound(SoundType.SLIME_BLOCK).noOcclusion());
});

 

Edited by samjviana
Link to comment
Share on other sites

1 hour ago, Luis_ST said:

i've test your code and unfortunately i can't tell you what'S exactly is the problem
the only thing i can tell you is that HalfTransparentBlock#skipRendering is not called,
but i don't know why

sorry

I thought that it should be called, place some logs inside it, but it's never called.
i could try to create an custom render, kinda copying the translucent, but i think is to much work

Link to comment
Share on other sites

  • 4 weeks later...
7 hours ago, Luis_ST said:

unfortunately it doesn't work for me either, the reason for that is that skipRendering is not called but i have no idea why

i'll try to create a new render, if it works i'll come back here with it.

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 Privacy Policy.