Jump to content

Recommended Posts

Posted

Hi,

 

I'm am a beginner at modding - I've been fooling around with modding 1.7.2 with eclipse, looked at several tutorials...

I've gotten to where I can do a lot of the basic things, adding items/recipes/foods.  But something I want to do is add a custom fishing pole that would be capable of catching items(fish) that I add into the game.  Could anyone help me out on how to do this?

 

I've searched for info on modding the fishing rods but couldn't find anything.

 

Any help would be appreciated. 

Posted

This post has some helpful stuff in it.

 

http://www.minecraftforge.net/forum/index.php?topic=9700.0

 

They do not appear to have solved it.

 

This is what I would try.

  • Extend the vanilla fishing pole and do nothing to it other than having your own theIcon variable and to override onitemRightClick to spawn your very own custom EntityHook.
  • Create your own custome entity extending EntityHook.  This will be more tricky.  It has a lot of private values, some of which you need to adjust.  You will need to create your own and adjust them.  Onupdate, func_146033 appear to be the two methods you need to customize.

 

Get it working exactly like the vanilla one first.  Then customize it.

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

Thanks for replying

 

Creating a custom fishing pole that acts just like the regular one is where I was wanting to start, unfortunately I'm just not knowledgeable enough in the programing to get it to work.  Best I've managed was to make an item that extends the FishingRod, but all I can get it to do is shoot out a hook and immediately retract. 

 

Probably asking a lot, but how do I go about overriding the on right click to spawn a custom entity?

 

The topic you linked is interesting and makes me think doing this is going to be complicated and way over my head

Posted

override this method

 

    /**

    * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer

    */

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

    {

        if (par3EntityPlayer.fishEntity != null)

        {

            int i = par3EntityPlayer.fishEntity.func_146034_e();

            par1ItemStack.damageItem(i, par3EntityPlayer);

            par3EntityPlayer.swingItem();

        }

        else

        {

            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

 

            if (!par2World.isRemote)

            {

                par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer));

            }

 

            par3EntityPlayer.swingItem();

        }

 

        return par1ItemStack;

    }

 

to do that add "@Override" to the line above

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

 

in your new overridden method change the line

par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer)); >>>>>>ENTITYFISHHOOK<<<<< to your new custom entity fish hook and fix the appropriate errors if any occur :)

 

Posted

Piz,

this isn't the easiest one to cut your teeth on.  Course the only way to learn is to try.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

Ok, been fooling around with this I added the override to spawn the custom hook, I am not sure how to change the theIcon variable or what to adjust with the Onupdate, func_146033 that you mentioned.

 

I'll show you what I've done so far, its not working atm, it crashes now when I right click with the rod, I assume that's because I haven't changed the things in the hook entity that need changing

 

The fishing rod-

 

  Reveal hidden contents

 

 

 

And the custom hook

 

  Reveal hidden contents

 

 

Under the Onupdate I see this line:

 

if (this.field_146042_b.isDead || !this.field_146042_b.isEntityAlive() || itemstack == null || itemstack.getItem() != Items.fishing_rod || this.getDistanceSqToEntity(this.field_146042_b) > 1024.0D)

 

Do I need to change the Items.fishing_rod to my custom rod item?  If so, how do I do that, I tried and get an error I can't seem to fix.

 

Again, thanks to both of you for the help :)

               

Posted

I'll try later to read your code and see if anything looks odd, but to answer your immediate question.

 

In your main mod file, you created an item and it has a variable associated with it.

 

For example

 

  Reveal hidden contents

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.