mojira.dev
MCPE-46286

Add-on Bug, minecraft:timer component is using times from previously active timer instead of currently active one.

There appears to be a bug for the minecraft:timer component that causes it to not correctly update the running timer to use the timer component from the currently active component group.

Instead it is using the timer values that were previously applied and just switched out for.

I have provided an example json entity with the issue, tested with "format_version": "1.10.0" and "format_version": "1.8.0", afaik my old 1.10 entities did not have this issue.

 

Expected behavior:

mzo:stage1 should be active for 1 second

mzo:stage2 should be active for 2 seconds

mzo:stage3 should be active for 3 seconds

Observing the entities scale as a debug to reflect the active component group.

Actual behavior:

mzo:stage1 is active for 3 seconds, the timer that was active previously

mzo:stage2 is active for 1 second, the timer that was active previously

mzo:stage3 is active for 2 seconds, the timer that was active previously

 

Example entity json with the issue:

 

{
  "format_version": "1.10.0",
  "minecraft:entity": {
    "description": {
      "identifier": "mzo:timer_test",
      "is_spawnable": true,
      "is_summonable": true,
      "is_experimental": false
    },

    "component_groups": {

      "mzo:stage1": {
        "minecraft:scale": {
          "value": 1.0
        },

        "minecraft:timer": {
          "time": [ 1, 1 ],
          "looping": false,
          "time_down_event": {
            "event": "mzo:event_stage2",
            "target": "self"
          }
        }
      },

      "mzo:stage2": {
        "minecraft:scale": {
          "value": 2.0
        },

        "minecraft:timer": {
          "time": [ 2, 2 ],
          "looping": false,
          "time_down_event": {
            "event": "mzo:event_stage3",
            "target": "self"
          }
        }
      },

      "mzo:stage3": {
        "minecraft:scale": {
          "value": 3.0
        },

        "minecraft:timer": {
          "time": [ 3, 3 ],
          "looping": false,
          "time_down_event": {
            "event": "mzo:event_stage1",
            "target": "self"
          }
        }
      }

    },

    "components": {

      "minecraft:type_family": {
        "family": [ "zombie", "undead", "monster" ]
      },

      "minecraft:attack": {
        "damage": 3
      },

      "minecraft:breathable": {
        "totalSupply": 15,
        "suffocateTime": 0,
        "breathesAir": true,
        "breathesWater": true
      },

      "minecraft:health": {
        "value": 20,
        "max": 20
      },

      "minecraft:collision_box": {
        "width": 0.72,
        "height": 2.0
      },
      "minecraft:navigation.walk": {
        "can_path_over_water": true
      },
      "minecraft:movement.basic": {
      },
      "minecraft:jump.static": {
      },
      "minecraft:can_climb": {
      },
      "minecraft:fire_immune": true,
      "minecraft:behavior.float": {
        "priority": 0
      },
      "minecraft:behavior.hurt_by_target": {
        "priority": 1
      },
      "minecraft:follow_range": {
        "value": 16,
        "max": 16
      },
      "minecraft:behavior.look_at_player": {
        "priority": 6,
        "look_distance": 8
      },
      "minecraft:behavior.nearest_attackable_target": {
        "priority": 2,
        "scan_interval": 10,
        "reselect_targets": true,
        "within_radius": 16,
        "entity_types": [
          {
            "filters": {
              "any_of": [
                {
                  "test": "is_family",
                  "subject": "other",
                  "value": "player"
                },
                {
                  "test": "is_family",
                  "subject": "other",
                  "value": "player_ally"
                }
              ]
            },
            "max_dist": 16
          }
        ],
        "must_see": false
      },

      "minecraft:physics": {
      }
    },

    "events": {
      "minecraft:entity_spawned": {
        "sequence": [
          {
            "add": {
              "component_groups": [
                "mzo:stage1"
              ]
            }
          }
        ]
      },
      "mzo:event_stage1": {
        "sequence": [
          {
            "add": {
              "component_groups": [
                "mzo:stage1"
              ]
            },
            "remove": {
              "component_groups": [
                "mzo:stage3"
              ]
            }
          }
        ]
      },
      "mzo:event_stage2": {
        "sequence": [
          {
            "add": {
              "component_groups": [
                "mzo:stage2"
              ]
            },
            "remove": {
              "component_groups": [
                "mzo:stage1"
              ]
            }
          }
        ]
      },
      "mzo:event_stage3": {
        "sequence": [
          {
            "add": {
              "component_groups": [
                "mzo:stage3"
              ]
            },
            "remove": {
              "component_groups": [
                "mzo:stage2"
              ]
            }
          }
        ]
      }
    }
  }
}

Comments 6

Might be fixed in 1.12 now, needs testing "Removing a timer component and adding a new one should no longer have the new timer inherit the old timer's time value"

Might be fixed in 1.12 now, needs testing "Removing a timer component and adding a new one should no longer have the new timer inherit the old timer's time value"

Having multiple timer components in different component groups makes that they will not work.
What is expected is that the entity will have multiple timers running on it at the same time and when one of them finishes the other one will still be running

