Organize imports option does not always work

Published by Anonymous (not verified) on Tue, 11/20/2018 - 10:37
Works as designed
Issue description

When in the code option MCreator can't import some needed imports EG
import net.minecraft.block.state.BlockStateContainer;

        protected BlockStateContainer createBlockState() {
            return new BlockStateContainer(this, new IProperty[]{FACING});

This is creating so many problems with custom codes and the reason people are having so much problem with custom code it people tell them put the code in and press import but
the import button at times does not even include the imports for BlockHorizontal when set as a extenderd class.

Issue comments

If the MCreator can't find the import (which may happen in some cases), you can still manually define it. Just add it to the imports and they should be there. If this does not help, just reply to this ticket and I will reopen it.

It's not finding it sometimes for functions it sometimes can import it's not conistant, and if you can manually and it works the MCreator should be able to do this, since it has to do a check if that import is there to give the error in the first place, this does need looking at the import 90% of the time for me does sweet F a, every example that says use it dont work so I have to add it myself what's bloody useless when I trying to help others with this tool.

But I hope you get this sorted in a future version.

Ok, I have checked and I can see why this is happening. There are two possible imports for BlockStateContainer:

  • net.minecraft.block.state.BlockStateContainer

Import formatter can't decide which one to use. The solution is to use explicit class names in your code. Such cases are very rare (just a few classes), but they do happen:

protected net.minecraft.block.state.BlockStateContainer createBlockState() {
    return new net.minecraft.block.state.BlockStateContainer(this, new IProperty[]{FACING});


Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.