Posted June 18, 20196 yr Like wheat and seeds in vanilla, how can I give an item the ability to breed animals?
June 18, 20196 yr 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.
June 18, 20196 yr 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.
June 18, 20196 yr Well crap. There is one. It's called onInteractionForEntity. Welp, I need to go change some code..
June 18, 20196 yr Author Thanks, I got that the breeding to work. What about making the item attract animals while being only held in your hand?
June 18, 20196 yr 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.
June 18, 20196 yr Author 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?
June 18, 20196 yr Remove that AI task and recreate it with a new list. Edited June 18, 20196 yr 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.
June 19, 20196 yr Would it also be an option to replace the Item Set with one of your own choice via reflection?
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.