Jump to content

Recommended Posts

Posted

Hello everybody, im new to this forum and this is my very first post :=)

So, basically, i want that i can place saplings and stuff on my own block. a quick look revealed that it has todo with the "canThisPlantGrowOnThisBlockID" method inside BlockFlower. It checks for the id of the blocked to be placed and only when it matches it places it.

Problem is, that the block that are allowed are hardcoded. i searched around a bit and came to the conclusion that i need a coremod and need to patch this method using bytecode manipulation. Now, i really have no clue on how todo those things^^

It would be cool if you could help me and yeah, any help is much appreciated :)

 

regards, Marc

Posted

Saplings are subclasses of BlockBush not BlockFlower from looking at 1,7.2 code.

 

However, trying to get a sapling to be plantable, is not a simple matter of deriving a class from 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;
    }

The above code hard-wires the check for a specific block, not just a suitably derived type of block. The code should have been written more like to make growing on other blocks readily possible.

    protected boolean canPlaceBlockOn(Block p_149854_1_)
    {
        return BlockGrass.class.isInstance(p_149854_1_) || BlockDirt.class.isInstance(p_149854_1_) || BlockFarmland.class.isInstance(p_149854_1_);
    }

I'm not sure (other than a coremod) how to make such things work.

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.