// Create a portal at each area effect cloud named ACV_Main if the location is a valid portal location.
// For each direction that should be taken into account there must be an area effect cloud located in the same block.
// The color is specified by ACV_Mains ACV_COLOR score.
// Params: area_effect_cloud named ACV_Main, area_effect_cloud tagged with ACV_Direction
process ACV_createPortals {
ACV_deleteRedundantMarkers()

ACV_validateDirections()

/scoreboard players tag @e[type=area_effect_cloud,name=ACV_Main] add ACV_handleFailedPortals_PARAM
/execute @e[type=area_effect_cloud,tag=ACV_Direction] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_Main,dy=0] remove ACV_handleFailedPortals_PARAM
ACV_handleFailedPortals()
/kill @e[type=area_effect_cloud,name=ACV_Main,tag=ACV_handleFailedPortals_PARAM]

/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ summon area_effect_cloud ~ ~ ~ {CustomName:"ACV_deletePortals_PARAM",Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_deletePortals_PARAM,r=0,c=1] ACV_COLOR = @e[type=area_effect_cloud,name=ACV_Main,r=0,c=1] ACV_COLOR
ACV_deletePortals()

/execute @e[type=area_effect_cloud,name=ACV_Up] ~ ~ ~ summon item_frame ~ ~-1 ~ {CustomName:"ACV_PortalMain",Tags:[ACV_Up],Facing:0b,Invulnerable:1b}
/execute @e[type=area_effect_cloud,name=ACV_Down] ~ ~ ~ summon item_frame ~ ~1 ~ {CustomName:"ACV_PortalMain",Tags:[ACV_Down],Facing:0b,Invulnerable:1b}
/execute @e[type=area_effect_cloud,name=ACV_South] ~ ~ ~ summon item_frame ~ ~-1 ~ {CustomName:"ACV_PortalMain",Tags:[ACV_South],Facing:0b,Invulnerable:1b}
/execute @e[type=area_effect_cloud,name=ACV_East] ~ ~ ~ summon item_frame ~ ~-1 ~ {CustomName:"ACV_PortalMain",Tags:[ACV_East],Facing:3b,Invulnerable:1b}
/execute @e[type=area_effect_cloud,name=ACV_North] ~ ~ ~ summon item_frame ~ ~-1 ~ {CustomName:"ACV_PortalMain",Tags:[ACV_North],Facing:2b,Invulnerable:1b}
/execute @e[type=area_effect_cloud,name=ACV_West] ~ ~ ~ summon item_frame ~ ~-1 ~ {CustomName:"ACV_PortalMain",Tags:[ACV_West],Facing:1b,Invulnerable:1b}
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ scoreboard players operation @e[type=item_frame,name=ACV_PortalMain,dy=-1] ACV_COLOR = @e[type=area_effect_cloud,name=ACV_Main,r=0,c=1] ACV_COLOR
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ scoreboard players operation @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down,dy=1] ACV_COLOR = @e[type=area_effect_cloud,name=ACV_Main,r=0,c=1] ACV_COLOR
ACV_spawnPortals()
ACV_texturePortals()
/kill @e[type=item_frame,name=ACV_PortalMain]

ACV_openConnections()

/testfor @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=0,score_ACV_COLOR=1]
conditional: /scoreboard players tag @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=0,score_ACV_COLOR=1] add ACV_createLightBridges_PARAM
/testfor @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=2,score_ACV_COLOR=3]
conditional: /scoreboard players tag @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=2,score_ACV_COLOR=3] add ACV_createLightBridges_PARAM
start ACV_createLightBridges

ACV_handleSuccessfulPortals()
/kill @e[type=area_effect_cloud,name=ACV_Main]
/kill @e[type=area_effect_cloud,tag=ACV_Direction]
}

// Delete all duplicate ACV_Main and the corresponding directions to prevent simultanious creation of multiple portals with the same color.
process ACV_deleteRedundantMarkers {
/scoreboard players tag @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=0,score_ACV_COLOR=0,c=1] add ACV_notRedundant
/scoreboard players tag @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=1,score_ACV_COLOR=1,c=1] add ACV_notRedundant
/scoreboard players tag @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=2,score_ACV_COLOR=2,c=1] add ACV_notRedundant
/scoreboard players tag @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=3,score_ACV_COLOR=3,c=1] add ACV_notRedundant
/kill @e[type=area_effect_cloud,name=ACV_Main,tag=!ACV_notRedundant]

/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,tag=ACV_Direction,dy=0] add ACV_notRedundant
/kill @e[type=area_effect_cloud,name=ACV_Up,tag=!ACV_notRedundant]
/kill @e[type=area_effect_cloud,name=ACV_Down,tag=!ACV_notRedundant]
/kill @e[type=area_effect_cloud,name=ACV_South,tag=!ACV_notRedundant]
/kill @e[type=area_effect_cloud,name=ACV_East,tag=!ACV_notRedundant]
/kill @e[type=area_effect_cloud,name=ACV_North,tag=!ACV_notRedundant]
/kill @e[type=area_effect_cloud,name=ACV_West,tag=!ACV_notRedundant]

/scoreboard players tag @e[type=area_effect_cloud,tag=ACV_notRedundant] remove ACV_notRedundant
}

// Spawn the area effect clouds and itemframes of a portal for each directional area effect cloud
// Params: AEC-ACV_PortalMain
// Return: AEC-ACV_PortalIn, AEC-ACV_PortalOut
process ACV_spawnPortals {
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~ ~0.46875 summon area_effect_cloud ~ ~-0.43 ~ {CustomName:"ACV_PortalOut",Tags:[ACV_Portal,ACV_TpProof,ACV_Up],Rotation:[0f,-90f],Duration:2147483647}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~ ~0.46875 summon area_effect_cloud ~ ~ ~ {CustomName:"ACV_PortalIn",Tags:[ACV_Portal,ACV_TpProof,ACV_Up],Duration:2147483647}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~ ~0.46875 summon area_effect_cloud ~ ~-0.43 ~ {CustomName:"ACV_PortalOut",Tags:[ACV_Portal,ACV_TpProof,ACV_Down],Rotation:[0f,90f],Duration:2147483647}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~ ~0.46875 summon area_effect_cloud ~ ~ ~ {CustomName:"ACV_PortalIn",Tags:[ACV_Portal,ACV_TpProof,ACV_Down],Duration:2147483647}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_South] ~ ~ ~0.46875 summon area_effect_cloud ~ ~-0.43 ~ {CustomName:"ACV_PortalOut",Tags:[ACV_Portal,ACV_TpProof,ACV_South],Rotation:[0f,0f],Duration:2147483647}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_South] ~ ~ ~0.46875 summon area_effect_cloud ~ ~ ~-1 {CustomName:"ACV_PortalIn",Tags:[ACV_Portal,ACV_TpProof,ACV_South],Duration:2147483647}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_East] ~0.46875 ~ ~ summon area_effect_cloud ~ ~-0.43 ~ {CustomName:"ACV_PortalOut",Tags:[ACV_Portal,ACV_TpProof,ACV_East],Rotation:[-90f,0f],Duration:2147483647}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_East] ~0.46875 ~ ~ summon area_effect_cloud ~-1 ~ ~ {CustomName:"ACV_PortalIn",Tags:[ACV_Portal,ACV_TpProof,ACV_East],Duration:2147483647}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_North] ~ ~ ~-0.46875 summon area_effect_cloud ~ ~-0.43 ~ {CustomName:"ACV_PortalOut",Tags:[ACV_Portal,ACV_TpProof,ACV_North],Rotation:[180f,0f],Duration:2147483647}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_North] ~ ~ ~-0.46875 summon area_effect_cloud ~ ~ ~1 {CustomName:"ACV_PortalIn",Tags:[ACV_Portal,ACV_TpProof,ACV_North],Duration:2147483647}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_West] ~-0.46875 ~ ~ summon area_effect_cloud ~ ~-0.43 ~ {CustomName:"ACV_PortalOut",Tags:[ACV_Portal,ACV_TpProof,ACV_West],Rotation:[90f,0f],Duration:2147483647}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_West] ~-0.46875 ~ ~ summon area_effect_cloud ~1 ~ ~ {CustomName:"ACV_PortalIn",Tags:[ACV_Portal,ACV_TpProof,ACV_West],Duration:2147483647}

// Set the direction scores
/scoreboard players set @e[tag=ACV_Up] ACV_DIRECTION -1
/scoreboard players set @e[tag=ACV_Down] ACV_DIRECTION -2
/scoreboard players set @e[tag=ACV_South] ACV_DIRECTION 0
/scoreboard players set @e[tag=ACV_East] ACV_DIRECTION 3
/scoreboard players set @e[tag=ACV_North] ACV_DIRECTION 2
/scoreboard players set @e[tag=ACV_West] ACV_DIRECTION 1

// Set the color scores
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_PortalOut,dy=0] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,r=0,c=1] ACV_COLOR
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_PortalIn,dy=0] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,r=0,c=1] ACV_COLOR
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_South] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_PortalIn,tag=ACV_South,dz=-1] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,tag=ACV_South,r=0,c=1] ACV_COLOR
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_East] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_PortalIn,tag=ACV_East,dx=-1] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,tag=ACV_East,r=0,c=1] ACV_COLOR
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_North] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_PortalIn,tag=ACV_North,dz=1] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,tag=ACV_North,r=0,c=1] ACV_COLOR
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_West] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_PortalIn,tag=ACV_West,dx=1] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,tag=ACV_West,r=0,c=1] ACV_COLOR

// Teleport the new ACV_PortalOut to it's final position
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~-0.43 ~0.46875 tp @e[type=area_effect_cloud,name=ACV_PortalOut,tag=ACV_Up,dy=0] ~ ~2 ~
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~-0.43 ~0.46875 tp @e[type=area_effect_cloud,name=ACV_PortalOut,tag=ACV_Down,dy=0] ~ ~-2 ~
}

install {
  /scoreboard teams add ACV_BluePortal
  /scoreboard teams add ACV_OrangePortal
  /scoreboard teams add ACV_PurplePortal
  /scoreboard teams add ACV_RedPortal
  /scoreboard teams option ACV_BluePortal color aqua
  /scoreboard teams option ACV_OrangePortal color gold
  /scoreboard teams option ACV_PurplePortal color dark_blue
  /scoreboard teams option ACV_RedPortal color dark_red
}

uninstall {
  /scoreboard teams remove ACV_BluePortal
  /scoreboard teams remove ACV_OrangePortal
  /scoreboard teams remove ACV_PurplePortal
  /scoreboard teams remove ACV_RedPortal
}

// Spawn the texture armorstands and itemframes of the portals and join them to their color team
// Params: AEC-ACV_PortalMain
// Return: AS-ACV_PortalDisplay, IF-ACV_PortalDisplay
process ACV_texturePortals {
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~ ~ summon armor_stand ~-0.21 ~-1.51 ~0.7 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Up],Rotation:[-90f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~ ~ summon armor_stand ~-0.21 ~-1.51 ~0.25 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Up],Rotation:[0f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~ ~ summon armor_stand ~0.23 ~-1.51 ~0.25 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Up],Rotation:[90f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~ ~ summon armor_stand ~0.23 ~-1.51 ~0.7 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Up],Rotation:[180f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~ ~ summon armor_stand ~-0.21 ~-1.95 ~0.7 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Down],Rotation:[-90f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~ ~ summon armor_stand ~-0.21 ~-1.95 ~0.25 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Down],Rotation:[0f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~ ~ summon armor_stand ~0.23 ~-1.95 ~0.25 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Down],Rotation:[90f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~ ~ summon armor_stand ~0.23 ~-1.95 ~0.7 {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_Down],Rotation:[180f,0f],DisabledSlots:2035728,NoGravity:1b,Invisible:1b,Invulnerable:1b}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_South] ~ ~ ~ summon item_frame ~ ~ ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_South],Facing:0b,Invulnerable:1b,Glowing:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_South] ~ ~ ~ summon item_frame ~ ~1 ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_South],Facing:0b,Invulnerable:1b,Glowing:1b}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_East] ~ ~ ~ summon item_frame ~ ~ ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_East],Facing:3b,Invulnerable:1b,Glowing:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_East] ~ ~ ~ summon item_frame ~ ~1 ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_East],Facing:3b,Invulnerable:1b,Glowing:1b}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_North] ~ ~ ~ summon item_frame ~ ~ ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_North],Facing:2b,Invulnerable:1b,Glowing:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_North] ~ ~ ~ summon item_frame ~ ~1 ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_North],Facing:2b,Invulnerable:1b,Glowing:1b}

