Jump to content

[1.16.5-texture] A Problem When Render Flowers and Crops (Solved)


刘 远睿

Recommended Posts

Hi, I'm new to Minecraft Forge Mod. I meet with a problem when rendering flower blocks and crop blocks. The transparent part of the texture is black.  I try to solve it by adding alpha channel in photoshop, but it doesn't work. The transparent part of the whole texture either render as black or white. Here's the resource of textures and the whole project: https://github.com/TheLawF/Gensokyo-Ontologics/blob/main/src/main/resources/assets/gensokyoontology/textures/block 

The code of LycorisRadiata.java is listed below:

LycorisRadiata.java:

package github.thelawf.gensokyoontology.common.block;

import net.minecraft.block.*;
import net.minecraft.block.material.Material;

public class LycorisRadiata extends BushBlock {
    public LycorisRadiata() {
        super(Properties.create(Material.PLANTS)
                .doesNotBlockMovement()
                .zeroHardnessAndResistance()
                .sound(SoundType.PLANT));
    }
}

 

Link to comment
Share on other sites

  • 刘 远睿 changed the title to [1.16.5-texture] A Problem When Render Flowers and Crops (Solved)

I just remember that the render type needs to register to mod bus. In this case, crops and flowers should use RenderType.getCutOut() in RenderTypeLookUp.setRenderLayer() method. I register my blocks in GensokyoOntology.java.

GensokyoOntology.java:

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD,value = Dist.CLIENT)
    public static class RenderTypeRegistry {
        @SubscribeEvent
        public static void onRenderTypeSetUp(FMLClientSetupEvent event){
            
				// Render transparent textures to block model like #cross and crop
            event.enqueueWork(() -> {
                RenderTypeLookup.setRenderLayer(BlockRegistry.LYCORIS_RADIATA.get(),
                        RenderType.getCutout());
                RenderTypeLookup.setRenderLayer(BlockRegistry.ONION_CROP_BLOCK.get(),
                        RenderType.getCutout());
            });

        }

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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