{
  "format_version": "1.16.0",
  "minecraft:entity": {
    "description": {
      "identifier": "legacy:smith_merchant_villager",
      "is_spawnable": true,
      "is_summonable": true,
      "is_experimental": false,
      "runtime_identifier": "minecraft:villager_v2"
    },
    "component_groups": {
      "minecraft:smith_aggro": {
        "minecraft:angry": {
          "duration": 30,
          "broadcast_anger": true,
          "broadcast_anger_on_attack": true,
          "broadcast_anger_on_being_attacked": true,
          "broadcast_range": 16,
          "broadcast_targets": [
			"villager"
          ],
          "calm_event": {
            "event": "minecraft:stop_aggro",
            "target": "self"
          }
        }
      },
      "regeneration": {
        "minecraft:spell_effects": {
          "add_effects": [
            {
              "effect": "regeneration",
              "amplifier": 2,
              "visible": 1,
              "ambient": false,
              "duration": 30
            }
          ]
        }
      },
      "attack_mode": {
        "minecraft:target_nearby_sensor": {
          "inside_range": 6,
          "outside_range": 8,
          "must_see": true,
          "on_inside_range": {
            "event": "minecraft:melee_mode",
            "target": "self"
          },
          "on_outside_range": {
            "event": "minecraft:melee_mode",
            "target": "self"
          }
        }
      },
      "melee_unit": {
        "minecraft:behavior.melee_attack": {
          "priority": 4,
          "track_target": true
        },
        "minecraft:attack": {
          "damage": 13
        },
        "minecraft:equipment": {
          "table": "loot_tables/entities/iron_sword_gear.json"
        },
        "minecraft:variant": {
          "value": 0
        }
      },
      "minecraft:default_targeting": {
        "minecraft:behavior.nearest_attackable_target": {
          "priority": 2,
          "within_radius": 12,
          "must_see": true,
          "must_see_forget_duration": 40.0,
          "entity_types": [
            {
              "filters": {
                "any_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "illager"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "monster"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "undead"
                  }
                ]
              },
              "max_dist": 12
            },
            {
              "filters": {
                "all_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "illager"
                  },
                  {
                    "test": "has_component",
                    "subject": "other",
                    "operator": "!=",
                    "value": "minecraft:is_baby"
                  }
                ]
              },
              "max_dist": 12
            }
          ]
        }
      },
      "minecraft:vindicator_fred": {
        "minecraft:behavior.nearest_attackable_target": {
          "priority": 2,
          "within_radius": 12,
          "must_see": true,
          "must_see_forget_duration": 40.0,
          "entity_types": [
            {
              "filters": {
                "any_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "illager"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "monster"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "undead"
                  }
                ]
              },
              "max_dist": 12
            },
            {
              "filters": {
                "all_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "illager"
                  },
                  {
                    "test": "has_component",
                    "subject": "other",
                    "operator": "!=",
                    "value": "minecraft:is_baby"
                  }
                ]
              },
              "max_dist": 12
            }
          ]
        }
      },
      "minecraft:smith_merchant_work": {
        "minecraft:behavior.move_to_block": {
          "priority": 5,
          "tick_interval": 35,
          "start_chance": 0.5,
          "search_range": 256,
          "search_height": 8,
          "goal_radius": 1,
          "stay_duration": 12,
          "target_offset": [
            0,
            0.25,
            0
          ],
          "target_blocks": [
            "minecraft:anvil"
          ],
          "on_stay_completed": {
            "event": "minecraft:resupply_trades"
          },
          "target_selection_method": "nearest",
          "speed_multiplier": 0.8
        },
        "minecraft:behavior.random_stroll": {
          "priority": 6,
          "speed_multiplier": 1.0
        },
        "minecraft:behavior.explore_outskirts": {
          "priority": 9,
          "explore_dist": 7,
          "speed_multiplier": 0.8
        },
        "minecraft:behavior.move_to_village": {
          "priority": 8,
          "speed_multiplier": 0.7
        },
        "minecraft:behavior.move_through_village": {
          "priority": 7,
          "speed_multiplier": 1,
          "only_at_night": true
        }
      },
      "explore_schedule_villager": {
        "minecraft:behavior.random_stroll": {
          "priority": 6,
          "speed_multiplier": 0.8
        },
        "minecraft:behavior.explore_outskirts": {
          "priority": 9,
          "explore_dist": 7,
          "speed_multiplier": 0.8
        },
        "minecraft:behavior.move_to_village": {
          "priority": 8,
          "speed_multiplier": 0.7
        },
        "minecraft:behavior.move_through_village": {
          "priority": 7,
          "speed_multiplier": 1,
          "only_at_night": true
        }
      },
      "gather_schedule_villager": {
        "minecraft:behavior.mingle": {
          "priority": 3,
          "speed_multiplier": 1.2,
          "duration": 30,
          "cooldown_time": 10,
          "mingle_partner_type": "legacy:smith_merchant_villager",
          "mingle_distance": 2
        }
      },
      "smith_merchant_schedule": {
        "minecraft:scheduler": {
          "min_delay_secs": 0,
          "max_delay_secs": 1,
          "scheduled_events": [
            {
              "filters": {
                "all_of": [
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003e\u003d",
                    "value": 0
                  },
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003c",
                    "value": 2000
                  }
                ]
              },
              "event": "minecraft:schedule_work_time"
            },
            {
              "filters": {
                "all_of": [
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003e\u003d",
                    "value": 2000
                  },
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003c",
                    "value": 4000
                  }
                ]
              },
              "event": "minecraft:schedule_gather_villager"
            },
            {
              "filters": {
                "all_of": [
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003e\u003d",
                    "value": 4000
                  },
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003c",
                    "value": 10000
                  }
                ]
              },
              "event": "minecraft:schedule_work"
            },
            {
              "filters": {
                "all_of": [
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003e\u003d",
                    "value": 8000
                  },
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003c",
                    "value": 10000
                  }
                ]
              },
              "event": "minecraft:schedule_gather_villager"
            },
            {
              "filters": {
                "all_of": [
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003e\u003d",
                    "value": 11800
                  },
                  {
                    "test": "hourly_clock_time",
                    "operator": "\u003c",
                    "value": 24000
                  }
                ]
              },
              "event": "minecraft:schedule_explore_village"
            }
          ]
        }
      },
      "trade_resupply_component_group": {
        "minecraft:trade_resupply": {},
        "minecraft:timer": {
          "time": 2,
          "looping": true,
          "time_down_event": {
            "event": "minecraft:stop_resupply"
          }
        }
      }
    },
    "components": {
      "minecraft:nameable": {
        "default_trigger": {
          "event": "minecraft:stop_fred",
          "target": "self"
        },
        "name_actions": [
          {
            "name_filter": "Fred",
            "on_named": {
              "event": "minecraft:start_fred",
              "target": "self"
            }
          }
        ],
        "alwaysShow": false,
        "allowNameTagRenaming": false
      },
      "minecraft:type_family": {
        "family": [
          "villager",
          "iron_golem",
          "mob"
        ]
      },
      "minecraft:variant": {
        "value": 0
      },
      "minecraft:dweller": {
        "dwelling_type": "village",
        "dweller_role": "inhabitant",
        "preferred_profession": "fisherman",
        "update_interval_base": 40,
        "update_interval_variant": 60,
        "can_migrate": false,
        "can_find_poi": true
      },
      "minecraft:shareables": {
        "items": [
          {
            "item": "minecraft:bread",
            "want_amount": 3,
            "surplus_amount": 6,
            "stored_in_inventory": true
          },
          {
            "item": "minecraft:carrot",
            "want_amount": 12,
            "surplus_amount": 24,
            "stored_in_inventory": true
          },
          {
            "item": "minecraft:potato",
            "want_amount": 12,
            "surplus_amount": 24,
            "stored_in_inventory": true
          },
          {
            "item": "minecraft:beetroot",
            "want_amount": 12,
            "surplus_amount": 24,
            "stored_in_inventory": true
          }
        ]
      },
      "minecraft:behavior.pickup_items": {
        "priority": 4,
        "max_dist": 3,
        "goal_radius": 2,
        "speed_multiplier": 0.8,
        "can_pickup_to_hand_or_equipment": false
      },
      "minecraft:behavior.share_items": {
        "priority": 6,
        "max_dist": 3,
        "goal_radius": 2,
        "speed_multiplier": 0.9,
        "entity_types": [
          {
            "filters": {
              "test": "is_family",
              "subject": "other",
              "value": "villager"
            }
          }
        ]
      },
      "minecraft:behavior.make_love": {
        "priority": 5
      },
      "minecraft:behavior.receive_love": {
        "priority": 6
      },
      "minecraft:breathable": {
        "totalSupply": 15,
        "suffocateTime": 0
      },
      "minecraft:collision_box": {
        "height": 1.9,
        "width": 0.6
      },
      "minecraft:health": {
        "value": 34,
        "max": 34
      },
      "minecraft:attack": {
        "damage": 14
      },
      "minecraft:movement": {
        "value": 0.35
      },
      "minecraft:navigation.walk": {
        "can_path_over_water": true,
        "can_pass_doors": true,
        "can_open_doors": true,
        "avoid_water": true
      },
      "minecraft:movement.basic": {},
      "minecraft:jump.static": {},
      "minecraft:follow_range": {
        "value": 64
      },
      "minecraft:loot": {
        "table": "loot_tables/entities/vindication_illager.json"
      },
      "minecraft:equipment": {
        "table": "loot_tables/entities/nope.json"
      },
      "minecraft:behavior.float": {
        "priority": 0
      },
      "minecraft:behavior.melee_attack": {
        "priority": 3,
        "speed_multiplier": 1,
        "track_target": false
      },
      "minecraft:behavior.random_stroll": {
        "priority": 9,
        "speed_multiplier": 1
      },
      "minecraft:behavior.look_at_player": {
        "priority": 10,
        "look_distance": 8,
        "probability": 0.02
      },
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "on_damage": {
              "filters": [
                {
                  "test": "is_family",
                  "subject": "other",
                  "value": "villager"
                }
              ]
            },
            "deals_damage": false
          }
        ]
      },
      "minecraft:behavior.hurt_by_target": {
        "priority": 1,
        "entity_types": {
          "filters": {
            "test": "is_family",
            "subject": "other",
            "operator": "!\u003d",
            "value": "villager"
          },
          "max_dist": 64
        }
      },
      "minecraft:on_target_acquired": {
        "event": "minecraft:become_aggro",
        "target": "self"
      },
      "minecraft:on_target_escape": {
        "event": "minecraft:stop_aggro",
        "target": "self"
      },
      "minecraft:physics": {},
      "minecraft:experience_reward": {
        "on_death": "query.last_hit_by_player ? 10 : 0"
      },
      "minecraft:underwater_movement": {
        "value": 0.02
      },
      "minecraft:scale": {
        "value": 1
      },
      "minecraft:economy_trade_table": {
        "display_name": "entity.legacy:smith_merchant_villager.name",
        "table": "trading/economy_trades/smith_merchant_trades.json",
        "new_screen": true,
        "persist_trades": true,
        "cured_discount": [
          -100,
          -100
        ],
        "max_cured_discount": [
          -500,
          -500
        ]
      },
      "minecraft:behavior.trade_interest": {
        "priority": 2,
        "within_radius": 6,
        "interest_time": 45,
        "remove_item_time": 1,
        "carried_item_switch_time": 2,
        "cooldown": 2
      },
      "minecraft:behavior.look_at_trading_player": {
        "priority": 4
      },
      "minecraft:equip_item": {},
      "minecraft:pushable": {
        "is_pushable": true,
        "is_pushable_by_piston": true
      }
    },
    "events": {
      "minecraft:entity_spawned": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "smith_merchant_schedule",
            "attack_mode"
          ]
        }
      },
      "minecraft:melee_mode": {
        "add": {
          "component_groups": [
            "melee_unit"
          ]
        }
      },
      "minecraft:become_aggro": {
        "add": {
          "component_groups": [
            "minecraft:smith_aggro"
          ]
        }
      },
      "minecraft:stop_aggro": {
        "remove": {
          "component_groups": [
            "minecraft:smith_aggro"
          ]
        },
        "run_command": {
          "command": [
            "replaceitem entity @s slot.weapon.mainhand 0 air"
          ]
        }
      },
      "minecraft:start_fred": {
        "add": {
          "component_groups": [
            "minecraft:vindicator_fred"
          ]
        }
      },
      "minecraft:stop_fred": {
        "remove": {
          "component_groups": [
            "minecraft:vindicator_fred"
          ]
        },
        "add": {
          "component_groups": [
            "minecraft:default_targeting"
          ]
        }
      },
      "minecraft:schedule_explore_village": {
        "add": {
          "component_groups": [
            "explore_schedule_villager",
            "trade_resupply_component_group"
          ]
        },
        "remove": {
          "component_groups": [
            "minecraft:smith_merchant_work",
            "gather_schedule_villager",
            "minecraft:default_targeting"
          ]
        }
      },
      "minecraft:schedule_work_time": {
        "remove": {
          "component_groups": [
            "bed_schedule_villager",
            "gather_schedule_villager"
          ]
        },
        "add": {
          "component_groups": [
            "minecraft:smith_merchant_work"
          ]
        }
      },
      "minecraft:schedule_gather_villager": {
        "remove": {
          "component_groups": [
            "bed_schedule_villager",
            "minecraft:smith_merchant_work"
          ]
        },
        "add": {
          "component_groups": [
            "gather_schedule_villager"
          ]
        }
      },
      "minecraft:schedule_work": {
        "remove": {
          "component_groups": [
            "bed_schedule_villager",
            "gather_schedule_villager"
          ]
        },
        "add": {
          "component_groups": [
            "minecraft:smith_merchant_work"
          ]
        }
      },
      "minecraft:give_regeneration_villager": {
        "add": {
          "component_groups": [
            "regeneration"
          ]
        }
      },
      "minecraft:resupply_trades": {
        "randomize": [
          {
            "weight": 1,
            "add": {
              "component_groups": [
                "trade_resupply_component_group"
              ]
            },
            "run_command": {
              "command": [
                "playsound random.anvil_use @r ~~~"
              ]
            }
          },
          {
            "weight": 11,
            "run_command": {
              "command": [
                "playsound block.grindstone.use @r ~~~"
              ]
            }
          }
        ]
      }
    }
  }
}