/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_West] ~ ~ ~ summon item_frame ~ ~ ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_West],Facing:1b,Invulnerable:1b,Glowing:1b}
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_West] ~ ~ ~ summon item_frame ~ ~1 ~ {CustomName:"ACV_PortalDisplay",Tags:[ACV_Portal,ACV_TpProof,ACV_West],Facing:1b,Invulnerable:1b,Glowing:1b}

// Set the color scores
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ scoreboard players operation @e[type=item_frame,name=ACV_PortalDisplay,dy=1] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,r=0,c=1] ACV_COLOR
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up] ~ ~ ~ scoreboard players operation @e[type=armor_stand,name=ACV_PortalDisplay,tag=ACV_Up,dy=-2] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Up,r=0,c=1] ACV_COLOR
/execute @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down] ~ ~ ~ scoreboard players operation @e[type=armor_stand,name=ACV_PortalDisplay,tag=ACV_Down,dy=-2] ACV_COLOR = @e[type=item_frame,name=ACV_PortalMain,tag=ACV_Down,r=0,c=1] ACV_COLOR

// texture blue portal
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~-2 ~ entitydata @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=0,score_ACV_COLOR=0,dy=0] {ArmorItems:[{},{},{},{id:"minecraft:skull",Count:1,Damage:3,tag:{SkullOwner:{Id:"cc01bc38-881f-420e-86d9-2308d28b5840",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmRhNmZiN2RlNzFhZjMyNTZhNjEzNWRjNjQ0NDRiNTY1ZGQ5YjkxMjM5NGUyNTU0MzViOWI3ZmQxYzU4MGFiIn19fQ=="}]}}}}]}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=0,score_ACV_COLOR=0,dy=0] {Item:{Damage:0,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~1 ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=0,score_ACV_COLOR=0,dy=0] {Item:{Damage:1,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ scoreboard teams join ACV_BluePortal @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=0,score_ACV_COLOR=0,dy=1]

// texture orange portal
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~-2 ~ entitydata @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=1,score_ACV_COLOR=1,dy=0] {ArmorItems:[{},{},{},{id:"minecraft:skull",Count:1,Damage:3,tag:{SkullOwner:{Id:"ff0f945d-8ef9-46f8-914d-53e0b5182a9e",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWFlOTlhMjllYTc0YzUzOTdjOTQ3YWE5ZWQyMWE2NGYxMzUxMzIzNGZjYzFkYThmZDkwYjc5NWZkOTA4NSJ9fX0="}]}}}}]}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=1,score_ACV_COLOR=1,dy=0] {Item:{Damage:2,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~1 ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=1,score_ACV_COLOR=1,dy=0] {Item:{Damage:3,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ scoreboard teams join ACV_OrangePortal @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=1,score_ACV_COLOR=1,dy=1]

// texture purple portal
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~-2 ~ entitydata @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=2,score_ACV_COLOR=2,dy=0] {ArmorItems:[{},{},{},{id:"minecraft:skull",Count:1,Damage:3,tag:{SkullOwner:{Id:"f6937a89-7e05-4eb0-9928-ec8664e3d21a",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTlmODI4ODgyYjIyOTZmNzU1ZjY2YjY5NWM5YjQ4NGZkMjQzYzFiZmNmMjMxMzdmMTlhYzVhNTIxN2FmZGYifX19"}]}}}}]}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=2,score_ACV_COLOR=2,dy=0] {Item:{Damage:4,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~1 ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=2,score_ACV_COLOR=2,dy=0] {Item:{Damage:5,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ scoreboard teams join ACV_PurplePortal @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=2,score_ACV_COLOR=2,dy=1]

// texture red portal
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~-2 ~ entitydata @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=3,score_ACV_COLOR=3,dy=0] {ArmorItems:[{},{},{},{id:"minecraft:skull",Count:1,Damage:3,tag:{SkullOwner:{Id:"409b8064-7097-4059-b208-99f53f7d6bc3",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTIxYzg5YWM0ODI4YjcyNzllMmJlZWZkZWI1NzVjZmQ3YzEyNTU1M2VhMmMzZjZiNTNhNjUxODRlNTY4NTYifX19"}]}}}}]}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=3,score_ACV_COLOR=3,dy=0] {Item:{Damage:6,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~1 ~ entitydata @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=3,score_ACV_COLOR=3,dy=0] {Item:{Damage:7,id:"minecraft:filled_map",Count:1}}
/execute @e[type=item_frame,name=ACV_PortalMain] ~ ~ ~ scoreboard teams join ACV_RedPortal @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=3,score_ACV_COLOR=3,dy=1]
}

// Save the blocks that will be replaced by the portal connection
// Params: AEC-ACV_Main, AEC-ACV_PortalIn
process ACV_saveSurfaceBlocks {
ACV_loadChunks()
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ clone ~ ~ ~ ~ ~1 ~ 0 1 0
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ clone ~ ~ ~ ~ ~1 ~ 1 1 0
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ clone ~ ~ ~ ~ ~1 ~ 2 1 0
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ clone ~ ~ ~ ~ ~1 ~ 3 1 0
}

// Open the connection between the two portals if both exist (regardless weather they are currently beeing created)
// Params: AEC-ACV_Main, AEC-ACV_PortalIn, AS-ACV_PortalDisplay
process ACV_openConnections {
ACV_saveSurfaceBlocks()

// blue and orange
/execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=0,score_ACV_COLOR=1] ~ ~ ~ fill ~ ~ ~ ~ ~1 ~ piston_extension
// If only one of the portals exists set the surface of horizontal portals to barrier
invert: /execute @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=0,score_ACV_COLOR=1] ~ ~ ~ setblock ~ ~2 ~ barrier

// purple and red
/execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=2,score_ACV_COLOR=3] ~ ~ ~ fill ~ ~ ~ ~ ~1 ~ piston_extension
// If only one of the portals exists set the surface of horizontal portals to barrier
invert: /execute @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=2,score_ACV_COLOR=3] ~ ~ ~ setblock ~ ~2 ~ barrier
}


flavor 1
srclang 3
id 65535
numfuncs 2
import "HelloWorld.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &LHelloWorld_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "HelloWorld.jar"}
srcfileinfo {
  1 "HelloWorld.java"}
javaclass $LHelloWorld_3B <$LHelloWorld_3B> public
func &LHelloWorld_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LHelloWorld_3B>>) void
func &LHelloWorld_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg2_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void
var $_C_STR_d9bd4a0c2c2117158ed933ab7468a461 fstatic <[4] u64> readonly = [0, 0x1900000000, 0x6c6c6548c63cb61d, 0x21646c726f57206f]
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
func &LHelloWorld_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LHelloWorld_3B>>) void {
  funcid 48153
  var %Reg1_R43694 <* <$LHelloWorld_3B>>
  var %Reg1_R57 <* <$Ljava_2Flang_2FObject_3B>>

  dassign %Reg1_R43694 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg1_R43694))
  callassigned &Ljava_2Flang_2FObject_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R57) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &LHelloWorld_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg2_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48154
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg1_R43 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161334 <* <$Ljava_2Flang_2FString_3B>>

  intrinsiccallwithtype <$LHelloWorld_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 3||0003:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_d9bd4a0c2c2117158ed933ab7468a461) { dassign %L_STR_161334 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161334)
  #INSTIDX : 5||0005:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 8||0008:  return
  return ()
}


flavor 1
srclang 3
id 65535
numfuncs 2
import "triangle.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "triangle.jar"}
srcfileinfo {
  1 "triangle.java"}
javaclass $Ltriangle_3B <$Ltriangle_3B> public
func &Ltriangle_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$Ltriangle_3B>>) void
func &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg10_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void
var $_C_STR_2000 fstatic <[3] u64> readonly = [0, 0x300000000, 0x2000000020]
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
func &Ltriangle_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$Ltriangle_3B>>) void {
  funcid 48153
  var %Reg1_R43694 <* <$Ltriangle_3B>>
  var %Reg1_R57 <* <$Ljava_2Flang_2FObject_3B>>

  dassign %Reg1_R43694 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg1_R43694))
  callassigned &Ljava_2Flang_2FObject_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R57) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg10_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48154
  var %Reg0_I i32
  var %Reg6_I i32
  var %Reg0_R9160 <* <[] <* <[] i32>>>>
  var %Reg7_R12 ref
  var %Reg8_I i32
  var %Reg9_I i32
  var %Reg7_R9160 <* <[] <* <[] i32>>>>
  var %Reg0_R12 ref
  var %Reg1_I i32
  var %Reg1_R12 ref
  var %Reg2_I i32
  var %Reg2_R12 ref
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg1_R43 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_15536 <* <$Ljava_2Flang_2FString_3B>>
  var %Reg1_R1112 <* <$Ljava_2Flang_2FStringBuilder_3B>>
  var %Reg3_I i32
  var %Reg2_R43 <* <$Ljava_2Flang_2FString_3B>>

  intrinsiccallwithtype <$Ltriangle_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  bipush
  dassign %Reg0_I 0 (constval i32 10)
  #INSTIDX : 2||0002:  istore_1
  dassign %Reg6_I 0 (dread i32 %Reg0_I)
  #INSTIDX : 3||0003:  iload_1
  #INSTIDX : 4||0004:  iload_1
  #INSTIDX : 5||0005:  multianewarray
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  #INSTIDX : 9||0009:  astore_2
  dassign %Reg7_R12 0 (dread ref %Reg0_R9160)
  #INSTIDX : 10||000a:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 11||000b:  istore_3
  dassign %Reg8_I 0 (dread i32 %Reg0_I)
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
@label0   #INSTIDX : 12||000c:  iload_3
  #INSTIDX : 13||000d:  iload_1
  #INSTIDX : 14||000e:  if_icmpge
  brtrue @label6 (ge i32 i32 (dread i32 %Reg8_I, dread i32 %Reg6_I))
  #INSTIDX : 17||0011:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 18||0012:  istore 4
  dassign %Reg9_I 0 (dread i32 %Reg0_I)
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
@label1   #INSTIDX : 20||0014:  iload 4
  #INSTIDX : 22||0016:  iload_3
  #INSTIDX : 23||0017:  if_icmpgt
  brtrue @label5 (gt i32 i32 (dread i32 %Reg9_I, dread i32 %Reg8_I))
  #INSTIDX : 26||001a:  iload 4
  #INSTIDX : 28||001c:  ifeq
  brtrue @label2 (eq i32 i32 (dread i32 %Reg9_I, constval i32 0))
  #INSTIDX : 31||001f:  iload_3
  #INSTIDX : 32||0020:  iload 4
  #INSTIDX : 34||0022:  if_icmpne
  brtrue @label3 (ne i32 i32 (dread i32 %Reg8_I, dread i32 %Reg9_I))
@label2   #INSTIDX : 37||0025:  aload_2
  #INSTIDX : 38||0026:  iload_3
  #INSTIDX : 39||0027:  aaload
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  dassign %Reg0_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg8_I)))
  #INSTIDX : 40||0028:  iload 4
  #INSTIDX : 42||002a:  iconst_1
  dassign %Reg1_I 0 (constval i32 1)
  #INSTIDX : 43||002b:  iastore
  iassign <* i32> 0 (
    array 1 ptr <* <[] i32>> (dread ref %Reg0_R12, dread i32 %Reg9_I),
    dread i32 %Reg1_I)
  #INSTIDX : 44||002c:  goto
  goto @label4
