{
  "format_version": "1.20.50",
  "minecraft:block": {
    "description": {
      "identifier": "rc:mechanical_bearing",
      "menu_category": {
        "group": "itemGroup.name.create",
        "category": "Items"
      },
      "states": {
        "rc:lado": [ 0, 1, 2, 3, 4, 5 ],
        "rc:direcao": [ "null", "x", "y", "z" ],
        "rc:speed": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ],
        "rc:sentido": [ "estatico", "horario", "antihorario" ],
        "rc:on": [0, 1],
        "rc:working": [0,1],
        "rc:stage": [0,1],
        "rc:placed": [0,1]
      }
    },
    "components": {
      "minecraft:transformation": {
        "rotation": [0, 0, 0]
      },
      "minecraft:selection_box": {
        "origin": [ -8, 0, -8],
        "size": [ 16, 16, 16 ]
    },
    "minecraft:collision_box": {
      "origin": [ -8, 0, -8],
      "size": [ 16, 16, 16 ]
    },"minecraft:on_player_placing": {
        "event": "placed",
        "target": "self"
      },
      "minecraft:material_instances": {
        "*": {
          "texture": "shaft",
          "render_method": "alpha_test"
        }
      },
      "minecraft:geometry": { 
         "identifier": "geometry.shaft"
       },
       "minecraft:queued_ticking": {
         "interval_range": [
           1,
           1
         ],
         "looping": true,
         "on_tick": {
           "event": "ticking"
         }
       },
      "minecraft:destructible_by_mining": {
        "seconds_to_destroy": 0.3
      },
      "minecraft:on_interact": {
        "event": "spin"
      }
    },
    "events": {
      "spin": {
        "sequence": [
          {
            "condition": "q.block_state('rc:on') == 0",
            "set_block_state": {
              "rc:on": 1
             }
          },
          {
            "condition": "q.block_state('rc:on') == 1",
            "set_block_state": {
              "rc:on": 0
             }
          }
        ]
      },
      "ticking":{
        "sequence":[
          {
        "run_command":{
          "command":[
            "scriptevent rc:mechanical_bearing"
          ]
        }
      }
      ,
      {
        "condition": "query.block_state('rc:lado') == 0 || query.block_state('rc:lado') == 1",
        "set_block_state": {
          "rc:direcao": "'y'"
                }
      },
      {
        "condition": "query.block_state('rc:lado') == 4 || query.block_state('rc:lado') == 5",
        "set_block_state": {
          "rc:direcao": "'x'"
                }
      },
      {
        "condition": "query.block_state('rc:lado') == 2 || query.block_state('rc:lado') == 3",
        "set_block_state": {
          "rc:direcao": "'z'"
                }
      }
    ]
      },
  "placed": {
    "sequence":[
      {
    "set_block_state": {
      "rc:lado": "query.cardinal_player_facing"
            }
          }
        ]
      }
    },
    "permutations": [
      {
          "condition": "query.block_state('rc:placed') == 0",
          "components": {
            "minecraft:geometry": { 
               "identifier": "geometry.mechanical_bearing_block"
             },
             "minecraft:material_instances": {
               "*": {
                 "texture": "mechanical_bearing_block",
                 "render_method": "alpha_test"
               }
            }
          }
      },
      {
          "condition": "query.block_state('rc:lado') == 0 || query.block_state('rc:lado') == 1",
          "components": {
            "minecraft:transformation": {
              "rotation": [0, 0, 0]
            }
          }
      },
      {
        "condition": "query.block_state('rc:lado') == 2 || query.block_state('rc:lado') == 3",
        "components": {    
          "minecraft:transformation": {
            "rotation": [90, 0, 0]
          }
        }
    },
    {
        "condition": "query.block_state('rc:lado') == 4 || query.block_state('rc:lado') == 5",
        "components": {    
          "minecraft:transformation": {
            "rotation": [90, 90, 0]
          }
        }
    },
    {
        "condition": "(query.block_state('rc:sentido') == 'estatico' || query.block_state('rc:speed') == 0)  && query.block_state('rc:placed') == 1",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 1",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_1",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 2",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_2",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 3",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_3",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 4",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_4",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 5",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_5",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 6",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_6",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 7",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_7",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 8",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_8",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 9",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_9",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'antihorario' && query.block_state('rc:speed') == 10",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_a_10",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 1",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_1",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 2",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_2",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 3",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_3",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 4",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_4",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 5",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_5",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 6",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_6",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 7",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_7",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 8",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_8",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 9",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_9",
              "render_method": "alpha_test"
            }
          }
        }
    },
    {
        "condition": "query.block_state('rc:sentido') == 'horario' && query.block_state('rc:speed') == 10",
        "components": {    
          "minecraft:material_instances": {
            "*": {
              "texture": "shaft_h_10",
              "render_method": "alpha_test"
            }
          }
        }
    }
    ]
  }
}