How to detect sheep color and run different procedure based on their color?

Started by jmods on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to detect sheep color and run different procedure based on their color?

I'm basically trying to make a different drop for each color sheep but I can't seem to figure out how. I've seen the block "Get color of sheep..." but I'm unsure on how to use it, and can't seem to find anything that shows an example of using it

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm pretty sure sheep color…
Wed, 01/24/2024 - 15:34

I'm pretty sure sheep color is an NBT tag. If it is, you just need to find the name of the tag, and you can access it with procedures. (So you could make a procedure that triggers when the entity dies, checks the tag, and uses it to determine which item to spawn.) 

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't figure out how to…
Fri, 02/09/2024 - 20:00

I can't figure out how to check the NBT tag for the color, do you have any ideas how I'd do that?

 

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
According to the wiki it's a…
Fri, 02/09/2024 - 23:57

According to the wiki it's a numeric tag. (0 is white, 1 is orange, 2 is pink, etc), and the tag is just called 'Color.' My guess is you should be able to access it with the 'custom NBT tag' entity function. (If not, there are more needlessly complicated workarounds you could try involving the /data command...)

Joined Sep 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Im trying to do the same…
Mon, 02/12/2024 - 21:48

Im trying to do the same thing, but with wolves.

 

I have tried using the "custom NBT tag" thing, but it never works.

 

Since the color values for Wolves and Sheep are the same, could you send me a procedure that would get the color of the wolf, set a variable to it, and do something if the variable is equal to 0, 1, 2, 3, ect.

 

Then spectrejks would be able to use this same procedure but swap out the CollarColor tag for the Color tag.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If custom NBT isn't working,…
Tue, 02/13/2024 - 01:13

If custom NBT isn't working, then you'll likely have to do a /data command of some sort. A procedure that triggers before the entity dies that runs a data command and returns a number.  (Something like /data get entity @e[type=sheep,sort=nearest,limit=1] {Color}). The tricky part is getting the return value from the command, I'm not entirely sure how you'd do this. 

It also might just be possible to make the loot table NBT dependent? I'm pretty sure there's loot tables that do this, but I haven't found any references to it in the documentation.

Joined Sep 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how would you get the return…
Wed, 02/14/2024 - 00:17

how would you get the return value from the command?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You would likely have to do…
Thu, 02/15/2024 - 20:19

You would likely have to do it all using commands. You can run conditional commands with /execute, so you would need to write a command that drops the block if the sheep's color data equals a certain number. Again, I'm not super familiar with /execute, but I've heard Legitimoose has a decent tutorial. (Though the command may not be the best route, it's the only way I can think of to do this if the usual NBT procedures aren't returning anything.)