Topic category: Help with MCreator software
How do I add dependencies as import statements when using custom code snippets?
I read in another post here which said that it should be automatically handled but it isn't for me.
For example if I want to use the snippet:entity.startSleeping(BlockPos.containing(entity.getX(), entity.getY(), entity.getZ()));
to force an entity to sleep it would require some stuff like:import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Pose;
but none of it will be added and if I do it with another code snippet, it would be placed somewhere in the middle of the procedure's function resulting in errors.
The only workaround I have found for some cases so far is placing if statements with some built in functions that import the required dependencies in the code with some no-op substitute so they won't affect my code. But that's a very weird way to solve it and does not work in every case. Has somebody found a better solution?
You have to use the variables, you want to use in the code snippets, somewhere else in block form. Otherwise MCreator just won't even put them in the method parameters.
Not sure if that's what you meant though..
The blocks shown in the picture built for me.