Jump to content

Recommended Posts

Posted

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)

Posted

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.

Posted (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 by Matt Wild
Posted
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.

Posted

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)

  • 5 weeks later...
Posted (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 by Matt Wild
Posted
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.

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.

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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