Jump to content

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


gendeathrow

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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. 

 

 

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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