Jump to content

Recommended Posts

Posted

I'm creating a cactus plant for a custom desert biome. I'm having trouble with the blocks that sustain the plant. I'm trying to override the "canSustainPlant" method, but, in the game, the cactus could only be planted in normal sand. Other trouble I have is with the model of the cacti.

My code:

Spoiler

public class DenseCactus extends CactusBlock {

    public DenseCactus(Properties p_i48435_1_) {
        super(p_i48435_1_);
    }


    @Override
    public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, IPlantable plantable) {
        BlockState plant = plantable.getPlant(world, pos.relative(facing));

        if (plant.getBlock() instanceof DenseCactus) {
            return BlockTags.SAND.contains(state.getBlock()) || state.getBlock() instanceof DenseCactus;
        }
        return super.canSustainPlant(state, world, pos, facing, plantable);
    }

    @Override
    public BlockState getPlant(IBlockReader world, BlockPos pos) {
        return defaultBlockState();
    }
}

 

And my actual cactus model:

Spoiler

image.thumb.png.06d17e1ba653cd3e802dec7e99deec49.png

 

Posted
12 hours ago, LuccaPossamai said:

I'm trying to override the "canSustainPlant" method, but, in the game, the cactus could only be planted in normal sand.

Have you tried stepping through your code with the debugger? I'd set a breakpoint at the beginning of the canSustainPlant method and step through it to see what's going down.

Posted
13 hours ago, LuccaPossamai said:

Other trouble I have is with the model of the cacti.

your model is a full block (in pixel 16*16*16) but the texture is of the cactus is not a full block (in pixel 14*16*14)
take a look at the vanilla cactus model, simple copy the model and change the texture

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.

Announcements



×
×
  • Create New...

Important Information

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