@label3   #INSTIDX : 47||002f:  aload_2
  #INSTIDX : 48||0030:  iload_3
  #INSTIDX : 49||0031:  aaload
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  dassign %Reg0_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg8_I)))
  #INSTIDX : 50||0032:  iload 4
  #INSTIDX : 52||0034:  aload_2
  #INSTIDX : 53||0035:  iload_3
  #INSTIDX : 54||0036:  iconst_1
  dassign %Reg1_I 0 (constval i32 1)
  #INSTIDX : 55||0037:  isub
  dassign %Reg1_I 0 (sub i32 (dread i32 %Reg8_I, dread i32 %Reg1_I))
  #INSTIDX : 56||0038:  aaload
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  dassign %Reg1_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg1_I)))
  #INSTIDX : 57||0039:  iload 4
  #INSTIDX : 59||003b:  iconst_1
  dassign %Reg2_I 0 (constval i32 1)
  #INSTIDX : 60||003c:  isub
  dassign %Reg2_I 0 (sub i32 (dread i32 %Reg9_I, dread i32 %Reg2_I))
  #INSTIDX : 61||003d:  iaload
  dassign %Reg1_I 0 (iread i32 <* i32> 0 (array 1 ptr <* <[] i32>> (dread ref %Reg1_R12, dread i32 %Reg2_I)))
  #INSTIDX : 62||003e:  aload_2
  #INSTIDX : 63||003f:  iload_3
  #INSTIDX : 64||0040:  iconst_1
  dassign %Reg2_I 0 (constval i32 1)
  #INSTIDX : 65||0041:  isub
  dassign %Reg2_I 0 (sub i32 (dread i32 %Reg8_I, dread i32 %Reg2_I))
  #INSTIDX : 66||0042:  aaload
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  dassign %Reg2_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg2_I)))
  #INSTIDX : 67||0043:  iload 4
  #INSTIDX : 69||0045:  iaload
  dassign %Reg2_I 0 (iread i32 <* i32> 0 (array 1 ptr <* <[] i32>> (dread ref %Reg2_R12, dread i32 %Reg9_I)))
  #INSTIDX : 70||0046:  iadd
  dassign %Reg1_I 0 (add i32 (dread i32 %Reg1_I, dread i32 %Reg2_I))
  #INSTIDX : 71||0047:  iastore
  iassign <* i32> 0 (
    array 1 ptr <* <[] i32>> (dread ref %Reg0_R12, dread i32 %Reg9_I),
    dread i32 %Reg1_I)
@label4   #INSTIDX : 72||0048:  iinc
  dassign %Reg9_I 0 (add i32 (dread i32 %Reg9_I, constval i32 1))
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
  #INSTIDX : 75||004b:  goto
  goto @label1
@label5   #INSTIDX : 78||004e:  iinc
  dassign %Reg8_I 0 (add i32 (dread i32 %Reg8_I, constval i32 1))
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
  #INSTIDX : 81||0051:  goto
  goto @label0
@label6   #INSTIDX : 84||0054:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 85||0055:  istore_3
  dassign %Reg8_I 0 (dread i32 %Reg0_I)
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
@label7   #INSTIDX : 86||0056:  iload_3
  #INSTIDX : 87||0057:  iload_1
  #INSTIDX : 88||0058:  if_icmpge
  brtrue @label12 (ge i32 i32 (dread i32 %Reg8_I, dread i32 %Reg6_I))
  #INSTIDX : 91||005b:  iload_3
  #INSTIDX : 92||005c:  istore 4
  dassign %Reg9_I 0 (dread i32 %Reg8_I)
@label8   #INSTIDX : 94||005e:  iload 4
  #INSTIDX : 96||0060:  iload_1
  #INSTIDX : 97||0061:  if_icmpge
  brtrue @label9 (ge i32 i32 (dread i32 %Reg9_I, dread i32 %Reg6_I))
  #INSTIDX : 100||0064:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 103||0067:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_2000) { dassign %L_STR_15536 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_15536)
  #INSTIDX : 105||0069:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprint_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 108||006c:  iinc
  dassign %Reg9_I 0 (add i32 (dread i32 %Reg9_I, constval i32 1))
  #INSTIDX : 111||006f:  goto
  goto @label8
@label9   #INSTIDX : 114||0072:  iload_1
  #INSTIDX : 115||0073:  iload_3
  #INSTIDX : 116||0074:  isub
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  dassign %Reg0_I 0 (sub i32 (dread i32 %Reg6_I, dread i32 %Reg8_I))
  #INSTIDX : 117||0075:  istore 4
  dassign %Reg9_I 0 (dread i32 %Reg0_I)
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
@label10   #INSTIDX : 119||0077:  iload 4
  #INSTIDX : 121||0079:  iload_1
  #INSTIDX : 122||007a:  if_icmpgt
  brtrue @label11 (gt i32 i32 (dread i32 %Reg9_I, dread i32 %Reg6_I))
  #INSTIDX : 125||007d:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 128||0080:  new
  intrinsiccallwithtype <$Ljava_2Flang_2FStringBuilder_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg1_R1112 0 (gcmalloc ref <$Ljava_2Flang_2FStringBuilder_3B>)
  #INSTIDX : 131||0083:  dup
  #INSTIDX : 132||0084:  invokespecial
  callassigned &Ljava_2Flang_2FStringBuilder_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R1112) {}
  #INSTIDX : 135||0087:  aload_2
  #INSTIDX : 136||0088:  iload_3
  #INSTIDX : 137||0089:  aaload
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  dassign %Reg2_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg8_I)))
  #INSTIDX : 138||008a:  iload_1
  #INSTIDX : 139||008b:  iload 4
  #INSTIDX : 141||008d:  isub
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  dassign %Reg3_I 0 (sub i32 (dread i32 %Reg6_I, dread i32 %Reg9_I))
  #INSTIDX : 142||008e:  iaload
  dassign %Reg2_I 0 (iread i32 <* i32> 0 (array 1 ptr <* <[] i32>> (dread ref %Reg2_R12, dread i32 %Reg3_I)))
  #INSTIDX : 143||008f:  invokevirtual
  virtualcallassigned &Ljava_2Flang_2FStringBuilder_3B_7Cappend_7C_28I_29Ljava_2Flang_2FStringBuilder_3B (dread ref %Reg1_R1112, dread i32 %Reg2_I) { dassign %Reg1_R1112 0 }
  #INSTIDX : 146||0092:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_2000) { dassign %L_STR_15536 0 }
  dassign %Reg2_R43 0 (dread ptr %L_STR_15536)
  #INSTIDX : 148||0094:  invokevirtual
  virtualcallassigned &Ljava_2Flang_2FStringBuilder_3B_7Cappend_7C_28Ljava_2Flang_2FString_3B_29Ljava_2Flang_2FStringBuilder_3B (dread ref %Reg1_R1112, dread ref %Reg2_R43) { dassign %Reg1_R1112 0 }
  #INSTIDX : 151||0097:  invokevirtual
  virtualcallassigned &Ljava_2Flang_2FStringBuilder_3B_7CtoString_7C_28_29Ljava_2Flang_2FString_3B (dread ref %Reg1_R1112) { dassign %Reg1_R43 0 }
  #INSTIDX : 154||009a:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprint_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 157||009d:  iinc
  dassign %Reg9_I 0 (add i32 (dread i32 %Reg9_I, constval i32 1))
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
  #INSTIDX : 160||00a0:  goto
  goto @label10
@label11   #INSTIDX : 163||00a3:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 166||00a6:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28_29V (dread ref %Reg0_R562) {}
  #INSTIDX : 169||00a9:  iinc
  dassign %Reg8_I 0 (add i32 (dread i32 %Reg8_I, constval i32 1))
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
  #INSTIDX : 172||00ac:  goto
  goto @label7
@label12   #INSTIDX : 175||00af:  return
  return ()
}


program ifst;	{sample25}
var ch : char;
begin
    readln(ch);
    if ch = 'a' then writeln('It is ''a'' ');
    else writeln('It is not ''a'' ')
end.


use DocumentTools in
	if parse(GetProperty("Refine", value)) then
		SetProperty("Refine", value, false):
		SetProperty("UsingUpTo", enabled, false):
		SetProperty("MaxPermutations", enabled, false):
		SetProperty("Permutations", enabled, false):
	fi:
end use;


# MarSystemComposite
# Type = Series
# Name = playbacknet

# MarControls = 19
# mrs_bool/active = 1
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_bool/hasData = 0
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_bool/hasData
# mrs_bool/probe = 0
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/loopPos = 0
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_natural/loopPos
# mrs_natural/nChannels = 1
# Links = 2
# /Series/playbacknet/SoundFileSource/src/mrs_natural/nChannels
# /Series/playbacknet/AudioSink/dest/mrs_natural/nChannels
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_natural/pos = 661500
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_natural/pos
# mrs_real/israte = 22050
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_real/israte
# mrs_real/osrate = 22050
# Links = 0
# mrs_realvec/input0 = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_realvec/input1 = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_string/filename = /home/gtzan/data/sound/music_speech/music/guitar.au
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_string/filename
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0

# nComponents = 3

# MarSystem
# Type = SoundFileSource
# Name = src

# MarControls = 27
# mrs_bool/active = 1
# Links = 0
# mrs_bool/advance = 0
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_bool/hasData = 0
# Links = 1
# /Series/playbacknet/mrs_bool/hasData
# mrs_bool/noteon = 0
# Links = 0
# mrs_bool/shuffle = 0
# Links = 0
# mrs_natural/cindex = 0
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/loopPos = 0
# Links = 1
# /Series/playbacknet/mrs_natural/loopPos
# mrs_natural/nChannels = 1
# Links = 1
# /Series/playbacknet/mrs_natural/nChannels
# mrs_natural/numFiles = 1
# Links = 0
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_natural/pos = 661500
# Links = 1
# /Series/playbacknet/mrs_natural/pos
# mrs_natural/size = 661500
# Links = 0
# mrs_real/duration = -1
# Links = 0
# mrs_real/frequency = 0
# Links = 0
# mrs_real/israte = 22050
# Links = 1
# /Series/playbacknet/mrs_real/israte
# mrs_real/osrate = 22050
# Links = 0
# mrs_real/repetitions = 1
# Links = 0
# mrs_string/allfilenames = ,
# Links = 0
# mrs_string/currentlyPlaying = daufile
# Links = 0
# mrs_string/filename = /home/gtzan/data/sound/music_speech/music/guitar.au
# Links = 1
# /Series/playbacknet/mrs_string/filename
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0

# MarSystem
# Type = Gain
# Name = gt

# MarControls = 15
# mrs_bool/RMScalc = 0
# Links = 0
# mrs_bool/active = 1
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_real/gain = 1
# Links = 0
# mrs_real/israte = 22050
# Links = 0
# mrs_real/osrate = 22050
# Links = 0
# mrs_realvec/inRMS = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_realvec/outRMS = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0

# MarSystem
# Type = AudioSink
# Name = dest

