L.J.Duckfield Posted June 25, 2012 Posted June 25, 2012 Trying to make bonemeal grow my crops instantly. I have used the below code within my 'mod_XXXX.java' MinecraftForge.registerBonemealHandler(new blockTomatoCropBonemealHandler()); And the following code in my 'XXXXBonemealHandler.java' package net.minecraft.src; import net.minecraft.src.forge.*; import net.minecraft.client.*; public class blockTomatoCropBonemealHandler implements IBonemealHandler { @Override public boolean onUseBonemeal(World world, int blockID, int X, int Y, int Z) { if (!world.isRemote) { ((blockTomatoCrop)mod_AbsolutCrop.blockTomatoCrop).fertilize(world, X, Y, Z); } return true; } } Any help will be highly appreciated Thank-you in advance Quote
L.J.Duckfield Posted June 25, 2012 Author Posted June 25, 2012 -EDIT Bonemeal now doing its job, but will not grow the crop unless User interacts with a block next to the target crop Any help would be appreciated Thank-you in advance Quote
OvermindDL1 Posted June 26, 2012 Posted June 26, 2012 -EDIT Bonemeal now doing its job, but will not grow the crop unless User interacts with a block next to the target crop Any help would be appreciated Thank-you in advance Likely you are using something like setBlockAndMetadata or so, use the notify versions like setBlockAndMetadataWithNotify of whatever method you use. Quote
L.J.Duckfield Posted June 26, 2012 Author Posted June 26, 2012 Added the following code, to the crop class file. Bonemeal now instantly works (tested in creative mode) .setRequiresSelfNotify() Sorry for the questions, but do you happen to know which file controls the dropping of seeds from TallGrass Thank-you Quote
OvermindDL1 Posted June 26, 2012 Posted June 26, 2012 Sorry for the questions, but do you happen to know which file controls the dropping of seeds from TallGrass Actually Forge already has a hook for that. Look in the forge hooks. Quote
L.J.Duckfield Posted June 26, 2012 Author Posted June 26, 2012 very nice and clean, simply added the following code to my 'mod_XXXX.java' MinecraftForge.addGrassSeed(itemXXXXSeeds.shiftedIndex, 0, 1, 10); Thank-you very much for your persistent help. I'm really enjoying my time here. Quote
L.J.Duckfield Posted June 26, 2012 Author Posted June 26, 2012 The bonemeal handler is working fine, and is actually growing the crop fully. (tested to drop crop & seeds after bonemeal usage) I am having a slight problem with the texture of the crop not being updated instantly, whilst testing in Eclipse. (there is a delay in the texture being updated after bonemeal usage) is there anything i can call in the 'blockXXXXCropBonemealHandler.java' which will update texture or check to see if the texture needs updating. Quote
L.J.Duckfield Posted June 26, 2012 Author Posted June 26, 2012 If it helps, this is my current BonemealHandler code package net.minecraft.src; import net.minecraft.src.forge.*; import net.minecraft.client.*; public class blockCarrotCropBonemealHandler implements IBonemealHandler { public boolean onUseBonemeal(World world, int blockID, int X, int Y, int Z) { if (!world.tickUpdates(true)) { ((blockCarrotCrop) ((blockCarrotCrop)mod_AbsolutCrop.blockCarrotCrop).setRequiresSelfNotify()).fertilize(world, X, Y, Z); } return true; } } Quote
LexManos Posted June 26, 2012 Posted June 26, 2012 We need to see your fertalize function. If you set the block's metadata properly with notify, then it should instantly show. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
L.J.Duckfield Posted June 26, 2012 Author Posted June 26, 2012 I must admit i am a complete 'newb' when it comes to java, i spend a good few hours a day looking through code and picking it up as i go along. I did look into what you said, and it seems there were two parts to my code for each crop that were complicating matters. This is how i have the code for each crop in the 'mod_XXXX.java' whereas beforehand, the bracketed value wasn't corresponding to the stage of growth it was meant to be representing. public static int blockCottonCrop0 = (0); public static int blockCottonCrop1 = (1); public static int blockCottonCrop2 = (2); public static int blockCottonCrop3 = (3); public static int blockCottonCrop4 = (4); public static int blockCottonCrop5 = (5); public static int blockCottonCrop6 = (6); public static int blockCottonCrop7 = (7); Secondly i created a new 'XXXXbonemealHandler' for each crop... rather than creating the one handler to deal with all crops in the mod. Noticing during tests that my first registered handler in the 'mod_XXXX.java' would actually grow the crop upon using bonemeal, i deleted the irrelevant 'BonemealHandlers' and added the data for each crop into the one file. Ran another test inside Eclipse and all worked correctly Thank-you for your patience, and ever-helpful responses. -EDIT - Tested after Re-obfuscation, also worked. Quote
Recommended Posts
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.