Jump to content

[1.7.2] [SOLVED] Custom Sapling won't grow on custom blocks


Recommended Posts

Posted

I thought I could figure this out by myself or by googling, but I've spent about a day and a half trying to figure this out. So here I go...

 

I've successfully made a custom sapling that grows a custom tree, and also works with vanilla bonemeal. Everything's working perfectly, however, I want this custom sapling to work with my custom dirt and grass just like it does with vanilla dirt and grass. I've tried copying the BlockBush file and modified this line of code.

 

/**
     * is the block grass, dirt or farmland
     */
    protected boolean canPlaceBlockOn(Block p_149854_1_)
    {
        return p_149854_1_ == Blocks.grass || p_149854_1_ == Blocks.dirt || p_149854_1_ == Blocks.farmland || p_149854_1_ == Mod1.NegativeGrass || p_149854_1_ == Mod1.NegativeDirt; 
    }

 

Then I made my custom sapling extend this file, but it still works on vanilla blocks, and not my custom blocks. Do I have to modify the blocks to sustain the custom sapling? Or is there something I have to add to the sapling to be sustained in the custom blocks?

 

Thanks in advance.

I may ask questions asking for help, but I know what I'm doing. If my post is helpful in any way, give a "Thank You" in return, I'd really appreciate it.

Posted

Override the method as in adding @Override to the line of code I showed earlier? Or override as in something else I don't know...?

 

I've added @Override and line of code returns with an error.

 

"The method canPlaceBlockOn(Block) of type ModBush must override or implement a supertype method"

 

And then tells me to remove @Override, is there something I'm doing wrong?

I may ask questions asking for help, but I know what I'm doing. If my post is helpful in any way, give a "Thank You" in return, I'd really appreciate it.

Posted

That message you get (with @Override) tells you exactly what the problem was. When you subclass another class (like Item, Block, etc.) you normally override methods that you need to change. Your method signature (that is name, return type, and types of arguments) does not have a method to override. Check you spelling and if you still can't figure it out, reread the class your subclassing.

 

By the way, if you copy the BlockBush class completely, then you obviously are not overriding the canPlaceBlockOn method; you are defining it. The class you copied works only with vanilla dirt. Of course a copy would do the same. Right?

 

The problem is this code in Block class:

        if (plantable instanceof BlockBush && ((BlockBush)plantable).canPlaceBlockOn(this))
        {
            return true;
        }

 

Since you have copied the class and renamed it, your method will never be called. As was suggested, you need to subclass BlockBush and override necessary methods like the one you changed.

Posted

Okay, so I've kinda fixed it, and now it can be placed on both vanilla dirt and my custom dirt...It just won't grow on the custom dirt.  ???

 

Here's my ModBush class if that helps.

 

public class ModBush extends BlockBush implements IPlantable
{

    protected ModBush(Material p_i45395_1_)
    {
        super(p_i45395_1_);
        this.setTickRandomly(true);
        float f = 0.2F;
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }

    protected ModBush()
    {
        this(Material.plants);
    }

