Jellofish83 Posted July 19, 2023 Posted July 19, 2023 Hello, I was trying to make a flower block, everything went fine until I excuted the program and tested it out. Once in game, both the flower block and the potted flower block was the expected cross model but with a black background instead of transparent background. Anyone have a solution to this? I was using Forge 1.18.2. The texture for the flower also have a transparent background in the image editor. The code for the flower: public static final RegistryObject<Block> FROZEN_ROSE = registerBlock("frozen_rose", () -> new FlowerBlock(MobEffects.MOVEMENT_SLOWDOWN, 5, BlockBehaviour.Properties.copy(Blocks.DANDELION).noOcclusion()), CreativeModeTab.TAB_DECORATIONS); Code for potted flower: public static final RegistryObject<Block> POTTED_FROZEN_ROSE = registerBlockWithoutBlockItem("potted_frozen_rose", () -> new FlowerPotBlock(() -> ((FlowerPotBlock) Blocks.FLOWER_POT), ModBlocks.FROZEN_ROSE, BlockBehaviour.Properties.copy(Blocks.POTTED_DANDELION).noOcclusion())); Code for the RenderType under FMLClientSetupEvent: private void clientSetup(final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(ModBlocks.FROZEN_ROSE.get(), RenderType.cutout()); ItemBlockRenderTypes.setRenderLayer(ModBlocks.POTTED_FROZEN_ROSE.get(), RenderType.cutout()); } I've also checked the JSON files, and they are all error free. Anyone have a solution to my issue here? Any help provided would be really appreciated! Quote
Zacomat Posted July 19, 2023 Posted July 19, 2023 the json is error free but do you have the line "render_type": "cutout" in your model class? Quote
Jellofish83 Posted July 19, 2023 Author Posted July 19, 2023 2 hours ago, Zacomat said: the json is error free but do you have the line "render_type": "cutout" in your model class? You mean under "models/block/blockname.json" or the main class? If so, the line "render_type":"cutout" doesn't work if written inside the json files and I have already included RenderType.cutout() under FMLClientSetupEvent in my main class. Quote
Zacomat Posted July 19, 2023 Posted July 19, 2023 I was referring to version 1.20.1. I apologize for mentioning the wrong version. Quote
Jellofish83 Posted July 20, 2023 Author Posted July 20, 2023 2 hours ago, Zacomat said: I was referring to version 1.20.1. I apologize for mentioning the wrong version. It's alright. But do you have a solution to my version? Quote
MFMods Posted July 21, 2023 Posted July 21, 2023 you already have it. you set RenderType.cutout() in FMLClientSetupEvent. find out why that code doesn't execute. Quote
Jellofish83 Posted July 21, 2023 Author Posted July 21, 2023 3 hours ago, MFMods said: you already have it. you set RenderType.cutout() in FMLClientSetupEvent. find out why that code doesn't execute. I already looked around and dug the external libraries, but found no solution. Also, if I can figure out why it doesn't execute, I won't be asking here. Quote
MFMods Posted July 22, 2023 Posted July 22, 2023 your client setup method looks fine. did you add it as a listener in main mod class constructor? DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientEvents::clientSetup)); (replace clientevents with how you called that class) Quote
Jellofish83 Posted July 22, 2023 Author Posted July 22, 2023 10 hours ago, MFMods said: your client setup method looks fine. did you add it as a listener in main mod class constructor? DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientEvents::clientSetup)); (replace clientevents with how you called that class) I looked back, and realised I forgot to put "eventBus.addListener(this::clientSetup);" in my main constructor. And I fixed it Anyways, thank you for you time. Quote
MFMods Posted July 23, 2023 Posted July 23, 2023 do not keep client-only code in your main mod class or any class that has anything else in it. it needs to be a separate class with client things (ItemBlockRenderTypes.setRenderLayer call etc.) and nothing else. on a dedicated server, it needs to stay unloaded. to subscribe to an event, use the annotation (preferred way) or the line i gave you above. do not call addListener unconditionally. Quote
Jellofish83 Posted July 23, 2023 Author Posted July 23, 2023 13 hours ago, MFMods said: do not keep client-only code in your main mod class or any class that has anything else in it. it needs to be a separate class with client things (ItemBlockRenderTypes.setRenderLayer call etc.) and nothing else. on a dedicated server, it needs to stay unloaded. to subscribe to an event, use the annotation (preferred way) or the line i gave you above. do not call addListener unconditionally. Ok noted, thank you. Quote
Recommended Posts
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.