How to code a craftable and spawnable a pet? (2023.3)

Started by Faydflowright on

Topic category: Help with modding (Java Edition)

Last seen on 19:46, 10. Mar 2024
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to code a craftable and spawnable a pet? (2023.3)

Hey everyone! I'm trying to make an original pet that I'm having trouble with trying to program.

1) I want to combine two things together to create the pet. Either by throwing it on the ground and *poof* mob pet is there OR you get the spawn egg of the mob which disappears after use.

2) that this creature is then tamed by the player immediately

 

Is this possible to do? And what kind of code could I put together to make this happen?

THANK YOU!!

Last seen on 16:25, 16. Jun 2024
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, that's possible :). You…
Mon, 09/18/2023 - 16:16

Yes, that's possible :).

You can ask ChatGPT which kind of code you could put together to make this happen.

Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is definitely possible!…
Mon, 09/18/2023 - 16:29

This is definitely possible! 

Once your creature/mob is created, you will need to create your spawn egg (assuming you are not using the default).

For the "throwing on the ground" option, you would need to create a ranged item, set your max stack size to whatever you want, and item usage count to 0. Make the projectile and your ranged item look like the egg. Then for your triggers make one procedure for "when item used" that will set the stack size to -1, so that it uses up the egg.  Then set up a "when projectile hits block" procedure, that says "spawn entity" then a block for "tame [get nearest entity of your entity] by [source entity(aka the player that threw the egg)]. Then you can just add the little details like summoning particles or playing a sound.

 

The other option of right clicking the egg on the ground. Set up a global trigger for "player right clicks on block" then have a check for "if item in main hand = spawn egg" do "spawn mob" and then the same thing as above with the setting up tamed, etc.

Last seen on 19:46, 10. Mar 2024
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Stitch THANKS! I'll try…
Mon, 09/18/2023 - 17:02

@Stitch THANKS! I'll try that now!