    /**
     * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
     */
    public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
    {
        return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_);
    }

    /**
     * is the block grass, dirt or farmland
     */
    @Override
    protected boolean canPlaceBlockOn(Block p_149854_1_)
    {
        return p_149854_1_ == Blocks.grass || p_149854_1_ == Blocks.dirt || p_149854_1_ == Blocks.farmland || p_149854_1_ == Mod1.NegativeGrass || p_149854_1_ == Mod1.NegativeDirt; 
    }

    /**
     * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
     * their own) Args: x, y, z, neighbor Block
     */
    public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
    {
        super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
        this.checkAndDropBlock(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_);
    }

    /**
     * Ticks the block if it's been scheduled
     */
    public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
    {
        this.checkAndDropBlock(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
    }

    /**
     * checks if the block can stay, if not drop as item
     */
    protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_)
    {
        if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_))
        {
            this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_, p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_), 0);
            p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, getBlockById(0), 0, 2);
        }
    }

    /**
     * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
     */
    public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_)
    {
        return  p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_).canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this);
    }

    /**
     * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
     * cleared to be reused)
     */
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
    {
        return null;
    }

    /**
     * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
     * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
     */
    public boolean isOpaqueCube()
    {
        return false;
    }

    /**
     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
     */
    public boolean renderAsNormalBlock()
    {
        return false;
    }

    /**
     * The type of render function that is called for this block
     */
    public int getRenderType()
    {
        return 1;
    }

    @Override
    public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
    {
        if (this == Blocks.wheat)          return Crop;
        if (this == Blocks.carrots)        return Crop;
        if (this == Blocks.potatoes)       return Crop;
        if (this == Blocks.melon_stem)     return Crop;
        if (this == Blocks.pumpkin_stem)   return Crop;
        if (this == Blocks.waterlily)      return Water;
        if (this == Blocks.red_mushroom)   return Cave;
        if (this == Blocks.brown_mushroom) return Cave;
        if (this == Blocks.nether_wart)    return Nether;
        if (this == Blocks.sapling)        return Plains;     
        return Plains;
    }

    @Override
    public Block getPlant(IBlockAccess world, int x, int y, int z)
    {
        return this;
    }

    @Override
    public int getPlantMetadata(IBlockAccess world, int x, int y, int z)
    {
        return world.getBlockMetadata(x, y, z);
    }
}

I may ask questions asking for help, but I know what I'm doing. If my post is helpful in any way, give a "Thank You" in return, I'd really appreciate it.

Posted

