Skip to content
This repository was archived by the owner on Aug 16, 2020. It is now read-only.

Commit b9f64cc

Browse files
committedApr 29, 2020
🐛 Fix not supporting new advancement format
1 parent 8a96dfd commit b9f64cc

File tree

3 files changed

+425
-33
lines changed

3 files changed

+425
-33
lines changed
 

‎playground/advancements/test.json

+27-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
"c": {
77
"trigger": "minecraft:placed_block",
88
"conditions": {
9-
"block": "minecraft:acacia_button"
9+
"block": "minecraft:acacia_button",
10+
"player": [
11+
{
12+
"condition": "minecraft:random_chance",
13+
"chance": 1
14+
}
15+
]
1016
}
1117
},
1218
"c2": {
@@ -19,6 +25,25 @@
1925
"dealt": 1
2026
}
2127
}
28+
},
29+
"c3": {
30+
"trigger": "minecraft:bred_animals",
31+
"conditions": {
32+
"player": [
33+
{
34+
"condition": "minecraft:entity_scores",
35+
"entity": "this",
36+
"scores": {
37+
"foo": {
38+
"min": 1
39+
}
40+
}
41+
}
42+
]
43+
}
44+
},
45+
"c4": {
46+
"trigger": "minecraft:tick"
2247
}
2348
}
24-
}
49+
}

‎src/advancement.json

