Jump to content

Bonemeal - Delayed Crop Texture


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;

}

}

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

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.