Posted July 19, 20232 yr 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!
July 19, 20232 yr the json is error free but do you have the line "render_type": "cutout" in your model class?
July 19, 20232 yr Author 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.
July 20, 20232 yr Author 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?
July 21, 20232 yr you already have it. you set RenderType.cutout() in FMLClientSetupEvent. find out why that code doesn't execute.
July 21, 20232 yr Author 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.
July 22, 20232 yr 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)
July 22, 20232 yr Author 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.
July 23, 20232 yr 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.
July 23, 20232 yr Author 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.
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.