# MarControls = 13
# mrs_bool/active = 1
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_natural/bufferSize = 256
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/nChannels = 1
# Links = 1
# /Series/playbacknet/mrs_natural/nChannels
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_real/israte = 22050
# Links = 0
# mrs_real/osrate = 22050
# Links = 0
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0


//impulse: /give @p spawn_egg 1 0 {display:{Name:"Light Bridge Spawner"},EntityTag:{id:"minecraft:chicken",CustomName:"MMH_LightBridgeSpawner",Silent:1,NoGravity:1}}
//MMH_loadChunks()
///clone ~1 ~1 ~1 ~3 ~3 ~3 20 1 16

#MMH
repeat process MMH_lightBridgeSpawner {
if: /testfor @e[type=Chicken,name=MMH_LightBridgeSpawner]
then {
  MMH_loadChunks()
  /execute @e[type=Chicken,name=MMH_LightBridgeSpawner] ~ ~ ~ scoreboard players operation Rotation MMH_Rotation = @p MMH_Rotation
  /scoreboard players test Rotation MMH_Rotation 0 0
  conditional: /execute @e[type=Chicken,name=MMH_LightBridgeSpawner] ~ ~ ~ clone 20 1 16 20 3 17 ~-2 ~-1 ~-1 masked
  /scoreboard players test Rotation MMH_Rotation 1 1
  conditional: /execute @e[type=Chicken,name=MMH_LightBridgeSpawner] ~ ~ ~ clone 21 1 16 22 3 16 ~ ~-1 ~-2 masked
  /scoreboard players test Rotation MMH_Rotation 2 2
  conditional: /execute @e[type=Chicken,name=MMH_LightBridgeSpawner] ~ ~ ~ clone 22 1 17 22 3 18 ~2 ~-1 ~ masked
  /scoreboard players test Rotation MMH_Rotation 3 3
  conditional: /execute @e[type=Chicken,name=MMH_LightBridgeSpawner] ~ ~ ~ clone 20 1 18 21 3 18 ~-1 ~-1 ~2 masked
  /tp @e[type=Chicken,name=MMH_LightBridgeSpawner] ~ -100 ~
}
}

//impulse: /summon area_effect_cloud ~2 ~1 ~ {CustomName:"ACV_LightBridge",Rotation:[-90.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_lightBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block
//impulse: /summon area_effect_cloud ~2 ~-1 ~ {CustomName:"ACV_AntiBridge",Rotation:[-90.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_antiBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block
//
//impulse: /summon area_effect_cloud ~ ~1 ~2 {CustomName:"ACV_LightBridge",Rotation:[0.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_lightBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block
//impulse: /summon area_effect_cloud ~ ~-1 ~2 {CustomName:"ACV_AntiBridge",Rotation:[0.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_antiBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block
//
//impulse: /summon area_effect_cloud ~-2 ~1 ~ {CustomName:"ACV_LightBridge",Rotation:[90.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_lightBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block
//impulse: /summon area_effect_cloud ~-2 ~-1 ~ {CustomName:"ACV_AntiBridge",Rotation:[90.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_antiBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block
//
//impulse: /summon area_effect_cloud ~ ~1 ~-2 {CustomName:"ACV_LightBridge",Rotation:[180.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_lightBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block
//impulse: /summon area_effect_cloud ~ ~-1 ~-2 {CustomName:"ACV_AntiBridge",Rotation:[180.0f,0.0f],Duration:2147483647}
///execute @e[name=ACV_antiBridges] ~ ~ ~ setblock ~ ~ ~ redstone_block


lines.linewidth: 1.0          # line width in points

text.color: 232F3E

axes.facecolor:     FAFAFA    # axes background color
axes.edgecolor:     CACFD0    # axes edge color
axes.linewidth:     1.5       # edge line width
axes.grid:          True      # display grid or not
axes.titlesize:     14        # font size of the axes title
axes.labelsize:     10        # font size of the x and y labels
axes.labelcolor:    FF9900    # color of the x and y labels
axes.titleweight:   bold      # font weight of title
axes.titlecolor:    FF9900    # color of the axes title
#axes.labelcolor:    0073BB
axes.prop_cycle: cycler('color', ['232F3E', '527FFF', '0073BB', '4d27aa', 'b0084d', 'bf0816', 'd45b07', 'FF9900', 'e38b00', '067f68', '16bf9f'])

xtick.color:         0073BB   # color of the ticks
xtick.labelsize:     9        # font size of the tick labels
ytick.color:         0073BB   # color of the ticks
ytick.labelsize:     9        # font size of the tick labels

grid.color:     232F3E        # grid color
grid.alpha:     0.1           # transparency, between 0.0 and 1.0

legend.framealpha:    0.5     # legend patch transparency
legend.facecolor:     fee385  # inherit from axes.facecolor; or color spec
legend.edgecolor:     e38b00  # background patch boundary color
legend.fancybox:      True    # if True, use a rounded box for the

figure.titlesize:   large     # size of the figure title (``Figure.suptitle()``)
figure.titleweight: bold      # weight of the figure title
figure.facecolor:   F2F3F3    # figure face color


//impulse: /give @p spawn_egg 1 0 {display:{Name:"Redirecting Cube Spawner"},EntityTag:{id:"minecraft:chicken",CustomName:"MMH_RedirectingCubeSpawner",Silent:1,NoGravity:1}}
//MMH_loadChunks()
///clone ~1 ~1 ~1 ~3 ~4 ~3 20 1 20

#MMH
repeat process MMH_discouragementRedirectionCubeSpawner {
if: /testfor @e[type=Chicken,name=MMH_RedirectingCubeSpawner]
then {
  MMH_loadChunks()
  /execute @e[type=Chicken,name=MMH_RedirectingCubeSpawner] ~ ~ ~ clone 20 1 20 22 4 22 ~-1 ~ ~-1 masked
  /execute @e[type=Chicken,name=MMH_RedirectingCubeSpawner] ~ ~ ~ fill ~ ~ ~ ~ ~ ~ air 0 replace pumpkin
  /tp @e[type=Chicken,name=MMH_RedirectingCubeSpawner] ~ -100 ~
}
}

//repeat: /testfor @e[type=armor_stand,name=ACV_Cube,tag=1]
///blockdata ${-1} {SuccessCount:1}
//conditional: /summon armor_stand ~1 ~-2 ~-1 {CustomName:"ACV_Cube",DisabledSlots:2035728,ArmorItems:[{},{},{},{Count:1,id:"dispenser"}],NoGravity:1b,Invisible:1b,Invulnerable:1b,Tags:["ACV_Redirecting","1"]}


