## Condition The Condition class defines conditions for the if widget and more. It can also combines conditions and generates an argument list. |constructor| | |--|--| |dynamic|the thing you want to test| Well it is not as easy as it looks. A condition can accept many values and this makes the Condition very complex. | The argument can be a... | and generates e.g || |--|--|--| | Block | if block ~ ~ ~ minecraft:stone |To test a specific location use Condition.block| | Entity | if entity @s | | Score | if score @s objective matches 5| Attention! This needs a score condition method! | Tag | if entity @s[tag=test] | turns a tag into an entity | | Location | unless block ~ ~2 ~ air | Just checks whether a block is present | Condition | if entity @s if block ~ ~ ~ stone | Yes, you can nest Conditions like Widgets and combine them. **Examples:** ```dart If( Condition( Entity.Selected() ) ,Then:[Log('entity')], ) ⇒ execute if entity @s run say entity If( Condition( Location.here() ), Then:[Say('block')], ) ⇒ execute unless block ~ ~ ~ minecraft:air run say block If.not( Condition( Score( Entity.PlayerName("Stevertus"), "objective" ).matches(10) ), Then:[Say('score')], ) ⇒ execute unless score Stevertus objective matches 10 run say score ``` For Score, Block and Entity there is also a named constructor along with: |Condition.blocks| | |--|--| |Area| the Area of blocks that you want to compare | |compare| the lowest comparison Location of the area of the same size | **Condition.block**: also requires a block type: ```dart If( Condition.block( Location.here(), block: Block.stone ), Then:[Say('stone')], ) ⇒ execute if block ~ ~ ~ minecraft:stone run say stone ``` **Condition.not**: accepts same dynamic condition types as above but negates them (if ⇒ unless, unless ⇒ if) **Condition.and**: accepts a list of dynamic condition types, that all have to be true to trigger: ```dart If( Condition.and([ Location.here(), Entity(), Condition(...) ]), Then:[Say('true')], ) ⇒ execute unless block ~ ~ ~ minecraft:air if entity @e if ... run say true ``` **Condition.or**: accepts a list of dynamic condition types, but just one has to be true to trigger: ```dart If( Condition.or([ Location.here(), Entity(), Condition(...) ]), Then:[Say('true')], ) ⇒ execute unless block ~ ~ ~ minecraft:air run tag @p add objd_isTrue1 ⇒ execute if entity @e run tag @p add objd_isTrue1 ⇒ execute if ... run tag @p add objd_isTrue1 ⇒ execute as @p if entity @s[tag=objd_isTrue1] run say true ⇒ tag @p remove objd_isTrue1 ``` > Just temporary, will be done with tags later... With this knowledge we can build pretty complex logical conditions: ```dart If.not( Condition.and([ Condition.not(Entity.Player()), Condition.or([ Entity.Random(), Condition.blocks( Area(x1: 0, y1: 0, z1: 0, x2: 10, y2: 10, z2: 10), compare: Location('~ ~ ~'), ), Condition.not( Condition.score( Score(Entity.Selected(),"test") .matchesRange(Range(from:0,to:5)) ), ), ]), ]), Then: [Say("I'm done")] ) ⇒ execute if entity @p unless entity @r run tag @p add objd_isTrue1 execute if entity @p unless blocks 0 0 0 10 10 10 ~ ~ ~ run tag @p add objd_isTrue1 execute if entity @p if score @s test matches 0..5 run tag @p add objd_isTrue1 execute as @p if entity @s[tag=objd_isTrue1] run say I'm done tag @p remove objd_isTrue1 ```