Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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.

Posted

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.

Posted

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;

}

}

Posted

We need to see your fertalize function.

If you set the block's metadata properly with notify, then it should instantly show.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

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.

 

 

 

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.