Jump to content

Custom Flower Block Have Black Background


Jellofish83

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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



×
×
  • Create New...

Important Information

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