-1

Basically i want to make chickens drop feathers some times like they do with eggs. My idea was to have a scoreboard and a command that adds on that scoreboard then when it reaches a certain amount of time another command would spawn at the chicken the feather and finally another command that would reset the whole thing. The problem with this though is that this would make every single chicken in the world drop feathers at the exact same time so how do i do this and have the chickens having their own time, maybe one chicken will drop a feather after 5 mins and another would drop after 4 or 6?

2
  • Try using a chicken-specific timer and then every time that timer reaches zero, reset it and run some commands. If you want variable timers, then store another scoreboard value that remembers that start time for that chicken. You can @e chickens.
    – aytimothy
    Commented Sep 30, 2018 at 23:19
  • 3
    Flagging question as unclear because it does not specify which edition is being played.
    – pppery
    Commented Jan 24, 2020 at 1:05

1 Answer 1

1

Well, that's simples. In essence, we want to do three things:

  1. When a chicken spawns, assign it a random "drop time" value.
  2. Every second, all chickens have their "drop time" timers decreased by a second.
  3. When a chicken's "drop time" timer is 0, reset it, execute some stuff (make it drop a feather) and reset the timer to the chicken's "drop time" value.

Assigning "Drop Time" Values

Well, there's nothing fancy here. Just your usual trigger.

# Create your two variables.
scoreboard objectives create hasTimerValue dummy Has Timer Value
scoreboard objectives create timerValue dummy Drop Cycle Time

hasTimerValue would house a 1 or 0; whether or not a chicken has a timerValue assigned to it, and timerValue obviously is how long the timer starts at every time it resets.

Then, simply run this continously...

# Give a random chicken a drop time value.
scoreboard players set @e[sort=random,limit=1,scores={hasTimerValue=0}] timerValue 240 
scoreboard players set @e[sort=random,limit=1,scores={hasTimerValue=0}] timerValue 300 
scoreboard players set @e[sort=random,limit=1,scores={hasTimerValue=0}] timerValue 360 
scoreboard players set @e[sort=random,limit=1,scores={hasTimerValue=0}] timerValue 420 
# Set the 'hasTimerValue' flag to true to the chickens with a timer value.
scoreboard players set @e[scores={timerValue=1..}

Note: You can simplify it by simply just testing for timerValue being equal or less than 0 than to have a hasTimerValue flag.
Note: You'll want to reorder it, or have some sort of random selection. This is to simply illustrate. There are better ways to do it, such as this one.


Decrease All drop timers by 1.

Nothing fancy here either.

# Create new scoreboard for timer.
scoreboard objectives add dropTimer dummy Time until Drop
# Decrease Timer by One
scoreboard players remove @e[scores={hasTimerValue=1,dropTimer=1..}] 1

Do stuff when Timer is 0, then reset it.

This answer should show you how to change values by getting and setting a value of another thing. Nothing fancy here either with picking who to execute.

# Do stuff.
execute positioned as @e[scores={hasTimerValue=1,dropTimer=0}] Stuff
# Reset the timer back to whatever the original interval was.
scoreboard players operation @e[scores={hasTimerValue=1,dropTimer=0}] dropTimer = @e[scores={hasTimerValue=1,dropTimer=0},limit=1] timerValue

Replace Stuff with whatever you want to run.

execute positioned as <entity> <command> is like a /sudo for Minecraft entities without access to the usual Bukkit/admin stuff.

3
  • ok i tried your commands but they don't seem to work i made all the scoreboards i changed the create to add cause it couldn't make it and then i placed all the commands in order in the command blocks and they didn't worked i added the type=chicken on every command but still it didn't worked, to see if the commands would work i put instead of the item to spawn a skeleton at the chicken but i was staring at the chicken for over 10 mins and nothing happen.
    – Alex
    Commented Oct 1, 2018 at 10:14
  • That's because the 'Assigning a drop time value' section code doesn't work. You needed to write your own command to give the mobs a timerValue. I can't exactly put a spider randomizer into command form.
    – aytimothy
    Commented Oct 1, 2018 at 10:21
  • so how do i give them their own timerValue do i just do /execute as @e[type=chicken] run scoreboard players add @e[type=minecraft:chicken] timerValue 100 to add on each chicken 100 ticks?
    – Alex
    Commented Oct 1, 2018 at 10:38

Not the answer you're looking for? Browse other questions tagged .