Example:

"component_groups": {
			"tv:spawn": {
				"minecraft:timer":{
					"looping": false,
					"time": 2.3,
					"time_down_event": {
						"event": "tv:runevent2",
						"target": "self"
					}
				},
				"minecraft:timer":{
					"looping": false,
					"time": 1.9,
					"time_down_event": {
						"event": "tv:runevent1",
						"target": "self"
					}
				}
			},
		},
		"events": {
			"minecraft:entity_spawned": {
				"add": {
					"component_groups": [
						"tv:spawn"
					]
				}
			},
			"tv:runevent1": {
                    ................
			},
			"tv:runevent2": {
                    ................
			}
		}

(Uncompleted file only important parts)

Expected:
On spawn the entity will hve 2 timers running on it.
After 1.9 seconds the event tv:runevent1 will execute and 0.4 seconds after that event executed the event tv:runevent2 will execute

Reality:
Random Behaviour, most of the time none of both timer works.

Example 2:

"component_groups": {
			"tv:spawn": {
				"minecraft:timer":{
					"looping": false,
					"time": 2.3,
					"time_down_event": {
						"event": "tv:runevent1",
						"target": "self"
					}
                }
            },
			"tv:afterevent1": {
				"minecraft:timer":{
					"looping": false,
					"time": 3.0,
					"time_down_event": {
						"event": "tv:runevent2",
						"target": "self"
					}
                }
            }
		},
		"events": {
			"minecraft:entity_spawned": {
				"add": {
					"component_groups": [
						"tv:spawn"
					]
				}
			},
			"tv:runevent1": {
				"add": {
					"component_groups": [
						"tv:afterevent1"
					]
				}
			},
			"tv:runevent2": {
                    ................
			}
		}

(Uncompleted file only important parts)

Expected:
At the entity spawn the tv:spawn timer will start running and when it ends the second timer will start running as it is called from the first one

Reality:
Random Behaviour, most of the times first timer executes, and second one does not.

Maybe after the first timer ends the component groups stays there without beaing autoremoved and as the entity cannot have multiple timers the second one does not work because the first one is still on its components even if it finished executing.

Best way to fix it will be making the entities allow have multiple timers running at once.

Tested in 1.13 release

Having multiple timer components in different component groups makes that they will not work.
What is expected is that the entity will have multiple timers running on it at the same time and when one of them finishes the other one will still be running

Example:

"component_groups": {
			"tv:spawn": {
				"minecraft:timer":{
					"looping": false,
					"time": 2.3,
					"time_down_event": {
						"event": "tv:runevent2",
						"target": "self"
					}
				},
				"minecraft:timer":{
					"looping": false,
					"time": 1.9,
					"time_down_event": {
						"event": "tv:runevent1",
						"target": "self"
					}
				}
			},
		},
		"events": {
			"minecraft:entity_spawned": {
				"add": {
					"component_groups": [
						"tv:spawn"
					]
				}
			},
			"tv:runevent1": {
                    ................
			},
			"tv:runevent2": {
                    ................
			}
		}

(Uncompleted file only important parts)

Expected:
On spawn the entity will hve 2 timers running on it.
After 1.9 seconds the event tv:runevent1 will execute and 0.4 seconds after that event executed the event tv:runevent2 will execute

Reality:
Random Behaviour, most of the time none of both timer works.

Example 2:

"component_groups": {
			"tv:spawn": {
				"minecraft:timer":{
					"looping": false,
					"time": 2.3,
					"time_down_event": {
						"event": "tv:runevent1",
						"target": "self"
					}
                }
            },
			"tv:afterevent1": {
				"minecraft:timer":{
					"looping": false,
					"time": 3.0,
					"time_down_event": {
						"event": "tv:runevent2",
						"target": "self"
					}
                }
            }
		},
		"events": {
			"minecraft:entity_spawned": {
				"add": {
					"component_groups": [
						"tv:spawn"
					]
				}
			},
			"tv:runevent1": {
				"add": {
					"component_groups": [
						"tv:afterevent1"
					]
				}
			},
			"tv:runevent2": {
                    ................
			}
		}

(Uncompleted file only important parts)

Expected:
At the entity spawn the tv:spawn timer will start running and when it ends the second timer will start running as it is called from the first one

Reality:
Random Behaviour, most of the times first timer executes, and second one does not.

Maybe after the first timer ends the component groups stays there without beaing autoremoved and as the entity cannot have multiple timers the second one does not work because the first one is still on its components even if it finished executing.

Best way to fix it will be making the entities allow have multiple timers running at once.

Tested in 1.13 release

Cleaning up old tickets: This ticket has not been updated recently (~1 year+) so is being closed as Cannot Reproduce. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki

Cleaning up old tickets: This ticket has not been updated recently (~1 year+) so is being closed as Cannot Reproduce. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki

Kevin Gagnon

(Unassigned)

279818

Community Consensus

Windows

Windows 10 1809

1.11.1, 1.11.2

Retrieved