Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] New Lantern Not Supporting Transparency
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Matt Wild

[1.16.1] New Lantern Not Supporting Transparency

By Matt Wild, October 29, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Matt Wild    0

Matt Wild

Matt Wild    0

  • Tree Puncher
  • Matt Wild
  • Members
  • 0
  • 5 posts
Posted October 29, 2020

Hi, I've been trying to make a modded lantern using net.minecraft.block.LanternBlock as a base.
 

My current class is as follows:
 

import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType;

public class GemLanternBase extends LanternBlock {

    public GemLanternBase(int lightValue) {
        super(LanternBlock.Properties.create(Material.IRON)
                .hardnessAndResistance(3.5f, 3.5f)
                .sound(SoundType.LANTERN)
                .harvestLevel(0)
                .harvestTool(ToolType.PICKAXE)
                .setLightLevel(value -> lightValue));
    }

}

 

I figured that using the default lantern would mean that the model in-game would support transparency, but I seem to be wrong.

The modded lantern has one difference to the default one, the chain texture doesn't support transparency. It's really annoying and I have no idea what I need to do in order to fix this. Is anyone able to help me on this one?

(p.s. I'm quite new to modding so treat me like I'm an idiot, thanks :D)

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 posts
Posted October 30, 2020

https://forums.minecraftforge.net/search/?q=transparent block&type=forums_topic&updated_after=any&sortby=relevancy&search_and_or=and

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

TheGreyGhost    818

TheGreyGhost

TheGreyGhost    818

  • Reality Controller
  • TheGreyGhost
  • Members
  • 818
  • 3280 posts
Posted October 30, 2020

Hi

 

You might find this working example of transparent models useful, just by coincidence it's also a lantern...!

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe05_block_advanced_models

https://greyminecraftcoder.blogspot.com/2020/05/minecraft-by-example.html  (mbe05)

 

Cheers

  TGG

  • Quote

Share this post


Link to post
Share on other sites

Matt Wild    0

Matt Wild

Matt Wild    0

  • Tree Puncher
  • Matt Wild
  • Members
  • 0
  • 5 posts
Posted October 30, 2020 (edited)
13 hours ago, TheGreyGhost said:

Hi

 

You might find this working example of transparent models useful, just by coincidence it's also a lantern...!

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe05_block_advanced_models

https://greyminecraftcoder.blogspot.com/2020/05/minecraft-by-example.html  (mbe05)

 

Cheers

  TGG

Hi, thanks for the reply and the example!

My lantern is a lot less fancy than the example given but I figured that I needed the following:

 - notSolid() to be called in the block properties
 - make the getRenderType method return BlockRenderType.MODEL

My new class looks like this:
 

import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType;

public class GemLanternBase extends LanternBlock {

    public GemLanternBase(int lightValue) {
        super(LanternBlock.Properties.create(Material.IRON)
                .hardnessAndResistance(3.5f, 3.5f)
                .sound(SoundType.LANTERN)
                .harvestLevel(0)
                .harvestTool(ToolType.PICKAXE)
                .setRequiresTool()
                .setLightLevel(value -> lightValue)
                .notSolid());
    }

    @Override
    public BlockRenderType getRenderType(BlockState iBlockState) {
        return BlockRenderType.MODEL;
    }

}


However, the issue is persisting. The chain still has black pixels where the transparent pixels should be. I also tried applying the voxel model but that didn't seem to make a difference. I'm very confused as to what causes Minecraft to allow for transparency.

Could you elaborate on what is missing from my class?

Many thanks :)


EDIT:
I've solved the problem!

Nothing was wrong with my class lol, though the example has been very helpful for adding new functionality!

Turns out I needed to call setRenderLayer from RenderTypeLookup in my client setup method. I had no idea this was a thing and when I first saw it I thought it was for blocks structures specifically. As I said I'm very new to this and I'm glad this is figured out, this is my first mod that I'm playing around with.


All I can say is thank god this forums exists, I find the official documentation for this to be kinda lack-lustre.

Edited October 30, 2020 by Matt Wild
  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    160

ChampionAsh5357

ChampionAsh5357    160

  • World Shaper
  • ChampionAsh5357
  • Members
  • 160
  • 1017 posts
Posted October 30, 2020
23 minutes ago, Matt Wild said:

 - notSolid() to be called in the block properties
 - make the getRenderType method return BlockRenderType.MODEL

Neither of these are correct. The first property says your block should not consider this for culling on all sides. This should not be necessary if you properly handle your voxel shape. The other method determines how your block should render, such as whether to use a model, a TER, or nothing at all. These do not affect the render layer.

26 minutes ago, Matt Wild said:

I've seen people talking about the RenderTypeLookup.setRenderLayer() method inside the client setup.

That's because that's what you need to do. If you look at the parameters, you should see the first one requires a block of some type. The second needs either a function or a RenderType. If you go into the RenderType class, you should find a bunch of static methods which will return RenderTypes. You should be able to determine which one you should use for this.

  • Quote

Share this post


Link to post
Share on other sites