// Spawn particles at every ACV_Main that did not have a successful validation.
// Params: area_effect_cloud named ACV_Main tagged with ACV_handleFailedPortals_PARAM
process ACV_handleFailedPortals {
/execute @e[type=area_effect_cloud,name=ACV_Main,tag=ACV_handleFailedPortals_PARAM,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ /particle iconcrack ~ ~ ~ 0.1 0.1 0.1 0 20 force @a 22
/execute @e[type=area_effect_cloud,name=ACV_Main,tag=ACV_handleFailedPortals_PARAM,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ /particle iconcrack ~ ~ ~ 0.1 0.1 0.1 0 20 force @a 159 1
/execute @e[type=area_effect_cloud,name=ACV_Main,tag=ACV_handleFailedPortals_PARAM,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ /particle iconcrack ~ ~ ~ 0.1 0.1 0.1 0 20 force @a 159 11
/execute @e[type=area_effect_cloud,name=ACV_Main,tag=ACV_handleFailedPortals_PARAM,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ /particle iconcrack ~ ~ ~ 0.1 0.1 0.1 0 20 force @a 159 14

// TODO: playsound
}


// Check if a portal can be spawned in any direction at the location of ACV_Main.
// All area effect clouds with tag ACV_Direction that would result in an invalid portal are killed.
// Of the remaining directions exactly one is retained with the following priority:
// * ACV_Up
// * ACV_Down
// * ACV_South
// * ACV_East
// * ACV_North
// * ACV_West
process ACV_validateDirections {
ACV_spaceValidation()
ACV_collisionValidation()
ACV_surfaceValidation()

/execute @e[type=area_effect_cloud,name=ACV_Up] ~ ~ ~ kill @e[type=area_effect_cloud,name=!ACV_Up,tag=ACV_Direction,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_Down] ~ ~ ~ kill @e[type=area_effect_cloud,name=!ACV_Down,tag=ACV_Direction,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_South] ~ ~ ~ kill @e[type=area_effect_cloud,name=!ACV_South,tag=ACV_Direction,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_East] ~ ~ ~ kill @e[type=area_effect_cloud,name=!ACV_East,tag=ACV_Direction,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_North] ~ ~ ~ kill @e[type=area_effect_cloud,name=!ACV_North,tag=ACV_Direction,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_West] ~ ~ ~ kill @e[type=area_effect_cloud,name=!ACV_West,tag=ACV_Direction,dy=0]
}

install {
  /scoreboard objectives add ACV_HEIGHT_VALID dummy
}

uninstall {
  /scoreboard objectives remove ACV_HEIGHT_VALID
}

// Checks if there is enough space to create the portal (is there air or carpet below a non floor Portal),
// if there is not, all directions of the affected creation are killed except for ACV_Up.
process ACV_spaceValidation {
/scoreboard players set @e[type=area_effect_cloud,tag=ACV_Direction] ACV_HEIGHT_VALID 0
/scoreboard players set @e[type=area_effect_cloud,name=ACV_Up] ACV_HEIGHT_VALID 1
/execute @e[type=area_effect_cloud,name=!ACV_Up,tag=ACV_Direction] ~ ~ ~ detect ~ ~-1 ~ air * scoreboard players set @e[type=area_effect_cloud,tag=ACV_Direction,r=0,c=1] ACV_HEIGHT_VALID 1
/execute @e[type=area_effect_cloud,name=!ACV_Up,tag=ACV_Direction] ~ ~ ~ detect ~ ~-1 ~ carpet * scoreboard players set @e[type=area_effect_cloud,tag=ACV_Direction,r=0,c=1] ACV_HEIGHT_VALID 1
/kill @e[type=area_effect_cloud,tag=ACV_Direction,score_ACV_HEIGHT_VALID=0]
}

// Checks if there is already a portal of a different color or an item frame or painting that would collide,
// if there is, all directions of the affected creation are killed.
process ACV_collisionValidation {
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ execute @e[type=painting,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ execute @e[type=item_frame,name=!ACV_PortalDisplay,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR=-1,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=1,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR=0,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=2,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR=1,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=3,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR=2,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
/execute @e[type=area_effect_cloud,name=ACV_Main,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=item_frame,name=ACV_PortalDisplay,score_ACV_COLOR_min=4,dy=-1,c=1] ~ ~ ~ kill @e[type=area_effect_cloud,tag=ACV_Direction,dy=1]
}

install {
  // The scoreboard Surface Valid Stat is filled by a stat command
  /scoreboard objectives add ACV_SURF_VALID_S dummy
}

uninstall {
  /scoreboard objectives remove ACV_SURF_VALID_S
}

// Checks if both the upper and lower block is valid.
// They are if they are non air, and either listed by the Block_Option or the Block_Option is empty.
// Invalid directions are killed.
process ACV_surfaceValidation {
/execute @e[type=area_effect_cloud,name=ACV_Up] ~ ~ ~ summon area_effect_cloud ~ ~-1 ~ {CustomName:"ACV_LowerBlock",Tags:[ACV_Up],Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Up] ~ ~ ~ summon area_effect_cloud ~ ~-1 ~ {CustomName:"ACV_UpperBlock",Tags:[ACV_Up],Duration:2147483647}

/execute @e[type=area_effect_cloud,name=ACV_Down] ~ ~ ~ summon area_effect_cloud ~ ~1 ~ {CustomName:"ACV_LowerBlock",Tags:[ACV_Down],Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Down] ~ ~ ~ summon area_effect_cloud ~ ~1 ~ {CustomName:"ACV_UpperBlock",Tags:[ACV_Down],Duration:2147483647}

/execute @e[type=area_effect_cloud,name=ACV_South] ~ ~ ~ summon area_effect_cloud ~ ~-1 ~-1 {CustomName:"ACV_LowerBlock",Tags:[ACV_South],Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_South] ~ ~ ~ summon area_effect_cloud ~ ~ ~-1 {CustomName:"ACV_UpperBlock",Tags:[ACV_South],Duration:2147483647}

/execute @e[type=area_effect_cloud,name=ACV_East] ~ ~ ~ summon area_effect_cloud ~-1 ~-1 ~ {CustomName:"ACV_LowerBlock",Tags:[ACV_East],Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_East] ~ ~ ~ summon area_effect_cloud ~-1 ~ ~ {CustomName:"ACV_UpperBlock",Tags:[ACV_East],Duration:2147483647}

/execute @e[type=area_effect_cloud,name=ACV_North] ~ ~ ~ summon area_effect_cloud ~ ~-1 ~1 {CustomName:"ACV_LowerBlock",Tags:[ACV_North],Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_North] ~ ~ ~ summon area_effect_cloud ~ ~ ~1 {CustomName:"ACV_UpperBlock",Tags:[ACV_North],Duration:2147483647}

/execute @e[type=area_effect_cloud,name=ACV_West] ~ ~ ~ summon area_effect_cloud ~1 ~-1 ~ {CustomName:"ACV_LowerBlock",Tags:[ACV_West],Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_West] ~ ~ ~ summon area_effect_cloud ~1 ~ ~ {CustomName:"ACV_UpperBlock",Tags:[ACV_West],Duration:2147483647}

/scoreboard players add @e[type=area_effect_cloud,name=ACV_LowerBlock] ACV_SURF_VALID_S 0
/scoreboard players add @e[type=area_effect_cloud,name=ACV_UpperBlock] ACV_SURF_VALID_S 0
/stats entity @e[type=area_effect_cloud,name=ACV_LowerBlock] set SuccessCount @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] ACV_SURF_VALID_S
/stats entity @e[type=area_effect_cloud,name=ACV_UpperBlock] set SuccessCount @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] ACV_SURF_VALID_S

ACV_loadChunks()

/testforblocks 0 1 1 6 2 1 0 1 2
conditional: /scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock] add ACV_SurfaceValid
conditional: /scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock] add ACV_SurfaceValid

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 0 1 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 1 1 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 2 1 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 3 1 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 4 1 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 5 1 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 6 1 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 0 2 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 1 2 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 2 2 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 3 2 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 4 2 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 5 2 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 6 2 1
/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid

/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 0 1 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 1 1 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 2 1 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 3 1 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 4 1 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 5 1 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 6 1 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 0 2 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 1 2 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 2 2 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 3 2 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 4 2 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 5 2 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ testforblocks ~ ~ ~ ~ ~ ~ 6 2 1
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,score_ACV_SURF_VALID_S_min=1] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ detect ~ ~ ~ piston_extension * scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] add ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ detect ~ ~ ~ piston_extension * scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] add ACV_SurfaceValid

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock] ~ ~ ~ detect ~ ~ ~ air * scoreboard players tag @e[type=area_effect_cloud,name=ACV_LowerBlock,r=0,c=1] remove ACV_SurfaceValid
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock] ~ ~ ~ detect ~ ~ ~ air * scoreboard players tag @e[type=area_effect_cloud,name=ACV_UpperBlock,r=0,c=1] remove ACV_SurfaceValid

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,tag=ACV_Up,tag=!ACV_SurfaceValid] ~ ~1 ~ kill @e[type=area_effect_cloud,name=ACV_Up,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,tag=ACV_Up,tag=!ACV_SurfaceValid] ~ ~1 ~ kill @e[type=area_effect_cloud,name=ACV_Up,dy=0]

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,tag=ACV_Down,tag=!ACV_SurfaceValid] ~ ~-1 ~ kill @e[type=area_effect_cloud,name=ACV_Down,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,tag=ACV_Down,tag=!ACV_SurfaceValid] ~ ~-1 ~ kill @e[type=area_effect_cloud,name=ACV_Down,dy=0]

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,tag=ACV_South,tag=!ACV_SurfaceValid] ~ ~1 ~1 kill @e[type=area_effect_cloud,name=ACV_South,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,tag=ACV_South,tag=!ACV_SurfaceValid] ~ ~ ~1 kill @e[type=area_effect_cloud,name=ACV_South,dy=0]

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,tag=ACV_East,tag=!ACV_SurfaceValid] ~1 ~1 ~ kill @e[type=area_effect_cloud,name=ACV_East,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,tag=ACV_East,tag=!ACV_SurfaceValid] ~1 ~ ~ kill @e[type=area_effect_cloud,name=ACV_East,dy=0]

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,tag=ACV_North,tag=!ACV_SurfaceValid] ~ ~1 ~-1 kill @e[type=area_effect_cloud,name=ACV_North,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,tag=ACV_North,tag=!ACV_SurfaceValid] ~ ~ ~-1 kill @e[type=area_effect_cloud,name=ACV_North,dy=0]

/execute @e[type=area_effect_cloud,name=ACV_LowerBlock,tag=ACV_West,tag=!ACV_SurfaceValid] ~-1 ~1 ~ kill @e[type=area_effect_cloud,name=ACV_West,dy=0]
/execute @e[type=area_effect_cloud,name=ACV_UpperBlock,tag=ACV_West,tag=!ACV_SurfaceValid] ~-1 ~ ~ kill @e[type=area_effect_cloud,name=ACV_West,dy=0]

/kill @e[type=area_effect_cloud,name=ACV_LowerBlock]
/kill @e[type=area_effect_cloud,name=ACV_UpperBlock]
}


# 基于 CodeParser.jar 的代码读取包。
# 优点在于：
# 	1. 可以去除预处理器必须在行首的限制。
# 	2. include默认使用相对路径。
#	3. 可以指定文件编码。
#	4. 默认每个文件只会include一遍。
# 注：会自动在 libname 包含的目录下寻找jar文件。
JavaCodeReader:=module()
	option  package;
	export 	ReadCode,ParseCode;
	local  	parseCode,
			parseStr,
			ModuleLoad;

	ModuleLoad:=proc()
		local jarName,jarPath,path,isFinded:=false;
		jarName:="CodeParser.jar";
		for path in :-libname do
			jarPath:=FileTools:-JoinPath([path,jarName]);
			if FileTools:-Exists(jarPath) then
				isFinded:=true;
				break;
			end if;
		end do;
		if not isFinded then
			error "找不到 %1 ，请确保 %2 下存在该文件。",jarName,[libname];
		end if;
		parseCode:=define_external(
			'mapleCall',
			JAVA,CLASSPATH=jarPath,
			CLASS="org.yjt.maple.ParseCodeUtil",
			'fin'::string,
			'fout'::string,
			'inputEncode'::string,
			'outputEncode'::string);
	end proc:
	ModuleLoad();

	# 采用Base64编码传递文件路径以支持中文
	# 注意Maple内部字符串的编码为UTF8
	parseStr:=proc(s::string)
		return StringTools:-Encode(s,'encoding'='base64');
	end proc:

	ParseCode:=proc(fin::string,fout::string,inEncode:="UTF8",outEncode:="UTF8")
		parseCode(parseStr(fin),parseStr(fout),inEncode,outEncode);
	end proc:

	ReadCode:=proc(fname::string,inEncode:="UTF8",outEncode:="UTF8")
		description "similar to `read`";
		local tmpFile;
		tmpFile:=cat(fname,".tmp.mpl");
		ParseCode(fname,tmpFile,inEncode,outEncode);
		read(tmpFile);
		FileTools[Remove](tmpFile);
		return;
	end proc:
end module:


process ACV_loadChunks {
/summon area_effect_cloud ~ ~ ~ {CustomName:"ACV_Chunkloader",Duration:1}
/spreadplayers 5 5 0 1 false @e[type=area_effect_cloud,name=ACV_Chunkloader]
/kill @e[type=area_effect_cloud,name=ACV_Chunkloader]
}


#!/usr/bin/microperl
#
# roombacmd.pl -- Roomba command-line tool,  part of RoombaComm
#
# http://roombahacking.com/
#
# Copyright (C) 2006, Tod E. Kurt, tod@todbot.com
#
#

# in case we have stty in the current directory
$ENV{'PATH'}="$ENV{PATH}:.";

sub usage() {
    printf "Usage: $0 {serialport} {init|forward|backward|spinleft|spinright|stop|poweroff}\n";
    exit(1);
}

sub roomba_init() {
    # this style stty is for linux
#    system("stty -F $PORT 115200 raw -parenb -parodd cs8 -hupcl -cstopb clocal");
#    stty ttyUSB0 115200 raw -parenb cs8 -hupcl -cstopb clocal;
    open TTYS0, ">$PORT" or die ("Cannot open $PORT");
    printf(TTYS0 "\x80"); sleep 1;
    printf(TTYS0 "\x83");
}
sub roomba_forward() {
    $vel="\x00\x40";
    $rad="\x80\x00";
    open TTYS0, ">$PORT" or die ("Cannot open $PORT");
    printf(TTYS0 "\x89$vel$rad");
}
sub roomba_backward() {
    $vel="\xff\xc0";
    $rad="\x80\x00";
    open TTYS0, ">$PORT" or die ("Cannot open $PORT");
    printf(TTYS0 "\x89$vel$rad");
}
sub roomba_spinleft() {
    $vel="\x00\x40";
    $rad="\x00\x01";
    open TTYS0, ">$PORT" or die ("Cannot open $PORT");
    printf(TTYS0 "\x89$vel$rad");
}
sub roomba_spinright() {
    $vel="\x00\x40";
    $rad="\xff\xff";
    open TTYS0, ">$PORT" or die ("Cannot open $PORT");
    printf(TTYS0 "\x89$vel$rad");
}
sub roomba_stop() {
    $vel="\x00\x00";
    $rad="\x00\x00";
    open TTYS0, ">$PORT" or die ("Cannot open $PORT");
    printf(TTYS0 "\x89$vel$rad");
}

sub roomba_poweroff() {
    open TTYS0, ">$PORT" or die ("Cannot open $PORT");
    printf(TTYS0 "\x85");
}

# If not enough arguments were passed, return
usage() if( @ARGV < 2 );

$PORT = $ARGV[0];
$CMD  = $ARGV[1];

if( $CMD eq 'init' ) {
    roomba_init();
}
elsif( $CMD eq 'forward' ) {
    roomba_forward();
}
elsif( $CMD eq 'backward' ) {
    roomba_backward();
}
elsif( $CMD eq 'spinleft' ) {
    roomba_spinleft();
}
elsif( $CMD eq 'spinright' ) {
    roomba_spinright();
}
elsif( $CMD eq 'stop' ) {
    roomba_stop();
}
elsif( $CMD eq 'poweroff' ) {
    roomba_poweroff();
}
else {
    usage();
}


//impulse: /give @p spawn_egg 1 0 {display:{Name:"Propulsion Gel Spawner"},EntityTag:{id:"minecraft:chicken",CustomName:"MMH_PropulsionGelSpawner",Silent:1,NoGravity:1}}
//MMH_loadChunks()
///clone ~1 ~1 ~1 ~3 ~5 ~3 20 1 24

