Before you read:
I already tested it and this code does still work. but I don't like the error there and the question is just about, if there is another way, because my code right now might not be working in the future.
I was following the here linked tutorial series on how to create Minecraft Mods for a while until I got stuck at episode 9.
Tutorial series (can recommend for every newcomer): https://www.youtube.com/watch?v=LpoSy091wYI&list=PLKGarocXCE1HrC60yuTNTGRoZc6hf5Uvl&index=1
Episode I got stuck on (9):
https://www.youtube.com/watch?v=_tD0-CHZIeE&list=PLKGarocXCE1HrC60yuTNTGRoZc6hf5Uvl&index=9
The Episode is about how to make a new crop for Minecraft. At around 4:20 in the video, he adds an line of code and there is the error I have.
He explains, that this line is to make the invisible pixels in the texture actually invisible in the 3D Model later inside the Game.
But here is the problem: That code gives me an error every time I try to write it out.
It always says, that this is wrong, but I don't really understand why. The IDE also says, that the wrong code is "marked for removal"
The line of code looks like this:
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
ItemBlockRenderTypes.setRenderLayer(ModBlocks.BLUEBERRY_CROP.get(), RenderType.cutout());
}
}
and is located in the main class of the project called: TestMod.java
The exact line I am referring to is this one:
ItemBlockRenderTypes.setRenderLayer(ModBlocks.BLUEBERRY_CROP.get(), RenderType.cutout());
The error appears always directly under the .setRenderLayer()
, so it states, that this is incorrect.
In the video, it was also not strikethrough in the preview, but in my code it was.
I also tried using the other types of .setRenderlayer()
, but it didnt work.
Here is also an Image how it looks in my IDE:
So my question is:
If anyone wants to replicate this: I am using IntelliJ-IDEA, the Temurium 17 SDK and the Mod runs on Minecraft 1.19(.0)
In 1.19+, it is no longer advised to set the render types in your code. Instead, you should do it through the JSON file, like this:
{
"parent": "minecraft:block/crop",
"textures": {
"crop": "examplemod:block/blueberry_crop"
},
"render_type": "minecraft:cutout"
}
There are many variations for render_type
, such as minecraft:solid
(which is default), minecraft:cutout
(which you want for most plants), minecraft:translucent
(which you want for blocks like stained glass), and many others.
More information about render_type
can be found on the official Forge documentation.