Matt Wild    0

Matt Wild

Matt Wild    0

  • Tree Puncher
  • Matt Wild
  • Members
  • 0
  • 5 posts
Posted October 30, 2020

Hey, thanks for the heads up ^^

I was very confused at first because I thought that the content of the class was the dependant factor for the texture rendering correctly. As for the confusion with the parameters, I realised I could grab the block from the registry. (none of this I've done before so I'm glad it's cleared up)

  • Quote

Share this post


Link to post
Share on other sites

MasterQuentus    0

MasterQuentus

MasterQuentus    0

  • Tree Puncher
  • MasterQuentus
  • Members
  • 0
  • 1 post
Posted November 29, 2020

how did you fix it

  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    160

ChampionAsh5357

ChampionAsh5357    160

  • World Shaper
  • ChampionAsh5357
  • Members
  • 160
  • 1017 posts
Posted November 29, 2020
26 minutes ago, MasterQuentus said:

how did you fix it

Don't necro an old thread. Create  your own topic with your own question and source so that users may help.

  • Quote

Share this post


Link to post
Share on other sites

Matt Wild    0

Matt Wild

Matt Wild    0

  • Tree Puncher
  • Matt Wild
  • Members
  • 0
  • 5 posts
Posted November 29, 2020 (edited)
10 hours ago, MasterQuentus said:

how did you fix it

try {
	RenderTypeLookup.setRenderLayer(RegistryHandler.SOL_LANTERN.get(), RenderType.getCutout());
} catch (java.lang.NoClassDefFoundError e) {
	
}

I put this code into my setup method within the main class. To my understanding, you parse in the block and RenderType to set how the client will render it. The catch statement is just a cheap way to stop a server from crashing if it were to use this mod xD

Apologies for posting on this old thread again, but the guys clearly new here with 1 post, might as well try to help him out. :)

Edited November 29, 2020 by Matt Wild
  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 posts
Posted November 29, 2020
4 hours ago, Matt Wild said:

I put this code into my setup method within the main class.

No! Bad modder!
Put client side code in a client side event subscriber!

Do not hide exceptions.

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

Danebi    26

Danebi

Danebi    26

  • Diamond Finder
  • Danebi
  • Members
  • 26
  • 428 posts
Posted November 29, 2020
4 hours ago, Matt Wild said:

I put this code into my setup method within the main class.

NO. Put it in the client setup.

  • Quote

Share this post


Link to post
Share on other sites

Matt Wild    0

Matt Wild

Matt Wild    0

  • Tree Puncher
  • Matt Wild
  • Members
  • 0
  • 5 posts
Posted November 29, 2020
13 minutes ago, Draco18s said:

No! Bad modder!
Put client side code in a client side event subscriber!

Do not hide exceptions.

teehee

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • poopoodice
      Adding jar files to existing environment

      By poopoodice · Posted 14 minutes ago

      It's been discussed for a long time, but none of the solutions worked for me (maybe I did not did them right). So I have created another mod (basically a tool) and I want to use it in another environment, this is what I've tried:   1. run normal build ./gradlew.bat build, and then put built jar from lib into the mods folder. 2. run jar build ./gradlew.bat jar, and then put built jar from reobfJar into the mods folder. 3. build jar using existing ide options, and then put built jar from lib into the mods folder.   1 & 2 causes crashes, and 3 does not work at all (not detected).   What is the correct way of doing it in 1.16.4? Thanks.
    • Draco18s
      GUI Documentation

      By Draco18s · Posted 40 minutes ago

      GUIs aren't that difficult. There's dozens of tutorials for them and they haven't really changed all that much in ten years.
    • Xenfo
      Mod Blocker

      By Xenfo · Posted 56 minutes ago

      Any mod blockers that actually work? Please link them if yes.
    • diesieben07
      Tessellator ignores lighting?

      By diesieben07 · Posted 1 hour ago

      Neither 1.10 now 1.14 are supported here. Please refer to the supported versions page: https://forums.minecraftforge.net/topic/91712-supported-version-directory/
    • CookieLukas
      Tessellator ignores lighting?

      By CookieLukas · Posted 1 hour ago

      Oh,  sorry, the code was 1.10.2, but as its not allowed here, I updated it to 1.14.4.
  • Topics

    • poopoodice
      0
      Adding jar files to existing environment

      By poopoodice
      Started 14 minutes ago

    • T1ps
      3
      GUI Documentation

      By T1ps
      Started Tuesday at 10:14 PM

    • Xenfo
      0
      Mod Blocker

      By Xenfo
      Started 56 minutes ago

    • CookieLukas
      3
      Tessellator ignores lighting?

      By CookieLukas
      Started 2 hours ago

    • Extrodonary
      1
      Forge isn't working on Minecraft Realms

      By Extrodonary
      Started 1 hour ago

  • Who's Online (See full list)

    • Pinary
    • StealthyNoodle
    • bananapizzuh
    • Xenfo
    • Warsade
    • monkeysHK
    • Microcellule
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] New Lantern Not Supporting Transparency
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community