#MMH
repeat process MMH_propulsionGelSpawner {
if: /testfor @e[type=Chicken,name=MMH_PropulsionGelSpawner]
then {
  MMH_loadChunks()
  /execute @e[type=Chicken,name=MMH_PropulsionGelSpawner] ~ ~ ~ clone 20 1 24 22 5 26 ~-1 ~ ~-1 masked
  /execute @e[type=Chicken,name=MMH_PropulsionGelSpawner] ~ ~ ~ fill ~ ~ ~ ~ ~ ~ air 0 replace pumpkin
  /tp @e[type=Chicken,name=MMH_PropulsionGelSpawner] ~ -100 ~
}
}

///summon item ~-1 ~-1 ~-1 {CustomName:"ACV_PropulsionGel",PickupDelay:32767,Item:{Count:1,Damage:1,id:"minecraft:wool"}}


# Bluetooth Audio - Media player configuration options

#
# Copyright (c) 2022 Nordic Semiconductor
#
# SPDX-License-Identifier: Apache-2.0
#

config BT_MPL
	bool "Support for media player"
	select BT_CCID
	select EXPERIMENTAL
	help
	  Enables support for media player
	  Note that the provided media player is a sample that only provides a
	  mock-up with no actual media being played.
	  For real media playback, the sample must be extended, hooked up to a
	  real media player or replaced with a real media player.

if BT_MPL

config BT_MPL_MEDIA_PLAYER_NAME
	string "Media Player Name"
	default "Player0"
	help
	  Use this option to set the name of the media player.

config BT_MPL_MEDIA_PLAYER_NAME_MAX
	int "Max length of media player name"
	default 20
	range 1 255
	help
	  Sets the maximum number of bytes (including the null termination) of
	  the name of the media player.

config BT_MPL_ICON_URL
	string "Media player Icon URL"
	default "http://server.some.where/path/icon.png"
	help
	  Use this option to set the URL of the Media Player Icon.

config BT_MPL_ICON_URL_MAX
	int "Max length of media player icon URL"
	default 40
	range 1 255
	help
	  Sets the maximum number of bytes (including the null termination) of
	  the media player icon URL.

config BT_MPL_TRACK_TITLE_MAX
	int "Max length of the title of a track"
	default 40
	range 1 255
	help
	  Sets the maximum number of bytes (including the null termination) of
	  the title of any track in the media player.

config BT_MPL_SEGMENT_NAME_MAX
	int "Max length of the name of a track segment"
	default 25
	range 1 255
	help
	  Sets the the maximum number of bytes (including the null termination)
	  of the name of any track segment in the media player.

config BT_MPL_GROUP_TITLE_MAX
	int "Max length of the title of a group of tracks"
	default BT_MPL_TRACK_TITLE_MAX
	range 1 255
	help
	  Sets the maximum number of bytes (including the null termination) of
	  the title of any group in the media player.

config BT_MPL_OBJECTS
	bool "Support for media player objects"
	depends on BT_OTS
	# TODO: Temporarily depends also on BT_MCS, to avoid issues with the
	# bt_mcs_get_ots() call
	depends on BT_MCS
	help
	  Enables support for objects in the media player
	  Objects are used to give/get more information about e.g. media tracks.
	  Requires the Object Transfer Service

if BT_MPL_OBJECTS

config BT_MPL_MAX_OBJ_SIZE
	int "Total memory size to use for storing the content of objects"
	default 127
	range 0 65536
	help
	  Sets the total memory size (in octets) to use for storing the content of objects.
	  This is used for the total memory pool buffer size from which memory
	  is allocated when sending object content.

config BT_MPL_ICON_BITMAP_SIZE
	int "Media player Icon bitmap object size"
	default 127
	help
	  This option sets the maximum size (in octets) of the icon object.

config BT_MPL_TRACK_MAX_SIZE
	int "Maximum size for a track object"
	default 127
	help
	  This option sets the maximum size (in octets) of a track object.

endif # BT_MPL_OBJECTS

config BT_DEBUG_MPL
	bool "Media player debug"
	help
	  Enables debug logs for the media player

endif # BT_MPL


print "Hello world!";


// Setup
include "ACV_setupScoreboards.mpl"
include "ACV_deleteScoreboards.mpl"

// Main
include "ACV_portals.mpl"

// Remote
include "ACV_remote_deletePortals.mpl"
include "ACV_remote_deleteAllPortals.mpl"
include "ACV_remote_createPortals.mpl"

// Extra
include "ACV_confirmBlockOption.mpl"
include "ACV_teleportation.mpl"
include "ACV_smoothTeleportation.mpl"
include "ACV_lightBridges.mpl"
include "ACV_antiBridges.mpl"
include "ACV_cubes.mpl"
include "ACV_lasers.mpl"
include "ACV_megs.mpl"
include "ACV_gels.mpl"

project ACV {
  orientation "zyx"
}

install {
/gamerule commandBlockOutput false
/gamerule logAdminCommands false
/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"red","extra":[{"text":"Starting Installation","color":"yellow"}]}

/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Setting up Scoreboards","color":"yellow"}]}
ACV_setupScoreboards()
/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Enabling UI","color":"yellow"}]}
/fill ${origin + (9 1 -7)} ${origin + (15 3 -6)} lever facing=north replace barrier
/blockdata ${origin + (7 1 -16)} {Command:"/setblock ~-7 ~ ~16 redstone_block"}
/setblock ${origin + (7 2 -14)} wall_sign 3 replace {Text1:"{\"text\":\"\"}",Text2:"{\"text\":\"[Uninstall]\",\"color\":\"dark_green\",\"bold\":\"true\"}",Text3:"{\"text\":\"\"}",Text4:"{\"text\":\"\"}"}
/fill ${origin + (6 0 -15)} ${origin + (9 2 -15)} stained_hardened_clay 13 replace stained_hardened_clay 14

/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Setting up Block-Option","color":"yellow"}]}
ACV_confirmBlockOption()
}

uninstall {
/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"red","extra":[{"text":"Starting Uninstallation","color":"yellow"}]}

/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Deleting Portals","color":"yellow"}]}
ACV_remote_deleteAllPortals()

/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Disabling UI","color":"yellow"}]}
/fill ${origin + (9 1 -7)} ${origin + (15 3 -6)} barrier 0 replace lever
/blockdata ${origin + (7 1 -16)} {Command:"/setblock ~-7 ~-1 ~16 redstone_block"}
/setblock ${origin + (7 2 -14)} wall_sign 3 replace {Text1:"{\"text\":\"\"}",Text2:"{\"text\":\"[Install]\",\"color\":\"dark_red\",\"bold\":\"true\"}",Text3:"{\"text\":\"\"}",Text4:"{\"text\":\"\"}"}
/fill ${origin + (6 0 -15)} ${origin + (9 2 -15)} stained_hardened_clay 14 replace stained_hardened_clay 13

///tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Interrupt all Interface calls","color":"yellow"}]}
///execute @e[tag=ACV_remote_interface] ~ ~ ~ /setblock ~ ~ ~ stone
///execute @e[tag=ACV_internal_interface] ~ ~ ~ /setblock ~ ~ ~ stone

/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Deleting Scoreboards","color":"yellow"}]}
ACV_deleteScoreboards()

// 3 tick delay
/setblock ${this+1} redstone_block
skip
impulse: /setblock ${this-1} stone
/setblock ${this+1} redstone_block
skip
impulse: /setblock ${this-1} stone
/setblock ${this+1} redstone_block
skip
impulse: /setblock ${this-1} stone
// 3 tick delay end

/tellraw @a {"text":"[ApertureCraft Vanilla] ","color":"gold","extra":[{"text":"Deleting Interfaces","color":"yellow"}]}
}


type $Ljava/lang/Object; <class  {
  @DEXINFO_isuserclass 0}>
type $Leh; <class <$Ljava/lang/Object;> {
  @DEXINFO_isuserclass 1,
  &foo public static (<* <$Leh;>>,<* <[0] <* <$Ljava/lang/String;>>>>) void}>
type $Ljava/lang/String; <class  {
  @DEXINFO_isuserclass 0}>
type $Ljava/io/PrintStream; <class  {
  @DEXINFO_isuserclass 0}>
type $Ljava/lang/System; <class  {
  @DEXINFO_isuserclass 0,
  @out <* <$Ljava/io/PrintStream;>>}>
type $Ljava/lang/Exception; <class  {
  @DEXINFO_isuserclass 0}>
  javaclass $javaclass|Leh; <$Leh;>

func &foo public static (var %_this <* <$Leh;>>, var %Reg2_R39 <* <[0] <* <$Ljava/lang/String;>>>>) void
var $const_array_0 <[3] i32> readonly = [1, 2, 3]
var $static|Ljava/lang/System;|out|Ljava/io/PrintStream;| <* <$Ljava/io/PrintStream;>>
func &Ljava/io/PrintStream;|print|_I_V| (var %_this <* <$Ljava/io/PrintStream;>>, var %Reg1_I i32) void
var $const_chars_1 <[11] u8> const readonly = [0, 0, 7, 0, 101, 114, 114, 111, 114, 49, 10]
func &Ljava/io/PrintStream;|print|_Ljava/lang/String;_V| (var %_this <* <$Ljava/io/PrintStream;>>, var %Reg1_R37 <* <$Ljava/lang/String;>>) void
var $const_chars_2 <[11] u8> const readonly = [0, 0, 7, 0, 101, 114, 114, 111, 114, 50, 10]

func &foo public static (var %_this <* <$Leh;>>, var %Reg2_R39 <* <[0] <* <$Ljava/lang/String;>>>>) void {
  var %Reg0_I i32
  var %Reg0_R45 <* <[3] i32>>
  var %Reg1_I i32
  var %Reg1_R47 <* <$Ljava/io/PrintStream;>>
  var %Reg0_R51 <* <$Ljava/lang/Exception;>>
  var %Reg0_R47 <* <$Ljava/io/PrintStream;>>
  var %Reg1_R53 <* u8>
  var %Reg0_R55 <* dynany>
  dassign %Reg0_I 0 (cvt i32 i8 (constval i8 3))
  javatry { @label1 }
  dassign %Reg0_R45 0 (malloc ptr (mul i32 (dread i32 %Reg0_I, sizeoftype u32 i32)))
  endtry
  intrinsiccallassigned DEX_ARRAY_SETELEM (dread ptr %Reg0_R45, constval i32 3, addrof ptr $const_array_0) {}
  dassign %Reg1_I 0 (cvt i32 i8 (constval i8 4))
  javatry { @label1 @label2 }
  dassign %Reg0_I 0 (iread i32 <* <[3] i32>> 0 (array ptr <* <[3] i32>> (dread ptr %Reg0_R45, dread i32 %Reg1_I)))
  dassign %Reg1_R47 0 (dread ptr $static|Ljava/lang/System;|out|Ljava/io/PrintStream;|)
  virtualcallassigned &Ljava/io/PrintStream;|print|_I_V| (dread ptr %Reg1_R47, dread i32 %Reg0_I) {}
  endtry
@label0   return ()
@label2   javacatch <* <$Ljava/lang/Exception;>>
  dassign %Reg0_R51 0 (regread ptr %%thrownval)
  javatry { @label1 }
  dassign %Reg0_R47 0 (dread ptr $static|Ljava/lang/System;|out|Ljava/io/PrintStream;|)
  dassign %Reg1_R53 0 (addrof ptr $const_chars_1)
  virtualcallassigned &Ljava/io/PrintStream;|print|_Ljava/lang/String;_V| (dread ptr %Reg0_R47, dread ptr %Reg1_R53) {}
  endtry
  goto @label0
@label1   javacatch <* <$Ljava/lang/Exception;>>
  dassign %Reg0_R51 0 (regread ptr %%thrownval)
  dassign %Reg0_R47 0 (dread ptr $static|Ljava/lang/System;|out|Ljava/io/PrintStream;|)
  dassign %Reg1_R53 0 (addrof ptr $const_chars_2)
  virtualcallassigned &Ljava/io/PrintStream;|print|_Ljava/lang/String;_V| (dread ptr %Reg0_R47, dread ptr %Reg1_R53) {}
  goto @label0
}


