Created
June 8, 2020 20:45
-
-
Save godmar/688fd256a64e7eb954de7bee1194e539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:objd/core.dart'; | |
class SummonOnlyOnce extends Widget { | |
Condition preCondition; | |
Summon summon; | |
String randomtag; | |
SummonOnlyOnce(Condition this.preCondition, Summon this.summon) { | |
this.randomtag = 'F3AAEC1'; // XXX: find out how to make random tag in dart | |
} | |
@override | |
Widget generate(Context context) { | |
this.summon.nbt["Tags"] = [ this.randomtag ]; | |
return If(Condition.and([this.preCondition, | |
Condition.not(Entity(tags: [this.randomtag])) | |
]), | |
then: [ | |
this.summon | |
]); | |
} | |
} | |
main() { | |
createProject(Project( | |
name: "demo1", | |
target: "../", | |
generate: Pack( | |
name: "objd", | |
load: File("setuptitle", | |
child: For.of([If( | |
Condition.and([ | |
Condition.block(Location.glob(x:20, y:15, z:-2412), | |
block: Blocks.grass_path), | |
Condition.not(Entity(tags: ['F3AAEC1'])) | |
]), | |
then: [ | |
Summon(Entities.area_effect_cloud, | |
location: Location('20 16.65 -2412'), | |
name: TextComponent('testing', color: Color.White), | |
nbt: { | |
"Tags": ["F3AAEC1"], | |
"Duration": 2147483647, | |
"CustomNameVisible": true | |
}) | |
]), | |
SummonOnlyOnce(Condition.block(Location.glob(x:20, y:15, z:-2412), | |
block: Blocks.grass_path), | |
Summon(Entities.area_effect_cloud, | |
location: Location('20 16.65 -2412'), | |
name: TextComponent('testing', color: Color.White), | |
nbt: { | |
"Duration": 2147483647, | |
"CustomNameVisible": true | |
}) | |
) | |
]))))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment