Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

I just took a second look at the BlockCactus/BlockReed's updateTick method and the metadata thing was the "'issue'". Apparently the cactus/reed block only grows a new block every 16th random tick. So my block was operating as intended, I just didn't understand the code.

I like trains.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.