// Deletes all portals whose color is specified by an entity named ACV_deletePortals_PARAM and then kill the params
// Params: entities with name ACV_deletePortals_PARAM and a score of ACV_COLOR
process ACV_deletePortals {
  triggerAntiBridges()
  closeConnections()
  killPortals()
  lightUpHorizontalPortals()

  // Kill the Params
  /kill @e[name=ACV_deletePortals_PARAM]
}

// Triggers the AntiBridges at every specified Portal
// Params: entities with tag ACV_deletePortals_PARAM and a score of ACV_COLOR
process triggerAntiBridges {
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=0,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalOut,score_ACV_COLOR_min=0,score_ACV_COLOR=1] ~ ~ ~ entitydata @e[type=area_effect_cloud,name=ACV_AntiBridge_Idle,dy=0] {CustomName:"ACV_AntiBridge"}
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=2,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalOut,score_ACV_COLOR_min=2,score_ACV_COLOR=3] ~ ~ ~ entitydata @e[type=area_effect_cloud,name=ACV_AntiBridge_Idle,dy=0] {CustomName:"ACV_AntiBridge"}
  start ACV_antiBridges
}

// Close the connection between the two portals
// Params: entities with tag ACV_deletePortals_PARAM and a score of ACV_COLOR
process closeConnections {
  ACV_loadChunks()
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=0,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ clone 0 1 0 0 2 0 ~ ~ ~
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=0,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ clone 1 1 0 1 2 0 ~ ~ ~
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=2,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ clone 2 1 0 2 2 0 ~ ~ ~
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=2,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=area_effect_cloud,name=ACV_PortalIn,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ clone 3 1 0 3 2 0 ~ ~ ~
}

// Delete the specified portals
// Params: entities with tag ACV_deletePortals_PARAM and a score of ACV_COLOR
process killPortals {
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ kill @e[tag=ACV_Portal,score_ACV_COLOR_min=0,score_ACV_COLOR=0]
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ kill @e[tag=ACV_Portal,score_ACV_COLOR_min=1,score_ACV_COLOR=1]
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ kill @e[tag=ACV_Portal,score_ACV_COLOR_min=2,score_ACV_COLOR=2]
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ kill @e[tag=ACV_Portal,score_ACV_COLOR_min=3,score_ACV_COLOR=3]
}

// Place barrier blocks at floor and ceiling portals, because otherwise the display turns dark
// Params: entities with tag ACV_deletePortals_PARAM and a score of ACV_COLOR
process lightUpHorizontalPortals {
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ execute @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ setblock ~ ~2 ~ barrier
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=1,score_ACV_COLOR=1] ~ ~ ~ execute @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=0,score_ACV_COLOR=0] ~ ~ ~ setblock ~ ~2 ~ barrier
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ execute @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ setblock ~ ~2 ~ barrier
  /execute @e[name=ACV_deletePortals_PARAM,score_ACV_COLOR_min=3,score_ACV_COLOR=3] ~ ~ ~ execute @e[type=armor_stand,name=ACV_PortalDisplay,score_ACV_COLOR_min=2,score_ACV_COLOR=2] ~ ~ ~ setblock ~ ~2 ~ barrier
}


repeat process ACV_gels {

// Water
/scoreboard players set @e[type=item,name=ACV_CleansingGel] OnGround 1 {OnGround:1b}
/execute @e[type=item,name=ACV_CleansingGel,score_OnGround_min=1] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~ ~1 air 0 replace carpet 1
/execute @e[type=item,name=ACV_CleansingGel,score_OnGround_min=1] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~ ~1 air 0 replace carpet 11
/kill @e[type=item,name=ACV_CleansingGel,score_OnGround_min=1]

// Repulsion Gel
/execute @a ~ ~ ~ detect ~ ~ ~ carpet 11 effect @p 8 1 3 true
/execute @a ~ ~ ~ detect ~ ~ ~ air 0 effect @p 8 0 3 true

/scoreboard players set @e[type=item,name=ACV_RepulsionGel] OnGround 1 {OnGround:1b}
/execute @e[type=item,name=ACV_RepulsionGel,score_OnGround_min=1] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~ ~1 carpet 11 keep
/execute @e[type=item,name=ACV_RepulsionGel,score_OnGround_min=1] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~ ~1 carpet 11 replace carpet 1
/kill @e[type=item,name=ACV_RepulsionGel,score_OnGround_min=1]

// Propulsion Gel
/execute @a ~ ~ ~ detect ~ ~ ~ carpet 1 effect @p 1 1 6 true
/execute @a ~ ~ ~ detect ~ ~ ~ air 0 effect @p 1 0 6 true

/scoreboard players set @e[type=item,name=ACV_PropulsionGel] OnGround 1 {OnGround:1b}
/execute @e[type=item,name=ACV_PropulsionGel,score_OnGround_min=1] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~ ~1 carpet 1 keep
/execute @e[type=item,name=ACV_PropulsionGel,score_OnGround_min=1] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~ ~1 carpet 1 replace carpet 11
/kill @e[type=item,name=ACV_PropulsionGel,score_OnGround_min=1]
}


A:B;
C:D;
|A B C D|
|^A _A ^^^B ^^_A|
[
  |A' B, A'' ^B,',|
  [
    |A B C D|
  ]
]


//impulse: /give @p spawn_egg 1 0 {display:{Name:"Portal Spawner"},EntityTag:{id:"minecraft:chicken",CustomName:"MMH_PortalSpawner",Silent:1,NoGravity:1}}
//MMH_loadChunks()
///clone ~1 ~1 ~1 ~3 ~3 ~3 16 1 16

#MMH
repeat process MMH_portalSpawner {
if: /testfor @e[type=Chicken,name=MMH_PortalSpawner]
then {
  MMH_loadChunks()
  /execute @e[type=Chicken,name=MMH_PortalSpawner] ~ ~ ~ scoreboard players operation Rotation MMH_Rotation = @p MMH_Rotation
  /scoreboard players test Rotation MMH_Rotation 0 0
  conditional: /execute @e[type=Chicken,name=MMH_PortalSpawner] ~ ~ ~ clone 16 1 17 16 3 17 ~-2 ~ ~ masked
  /scoreboard players test Rotation MMH_Rotation 1 1
  conditional: /execute @e[type=Chicken,name=MMH_PortalSpawner] ~ ~ ~ clone 17 1 16 17 3 16 ~ ~ ~-2 masked
  /scoreboard players test Rotation MMH_Rotation 2 2
  conditional: /execute @e[type=Chicken,name=MMH_PortalSpawner] ~ ~ ~ clone 18 1 17 18 3 17 ~2 ~ ~ masked
  /scoreboard players test Rotation MMH_Rotation 3 3
  conditional: /execute @e[type=Chicken,name=MMH_PortalSpawner] ~ ~ ~ clone 17 1 18 17 3 18 ~ ~ ~2 masked
  /tp @e[type=Chicken,name=MMH_PortalSpawner] ~ -100 ~
}
}

//impulse: /summon area_effect_cloud ~2 ~.1 ~ {CustomName:"ACV_remote_createPortals_PARAM",Tags:["ACV_Blue"],Duration:2147483647}
///execute @e[name=ACV_remote_createPortals] ~ ~ ~ setblock ~ ~ ~ redstone_block
//
//impulse: /summon area_effect_cloud ~ ~.1 ~2 {CustomName:"ACV_remote_createPortals_PARAM",Tags:["ACV_Blue"],Duration:2147483647}
///execute @e[name=ACV_remote_createPortals] ~ ~ ~ setblock ~ ~ ~ redstone_block
//
//impulse: /summon area_effect_cloud ~-2 ~.1 ~ {CustomName:"ACV_remote_createPortals_PARAM",Tags:["ACV_Blue"],Duration:2147483647}
///execute @e[name=ACV_remote_createPortals] ~ ~ ~ setblock ~ ~ ~ redstone_block
//
//impulse: /summon area_effect_cloud ~ ~.1 ~-2 {CustomName:"ACV_remote_createPortals_PARAM",Tags:["ACV_Blue"],Duration:2147483647}
///execute @e[name=ACV_remote_createPortals] ~ ~ ~ setblock ~ ~ ~ redstone_block


repeat process ACV_portals {
/scoreboard players set @e[type=arrow,c=1] ACV_COLOR 0 {inGround:1b,damage:5.5}
/scoreboard players set @e[type=arrow,c=1] ACV_COLOR 1 {inGround:1b,damage:6.0}
/scoreboard players set @e[type=arrow,c=1] ACV_COLOR 2 {inGround:1b,damage:6.5}
/scoreboard players set @e[type=arrow,c=1] ACV_COLOR 3 {inGround:1b,damage:7.0}
/execute @e[type=arrow,score_ACV_COLOR_min=0] ~ ~ ~ summon area_effect_cloud ~ ~ ~ {CustomName:"ACV_Main",Duration:2147483647}
/execute @e[type=arrow,score_ACV_COLOR_min=0] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=ACV_Main,r=0,c=1] ACV_COLOR = @e[type=arrow,score_ACV_COLOR_min=0,c=1] ACV_COLOR
/kill @e[type=arrow,score_ACV_COLOR_min=0]
conditional: start ACV_processMain
}