+389-29
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,51 @@
157157
"properties": {
158158
"trigger": {
159159
"type": "string"
160+
},
161+
"conditions": {
162+
"player": {
163+
"$ref": "#/definitions/entity_conditions"
164+
}
160165
}
161166
},
162167
"required": [
163168
"trigger"
164169
],
165170
"type": "object",
166171
"oneOf": [
172+
{
173+
"additionalProperties": false,
174+
"properties": {
175+
"trigger": {
176+
"type": "string",
177+
"enum": [
178+
"minecraft:bee_nest_destroyed"
179+
],
180+
"title": "Destroyed bee nest",
181+
"description": "This criteria will be checked whenever the player changes dimension (such as by going through a portal)"
182+
},
183+
"conditions": {
184+
"type": "object",
185+
"additionalProperties": false,
186+
"title": "Required conditions",
187+
"description": "All of these conditions must pass for the criteria to be activated",
188+
"properties": {
189+
"player": {
190+
"$ref": "#/definitions/entity_conditions"
191+
},
192+
"block": {
193+
"type": "string"
194+
},
195+
"item": {
196+
"$ref": "./shared/predicate.json#/definitions/item"
197+
},
198+
"num_bees_inside": {
199+
"type": "number"
200+
}
201+
}
202+
}
203+
}
204+
},
167205
{
168206
"additionalProperties": false,
169207
"properties": {
@@ -181,18 +219,42 @@
181219
"title": "Required conditions",
182220
"description": "All of these conditions must pass for the criteria to be activated",
183221
"properties": {
222+
"player": {
223+
"$ref": "#/definitions/entity_conditions"
224+
},
184225
"parent": {
185-
"$ref": "./shared/predicate.json#/definitions/entity",
186226
"title": "Conditions to test against either of the parents",
187-
"description": "Using both parent and partner is only useful when using horses/donkeys"
227+
"description": "Using both parent and partner is only useful when using horses/donkeys",
228+
"oneOf": [
229+
{
230+
"$ref": "./shared/predicate.json#/definitions/entity"
231+
},
232+
{
233+
"$ref": "#/definitions/entity_conditions"
234+
}
235+
]
188236
},
189237
"partner": {
190-
"$ref": "./shared/predicate.json#/definitions/entity",
191-
"title": "Conditions to test against either of the parents"
238+
"title": "Conditions to test against either of the parents",
239+
"oneOf": [
240+
{
241+
"$ref": "./shared/predicate.json#/definitions/entity"
242+
},
243+
{
244+
"$ref": "#/definitions/entity_conditions"
245+
}
246+
]
192247
},
193248
"child": {
194-
"$ref": "./shared/predicate.json#/definitions/entity",
195-
"title": "Conditions to test against the child entity"
249+
"title": "Conditions to test against the child entity",
250+
"oneOf": [
251+
{
252+
"$ref": "./shared/predicate.json#/definitions/entity"
253+
},
254+
{
255+
"$ref": "#/definitions/entity_conditions"
256+
}
257+
]
196258
}
197259
}
198260
}
@@ -215,6 +277,9 @@
215277
"description": "All of these conditions must pass for the criteria to be activated",
216278
"type": "object",
217279
"properties": {
280+
"player": {
281+
"$ref": "#/definitions/entity_conditions"
282+
},
218283
"potion": {
219284
"type": "string",
220285
"parser": "Identity",
@@ -244,6 +309,9 @@
244309
"title": "Required conditions",
245310
"description": "All of these conditions must pass for the criteria to be activated",
246311
"properties": {
312+
"player": {
313+
"$ref": "#/definitions/entity_conditions"
314+
},
247315
"to": {
248316
"type": "string",
249317
"parser": "Identity",
@@ -264,6 +332,41 @@
264332
}
265333
}
266334
},
335+
{
336+
"additionalProperties": false,
337+
"properties": {
338+
"trigger": {
339+
"type": "string",
340+
"enum": [
341+
"minecraft:channeled_lightning"
342+
]
343+
},
344+
"conditions": {
345+
"type": "object",
346+
"additionalProperties": false,
347+
"title": "Required conditions",
348+
"description": "All of these conditions must pass for the criteria to be activated",
349+
"properties": {
350+
"player": {
351+
"$ref": "#/definitions/entity_conditions"
352+
},
353+
"victims": {
354+
"type": "array",
355+
"items": {
356+
"oneOf": [
357+
{
358+
"$ref": "./shared/predicate.json#/definitions/entity"
359+
},
360+
{
361+
"$ref": "#/definitions/entity_conditions"
362+
}
363+
]
364+
}
365+
}
366+
}
367+
}
368+
}
369+
},
267370
{
268371
"additionalProperties": false,
269372
"properties": {
@@ -281,6 +384,9 @@
281384
"title": "Required conditions",
282385
"description": "All of these conditions must pass for the criteria to be activated",
283386
"properties": {
387+
"player": {
388+
"$ref": "#/definitions/entity_conditions"
389+
},
284390
"level": {
285391
"$ref": "./shared/range.json",
286392
"title": "The beacon level"
@@ -307,6 +413,9 @@
307413
"description": "All of these conditions must pass for the criteria to be activated",
308414
"type": "object",
309415
"properties": {
416+
"player": {
417+
"$ref": "#/definitions/entity_conditions"
418+
},
310419
"item": {
311420
"$ref": "./shared/predicate.json#/definitions/item",
312421
"title": "Item",
@@ -333,13 +442,30 @@
333442
"description": "All of these conditions must pass for the criteria to be activated",
334443
"type": "object",
335444
"properties": {
445+
"player": {
446+
"$ref": "#/definitions/entity_conditions"
447+
},
336448
"zombie": {
337-
"$ref": "./shared/predicate.json#/definitions/entity",
338-
"title": "Information about the zombie villager"
449+
"title": "Information about the zombie villager",
450+
"oneOf": [
451+
{
452+
"$ref": "./shared/predicate.json#/definitions/entity"
453+
},
454+
{
455+
"$ref": "#/definitions/entity_conditions"
456+
}
457+
]
339458
},
340459
"villager": {
341-
"$ref": "./shared/predicate.json#/definitions/entity",
342-
"title": "Information about villager cured into"
460+
"title": "Information about villager cured into",
461+
"oneOf": [
462+
{
463+
"$ref": "./shared/predicate.json#/definitions/entity"
464+
},
465+
{
466+
"$ref": "#/definitions/entity_conditions"
467+
}
468+
]
343469
}
344470
}
345471
}
@@ -362,6 +488,9 @@
362488
"description": "All of these conditions must pass for the criteria to be activated",
363489
"type": "object",
364490
"properties": {
491+
"player": {
492+
"$ref": "#/definitions/entity_conditions"
493+
},
365494
"effects": {
366495
"$ref": "./shared/predicate.json#/definitions/effect",
367496
"title": "The potion effects of the player"
@@ -387,6 +516,9 @@
387516
"description": "All of these conditions must pass for the criteria to be activated",
388517
"type": "object",
389518
"properties": {
519+
"player": {
520+
"$ref": "#/definitions/entity_conditions"
521+
},
390522
"item": {
391523
"$ref": "./shared/predicate.json#/definitions/item",
392524
"title": "The item enchanted"
@@ -411,10 +543,18 @@
411543
"description": "This criteria will be checked whenever the player moves"
412544
},
413545
"conditions": {
414-
"additionalProperties": false,
415546
"title": "The block to check",
416547
"description": "The block which was entered to check the trigger",
417-
"$ref": "./shared/predicate.json#/definitions/block"
548+
"allOf": [
549+
{
550+
"$ref": "./shared/predicate.json#/definitions/block"
551+
}
552+
],
553+
"properties": {
554+
"player": {
555+
"$ref": "#/definitions/entity_conditions"
556+
}
557+
}
418558
}
419559
}
420560
},
@@ -435,6 +575,9 @@
435575
"description": "All of these conditions must pass for the criteria to be activated",
436576
"type": "object",
437577
"properties": {
578+
"player": {
579+
"$ref": "#/definitions/entity_conditions"
580+
},
438581
"damage": {
439582
"$ref": "./shared/predicate.json#/definitions/damage",
440583
"title": "The damage taken"
@@ -460,12 +603,22 @@
460603
"description": "All of these conditions must pass for the criteria to be activated",
461604
"type": "object",
462605
"properties": {
606+
"player": {
607+
"$ref": "#/definitions/entity_conditions"
608+
},
463609
"damage": {
464610
"$ref": "./shared/predicate.json#/definitions/damage",
465611
"title": "The damage taken"
466612
},
467613
"entity": {
468-
"$ref": "./shared/predicate.json#/definitions/entity"
614+
"oneOf": [
615+
{
616+
"$ref": "./shared/predicate.json#/definitions/entity"
617+
},
618+
{
619+
"$ref": "#/definitions/entity_conditions"
620+
}
621+
]
469622
}
470623
}
471624
}
@@ -484,10 +637,18 @@
484637
"description": "This criteria will be checked whenever the player kills or is killed by an entity"
485638
},
486639
"conditions": {
487-
"additionalProperties": false,
488640
"title": "The death object",
489641
"description": "The conditions object is a direct reference to a death object",
490-
"$ref": "./shared/predicate.json#/definitions/death"
642+
"allOf": [
643+
{
644+
"$ref": "./shared/predicate.json#/definitions/death"
645+
}
646+
],
647+
"properties": {
648+
"player": {
649+
"$ref": "#/definitions/entity_conditions"
650+
}
651+
}
491652
}
492653
}
493654
},
@@ -497,11 +658,99 @@
497658
"trigger": {
498659
"type": "string",
499660
"enum": [
500-
"minecraft:impossible",
501-
"minecraft:tick"
661+
"minecraft:filled_bucket"
662+
]
663+
},
664+
"conditions": {
665+
"type": "object",
666+
"additionalProperties": false,
667+
"title": "Required conditions",
668+
"description": "All of these conditions must pass for the criteria to be activated",
669+
"properties": {
670+
"player": {
671+
"$ref": "#/definitions/entity_conditions"
672+
},
673+
"item": {
674+
"$ref": "./shared/predicate.json#/definitions/item"
675+
}
676+
}
677+
}
678+
}
679+
},
680+
{
681+
"additionalProperties": false,
682+
"properties": {
683+
"trigger": {
684+
"type": "string",
685+
"enum": [
686+
"minecraft:fishing_rod_hooked"
687+
]
688+
},
689+
"conditions": {
690+
"type": "object",
691+
"additionalProperties": false,
692+
"title": "Required conditions",
693+
"description": "All of these conditions must pass for the criteria to be activated",
694+
"properties": {
695+
"player": {
696+
"$ref": "#/definitions/entity_conditions"
697+
},
698+
"entity": {
699+
"oneOf": [
700+
{
701+
"$ref": "./shared/predicate.json#/definitions/entity"
702+
},
703+
{
704+
"$ref": "#/definitions/entity_conditions"
705+
}
706+
]
707+
},
708+
"item": {
709+
"$ref": "./shared/predicate.json#/definitions/item"
710+
},
711+
"rod": {
712+
"$ref": "./shared/predicate.json#/definitions/item"
713+
}
714+
}
715+
}
716+
}
717+
},
718+
{
719+
"additionalProperties": false,
720+
"properties": {
721+
"trigger": {
722+
"type": "string",
723+
"enum": [
724+
"minecraft:hero_of_the_village"
725+
]
726+
},
727+
"conditions": {
728+
"type": "object",
729+
"title": "Required conditions",
730+
"description": "All of these conditions must pass for the criteria to be activated",
731+
"allOf": [
732+
{
733+
"$ref": "./shared/predicate.json#/definitions/location"
734+
}
502735
],
503-
"title": "Conditionless criteria",
504-
"description": "The impossible trigger can be only granted with a command, the tick trigger is given once each tick"
736+
"properties": {
737+
"player": {
738+
"$ref": "#/definitions/entity_conditions"
739+
}
740+
}
741+
}
742+
}
743+
},
744+
{
745+
"additionalProperties": false,
746+
"properties": {
747+
"trigger": {
748+
"type": "string",
749+
"enum": [
750+
"minecraft:impossible"
751+
],
752+
"title": "Impossible trigger",
753+
"description": "The impossible trigger can be only granted with a command"
505754
}
506755
}
507756
},
@@ -522,6 +771,9 @@
522771
"description": "All of these conditions must pass for the criteria to be activated",
523772
"type": "object",
524773
"properties": {
774+
"player": {
775+
"$ref": "#/definitions/entity_conditions"
776+
},
525777
"slots": {
526778
"additionalProperties": false,
527779
"properties": {
@@ -569,6 +821,9 @@
569821
"description": "All of these conditions must pass for the criteria to be activated",
570822
"type": "object",
571823
"properties": {
824+
"player": {
825+
"$ref": "#/definitions/entity_conditions"
826+
},
572827
"item": {
573828
"$ref": "./shared/predicate.json#/definitions/item",
574829
"title": "The item",
@@ -604,6 +859,9 @@
604859
"description": "All of these conditions must pass for the criteria to be activated",
605860
"type": "object",
606861
"properties": {
862+
"player": {
863+
"$ref": "#/definitions/entity_conditions"
864+
},
607865
"duration": {
608866
"$ref": "./shared/range.json",
609867
"title": "Time applied",
@@ -630,10 +888,18 @@
630888
"description": "This criteria will be checked whenever the player sleeps (for \"slept_in_bed\"), or once every 20 ticks (\"location\")"
631889
},
632890
"conditions": {
633-
"additionalProperties": false,
634891
"title": "Location of the player",
635892
"description": "The location of the player at the time of checking (for \"slept_in_bed\" this is just after they went to sleep)",
636-
"$ref": "./shared/predicate.json#/definitions/location"
893+
"allOf": [
894+
{
895+
"$ref": "./shared/predicate.json#/definitions/location"
896+
}
897+
],
898+
"properties": {
899+
"player": {
900+
"$ref": "#/definitions/entity_conditions"
901+
}
902+
}
637903
}
638904
}
639905
},
@@ -653,6 +919,9 @@
653919
"description": "All of these conditions must pass for the criteria to be activated",
654920
"type": "object",
655921
"properties": {
922+
"player": {
923+
"$ref": "#/definitions/entity_conditions"
924+
},
656925
"entered": {
657926
"$ref": "./shared/predicate.json#/definitions/location",
658927
"title": "Entering the nether",
@@ -684,7 +953,6 @@
684953
"description": "This criteria will be checked whenever the player places a block"
685954
},
686955
"conditions": {
687-
"additionalProperties": false,
688956
"title": "Required conditions",
689957
"description": "The placed block",
690958
"allOf": [
@@ -703,8 +971,9 @@
703971
"title": "Location of block",
704972
"description": "The location at which the block is placed"
705973
},
706-
"block": {},
707-
"state": {}
974+
"player": {
975+
"$ref": "#/definitions/entity_conditions"
976+
}
708977
}
709978
}
710979
}
@@ -726,6 +995,9 @@
726995
"description": "All of these conditions must pass for the criteria to be activated",
727996
"type": "object",
728997
"properties": {
998+
"player": {
999+
"$ref": "#/definitions/entity_conditions"
1000+
},
7291001
"recipe": {
7301002
"type": "string",
7311003
"title": "The name of the recipe",
@@ -753,14 +1025,81 @@
7531025
"description": "All of these conditions must pass for the criteria to be activated",
7541026
"type": "object",
7551027
"properties": {
1028+
"player": {
1029+
"$ref": "#/definitions/entity_conditions"
1030+
},
7561031
"entity": {
757-
"$ref": "./shared/predicate.json#/definitions/entity",
758-
"title": "The entity summmoned"
1032+
"title": "The entity summmoned",
1033+
"oneOf": [
1034+
{
1035+
"$ref": "./shared/predicate.json#/definitions/entity"
1036+
},
1037+
{
1038+
"$ref": "#/definitions/entity_conditions"
1039+
}
1040+
]
7591041
}
7601042
}
7611043
}
7621044
}
7631045
},
1046+
{
1047+
"additionalProperties": false,
1048+
"properties": {
1049+
"trigger": {
1050+
"type": "string",
1051+
"enum": [
1052+
"minecraft:target_hit‌"
1053+
]
1054+
},
1055+
"conditions": {
1056+
"type": "object",
1057+
"additionalProperties": false,
1058+
"title": "Required conditions",
1059+
"description": "All of these conditions must pass for the criteria to be activated",
1060+
"properties": {
1061+
"player": {
1062+
"$ref": "#/definitions/entity_conditions"
1063+
},
1064+
"signal_strength": {
1065+
"type": "integer"
1066+
},
1067+
"projectile": {
1068+
"oneOf": [
1069+
{
1070+
"$ref": "./shared/predicate.json#/definitions/entity"
1071+
},
1072+
{
1073+
"$ref": "#/definitions/entity_conditions"
1074+
}
1075+
]
1076+
},
1077+
"shooter": {
1078+
"$ref": "./shared/predicate.json#/definitions/entity"
1079+
}
1080+
}
1081+
}
1082+
}
1083+
},
1084+
{
1085+
"additionalProperties": false,
1086+
"properties": {
1087+
"trigger": {
1088+
"type": "string",
1089+
"enum": [
1090+
"minecraft:tick"
1091+
],
1092+
"title": "Conditionless criteria",
1093+
"description": "The tick trigger is given once each tick"
1094+
},
1095+
"conditions": {
1096+
"additionalProperties": false,
1097+
"player": {
1098+
"$ref": "#/definitions/entity_conditions"
1099+
}
1100+
}
1101+
}
1102+
},
7641103
{
7651104
"additionalProperties": false,
7661105
"properties": {
@@ -778,6 +1117,9 @@
7781117
"description": "All of these conditions must pass for the criteria to be activated",
7791118
"type": "object",
7801119
"properties": {
1120+
"player": {
1121+
"$ref": "#/definitions/entity_conditions"
1122+
},
7811123
"distance": {
7821124
"$ref": "./shared/range.json",
7831125
"title": "Distance from player to stronghold",
@@ -804,9 +1146,19 @@
8041146
"description": "All of these conditions must pass for the criteria to be activated",
8051147
"type": "object",
8061148
"properties": {
1149+
"player": {
1150+
"$ref": "#/definitions/entity_conditions"
1151+
},
8071152
"villager": {
808-
"$ref": "./shared/predicate.json#/definitions/entity",
809-
"title": "The villager traded with"
1153+
"title": "The villager traded with",
1154+
"oneOf": [
1155+
{
1156+
"$ref": "./shared/predicate.json#/definitions/entity"
1157+
},
1158+
{
1159+
"$ref": "#/definitions/entity_conditions"
1160+
}
1161+
]
8101162
},
8111163
"item": {
8121164
"$ref": "./shared/predicate.json#/definitions/item",
@@ -817,6 +1169,14 @@
8171169
}
8181170
}
8191171
]
1172+
},
1173+
"entity_conditions": {
1174+
"type": "array",
1175+
"title": "Conditions",
1176+
"description": "The conditions that the entity must pass",
1177+
"items": {
1178+
"$ref": "./predicate.json"
1179+
}
8201180
}
8211181
}
822-
}
1182+
}

‎src/shared/predicate.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,15 @@
9393
"properties": {
9494
"entity": {
9595
"$ref": "#/definitions/entity",
96-
"title": "The entity which died"
96+
"title": "The entity which died",
97+
"oneOf": [
98+
{
99+
"$ref": "#/definitions/entity"
100+
},
101+
{
102+
"$ref": "../advancement.json#/definitions/entity_conditions"
103+
}
104+
]
97105
},
98106
"killing_blow": {
99107
"$ref": "#/definitions/damage_flags",
@@ -484,7 +492,6 @@
484492
},
485493
"location": {
486494
"type": "object",
487-
"additionalProperties": false,
488495
"properties": {
489496
"biome": {
490497
"title": "The biome the location is in",

0 commit comments

Comments
 (0)
This repository has been archived.