Jump to content

[1.15.2] [Solved] How to archive transparent leaves?


Budschie

Recommended Posts

Hello. I want to archive a block which has a transparent texture.

I've already found out how to do basic transparency, but when I try to

use a texture which has an other alpha value than 0 or 255, the alpha value for that pixel changes to 255.

Thanks for any help.

Link to comment
Share on other sites

What render layer is your block on?

Please also post your code, preferably as a GitHub repo.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

8 hours ago, Budschie said:

@DavidM Here is my github repo:

https://github.com/Budschie/Deepnether-Mod/

I use the translucent render layer, but I also tried cutout and cutout mipped, but those didn't work either.

By the way, I have no idea how the render layers work, what performance impact they have etc.

You may find this info helpful https://greyminecraftcoder.blogspot.com/2020/04/block-rendering-1144.html

 

8 hours ago, Budschie said:

I also noticed a weird behaviour of the block rendering, the pixels are flickering a bit.

Flickering normally means that you're trying to render two quads directly on top of each other (called 'z-fighting').  Remove one of the quads or move it slightly (say 0.001)

 

Is your block supposed to be translucent (like ice) or have holes (like glass block or leaves)?  The first one needs transparent layer, the second needs cutout layer.

 

-TGG

 

 

  • Like 1
Link to comment
Share on other sites

@TheGreyGhost I'm sure it is not z-fighting, because there is no pattern that usually occurs when I have z-fighting. The whole brightness of the pixel changes.

10 hours ago, TheGreyGhost said:

Is your block supposed to be translucent (like ice) or have holes (like glass block or leaves)?  The first one needs transparent layer, the second needs cutout layer.

It should be translucent like for example ice. But when I set the RenderLayer to translucent, the alpha is still either 0 or 255.

Link to comment
Share on other sites

Howdy

I looked at your github repo but it doesn't compile.

-TGG

eg

C:\Users\Richard\Documents\IntellijProjects\Deepnether-Mod-master\src\main\java\de\budschie\deepnether\main\DeepnetherMain.java:77: error: cannot find symbol
    	INSTANCE.<StructureIDPacket>registerMessage(disc++, StructureIDPacket.class, StructureIDPacket::encodeAtServer, StructureIDPacket::decodeAtClient, StructureIDPacket::handleAtClient);
    	                                                    ^
  symbol:   class StructureIDPacket
  location: class DeepnetherMain
C:\Users\Richard\Documents\IntellijProjects\Deepnether-Mod-master\src\main\java\de\budschie\deepnether\main\DeepnetherMain.java:77: error: cannot find symbol
    	INSTANCE.<StructureIDPacket>registerMessage(disc++, StructureIDPacket.class, StructureIDPacket::encodeAtServer, StructureIDPacket::decodeAtClient, StructureIDPacket::handleAtClient);
    	          ^
  symbol:   class StructureIDPacket
  location: class DeepnetherMain
C:\Users\Richard\Documents\IntellijProjects\Deepnether-Mod-master\src\main\java\de\budschie\deepnether\main\DeepnetherMain.java:77: error: cannot find symbol
    	INSTANCE.<StructureIDPacket>registerMessage(disc++, StructureIDPacket.class, StructureIDPacket::encodeAtServer, StructureIDPacket::decodeAtClient, StructureIDPacket::handleAtClient);
    	                                                                                                                                                   ^
  symbol:   variable StructureIDPacket
  location: class DeepnetherMain
C:\Users\Richard\Documents\IntellijProjects\Deepnether-Mod-master\src\main\java\de\budschie\deepnether\main\DeepnetherMain.java:77: error: cannot find symbol
    	INSTANCE.<StructureIDPacket>registerMessage(disc++, StructureIDPacket.class, StructureIDPacket::encodeAtServer, StructureIDPacket::decodeAtClient, StructureIDPacket::handleAtClient);
    	                                                                                                                ^
  symbol:   variable StructureIDPacket
  location: class DeepnetherMain
C:\Users\Richard\Documents\IntellijProjects\Deepnether-Mod-master\src\main\java\de\budschie\deepnether\main\DeepnetherMain.java:77: error: cannot find symbol
    	INSTANCE.<StructureIDPacket>registerMessage(disc++, StructureIDPacket.class, StructureIDPacket::encodeAtServer, StructureIDPacket::decodeAtClient, StructureIDPacket::handleAtClient);
    	                                                                             ^
  symbol:   variable StructureIDPacket
  location: class DeepnetherMain
C:\Users\Richard\Documents\IntellijProjects\Deepnether-Mod-master\src\main\java\de\budschie\deepnether\main\DeepnetherMain.java:97: error: cannot find symbol
    	RenderTypeLookup.setRenderLayer(BlockInit.ANCIENT_LEAVES, RenderType.getTranslucent());
    	                                         ^
  symbol:   variable ANCIENT_LEAVES
  location: class BlockInit
C:\Users\Richard\Documents\IntellijProjects\Deepnether-Mod-master\src\main\java\de\budschie\deepnether\main\DeepnetherMain.java:98: error: cannot find symbol
    	RenderTypeLookup.setRenderLayer(BlockInit.ANCIENT_WITHERED_LEAVES, RenderType.getTranslucent());
    	                                         ^
  symbol:   variable ANCIENT_WITHERED_LEAVES
  location: class BlockInit

 

 

Link to comment
Share on other sites

  • Budschie changed the title to [1.15.2] [Solved] How to archive transparent leaves?
4 hours ago, Budschie said:

I finally managed to solve my issue: I just had to extend my ModLeavesBlock from BreakableBlock instead of LeavesBlock.

That fixed the transparency issue... But I'm not exactly sure why. Maybe some instanceof checking.

Ah, yeah you're right.  Vanilla does have a few of these dirty "quick fixes" hidden away in the guts of the code. 

 

   @Deprecated
   public static RenderType getChunkRenderType(BlockState blockStateIn) {
      Block block = blockStateIn.getBlock();
      if (block instanceof LeavesBlock) {
         return fancyGraphics ? RenderType.getCutoutMipped() : RenderType.getSolid();
      } else {
         RenderType rendertype = TYPES_BY_BLOCK.get(block);
         return rendertype != null ? rendertype : RenderType.getSolid();
      }
   }

and

   public static boolean canRenderInLayer(BlockState state, RenderType type) {
      Block block = state.getBlock();
      if (block instanceof LeavesBlock) {
         return fancyGraphics ? type == RenderType.getCutoutMipped() : type == RenderType.getSolid();
      } else {
         java.util.function.Predicate<RenderType> rendertype;
         synchronized (RenderTypeLookup.class) {
             rendertype = blockRenderChecks.get(block.delegate);
         }
         return rendertype != null ? rendertype.test(type) : type == RenderType.getSolid();
      }
   }

 

 

 

  • Thanks 1
  • Haha 1
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



×
×
  • Create New...

Important Information

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