impulse process ACV_processMain {
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ summon area_effect_cloud ~ ~0.9 ~ {CustomName:"ACV_Up",Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ summon area_effect_cloud ~ ~-1.45 ~ {CustomName:"ACV_Down",Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ summon area_effect_cloud ~ ~ ~0.95 {CustomName:"ACV_South",Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ summon area_effect_cloud ~0.95 ~ ~ {CustomName:"ACV_East",Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ summon area_effect_cloud ~ ~ ~-0.95 {CustomName:"ACV_North",Duration:2147483647}
/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ summon area_effect_cloud ~-0.95 ~ ~ {CustomName:"ACV_West",Duration:2147483647}

/execute @e[type=area_effect_cloud,name=ACV_Main] ~ ~ ~ scoreboard players tag @e[type=area_effect_cloud,name=!ACV_Main,dy=0] add ACV_Direction

/kill @e[type=area_effect_cloud,name=ACV_Up,tag=!ACV_Direction]
/kill @e[type=area_effect_cloud,name=ACV_Down,tag=!ACV_Direction]
/kill @e[type=area_effect_cloud,name=ACV_South,tag=!ACV_Direction]
/kill @e[type=area_effect_cloud,name=ACV_East,tag=!ACV_Direction]
/kill @e[type=area_effect_cloud,name=ACV_North,tag=!ACV_Direction]
/kill @e[type=area_effect_cloud,name=ACV_West,tag=!ACV_Direction]

/tp @e[type=area_effect_cloud,name=ACV_Down] ~ ~1 ~

ACV_createPortals()
}


//impulse: /give @p spawn_egg 1 0 {display:{Name:"Repulsion Gel Spawner"},EntityTag:{id:"minecraft:chicken",CustomName:"MMH_RepulsionGelSpawner",Silent:1,NoGravity:1}}
//MMH_loadChunks()
///clone ~1 ~1 ~1 ~3 ~5 ~3 16 1 24

#MMH
repeat process MMH_repulsionGelSpawner {
if: /testfor @e[type=Chicken,name=MMH_RepulsionGelSpawner]
then {
  MMH_loadChunks()
  /execute @e[type=Chicken,name=MMH_RepulsionGelSpawner] ~ ~ ~ clone 16 1 24 18 5 26 ~-1 ~ ~-1 masked
  /execute @e[type=Chicken,name=MMH_RepulsionGelSpawner] ~ ~ ~ fill ~ ~ ~ ~ ~ ~ air 0 replace pumpkin
  /tp @e[type=Chicken,name=MMH_RepulsionGelSpawner] ~ -100 ~
}
}

///summon item ~-1 ~-1 ~-1 {CustomName:"ACV_RepulsionGel",PickupDelay:32767,Item:{Count:1,Damage:11,id:"minecraft:wool"}}


flavor 1
srclang 3
id 65535
numfuncs 7
import "ThreadTest.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &LThreadTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "ThreadTest.jar"}
srcfileinfo {
  1 "ThreadTest.java"}
javaclass $LThreadTest_3B <$LThreadTest_3B> public
javaclass $LThreadTest_24FirstThread_3B <$LThreadTest_24FirstThread_3B>
javaclass $LThreadTest_24SecondThread_3B <$LThreadTest_24SecondThread_3B>
func &LThreadTest_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LThreadTest_3B>>) void
func &LThreadTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg5_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void
func &LThreadTest_3B_7C_3Cclinit_3E_7C_28_29V static constructor () void
func &LThreadTest_24FirstThread_3B_7C_3Cinit_3E_7C_28_29V constructor (var %_this <* <$LThreadTest_24FirstThread_3B>>) void
func &LThreadTest_24FirstThread_3B_7Crun_7C_28_29V public virtual (var %_this <* <$LThreadTest_24FirstThread_3B>>) void
func &LThreadTest_24SecondThread_3B_7C_3Cinit_3E_7C_28_29V constructor (var %_this <* <$LThreadTest_24SecondThread_3B>>) void
func &LThreadTest_24SecondThread_3B_7Crun_7C_28_29V public virtual (var %_this <* <$LThreadTest_24SecondThread_3B>>) void
var $_C_STR_5ca9762cf0b6a8cb0f4e692a3a6e142c fstatic <[5] u64> readonly = [0, 0x2700000000, 0x45544e498db7b2ca, 0x5f44455450555252, 0x4547415353454d]
var $_C_STR_4f004b00 fstatic <[3] u64> readonly = [0, 0x500000000, 0x4b4f000009dc]
var $LThreadTest_3B_7Cflag i64 static volatile = 0
var $LThreadTest_3B_7Cnumber i32 static = 0
func &LThreadTest_24FirstThread_3B_7Cstart_7C_28_29V public virtual synchronized (var %_this <* <$LThreadTest_24FirstThread_3B>>) void
func &LThreadTest_24SecondThread_3B_7Cstart_7C_28_29V public virtual synchronized (var %_this <* <$LThreadTest_24SecondThread_3B>>) void
func &LThreadTest_24FirstThread_3B_7Cjoin_7C_28_29V final public virtual (var %_this <* <$LThreadTest_24FirstThread_3B>>) void
func &LThreadTest_24SecondThread_3B_7Cjoin_7C_28_29V final public virtual (var %_this <* <$LThreadTest_24SecondThread_3B>>) void
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
func &LThreadTest_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LThreadTest_3B>>) void {
  funcid 48153
  var %Reg1_R43698 <* <$LThreadTest_3B>>
  var %Reg1_R57 <* <$Ljava_2Flang_2FObject_3B>>

  dassign %Reg1_R43698 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg1_R43698))
  callassigned &Ljava_2Flang_2FObject_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R57) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &LThreadTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg5_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48154
  var %Reg0_R43700 <* <$LThreadTest_24FirstThread_3B>>
  var %Reg2_R43700 <* <$LThreadTest_24FirstThread_3B>>
  var %Reg0_R43702 <* <$LThreadTest_24SecondThread_3B>>
  var %Reg3_R43702 <* <$LThreadTest_24SecondThread_3B>>
  var %Reg0_R20155 <* <$Ljava_2Flang_2FInterruptedException_3B>>
  var %Reg4_R20155 <* <$Ljava_2Flang_2FInterruptedException_3B>>
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg1_R43 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161348 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161349 <* <$Ljava_2Flang_2FString_3B>>

  intrinsiccallwithtype <$LThreadTest_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  new
  intrinsiccallwithtype <$LThreadTest_24FirstThread_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R43700 0 (gcmalloc ref <$LThreadTest_24FirstThread_3B>)
  #INSTIDX : 3||0003:  dup
  #INSTIDX : 4||0004:  invokespecial
  callassigned &LThreadTest_24FirstThread_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg0_R43700) {}
  #INSTIDX : 7||0007:  astore_1
  dassign %Reg2_R43700 0 (dread ref %Reg0_R43700)
  #INSTIDX : 8||0008:  new
  intrinsiccallwithtype <$LThreadTest_24SecondThread_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R43702 0 (gcmalloc ref <$LThreadTest_24SecondThread_3B>)
  #INSTIDX : 11||000b:  dup
  #INSTIDX : 12||000c:  invokespecial
  callassigned &LThreadTest_24SecondThread_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg0_R43702) {}
  #INSTIDX : 15||000f:  astore_2
  dassign %Reg3_R43702 0 (dread ref %Reg0_R43702)
  #INSTIDX : 16||0010:  aload_1
  #INSTIDX : 17||0011:  invokevirtual
  virtualcallassigned &LThreadTest_24FirstThread_3B_7Cstart_7C_28_29V (dread ref %Reg2_R43700) {}
  #INSTIDX : 20||0014:  aload_2
  #INSTIDX : 21||0015:  invokevirtual
  virtualcallassigned &LThreadTest_24SecondThread_3B_7Cstart_7C_28_29V (dread ref %Reg3_R43702) {}
  try { @label0 }
  #INSTIDX : 24||0018:  aload_1
  #INSTIDX : 25||0019:  invokevirtual
  virtualcallassigned &LThreadTest_24FirstThread_3B_7Cjoin_7C_28_29V (dread ref %Reg2_R43700) {}
  #INSTIDX : 28||001c:  aload_2
  #INSTIDX : 29||001d:  invokevirtual
  virtualcallassigned &LThreadTest_24SecondThread_3B_7Cjoin_7C_28_29V (dread ref %Reg3_R43702) {}
  endtry
  #INSTIDX : 32||0020:  goto
  goto @label1
@label0   catch { <* <$Ljava_2Flang_2FInterruptedException_3B>> }
  dassign %Reg0_R20155 0 (regread ptr %%thrownval)
  #INSTIDX : 35||0023:  astore_3
  dassign %Reg4_R20155 0 (dread ref %Reg0_R20155)
  #INSTIDX : 36||0024:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 39||0027:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_5ca9762cf0b6a8cb0f4e692a3a6e142c) { dassign %L_STR_161348 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161348)
  #INSTIDX : 41||0029:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
@label1   #INSTIDX : 44||002c:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 47||002f:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_4f004b00) { dassign %L_STR_161349 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161349)
  #INSTIDX : 49||0031:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 52||0034:  return
  return ()
}
func &LThreadTest_3B_7C_3Cclinit_3E_7C_28_29V static constructor () void {
  funcid 48155
  var %Reg0_J i64
  var %Reg0_I i32

  #INSTIDX : 0||0000:  lconst_0
  dassign %Reg0_J 0 (constval i64 0)
  #INSTIDX : 1||0001:  putstatic
  dassign $LThreadTest_3B_7Cflag 0 (dread i64 %Reg0_J)
  #INSTIDX : 4||0004:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 5||0005:  putstatic
  dassign $LThreadTest_3B_7Cnumber 0 (dread i32 %Reg0_I)
  #INSTIDX : 8||0008:  return
  return ()
}
func &LThreadTest_24FirstThread_3B_7C_3Cinit_3E_7C_28_29V constructor (var %_this <* <$LThreadTest_24FirstThread_3B>>) void {
  funcid 48156
  var %Reg1_R43700 <* <$LThreadTest_24FirstThread_3B>>
  var %Reg1_R1610 <* <$Ljava_2Flang_2FThread_3B>>

  dassign %Reg1_R43700 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R1610 0 (retype ref <* <$Ljava_2Flang_2FThread_3B>> (dread ref %Reg1_R43700))
  callassigned &Ljava_2Flang_2FThread_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R1610) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &LThreadTest_24FirstThread_3B_7Crun_7C_28_29V public virtual (var %_this <* <$LThreadTest_24FirstThread_3B>>) void {
  funcid 48157
  var %Reg4_R43700 <* <$LThreadTest_24FirstThread_3B>>
  var %Reg0_J i64
  var %Reg1_J i64
  var %Reg0_I i32
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg1_I i32

  dassign %Reg4_R43700 0 (dread ref %_this)
@label2   #INSTIDX : 0||0000:  getstatic
  intrinsiccallwithtype <$LThreadTest_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_J 0 (dread i64 $LThreadTest_3B_7Cflag)
  #INSTIDX : 3||0003:  ldc2_w
  dassign %Reg1_J 0 (constval i64 0x7fffffffffffffff)
  #INSTIDX : 6||0006:  lcmp
  dassign %Reg0_I 0 (cmp i32 i64 (dread i64 %Reg0_J, dread i64 %Reg1_J))
  #INSTIDX : 7||0007:  ifeq
  brtrue @label3 (eq i32 i32 (dread i32 %Reg0_I, constval i32 0))
  #INSTIDX : 10||000a:  goto
  goto @label2
@label3   #INSTIDX : 13||000d:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 16||0010:  getstatic
  intrinsiccallwithtype <$LThreadTest_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg1_I 0 (dread i32 $LThreadTest_3B_7Cnumber)
  #INSTIDX : 19||0013:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28I_29V (dread ref %Reg0_R562, dread i32 %Reg1_I) {}
  #INSTIDX : 22||0016:  return
  return ()
}
func &LThreadTest_24SecondThread_3B_7C_3Cinit_3E_7C_28_29V constructor (var %_this <* <$LThreadTest_24SecondThread_3B>>) void {
  funcid 48158
  var %Reg1_R43702 <* <$LThreadTest_24SecondThread_3B>>
  var %Reg1_R1610 <* <$Ljava_2Flang_2FThread_3B>>

  dassign %Reg1_R43702 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R1610 0 (retype ref <* <$Ljava_2Flang_2FThread_3B>> (dread ref %Reg1_R43702))
  callassigned &Ljava_2Flang_2FThread_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R1610) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &LThreadTest_24SecondThread_3B_7Crun_7C_28_29V public virtual (var %_this <* <$LThreadTest_24SecondThread_3B>>) void {
  funcid 48159
  var %Reg2_R43702 <* <$LThreadTest_24SecondThread_3B>>
  var %Reg0_I i32
  var %Reg0_J i64

  dassign %Reg2_R43702 0 (dread ref %_this)
  #INSTIDX : 0||0000:  bipush
  dassign %Reg0_I 0 (constval i32 42)
  #INSTIDX : 2||0002:  putstatic
  intrinsiccallwithtype <$LThreadTest_3B> JAVA_CLINIT_CHECK ()
  dassign $LThreadTest_3B_7Cnumber 0 (dread i32 %Reg0_I)
  #INSTIDX : 5||0005:  ldc2_w
  dassign %Reg0_J 0 (constval i64 0x7fffffffffffffff)
  #INSTIDX : 8||0008:  putstatic
  intrinsiccallwithtype <$LThreadTest_3B> JAVA_CLINIT_CHECK ()
  dassign $LThreadTest_3B_7Cflag 0 (dread i64 %Reg0_J)
  #INSTIDX : 11||000b:  return
  return ()
}