(Not sure if okay to bump, so I apologize if I've done something wrong by bumping.)

 

I've been screwing around with the code, and still no luck with my custom sapling growing on my custom blocks. I can place them on the custom blocks now, but they won't grow, I've been spamming bonemeal on it every time I make a change. xD

I may ask questions asking for help, but I know what I'm doing. If my post is helpful in any way, give a "Thank You" in return, I'd really appreciate it.

Posted

The Plants normally check and decide it it's time to grow or full-grown in UpdateTick. You did nothing (except for checking to see if the plant can stay), so your plant will not "grow".

 

Check out the BlockSapling class for some ideas.

Posted

So I fixed the problem, except with the fact vanilla saplings also grow on my custom dirt/grass. Though it doesn't really matter much to me. Thanks for helping out. ;D

 

I may ask questions asking for help, but I know what I'm doing. If my post is helpful in any way, give a "Thank You" in return, I'd really appreciate it.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Make a test without xaerominimap
    • Hello everyone, there was a problem with my build in prism launcher, when I launch the world, the game immediately crashes https://mclo.gs/I0BNk7n can someone help please😩
    • Saving big while shopping online is easier than ever with the Temu coupon code £100 off. This deal is among the best you can get today. When you use the acs670886 Temu coupon code, you'll unlock massive benefits tailored for users in the United Kingdom and other parts of Europe. It's our way of making shopping more rewarding for everyone across the region. By using Temu coupon £100 off and Temu 100 off coupon code, you're not just saving money, you're joining a community of savvy shoppers who never pay full price. What Is The Coupon Code For Temu £100 Off? Both new and existing customers can enjoy amazing benefits using our Temu coupon £100 off. You can redeem this £100 off Temu coupon through the Temu website or mobile app easily. acs670886: Flat £100 off your purchase, no minimum order value.   acs670886: Get a £100 coupon pack for multiple uses across several categories.   acs670886: £100 flat discount specially tailored for first-time UK customers.   acs670886: Extra £100 promotional discount for existing European users.   acs670886: Exclusive £100 coupon for Temu UK users with added benefits.   Temu Coupon Code £100 Off For New Users In 2025 If you're new to Temu, you're in luck—our coupon code offers the highest perks for first-time shoppers. Use the Temu coupon £100 off and Temu coupon code £100 off to maximize your savings today. acs670886: Flat £100 discount for brand-new Temu users.   acs670886: Receive a generous £100 coupon bundle immediately after sign-up.   acs670886: Use up to £100 in coupons across multiple purchases.   acs670886: Enjoy free shipping throughout Europe.   acs670886: First-time users also get an additional 30% off on their initial order.   How To Redeem The Temu coupon £100 off For New Customers? To activate your Temu £100 coupon, create a new account on the Temu app or website. Find the coupon section in your profile and enter the Temu £100 off coupon code for new users. Apply acs670886 during checkout to see the discount reflected instantly. Temu Coupon £100 Off For Existing Customers Our discounts aren’t just for new users—existing customers can also enjoy serious savings! Use the Temu £100 coupon codes for existing users and benefit from Temu coupon £100 off for existing customers free shipping. acs670886: £100 extra discount for returning Temu shoppers.   acs670886: Coupon bundle worth £100 for multi-item purchases.   acs670886: Complimentary gift and free express delivery across Europe.   acs670886: Stackable with up to 70% discounts on select items.   acs670886: Unlimited free shipping for all UK-based customers.   How To Use The Temu Coupon Code £100 Off For Existing Customers? Log into your Temu account and go to the promo code section. Apply the Temu coupon code £100 off or Temu coupon £100 off code by entering acs670886 before checking out. Latest Temu Coupon £100 Off First Order Maximize your savings during your first order using our special code. Just apply the Temu coupon code £100 off first order, Temu coupon code first order, or Temu coupon code £100 off first time user. acs670886: Flat £100 discount for your first Temu purchase.   acs670886: Welcome bundle worth £100 just for signing up.   acs670886: Apply multiple coupon slices totaling £100.   acs670886: Free shipping extended to all EU nations.   acs670886: 30% bonus discount on top of the initial order savings.   How To Find The Temu Coupon Code £100 Off? You can discover the latest Temu coupon £100 off and Temu coupon £100 off Reddit by subscribing to Temu's newsletter. Social media pages and trusted coupon websites also share new codes weekly. Is Temu £100 Off Coupon Legit? Yes, the Temu £100 Off Coupon Legit question has a very simple answer: Absolutely! The Temu 100 off coupon legit status is confirmed through daily testing and real customer feedback. Our acs670886 coupon code is completely valid and safe for UK and EU users. Use it without worry for both new and repeat purchases. How Does Temu £100 Off Coupon Work? The Temu coupon code £100 off first-time user is a digital promo you apply during checkout. By using Temu coupon codes 100 off, you receive instant deductions or bundles applied to your total, helping you save more with every order. How To Earn Temu £100 Coupons As A New Customer? To earn your Temu coupon code £100 off, simply register on the Temu app or website as a new customer. The 100 off Temu coupon code is auto-added to your account or made available via email or push notifications. What Are The Advantages Of Using The Temu Coupon £100 Off? £100 discount on your first order   £100 coupon bundle usable across several orders   Up to 70% off on trending items   30% additional discount for UK-based loyal customers   Up to 90% off selected promotional products   Free gifts for new users   Free shipping in UK and Europe   Temu £100 Discount Code And Free Gift For New And Existing Customers By using the Temu £100 off coupon code or £100 off Temu coupon code, you enjoy unmatched shopping privileges. Whether new or returning, our users love the flexibility and value. acs670886: £100 first-order discount with instant activation   acs670886: Extra 30% on all product categories   acs670886: Receive free welcome gift as a new user   acs670886: Discount stackable with up to 70% sale prices   acs670886: Free shipping plus surprise gifts across Europe   Pros And Cons Of Using Temu Coupon Code £100 Off This Month Pros:   Flat £100 discount   Extra 30% off for UK users   Free gifts included   No expiration date   Can be combined with other offers   Cons:   One-time use per account for new users   Limited eligibility on some product categories   Terms And Conditions Of Using The Temu Coupon £100 Off In 2025 Temu coupon code £100 off free shipping available to all UK and EU users   Latest Temu coupon code £100 off is updated regularly   No expiration date for acs670886   Valid for both new and existing users   No minimum purchase requirement to activate the coupon   Final Note: Use The Latest Temu Coupon Code £100 Off You can enjoy real savings with the Temu coupon code £100 off on both your first and subsequent orders. Start shopping smarter by using this code today. The Temu coupon £100 off isn’t just a promotion—it’s your ticket to unmatched value and convenience across Europe. FAQs Of Temu £100 Off Coupon 1. What is the Temu £100 off coupon code? The code is acs670886, and it gives you up to £100 off instantly on the Temu app or website, with no minimum purchase needed. 2. Is the Temu coupon £100 off valid in 2025? Yes, this coupon is 100% valid in 2025 for both new and existing users in the UK and Europe. 3. Can existing users also benefit from the £100 coupon? Absolutely! Existing users can get an extra £100 coupon pack and additional savings like free gifts and shipping. 4. Is there a limit to how many times I can use the Temu coupon? New users can use it once, while existing users can use acs670886 across multiple purchases via the coupon bundle. 5. Where can I find more Temu coupons in 2025? Check Temu's newsletter, Reddit, and verified coupon sites to always stay updated with the newest discounts.  
    • If you're shopping for the first time on Temu, here's exciting news: you can get a Temu coupon code £100 off for your order. It’s a fantastic way to save big while exploring the thousands of items on Temu. Use our exclusive Temu coupon code acs670886 and unlock maximum benefits when shopping from the United Kingdom or any European country. Whether you're after fashion, home goods, or gadgets, this code offers an unbeatable start. With the Temu coupon £100 off and Temu 100 off coupon code, you’ll enjoy substantial discounts and access exclusive first-time offers that make your online shopping experience even more rewarding. What Is The Coupon Code For Temu £100 Off? If you’re new or even a regular shopper on Temu, there’s a huge treat for you. Use our special Temu coupon £100 off and enjoy big savings. This £100 off Temu coupon is valid for all users. acs670886: Enjoy a flat £100 discount on your order instantly.   acs670886: Get a £100 coupon pack that can be used across multiple purchases.   acs670886: Exclusive £100 flat discount for new customers.   acs670886: Receive an extra £100 off as a promo offer for existing Temu shoppers.   acs670886: Designed specifically for shoppers in the UK for maximum benefit.   Temu Coupon Code £100 Off For New Users In 2025 If you're a new user, you're in for a treat. Our Temu coupon £100 off and Temu coupon code £100 off gives you top-tier benefits right from the start. acs670886: Get a flat £100 discount as a welcome gift.   acs670886: Unlock a £100 coupon bundle curated for first-time users.   acs670886: Benefit from up to £100 in multiple-use coupon packs.   acs670886: Free shipping all over Europe with your first order.   acs670886: Enjoy an additional 30% discount on any first-time purchase.   How To Redeem The Temu coupon £100 off For New Customers? To activate your Temu £100 coupon and use the Temu £100 off coupon code for new users, follow these steps: Download the Temu app or visit the website.   Sign up for a new account using your email or social ID.   Add your desired items to the cart.   On the checkout page, locate the "Apply Coupon Code" section.   Enter acs670886 and click apply.   Enjoy your discounts and complete the purchase!   Temu Coupon £100 Off For Existing Customers Even if you're a regular Temu customer, you can still grab exclusive benefits. With our Temu £100 coupon codes for existing users and Temu coupon £100 off for existing customers free shipping, savings are guaranteed. acs670886: Receive an extra £100 off on your next Temu order.   acs670886: Access a special £100 coupon bundle for repeat customers.   acs670886: Enjoy a free gift and express delivery throughout Europe.   acs670886: Up to 70% discount stacked on your coupon benefits.   acs670886: Free delivery throughout the United Kingdom.   How To Use The Temu Coupon Code £100 Off For Existing Customers? To enjoy the Temu coupon code £100 off and make use of the Temu coupon £100 off code, follow this guide: Log into your existing Temu account.   Browse and add products to your shopping basket.   Proceed to checkout.   In the coupon field, type acs670886.   Apply the code and see the discount activate instantly.   Complete your order with massive savings.   Latest Temu Coupon £100 Off First Order The best time to save is on your first order, and we’ve made that easy. Use the Temu coupon code £100 off first order, Temu coupon code first order, and Temu coupon code £100 off first time user for incredible savings. acs670886: Enjoy a flat £100 discount on your very first purchase.   acs670886: Redeem a full £100 Temu coupon code first order benefit.   acs670886: Get up to £100 in multiple-use coupon vouchers.   acs670886: Free shipping across European countries.   acs670886: Additional 30% off on every item in your first order.   How To Find The Temu Coupon Code £100 Off? If you're looking for the latest Temu coupon £100 off and even those discussed on Temu coupon £100 off Reddit, here’s how to find them. Start by signing up for Temu’s official newsletter to receive coupons directly in your inbox. Additionally, keep an eye on Temu’s social media pages like Instagram, Facebook, and Twitter. For the latest and verified coupons, always visit trusted coupon websites that update their listings daily. Is Temu £100 Off Coupon Legit? Yes, the Temu £100 Off Coupon Legit and Temu 100 off coupon legit claims are 100% valid. Our Temu coupon code acs670886 is legitimate, safe to use, and regularly tested. You can confidently use it on both new and recurring orders in 2025. This coupon works across the UK and Europe with no expiration restrictions, ensuring you save consistently. How Does Temu £100 Off Coupon Work? The Temu coupon code £100 off first-time user and Temu coupon codes 100 off work as discount codes that you enter during checkout. Once the code is applied, you get instant deductions from your total bill, and in some cases, added perks like free shipping and free gifts. This code can also unlock bundles or extra discounts depending on your cart size and product type. It’s designed to maximise your savings and encourage smart shopping for new and regular users alike. How To Earn Temu £100 Coupons As A New Customer? You can earn the Temu coupon code £100 off and 100 off Temu coupon code simply by creating a new account and entering the code during your first purchase. The platform may also reward you for referrals, app downloads, or completing your profile. Always check your email and Temu account dashboard for exclusive coupon notifications and bonus vouchers. What Are The Advantages Of Using The Temu Coupon £100 Off? Here are the key benefits of using the Temu coupon code 100 off and Temu coupon code £100 off: £100 off on your first Temu order.   Access to a £100 coupon bundle for multiple orders.   70% off popular trending products.   Extra 30% discount for existing UK users.   Up to 90% off on selected clearance items.   Free welcome gift for first-time UK shoppers.   Complimentary delivery throughout Europe.   Temu £100 Discount Code And Free Gift For New And Existing Customers With our Temu £100 off coupon code and £100 off Temu coupon code, shopping on Temu becomes an exciting experience. Here are some of the most attractive benefits: acs670886: £100 discount applied immediately on checkout.   acs670886: Extra 30% off on your selected items.   acs670886: Free welcome gift for all new users.   acs670886: Up to 70% savings across categories.   acs670886: Free shipping and gift delivery in Europe and the UK.   Pros And Cons Of Using Temu Coupon Code £100 Off This Month Let’s explore the pros and cons of the Temu coupon £100 off code and Temu 100 off coupon: Pros: Substantial £100 discount.   Stackable with other offers.   No expiration date.   Free delivery in the UK and Europe.   Works for new and existing customers.   Cons: Limited to specific categories occasionally.   Some items may be excluded from additional discounts.   Terms And Conditions Of Using The Temu Coupon £100 Off In 2025 Below are the terms for Temu coupon code £100 off free shipping and latest Temu coupon code £100 off: No expiration date; use anytime.   Valid for both new and existing users.   Usable across the UK and Europe.   No minimum purchase required.   Must enter acs670886 at checkout for discounts to apply.   Final Note: Use The Latest Temu Coupon Code £100 Off Don’t miss your chance to save with the Temu coupon code £100 off. This is the perfect time to stock up and explore Temu’s extensive product selection with extra value. Get the best of Temu today by using your exclusive Temu coupon £100 off and enjoy shopping smarter. FAQs Of Temu £100 Off Coupon 1. What is the Temu coupon code for £100 off? You can use the code acs670886 during checkout to get a £100 discount on your order. It’s valid for both new and existing users across the UK and Europe. 2. Can I use the £100 Temu coupon more than once? Yes, you can use acs670886 for bundles and repeated benefits until the full £100 value is utilised. 3. Is the Temu £100 coupon code legit? Absolutely. The coupon code is tested, verified, and safe to use for UK and European shoppers. 4. How do I redeem the Temu coupon code as a new user? Simply create a new account on Temu, add items to your cart, and apply acs670886 during checkout. 5. Are there shipping charges with the £100 Temu coupon? No. When you apply acs670886, shipping is free throughout the UK and Europe.
  • Topics

×
×
  • Create New...

Important Information

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