Posted April 10, 201411 yr So I have a block that acts like soil and can have plants planted on it but I would like to know how to make my block accelerate the growth speed of the plants on it. Sapling, crops and pumpkins/melons.
April 11, 201411 yr When I'm modding I usually try to find the vanilla code that does similar effect. It sounds like you want an effect maybe like same as if bonemeal was added to the plant above your block? I dug around a little bit. Note I'm using 1.7.2 -- you might have better luck with 1.6.4 since the code is less obfuscated there. The first thing that makes it a bit difficult to find is that bonemeal is also used sort of as a dye, so it looks like the code for applying bonemeal is actually in ItemDye class. There you will find an applyBoneMeal() method and you can see code where it is checking if the block applied implements IGrowable. The interesting part of the code seems to be: if (block instanceof IGrowable) { IGrowable igrowable = (IGrowable)block; if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote)) { if (!p_150919_1_.isRemote) { if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_)) { igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_); } } } } As you can see, unfortunately much of that code is obfuscated (you should look at it in Eclipse or your IDE to follow the various parameters. But it looks like the right place to start to me -- you can get the block above your grass (with additional code) then check to see if it is an instance of IGrowable and then update the growth. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.