Jump to content

Block to make crops grow faster doesn't seem to work with cactus or reeds


UntouchedWagons

Recommended Posts

This is the updateTick method of my block:

 

    public void updateTick(World world, int x, int y, int z, Random prng)
    {
        if (!world.blockExists(x, y + 1, z)) return;

        Block b1 = world.getBlock(x, y + 1, z);

        // If the block above it is farm land (AKA tilled dirt)
        if (b1 instanceof BlockFarmland)
        {
            if (!world.blockExists(x, y + 2, z))
                return;

            // Get the block above that one
            Block plant_block = world.getBlock(x, y + 2, z);

            if (plant_block instanceof IPlantable ||
                    plant_block instanceof IGrowable)
            {
                plant_block.updateTick(world, x, y + 2, z, this.prng);
            }
        }
        else if (b1 instanceof BlockDirt ||
                b1 instanceof BlockGrass ||
                b1 instanceof BlockSand ||
                b1 instanceof BlockSoulSand)
        {
            if (!world.blockExists(x, y + 2, z))
                return;

            // Get the block above that one
            Block b2 = world.getBlock(x, y + 2, z);

            if (b2 instanceof BlockSapling || b2 instanceof BlockNetherWart)
            {
                b2.updateTick(world, x, y + 2, z, this.prng);
            }
            // Reeds and saplings are a bit different
            else if (b2 instanceof BlockReed || b2 instanceof BlockCactus)
            {
                System.out.println("Cactus tick a");
                for (int l = 1; world.blockExists(x, y + 1 + l, z) && l < 3; l++)
                {
                    System.out.println("Cactus tick b");
                    world.getBlock(x, y + 1 + l, z)
                            .updateTick(world, x, y + 1 + l, z, this.prng);
                }
            }
        }
        else
            b1.updateTick(world, x, y + 1, z, prng);
    }

 

It works fine for seeds, potatoes, carrots, nether wart, melon and pumpkin stems great. However my block doesn't seem to work with cactus or sugar cane and I'm not sure why.

 

According to BlockReed's updateTick method it checks if the block above it is air and if it is, calculates the height of the plant. Then if it's less than 3, it then checks if its metadata is 15 (not sure of the circumstances for this check). If it is 15, it places a reed above it.

 

The only reason I think this is failing is because the metadata isn't 15.

I like trains.

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.