{
    "format_version": "1.20.50",
    "minecraft:block": {
        "description": {
            "identifier": "rc:transmitter",
            "menu_category": {
              "group": "itemGroup.name.create",
              "category": "Items"
            },
            "states": {
               "rc:color": [
                 "pink_dye",
                 "white_dye",
                 "black_dye",
                 "orange_dye",
                 "red_dye",
                 "magenta_dye",
                 "blue_dye",
                 "gray_dye",
                 "yellow_dye",
                 "brown_dye",
                 "green_dye",
                 "purple_dye",
                 "lime_dye",
                 "light_blue_dye",
                 "light_gray_dye",
                 "cyan_dye"
               ],
               "rc:active_c": [0, 1],
               "rc:lado": [0, 1, 2, 3, 4, 5],
               "rc:state": ["transmitter", "receiver"]
            }
        },
        "components": {
          "minecraft:transformation": {
            "rotation": [0, 0, 0]
          },
           "minecraft:material_instances": {
          "*": {
             "texture": "redstone_link_withe",
					"render_method": "alpha_test",
            "ambient_occlusion": true
				}
		 	},
            "minecraft:selection_box": {
                "origin": [ -6, 0, -6 ],
                "size": [ 12, 8, 12 ]
            },
            "minecraft:collision_box": {
                  "origin": [ -6, 0, -6 ],
                  "size": [ 12, 3, 12 ]
              },
            
              "minecraft:geometry": { 
                "identifier": "geometry.receiver_default",
                "bone_visibility": {
                  "color": "q.block_state('rc:active_c') == 1"
                }
               },
            "minecraft:on_player_placing": {
              "event": "summon",
              "target": "self"
            },
             "minecraft:queued_ticking": {
               "interval_range": [
                 1,
                 1
               ],
               "looping": true,
               "on_tick": {
                 "event": "active",
                 "condition": "q.block_state('rc:active_c') == 1"
               }
             },
             "minecraft:on_interact": {
               "event": "add_color"
             }
        },
        "events": {
          "active": {
             "sequence": [
               {
                 "condition": "(q.block_state('rc:state') == 'transmitter')",
               "sequence": [
                  {
                    "condition": "(q.block_state('rc:color') == 'white_dye')",
                   "run_command": {
                     "command": [
                       "scriptevent rc:redstone_link white"
                     ]
                   }
                  },
                  {
                   "condition": "(q.block_state('rc:color') == 'black_dye')",
                  "run_command": {
                     "command": [
                       "scriptevent rc:redstone_link black"
                     ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'red_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link red"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'blue_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link blue"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'green_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link green"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'lime_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link lime"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'orange_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link orange"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'pink_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link pink"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'magenta_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link magenta"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'purple_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link purple"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'brown_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link brown"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'yellow_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link yellow"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'cyan_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link cyan"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'gray_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link gray"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'light_gray_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link light_gray"
                   ]
                  }
                 },
                 {
                   "condition": "(q.block_state('rc:color') == 'light_blue_dye')",
                  "run_command": {
                   "command": [
                     "scriptevent rc:redstone_link light_blue"
                   ]
                  }
                 }
               ]
            },


            {
             "condition": "(q.block_state('rc:state') == 'receiver')",
             "sequence": [
                { 
                  "condition": "(q.block_state('rc:color') == 'white_dye')",
                 "run_command": {
                    "command": ["execute as @e[type=rc:redstone_link, name=white, r=60] run function redstone_link"]
                 }
                },
                {
                 "condition": "(q.block_state('rc:color') == 'black_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=black, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'red_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=red, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'blue_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=blue, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'green_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=green, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'lime_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=lime, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'orange_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=orange, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'pink_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=pink, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'magenta_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=magenta, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'purple_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=purple, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'brown_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=brown, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'yellow_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=yellow, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'cyan_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=cyan, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'gray_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=gray, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'light_gray_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=light_gray, r=60] run function redstone_link"]
                }
               },
               {
                 "condition": "(q.block_state('rc:color') == 'light_blue_dye')",
                "run_command": {
                   "command": ["execute as @e[type=rc:redstone_link, name=light_blue, r=60] run function redstone_link"]
                }
               }
             ]
          }
           ]
         },
          "add_color": {
            "sequence": [
              {
                "condition": "!q.is_sneaking && q.is_item_name_any('slot.weapon.mainhand', 'minecraft:white_dye','minecraft:black_dye', 'minecraft:red_dye','minecraft:blue_dye','minecraft:green_dye', 'minecraft:lime_dye','minecraft:orange_dye', 'minecraft:pink_dye','minecraft:purple_dye', 'minecraft:brown_dye','minecraft:yellow_dye', 'minecraft:cyan_dye','minecraft:gray_dye', 'minecraft:light_gray_dye','minecraft:light_blue_dye','minecraft:magenta_dye')",
                 "set_block_state": {
                  "rc:color": "query.get_equipped_item_name('main_hand')",
                  "rc:active_c": 1
                 }
              },
              {
                "condition": "q.is_sneaking && q.block_state('rc:state') == 'transmitter'",
                "set_block_state": {
                  "rc:state": "'receiver'"
                 }
              },
              {
                "condition": "q.is_sneaking && q.block_state('rc:state') == 'receiver'",
                "set_block_state": {
                  "rc:state": "'transmitter'"
                 }
              }
            ]
          },
          "summon": {
            "set_block_state": {
              "rc:lado": "(query.block_face)"
                 }
             }
       },















       "permutations": [{
        "condition": "query.block_state('rc:lado') == 3",
        "components": {    
          "minecraft:transformation": {
            "rotation": [0, 0, 0]
          }
        }
    },
    {
        "condition": "query.block_state('rc:lado') == 2",
        "components": {  
          "minecraft:transformation": {
            "rotation": [0, 180, 0]
          }
        }
    },
    {
        "condition": "query.block_state('rc:lado') == 5",
        "components": {    
          "minecraft:transformation": {
            "rotation": [0, 90, 0]
          }
        }
    },
    {
        "condition": "query.block_state('rc:lado') == 4",
        "components": {    
          "minecraft:transformation": {
            "rotation": [0, 270, 0]
          }
        }
    },
    {
      "condition": "query.block_state('rc:lado') == 1",
      "components": { 
        "minecraft:transformation": {
          "rotation": [0, 0, 0]
        }
      }
  },
  {
      "condition": "query.block_state('rc:lado') == 0 && query.block_state('rc:active_c') == 1",
      "components": {
        "minecraft:transformation": {
          "rotation": [180, 0, 0]
        }
      }
  },







        {
          "condition": "( q.block_state('rc:lado') == 0 || q.block_state('rc:lado') == 1 ) && q.block_state('rc:state') == 'receiver'",
          "components": {
            "minecraft:geometry":{
              "identifier": "geometry.receiver_default",
              "bone_visibility": {
                "color": "q.block_state('rc:active_c') == 1"
              }
             },
              "minecraft:material_instances": {
         "*": {
            "texture": "receiver",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
          }
        },
        {
          "condition": "( q.block_state('rc:lado') == 2 || q.block_state('rc:lado') == 3 || q.block_state('rc:lado') == 4 || q.block_state('rc:lado') == 5 ) && q.block_state('rc:state') == 'receiver'",
          "components": {
            "minecraft:selection_box": {
                "origin": [ -6, 2, -8 ],
                "size": [ 12, 12, 8 ]
            },
            "minecraft:collision_box": {
                  "origin": [ -6, 2, -8 ],
                  "size": [ 12, 12, 3 ]
              },
            "minecraft:geometry":{
              "identifier": "geometry.receiver",
              "bone_visibility": {
                "color": "q.block_state('rc:active_c') == 1"
              }
             },
              "minecraft:material_instances": {
         "*": {
            "texture": "receiver",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
          }
        },
        {
          "condition": "( q.block_state('rc:lado') == 0 || q.block_state('rc:lado') == 1 ) && q.block_state('rc:state') == 'transmitter'",
          "components": {
            "minecraft:geometry":{
              "identifier": "geometry.transmitter_default",
              "bone_visibility": {
                "color": "q.block_state('rc:active_c') == 1"
              }
             },
              "minecraft:material_instances": {
         "*": {
            "texture": "transmitter",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
          }
        },
        {
          "condition": "( q.block_state('rc:lado') == 2 || q.block_state('rc:lado') == 3 || q.block_state('rc:lado') == 4 || q.block_state('rc:lado') == 5 ) && q.block_state('rc:state') == 'transmitter'",
          "components": {
            "minecraft:selection_box": {
                "origin": [ -6, 2, -8 ],
                "size": [ 12, 12, 8 ]
            },
            "minecraft:collision_box": {
                  "origin": [ -6, 2, -8 ],
                  "size": [ 12, 12, 3 ]
              },
            "minecraft:geometry":{
              "identifier": "geometry.transmitter",
              "bone_visibility": {
                "color": "q.block_state('rc:active_c') == 1"
              }
             },
              "minecraft:material_instances": {
         "*": {
            "texture": "transmitter",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
          }
        },








         {
           "condition": "(q.block_state('rc:color') == 'white_dye')",
           "components": {
               "minecraft:material_instances": {
          "*": {
             "texture": "redstone_link_withe",
					"render_method": "alpha_test",
           "ambient_occlusion": true
			         	}
		 	        }
           }
         },
          {
           "condition": "(q.block_state('rc:color') == 'black_dye')",
           "components": {
               "minecraft:material_instances": {
          "*": {
             "texture": "redstone_link_black",
					"render_method": "alpha_test",
           "ambient_occlusion": true
			         	}
		 	        }
             
           }
         },
         {
          "condition": "(q.block_state('rc:color') == 'orange_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_orange",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'red_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_red",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'blue_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_blue",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'pink_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_pink",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'magenta_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_magenta",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'cyan_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_cyan",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'gray_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_gray",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'green_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_green",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'lime_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_lime",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'purple_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_purple",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'brown_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_brown",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'yellow_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_yellow",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'light_blue_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_light_blue",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        },
        {
          "condition": "(q.block_state('rc:color') == 'light_gray_dye')",
          "components": {
              "minecraft:material_instances": {
         "*": {
            "texture": "redstone_link_light_gray",
         "render_method": "alpha_test",
          "ambient_occlusion": true
                }
              }
            
          }
        }
       ]
    }
}