Jump to content

[1.12.2] Give item ability to breed animals


Enemeez

Recommended Posts

This is actually code in the Entity, not the Item.  If you have a new custom animal that you want your custom item to be able to put into "breeding mode" you would override isBreedingItem in your entity's class.  If you want a custom item to work on preexisting entities you would have to hook into the EntityInteract event.

Link to comment
Share on other sites

The Item class should already have an OnEntityInteract method (can't remember the exact name, but is used by a few items like shears) that you can use. You'd then want to call entity.setInLove(player). (Maybe it takes the stack? Looking at old code where I was doing it from an AI task, so I was passing null).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

3 hours ago, Enemeez said:

What about making the item attract animals while being only held in your hand?

You might have to make an AI task for that. Check how vanilla handles it already.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

private static final Set<Item> TEMPTATION_ITEMS = Sets.newHashSet(Items.CARROT, Items.POTATO, Items.BEETROOT);
  
   protected void initEntityAI()
    {
        this.tasks.addTask(4, new EntityAITempt(this, 1.2D, false, TEMPTATION_ITEMS));
    }

 

Just to clarify, I did not make a custom entity. I'm trying to tempt vanilla animals.

 

With this in mind, here is a snippet of the code from the EntityPig class. To add my item to TEMPTATION_ITEMS, will I need to create myself a new EntityPig class with my item inside the set? Or how do I go about modifying this?

 

 

Link to comment
Share on other sites

Remove that AI task and recreate it with a new list.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.