Jump to content

[1.15.2 - 31.1.0] Transparent / Translucent Blocks & Items Issues


Recommended Posts

Posted

Hi so after doing some research I finally figured out the new change for render layer type The issue I am having now is rendering a torch inside of a block. Now I'm not sure if I am doing it right or maybe something with this rendering code. The block Items render correctly but the touches inside the block do not. I Ideally I would appreciate to get the translucent rendering type to work. I just want the item blocks and the blocks to look the same. I can do a work around with recreating all the textures and using cutout mipped version, but would rather not do this if its not needed. 

All Textures are Vanilla textures from Stained Glass

 

Here is an example with the render type set to translucent (Item blocks render Correct, Blocks in world do not)

 

image.png.ae9a9401bb58e65dc21cc6fab67cfb74.png

 

 

I was also trying to use cutout mipped (Below)(Item blocks don't render correctly, Blocks in world do)

You will notice red does not render the alpha same as other colors

 

image.png.c6d2540c494f1a7b63fe80a3e8317340.png

 

 

Setting Render layer:

 

    private void doClientStuff(final FMLClientSetupEvent event) {
    	
    	RenderType solid = RenderType.func_228639_c_();
    	RenderType cutout_mipped = RenderType.func_228641_d_();
    	RenderType cutout = RenderType.func_228643_e_();
    	RenderType translucent = RenderType.func_228645_f_();
    	RenderType translucent_no_crumbling = RenderType.func_228647_g_();

    	RenderTypeLookup.setRenderLayer(TechBlocks.lamp.get(),          cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.black_lamp.get(),    cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.blue_lamp.get(),     cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.brown_lamp.get(),    cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.cyan_lamp.get(),     cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.gray_lamp.get(),     cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.green_lamp.get(),    cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.lightblue_lamp.get(),cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.lime_lamp.get(),     cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.magenta_lamp.get(),  cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.orange_lamp.get(),   cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.pink_lamp.get(),     cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.purple_lamp.get(),   cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.red_lamp.get(),      cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.white_lamp.get(),    cutout_mipped);
    	RenderTypeLookup.setRenderLayer(TechBlocks.yellow_lamp.get(),   cutout_mipped);
    }

 

Lamp model Json:

{
    "parent": "block/cube_all",
    "ambientocclusion": false,
    "elements": [
{   "from": [ 7, 0, 7 ],
            "to": [ 9, 10, 9 ],
            "shade": false,
            "faces": {
                "down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" },
                "up":   { "uv": [ 7,  6, 9,  8 ], "texture": "#torch" }
            }
        },
        {   "from": [ 7, 0, 0 ],
            "to": [ 9, 16, 16 ],
            "shade": false,
            "faces": {
                "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
                "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
            }
        },
        {   "from": [ 0, 0, 7 ],
            "to": [ 16, 16, 9 ],
            "shade": false,
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
            }
        },
        {
            "from": [0, 0, 0],
            "to": [16, 16, 16],
            "faces": {
                "down": { "uv": [0, 0, 16, 16], "texture": "#t1" },
                "up": { "uv": [0, 0, 16, 16], "texture": "#t1" },
                "north": { "uv": [0, 0, 16, 16], "texture": "#t1" },
                "south": { "uv": [0, 0, 16, 16], "texture": "#t1" },
                "west": { "uv": [0, 0, 16, 16], "texture": "#t1" },
                "east": { "uv": [0, 0, 16, 16], "texture": "#t1" }
            }
        }
    ],
    "textures": {
        "particle": "block/glass",
        "t1": "block/glass",
        "torch": "block/torch"
    }
}

 

Colored Lamp Json:

{
    "parent": "tp:block/lamp",
    "textures": {
        "particle": "block/blue_stained_glass",
        "t1": "block/blue_stained_glass"
    }
}

 

Item Json:

{
    "parent": "tp:block/lamp_blue"
}

 

BlockState Json:

{
    "variants": {
        "": { "model": "tp:block/lamp_blue" }
    }
}

 

Lamp Block:

public class Lamp extends AbstractGlassBlock
{
	public Lamp(Properties prop)
	{
		super(prop.hardnessAndResistance(.5F, 1F).lightValue(15).sound(SoundType.GLASS).noDrops().func_226896_b_());
	}
	
	@Override
    public BlockRenderType getRenderType(BlockState state) {
		
        return BlockRenderType.MODEL;
     }

   @OnlyIn(Dist.CLIENT)
   public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
      double d0 = (double)pos.getX() + 0.5D;
      double d1 = (double)pos.getY() + 0.7D;
      double d2 = (double)pos.getZ() + 0.5D;
      worldIn.addParticle(ParticleTypes.SMOKE, d0, d1, d2, 0.0D, 0.0D, 0.0D);
      worldIn.addParticle(ParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D);
   }
}

 

 

I'm hopping I'm just missing something. or there is a simple fix to this.  If anyone has some insights I would greatly appreciate it. 

 

Thanks

Posted

You should try to create a standard block model for the torch rather than using the one provided in Minecraft. Minecraft does a very strange thing with the torch by creating two extra cubes to render the sides of the torch without uv distortion. I'm not sure why they use this, probably someone more knowledgeable about how Minecraft was programmed could answer that. However, this sort of poses an issue when rendering. The torch by default is rendered as a cutout while the stained glass is rendered as translucent. This means that either the glass will be treated as a cutout (no variable opacity/alpha) or the torch will be treated as translucent (texture might incorrectly render at some places since it is still 16x2 or 2x16 on the cubes). The best way to fix this is just to adjust the torch element so that it is just a single block rather than 3 cubes that render the sides.

 

If you have done that, the code should look somewhat like this for the torch faces:

"north": {"uv": [7, 6, 9, 16], "texture": "#torch"},
"east": {"uv": [7, 6, 9, 16], "texture": "#torch"},
"south": {"uv": [7, 6, 9, 16], "texture": "#torch"},
"west": {"uv": [7, 6, 9, 16], "texture": "#torch"},
"up": {"uv": [7, 6, 9, 8], "texture": "#torch"},
"down": {"uv": [7, 13, 9, 15], "texture": "#torch"}

This should remove the need for your block to be rendered as a cutout making it valid on any render layer.

  • Like 1
Posted

I had wondered why that was done that way. your method works to at least fix the torch issue for translucent render layer. but translucent render layer doesn't like particles inside the block as they get hidden. So I may go with the idea I didn't really want to do and create custom textures and use the cutout mipped version. but thank you cause your method did work the way I needed it. 

 

 

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.

Announcements



×
×
  • Create New...

Important Information

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