Is it possible to make a custom mob that can be milked, similar to a Cow or Mooshroom in the base game?

Started by xavier23 on

Topic category: Help with modding (Java Edition)

Last seen on 02:30, 19. Jun 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is it possible to make a custom mob that can be milked, similar to a Cow or Mooshroom in the base game?

Hello there! I am currently working on a new variant of the Cow in my Minecraft Mod (the Moobloom, a flower Cow) and I was curious on how I can make this new mob milkable with a specific item, similar to how its vanilla counterparts function in the base game. (For example, normal Cows can be milked only with a bucket (which gives Milk Buckets) and Mooshrooms can be milkable with a Bowl (to give Mushroom Stew or Suspicious Stew items,) and I was wanting my custom Cow mob to give an item to the player (such as Suspicious Stew or Milk) whenever it would be right clicked with a specific item (like a Bowl or Bucket.)) I have been trying to figure out how to resolve this issue for quite a bit, but I cannot figure out how to make a procedure in particular that doesn't make all mobs in the game milkable with the specific item I was using! Thank you kindly for your help, Happy April Fools' Day!

Last seen on 18:01, 13. Jun 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There's a global trigger for…
Fri, 04/12/2024 - 11:11

There's a global trigger for 'entity right clicked,' and you can then use the 'get item in main hand' and 'get item in off-hand' functions to determine what item the player is holding when the entity is clicked. So you would need to make a procedure with this trigger, check if the event/target entity is your custom mob, check if the item in the source entity's main hand is a bucket, and then set your custom bucket in the player's main hand. (Or shrink the item in their main hand for one, and add one custom item to their inventory, if it's something stackable.)