-
-
Notifications
You must be signed in to change notification settings - Fork 147
/
TestWorkspaceDataProvider.java
1946 lines (1860 loc) · 98.4 KB
/
TestWorkspaceDataProvider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* MCreator (https://mcreator.net/)
* Copyright (C) 2012-2020, Pylo
* Copyright (C) 2020-2023, Pylo, opensource contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.mcreator.integration;
import net.mcreator.element.GeneratableElement;
import net.mcreator.element.ModElementType;
import net.mcreator.element.parts.Particle;
import net.mcreator.element.parts.*;
import net.mcreator.element.parts.gui.Button;
import net.mcreator.element.parts.gui.Checkbox;
import net.mcreator.element.parts.gui.Image;
import net.mcreator.element.parts.gui.Label;
import net.mcreator.element.parts.gui.TextField;
import net.mcreator.element.parts.gui.*;
import net.mcreator.element.parts.procedure.Procedure;
import net.mcreator.element.parts.procedure.*;
import net.mcreator.element.types.Dimension;
import net.mcreator.element.types.Enchantment;
import net.mcreator.element.types.Fluid;
import net.mcreator.element.types.*;
import net.mcreator.element.types.interfaces.IBlockWithBoundingBox;
import net.mcreator.generator.GeneratorStats;
import net.mcreator.io.FileIO;
import net.mcreator.minecraft.*;
import net.mcreator.ui.dialogs.wysiwyg.AbstractWYSIWYGDialog;
import net.mcreator.ui.minecraft.states.PropertyData;
import net.mcreator.ui.minecraft.states.PropertyDataWithValue;
import net.mcreator.ui.minecraft.states.StateMap;
import net.mcreator.ui.modgui.ItemGUI;
import net.mcreator.ui.modgui.LivingEntityGUI;
import net.mcreator.ui.workspace.resources.TextureType;
import net.mcreator.util.StringUtils;
import net.mcreator.util.image.EmptyIcon;
import net.mcreator.workspace.Workspace;
import net.mcreator.workspace.elements.*;
import java.awt.*;
import java.awt.image.RenderedImage;
import java.io.File;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
public class TestWorkspaceDataProvider {
private static ModElement me(Workspace workspace, ModElementType<?> type, String suffix) {
return new ModElement(workspace, "Example" + type.getRegistryName() + suffix, type);
}
public static List<GeneratableElement> getModElementExamplesFor(Workspace workspace, ModElementType<?> type,
boolean uiTest, Random random) {
List<GeneratableElement> generatableElements = new ArrayList<>();
if (type == ModElementType.RECIPE) {
generatableElements.add(getRecipeExample(me(workspace, type, "1"), "Crafting", random, true));
generatableElements.add(getRecipeExample(me(workspace, type, "2"), "Crafting", random, false));
generatableElements.add(getRecipeExample(me(workspace, type, "3"), "Smelting", random, true));
generatableElements.add(getRecipeExample(me(workspace, type, "4"), "Blasting", random, true));
generatableElements.add(getRecipeExample(me(workspace, type, "5"), "Smoking", random, true));
generatableElements.add(getRecipeExample(me(workspace, type, "6"), "Stone cutting", random, true));
generatableElements.add(getRecipeExample(me(workspace, type, "7"), "Campfire cooking", random, true));
generatableElements.add(getRecipeExample(me(workspace, type, "8"), "Smithing", random, true));
generatableElements.add(getRecipeExample(me(workspace, type, "9"), "Brewing", random, true));
} else if (type == ModElementType.TOOL) {
generatableElements.add(getToolExample(me(workspace, type, "1"), "Pickaxe", random, false, false));
generatableElements.add(getToolExample(me(workspace, type, "2"), "Pickaxe", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "3"), "Pickaxe", random, false, true));
generatableElements.add(getToolExample(me(workspace, type, "4"), "Pickaxe", random, true, true));
generatableElements.add(getToolExample(me(workspace, type, "5"), "Axe", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "6"), "Sword", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "7"), "Spade", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "8"), "Hoe", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "9"), "Special", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "10"), "MultiTool", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "11"), "Shears", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "12"), "Fishing rod", random, true, false));
generatableElements.add(getToolExample(me(workspace, type, "13"), "Shield", random, true, false));
} else if (type == ModElementType.TAB) {
generatableElements.add(getExampleFor(me(workspace, type, "1"), uiTest, random, true, true, 0));
generatableElements.add(getExampleFor(me(workspace, type, "2"), uiTest, random, true, false, 1));
} else if (type == ModElementType.COMMAND) {
generatableElements.add(getCommandExample(me(workspace, type, "1"), "STANDARD", random));
generatableElements.add(getCommandExample(me(workspace, type, "2"), "SINGLEPLAYER_ONLY", random));
generatableElements.add(getCommandExample(me(workspace, type, "3"), "MULTIPLAYER_ONLY", random));
generatableElements.add(getCommandExample(me(workspace, type, "4"), "CLIENTSIDE", random));
} else if (type == ModElementType.FUNCTION || type == ModElementType.PAINTING || type == ModElementType.KEYBIND
|| type == ModElementType.PROCEDURE || type == ModElementType.FEATURE || type == ModElementType.CODE) {
generatableElements.add(
getExampleFor(new ModElement(workspace, "Example" + type.getRegistryName(), type), uiTest, random,
true, true, 0));
} else {
generatableElements.add(getExampleFor(me(workspace, type, "1"), uiTest, random, true, true, 0));
generatableElements.add(getExampleFor(me(workspace, type, "2"), uiTest, random, true, false, 1));
generatableElements.add(getExampleFor(me(workspace, type, "3"), uiTest, random, false, true, 2));
generatableElements.add(getExampleFor(me(workspace, type, "4"), uiTest, random, false, false, 3));
generatableElements.add(getExampleFor(me(workspace, type, "5"), uiTest, random, true, true, 3));
generatableElements.add(getExampleFor(me(workspace, type, "6"), uiTest, random, true, false, 2));
generatableElements.add(getExampleFor(me(workspace, type, "7"), uiTest, random, false, true, 1));
generatableElements.add(getExampleFor(me(workspace, type, "8"), uiTest, random, false, false, 0));
}
generatableElements.removeAll(Collections.singleton(null));
return generatableElements;
}
public static void fillWorkspaceWithTestData(Workspace workspace) {
if (workspace.getGeneratorStats().getBaseCoverageInfo().get("sounds") == GeneratorStats.CoverageStatus.FULL) {
for (int i = 1; i <= 3; i++) {
SoundElement sound = new SoundElement("test" + i, List.of(), "neutral", null);
workspace.addSoundElement(sound);
}
}
if (workspace.getGeneratorStats().getBaseCoverageInfo().get("tags") == GeneratorStats.CoverageStatus.FULL) {
TagElement tag = new TagElement(TagType.ITEMS, "minecraft:test");
workspace.addTagElement(tag);
workspace.getTagElements().get(tag).add("minecraft:stone");
workspace.getTagElements().get(tag).add("~minecraft:dirt");
tag = new TagElement(TagType.BLOCKS, "minecraft:test");
workspace.addTagElement(tag);
workspace.getTagElements().get(tag).add("minecraft:stone");
workspace.getTagElements().get(tag).add("~minecraft:dirt");
tag = new TagElement(TagType.ENTITIES, "minecraft:test");
workspace.addTagElement(tag);
workspace.getTagElements().get(tag).add("minecraft:creeper");
workspace.getTagElements().get(tag).add("~minecraft:zombie");
tag = new TagElement(TagType.BIOMES, "minecraft:test");
workspace.addTagElement(tag);
workspace.getTagElements().get(tag).add("minecraft:plains");
workspace.getTagElements().get(tag).add("~testmod:testbiome");
tag = new TagElement(TagType.DAMAGE_TYPES, "minecraft:test");
workspace.addTagElement(tag);
workspace.getTagElements().get(tag).add("testmod:testdamage");
workspace.getTagElements().get(tag).add("~testmod:testdamage2");
}
if (workspace.getGeneratorStats().getBaseCoverageInfo().get("variables")
== GeneratorStats.CoverageStatus.FULL) {
VariableElement sampleVariable1 = new VariableElement("test");
sampleVariable1.setValue("true");
sampleVariable1.setType(VariableTypeLoader.BuiltInTypes.LOGIC);
sampleVariable1.setScope(VariableType.Scope.GLOBAL_WORLD);
workspace.addVariableElement(sampleVariable1);
int idx = 0;
for (VariableType.Scope scope : VariableType.Scope.values()) {
if (scope != VariableType.Scope.LOCAL) {
VariableElement variable = new VariableElement("logic" + (idx++));
variable.setValue("true");
variable.setType(VariableTypeLoader.BuiltInTypes.LOGIC);
variable.setScope(scope);
workspace.addVariableElement(variable);
}
}
idx = 0;
for (VariableType.Scope scope : VariableType.Scope.values()) {
if (scope != VariableType.Scope.LOCAL) {
VariableElement variable = new VariableElement("number" + (idx++));
variable.setValue("12");
variable.setType(VariableTypeLoader.BuiltInTypes.NUMBER);
variable.setScope(scope);
workspace.addVariableElement(variable);
}
}
idx = 0;
for (VariableType.Scope scope : VariableType.Scope.values()) {
if (scope != VariableType.Scope.LOCAL) {
VariableElement variable = new VariableElement("string" + (idx++));
variable.setValue("test");
variable.setType(VariableTypeLoader.BuiltInTypes.STRING);
variable.setScope(scope);
workspace.addVariableElement(variable);
}
}
idx = 0;
for (VariableType.Scope scope : VariableType.Scope.values()) {
if (scope != VariableType.Scope.LOCAL) {
VariableElement variable = new VariableElement("itemstack" + (idx++));
variable.setValue("ItemStack.EMPTY");
variable.setType(VariableTypeLoader.BuiltInTypes.ITEMSTACK);
variable.setScope(scope);
workspace.addVariableElement(variable);
}
}
idx = 0;
for (VariableType.Scope scope : VariableType.Scope.values()) {
if (scope != VariableType.Scope.LOCAL) {
VariableElement variable = new VariableElement("direction" + (idx++));
variable.setValue("UP");
variable.setType(VariableTypeLoader.BuiltInTypes.DIRECTION);
variable.setScope(scope);
workspace.addVariableElement(variable);
}
}
idx = 0;
for (VariableType.Scope scope : VariableType.Scope.values()) {
if (scope != VariableType.Scope.LOCAL) {
VariableElement variable = new VariableElement("blockstate" + (idx++));
variable.setValue("Blocks.AIR");
variable.setType(VariableTypeLoader.BuiltInTypes.BLOCKSTATE);
variable.setScope(scope);
workspace.addVariableElement(variable);
}
}
}
EmptyIcon.ImageIcon imageIcon = new EmptyIcon.ImageIcon(16, 16);
if (workspace.getFolderManager().getTexturesFolder(TextureType.BLOCK) != null) {
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test", TextureType.BLOCK));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test2", TextureType.BLOCK));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test3", TextureType.BLOCK));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test4", TextureType.BLOCK));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test5", TextureType.BLOCK));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test6", TextureType.BLOCK));
}
if (workspace.getFolderManager().getTexturesFolder(TextureType.ITEM) != null) {
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test", TextureType.ITEM));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test2", TextureType.ITEM));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test3", TextureType.ITEM));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test4", TextureType.ITEM));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("itest", TextureType.ITEM));
}
if (workspace.getFolderManager().getTexturesFolder(TextureType.OTHER) != null) {
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test", TextureType.OTHER));
}
if (workspace.getFolderManager().getTexturesFolder(TextureType.ENTITY) != null) {
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test", TextureType.ENTITY));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("entityTx1", TextureType.ENTITY));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("entityTx2", TextureType.ENTITY));
}
if (workspace.getFolderManager().getTexturesFolder(TextureType.EFFECT) != null) {
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("effect1", TextureType.EFFECT));
}
if (workspace.getFolderManager().getTexturesFolder(TextureType.PARTICLE) != null) {
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("particle1", TextureType.PARTICLE));
}
if (workspace.getFolderManager().getTexturesFolder(TextureType.SCREEN) != null) {
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("test", TextureType.SCREEN));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("picture1", TextureType.SCREEN));
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(),
workspace.getFolderManager().getTextureFile("picture2", TextureType.SCREEN));
}
if (workspace.getFolderManager().getTexturesFolder(TextureType.ARMOR) != null) {
File[] armorPars = workspace.getFolderManager().getArmorTextureFilesForName("armorTexture");
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(), armorPars[0]);
FileIO.writeImageToPNGFile((RenderedImage) imageIcon.getImage(), armorPars[1]);
}
if (workspace.getFolderManager().getStructuresDir() != null) {
FileIO.writeBytesToFile(new byte[0], new File(workspace.getFolderManager().getStructuresDir(), "test.nbt"));
FileIO.writeBytesToFile(new byte[0], new File(workspace.getFolderManager().getStructuresDir(), "test1.nbt"));
FileIO.writeBytesToFile(new byte[0], new File(workspace.getFolderManager().getStructuresDir(), "test2.nbt"));
FileIO.writeBytesToFile(new byte[0], new File(workspace.getFolderManager().getStructuresDir(), "test3.nbt"));
}
}
/**
* Provides list of GEs for tests
*
* @param modElement ME for this GE
* @param uiTest true if test is UI test and not generator test
* @return List of GEs for tests
*/
private static GeneratableElement getExampleFor(ModElement modElement, boolean uiTest, Random random, boolean _true,
boolean emptyLists, int valueIndex) {
List<MCItem> blocksAndItems = ElementUtil.loadBlocksAndItems(modElement.getWorkspace());
List<MCItem> blocksAndItemsAndTags = ElementUtil.loadBlocksAndItemsAndTags(modElement.getWorkspace());
List<MCItem> blocks = ElementUtil.loadBlocks(modElement.getWorkspace());
List<MCItem> blocksAndTags = ElementUtil.loadBlocksAndTags(modElement.getWorkspace());
List<DataListEntry> biomes = ElementUtil.loadAllBiomes(modElement.getWorkspace());
if (ModElementType.ADVANCEMENT.equals(modElement.getType())) {
Achievement achievement = new Achievement(modElement);
achievement.achievementName = "Test Achievement";
achievement.achievementDescription = "Description of it";
achievement.achievementIcon = new MItemBlock(modElement.getWorkspace(),
getRandomMCItem(random, blocksAndItems).getName());
achievement.achievementType = new String[] { "task", "goal", "challenge", "challenge" }[valueIndex];
achievement.parent = new AchievementEntry(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllAchievements(modElement.getWorkspace())));
achievement.announceToChat = _true;
achievement.showPopup = _true;
achievement.disableDisplay = !_true;
achievement.rewardXP = 14;
achievement.hideIfNotCompleted = !_true;
achievement.rewardFunction = "No function";
achievement.background = emptyLists ? "Default" : "test.png";
achievement.rewardLoot = new ArrayList<>();
if (!emptyLists) {
achievement.rewardLoot.add("ExampleLootTable1");
achievement.rewardLoot.add("ExampleLootTable2");
}
achievement.rewardRecipes = new ArrayList<>();
if (!emptyLists) {
achievement.rewardRecipes.add("ExampleRecipe1");
achievement.rewardRecipes.add("ExampleRecipe2");
}
achievement.triggerxml = "<xml xmlns=\"https://developers.google.com/blockly/xml\">"
+ "<block type=\"advancement_trigger\" deletable=\"false\" x=\"40\" y=\"80\"><next>"
+ "<block type=\"tick\"></block></next></block></xml>";
return achievement;
} else if (ModElementType.BIOME.equals(modElement.getType())) {
Biome biome = new Biome(modElement);
biome.name = modElement.getName();
biome.groundBlock = new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocks).getName());
biome.undergroundBlock = new MItemBlock(modElement.getWorkspace(),
getRandomMCItem(random, blocks).getName());
biome.underwaterBlock = new MItemBlock(modElement.getWorkspace(),
emptyLists ? "" : getRandomMCItem(random, blocks).getName());
biome.vanillaTreeType = getRandomItem(random,
new String[] { "Default", "Big trees", "Birch trees", "Savanna trees", "Mega pine trees",
"Mega spruce trees" });
biome.airColor = Color.red;
if (!emptyLists) {
biome.grassColor = Color.green;
biome.foliageColor = Color.magenta;
biome.waterColor = Color.blue;
biome.waterFogColor = Color.cyan;
}
biome.ambientSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
biome.moodSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
biome.moodSoundDelay = new int[] { 1, 266, 479, 393 }[valueIndex];
biome.additionsSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
biome.music = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
biome.spawnParticles = _true;
biome.particleToSpawn = new Particle(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllParticles(modElement.getWorkspace())));
biome.particlesProbability = 0.0123;
biome.treesPerChunk = new int[] { 0, 5, 10, 16 }[valueIndex];
biome.spawnShipwreck = _true;
biome.spawnShipwreckBeached = _true;
biome.oceanRuinType = getRandomItem(random, new String[] { "NONE", "COLD", "WARM" });
biome.spawnOceanMonument = !_true;
biome.spawnBuriedTreasure = !_true;
biome.spawnWoodlandMansion = _true;
biome.spawnJungleTemple = !_true;
biome.spawnDesertPyramid = !_true;
biome.spawnSwampHut = !_true;
biome.spawnIgloo = !_true;
biome.spawnPillagerOutpost = !_true;
biome.spawnStronghold = _true;
biome.spawnMineshaft = !_true;
biome.spawnMineshaftMesa = !_true;
biome.spawnNetherBridge = !_true;
biome.spawnNetherFossil = !_true;
biome.spawnBastionRemnant = !_true;
biome.spawnEndCity = !_true;
biome.spawnRuinedPortal = getRandomItem(random,
new String[] { "NONE", "STANDARD", "DESERT", "JUNGLE", "SWAMP", "MOUNTAIN", "OCEAN", "NETHER" });
biome.villageType = getRandomItem(random,
new String[] { "none", "desert", "plains", "savanna", "snowy", "taiga" });
biome.genTemperature = new Biome.ClimatePoint(0.1, 0.4);
biome.genHumidity = new Biome.ClimatePoint(-0.1, 0.4);
biome.genContinentalness = new Biome.ClimatePoint(-2.0, 2.0);
biome.genErosion = new Biome.ClimatePoint(0.4, 1.4);
biome.genWeirdness = new Biome.ClimatePoint(1.0, 1.1);
biome.rainingPossibility = 1.1;
biome.temperature = 2.1;
List<Biome.SpawnEntry> entities = new ArrayList<>();
if (!emptyLists) {
Biome.SpawnEntry entry1 = new Biome.SpawnEntry();
entry1.entity = new EntityEntry(modElement.getWorkspace(), getRandomDataListEntry(random,
ElementUtil.loadAllSpawnableEntities(modElement.getWorkspace())));
entry1.minGroup = 10;
entry1.maxGroup = 134;
entry1.weight = 13;
entry1.spawnType = getRandomItem(random, ElementUtil.getDataListAsStringArray("mobspawntypes"));
entities.add(entry1);
Biome.SpawnEntry entry2 = new Biome.SpawnEntry();
entry2.entity = new EntityEntry(modElement.getWorkspace(), getRandomDataListEntry(random,
ElementUtil.loadAllSpawnableEntities(modElement.getWorkspace())));
entry2.minGroup = 23;
entry2.maxGroup = 145;
entry2.weight = 11;
entry2.spawnType = getRandomItem(random, ElementUtil.getDataListAsStringArray("mobspawntypes"));
entities.add(entry2);
Biome.SpawnEntry entry3 = new Biome.SpawnEntry();
entry3.entity = new EntityEntry(modElement.getWorkspace(), getRandomDataListEntry(random,
ElementUtil.loadAllSpawnableEntities(modElement.getWorkspace())));
entry3.minGroup = 23;
entry3.maxGroup = 145;
entry3.weight = 11;
entry3.spawnType = getRandomItem(random, ElementUtil.getDataListAsStringArray("mobspawntypes"));
entities.add(entry3);
Biome.SpawnEntry entry4 = new Biome.SpawnEntry();
entry4.entity = new EntityEntry(modElement.getWorkspace(), getRandomDataListEntry(random,
ElementUtil.loadAllSpawnableEntities(modElement.getWorkspace())));
entry4.minGroup = 23;
entry4.maxGroup = 145;
entry4.weight = 11;
entry4.spawnType = getRandomItem(random, ElementUtil.getDataListAsStringArray("mobspawntypes"));
entities.add(entry4);
}
biome.spawnEntries = entities;
biome.minHeight = 2;
List<String> biomeDefaultFeatures = new ArrayList<>();
if (!emptyLists)
biomeDefaultFeatures.addAll(Arrays.asList(ElementUtil.getDataListAsStringArray("defaultfeatures")));
biome.defaultFeatures = biomeDefaultFeatures;
if (!emptyLists) {
biome.treeType = biome.TREES_CUSTOM;
biome.treeVines = new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocks).getName());
biome.treeStem = new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocks).getName());
biome.treeBranch = new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocks).getName());
biome.treeFruits = new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocks).getName());
} else {
biome.treeType = biome.TREES_VANILLA;
biome.treeVines = new MItemBlock(modElement.getWorkspace(), "");
biome.treeStem = new MItemBlock(modElement.getWorkspace(), "");
biome.treeBranch = new MItemBlock(modElement.getWorkspace(), "");
biome.treeFruits = new MItemBlock(modElement.getWorkspace(), "");
}
biome.spawnBiome = !_true;
biome.spawnInCaves = _true;
biome.spawnBiomeNether = !_true && emptyLists;
return biome;
} else if (ModElementType.FLUID.equals(modElement.getType())) {
Fluid fluid = new Fluid(modElement);
fluid.name = modElement.getName();
fluid.textureFlowing = "test";
fluid.textureStill = "test2";
fluid.canMultiply = _true;
fluid.flowRate = 8;
fluid.levelDecrease = 2;
fluid.slopeFindDistance = 3;
fluid.spawnParticles = !_true;
fluid.dripParticle = new Particle(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllParticles(modElement.getWorkspace())));
fluid.tintType = getRandomString(random,
Arrays.asList("No tint", "Grass", "Foliage", "Birch foliage", "Spruce foliage", "Default foliage",
"Water", "Sky", "Fog", "Water fog"));
fluid.flowStrength = 2.3;
fluid.luminosity = 3;
fluid.density = 5;
fluid.viscosity = 10;
fluid.temperature = 375;
fluid.generateBucket = !_true;
fluid.bucketName = modElement.getName() + " Bucket";
fluid.textureBucket = emptyLists ? "" : "itest";
fluid.creativeTab = new TabEntry(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllTabs(modElement.getWorkspace())));
fluid.emptySound = !emptyLists ?
new Sound(modElement.getWorkspace(), "") :
new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
fluid.rarity = getRandomString(random, Arrays.asList("COMMON", "UNCOMMON", "RARE", "EPIC"));
fluid.specialInformation = new StringListProcedure(emptyLists ? null : "string1",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
fluid.resistance = 52.2;
fluid.emissiveRendering = _true;
fluid.luminance = 6;
fluid.tickRate = _true ? 0 : 13;
fluid.lightOpacity = 2;
fluid.flammability = 5;
fluid.fireSpreadSpeed = 12;
fluid.colorOnMap = getRandomItem(random, ElementUtil.getDataListAsStringArray("mapcolors"));
fluid.onBlockAdded = new Procedure("procedure5");
fluid.onNeighbourChanges = new Procedure("procedure2");
fluid.onTickUpdate = new Procedure("procedure3");
fluid.onEntityCollides = new Procedure("procedure1");
fluid.onRandomUpdateEvent = new Procedure("procedure5");
fluid.onDestroyedByExplosion = new Procedure("procedure6");
fluid.flowCondition = new Procedure("condition1");
fluid.beforeReplacingBlock = new Procedure("procedure7");
fluid.type = _true ? "WATER" : "LAVA";
return fluid;
} else if (ModElementType.KEYBIND.equals(modElement.getType())) {
KeyBinding keyBinding = new KeyBinding(modElement);
keyBinding.triggerKey = getRandomString(random,
DataListLoader.loadDataList("keybuttons").stream().map(DataListEntry::getName).toList());
keyBinding.keyBindingName = modElement.getName();
keyBinding.keyBindingCategoryKey = "test_category";
if (!emptyLists)
keyBinding.onKeyPressed = new Procedure("procedure3");
if (_true)
keyBinding.onKeyReleased = new Procedure("procedure2");
return keyBinding;
} else if (ModElementType.TAB.equals(modElement.getType())) {
Tab tab = new Tab(modElement);
tab.name = modElement.getName();
tab.icon = new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocksAndItems).getName());
tab.showSearch = _true;
return tab;
} else if (ModElementType.OVERLAY.equals(modElement.getType())) {
Overlay overlay = new Overlay(modElement);
overlay.priority = getRandomItem(random, new String[] { "NORMAL", "HIGH", "HIGHEST", "LOW", "LOWEST" });
ArrayList<GUIComponent> components = new ArrayList<>();
components.add(new Label("text", 100, 150, new StringProcedure(_true ? "string1" : null, "fixed value 1"),
Color.red, new Procedure("condition1"), getRandomItem(random, GUIComponent.AnchorPoint.values())));
components.add(new Label("text2", 100, 150, new StringProcedure(!_true ? "string2" : null, "fixed value 2"),
Color.white, new Procedure("condition4"),
getRandomItem(random, GUIComponent.AnchorPoint.values())));
components.add(new Image(20, 30, "picture1", true, new Procedure("condition1"),
getRandomItem(random, GUIComponent.AnchorPoint.values())));
components.add(new Image(22, 31, "picture2", false, new Procedure("condition2"),
getRandomItem(random, GUIComponent.AnchorPoint.values())));
components.add(new EntityModel(60, 20, new Procedure("entity1"), new Procedure("condition3"), 30, 0, false,
getRandomItem(random, GUIComponent.AnchorPoint.values())));
components.add(
new EntityModel(60, 20, new Procedure("entity1"), new Procedure(!_true ? "condition4" : null), 30,
90, false, getRandomItem(random, GUIComponent.AnchorPoint.values())));
overlay.displayCondition = new Procedure("condition1");
overlay.components = components;
overlay.baseTexture = emptyLists ? "" : "test.png";
if (_true)
overlay.overlayTarget = "Ingame";
else
overlay.overlayTarget = getRandomItem(random, ElementUtil.getDataListAsStringArray("screens"));
return overlay;
} else if (ModElementType.GUI.equals(modElement.getType())) {
GUI gui = new GUI(modElement);
gui.type = new int[] { 0, 0, 1, 1 }[valueIndex];
gui.width = new int[] { 600, 400, 352, 500 }[valueIndex];
gui.height = new int[] { 500, 400, 353, 450 }[valueIndex];
gui.renderBgLayer = !_true;
gui.doesPauseGame = _true;
gui.inventoryOffsetX = 20;
gui.inventoryOffsetY = 123;
if (!emptyLists) {
gui.onOpen = new Procedure("procedure12");
gui.onTick = new Procedure("procedure7");
gui.onClosed = new Procedure("procedure10");
}
ArrayList<GUIComponent> components = new ArrayList<>();
if (!emptyLists) {
components.add(new Label(AbstractWYSIWYGDialog.textToMachineName(components, null,
"This is --...p a test string ŽĐĆ @ /test//\" tes___"), 100, 150,
new StringProcedure(_true ? "string1" : null, "fixed value 1"), Color.red,
new Procedure("condition1")));
components.add(new Label(AbstractWYSIWYGDialog.textToMachineName(components, null,
"This is --...p a test string ŽĐĆ @ /test//\" tes___"), 100, 150,
new StringProcedure(!_true ? "string2" : null, "fixed value 2"), Color.white,
new Procedure("condition4")));
components.add(new Image(20, 30, "picture1", true, new Procedure("condition1")));
components.add(new Image(22, 31, "picture2", false, new Procedure("condition2")));
components.add(new Button(AbstractWYSIWYGDialog.textToMachineName(components, null, "button"), 10, 10,
"button1", 100, 200, _true, new Procedure("procedure10"), null));
components.add(new Button("button2", 10, 10, "button2", 100, 200, !_true, null, null));
components.add(
new Button("button3", 10, 10, "button3", 100, 200, _true, null, new Procedure("condition3")));
components.add(new Button(AbstractWYSIWYGDialog.textToMachineName(components, null, "button"), 10, 10,
"button4", 100, 200, !_true, new Procedure("procedure2"), new Procedure("condition4")));
components.add(
new ImageButton("imagebutton1", 0, 48, "picture1", "picture2", new Procedure("procedure10"),
null));
components.add(
new ImageButton("imagebutton2", 16, 32, "picture2", "", new Procedure(""), new Procedure("")));
components.add(new ImageButton("imagebutton3", 32, 16, "picture1", "picture2", null,
new Procedure("condition3")));
components.add(new ImageButton("imagebutton4", 48, 0, "picture2", "", new Procedure("procedure2"),
new Procedure("condition4")));
components.add(new InputSlot(0, 20, 30, Color.red, new LogicProcedure("condition1", true),
new LogicProcedure("condition1", true), _true, new Procedure("procedure3"),
new Procedure("procedure10"), new Procedure("procedure2"),
new MItemBlock(modElement.getWorkspace(), "")));
components.add(new InputSlot(3, 20, 30, Color.white, new LogicProcedure(null, true),
new LogicProcedure("condition1", true), !_true, new Procedure("procedure4"), null, null,
new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocksAndItems).getName())));
new InputSlot(5, 20, 30, Color.white, new LogicProcedure("condition1", true),
new LogicProcedure(null, true), !_true, new Procedure("procedure4"), null, null,
new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocksAndItems).getName()));
components.add(new InputSlot(4, 20, 30, Color.green, new LogicProcedure(null, _true),
new LogicProcedure("condition1", !_true), _true, new Procedure("procedure5"), null, null,
new MItemBlock(modElement.getWorkspace(), "TAG:flowers")));
components.add(new OutputSlot(5, 10, 20, Color.black, new LogicProcedure("condition2", _true), !_true,
new Procedure("procedure10"), new Procedure("procedure2"), new Procedure("procedure3")));
components.add(
new OutputSlot(6, 243, 563, Color.black, new LogicProcedure("condition2", true), _true, null,
null, null));
components.add(new TextField("text1", 0, 10, 100, 20, "Input value ..."));
components.add(new TextField("text2", 55, 231, 90, 20, ""));
components.add(new Checkbox("checkbox1", 100, 100, "Text", new Procedure("condition1")));
components.add(new Checkbox("checkbox2", 125, 125, "Other text", new Procedure("condition2")));
components.add(
new EntityModel(60, 20, new Procedure("entity1"), new Procedure("condition3"), 30, 0, _true));
components.add(
new EntityModel(60, 20, new Procedure("entity1"), new Procedure(!_true ? "condition4" : null),
30, 270, !_true));
components.add(new Tooltip(AbstractWYSIWYGDialog.textToMachineName(components, null,
"This is --...p a test string ŽĐĆ @ /test//\" tes___"), 20, 40, 70, 10,
new StringProcedure(_true ? "string1" : null, "fixed value 1"), new Procedure("condition4")));
}
gui.components = components;
return gui;
} else if (ModElementType.LIVINGENTITY.equals(modElement.getType())) {
return getLivingEntity(modElement, random, _true, emptyLists, blocksAndItems, blocksAndItemsAndTags,
biomes);
} else if (ModElementType.DIMENSION.equals(modElement.getType())) {
Dimension dimension = new Dimension(modElement);
dimension.texture = "test";
dimension.portalTexture = "test2";
dimension.enableIgniter = true; // we always want it as it can be referenced in other tests
dimension.portalParticles = new Particle(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllParticles(modElement.getWorkspace())));
dimension.igniterTab = new TabEntry(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllTabs(modElement.getWorkspace())));
dimension.portalSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
dimension.biomesInDimension = new ArrayList<>();
if (!emptyLists) {
dimension.biomesInDimension.addAll(
biomes.stream().skip(_true ? 0 : ((long) (biomes.size() / 4) * valueIndex))
.limit(biomes.size() / 4)
.map(e -> new BiomeEntry(modElement.getWorkspace(), e.getName())).toList());
} else {
dimension.biomesInDimension.add(
new BiomeEntry(modElement.getWorkspace(), getRandomDataListEntry(random, biomes)));
}
dimension.airColor = Color.cyan;
dimension.canRespawnHere = _true;
dimension.hasFog = _true;
dimension.hasSkyLight = !_true;
dimension.imitateOverworldBehaviour = _true;
dimension.isDark = _true;
dimension.doesWaterVaporize = !_true;
dimension.enablePortal = true; // we always want it as it can be referenced in other tests
dimension.portalLuminance = 8;
dimension.portalFrame = new MItemBlock(modElement.getWorkspace(),
getRandomMCItem(random, blocks).getName());
dimension.igniterName = modElement.getName();
dimension.igniterRarity = getRandomString(random, Arrays.asList("COMMON", "UNCOMMON", "RARE", "EPIC"));
dimension.specialInformation = new StringListProcedure(emptyLists ? null : "string1",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
dimension.worldGenType = new String[] { "Nether like gen", "Normal world gen", "End like gen",
"Normal world gen" }[valueIndex];
dimension.mainFillerBlock = new MItemBlock(modElement.getWorkspace(),
getRandomMCItem(random, blocks).getName());
dimension.fluidBlock = new MItemBlock(modElement.getWorkspace(), getRandomMCItem(random, blocks).getName());
dimension.whenPortaTriggerlUsed = emptyLists ?
new Procedure("actionresulttype1") :
new Procedure("procedure1");
dimension.onPortalTickUpdate = new Procedure("procedure3");
dimension.onPlayerEntersDimension = new Procedure("procedure4");
dimension.onPlayerLeavesDimension = new Procedure("procedure5");
dimension.portalMakeCondition = new Procedure("condition3");
dimension.portalUseCondition = new Procedure("condition4");
return dimension;
} else if (ModElementType.STRUCTURE.equals(modElement.getType())) {
Structure structure = new Structure(modElement);
structure.structure = "test";
structure.surfaceDetectionType = getRandomString(random,
Arrays.asList("WORLD_SURFACE_WG", "WORLD_SURFACE", "OCEAN_FLOOR_WG", "OCEAN_FLOOR",
"MOTION_BLOCKING", "MOTION_BLOCKING_NO_LEAVES"));
structure.ignoredBlocks = new ArrayList<>();
if (!emptyLists) {
structure.ignoredBlocks.addAll(
blocks.stream().skip(_true ? 0 : ((long) (blocks.size() / 4) * valueIndex))
.limit(blocks.size() / 4)
.map(e -> new MItemBlock(modElement.getWorkspace(), e.getName())).toList());
}
structure.terrainAdaptation = getRandomString(random,
Arrays.asList("none", "beard_thin", "beard_box", "bury"));
structure.projection = getRandomString(random, Arrays.asList("rigid", "terrain_matching"));
structure.restrictionBiomes = new ArrayList<>();
structure.spacing = 14;
structure.separation = 6;
if (_true) {
structure.restrictionBiomes.addAll(
biomes.stream().map(e -> new BiomeEntry(modElement.getWorkspace(), e.getName())).toList());
} else {
structure.restrictionBiomes.add(new BiomeEntry(modElement.getWorkspace(), "#is_overworld"));
}
structure.generationStep = TestWorkspaceDataProvider.getRandomItem(random,
ElementUtil.getDataListAsStringArray("generationsteps"));
structure.size = 4;
structure.maxDistanceFromCenter = 96;
structure.jigsawPools = new ArrayList<>();
if (!emptyLists) {
Structure.JigsawPool pool = new Structure.JigsawPool();
pool.poolName = "pool1";
pool.fallbackPool = "test_mod:" + modElement.getRegistryName() + "_pool2";
pool.poolParts = new ArrayList<>();
Structure.JigsawPool.JigsawPart part = new Structure.JigsawPool.JigsawPart();
part.weight = 3;
part.structure = "test1";
part.projection = "rigid";
part.ignoredBlocks = blocks.stream().skip(_true ? 0 : ((long) (blocks.size() / 4) * valueIndex))
.limit(blocks.size() / 4).map(e -> new MItemBlock(modElement.getWorkspace(), e.getName()))
.toList();
pool.poolParts.add(part);
part = new Structure.JigsawPool.JigsawPart();
part.weight = 7;
part.structure = "test2";
part.projection = "terrain_matching";
part.ignoredBlocks = blocks.stream().skip(_true ? 0 : ((long) (blocks.size() / 4) * valueIndex))
.limit(blocks.size() / 4).map(e -> new MItemBlock(modElement.getWorkspace(), e.getName()))
.toList();
pool.poolParts.add(part);
structure.jigsawPools.add(pool);
pool = new Structure.JigsawPool();
pool.poolName = "pool2";
pool.fallbackPool = "";
pool.poolParts = new ArrayList<>();
part = new Structure.JigsawPool.JigsawPart();
part.weight = 1;
part.structure = "test3";
part.projection = "rigid";
part.ignoredBlocks = blocks.stream().skip(_true ? 0 : ((long) (blocks.size() / 4) * valueIndex))
.limit(blocks.size() / 4).map(e -> new MItemBlock(modElement.getWorkspace(), e.getName()))
.toList();
pool.poolParts.add(part);
structure.jigsawPools.add(pool);
}
return structure;
} else if (ModElementType.ARMOR.equals(modElement.getType())) {
Armor armor = new Armor(modElement);
armor.enableHelmet = !_true;
armor.textureHelmet = "test";
armor.helmetModelTexture = emptyLists ? "From armor" : "test.png";
armor.enableBody = !_true;
armor.textureBody = "test2";
armor.bodyModelTexture = emptyLists ? "From armor" : "test.png";
armor.enableLeggings = !_true;
armor.textureLeggings = "test3";
armor.leggingsModelTexture = emptyLists ? "From armor" : "test.png";
armor.enableBoots = !_true;
armor.textureBoots = "test4";
armor.bootsModelTexture = emptyLists ? "From armor" : "test.png";
armor.helmetItemRenderType = 0;
armor.helmetItemCustomModelName = "Normal";
armor.bodyItemRenderType = 0;
armor.bodyItemCustomModelName = "Normal";
armor.leggingsItemRenderType = 0;
armor.leggingsItemCustomModelName = "Normal";
armor.bootsItemRenderType = 0;
armor.bootsItemCustomModelName = "Normal";
armor.helmetSpecialInformation = new StringListProcedure(emptyLists ? null : "string1",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
armor.bodySpecialInformation = new StringListProcedure(emptyLists ? null : "string2",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
armor.leggingsSpecialInformation = new StringListProcedure(emptyLists ? null : "string3",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
armor.bootsSpecialInformation = new StringListProcedure(emptyLists ? null : "string4",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
armor.helmetImmuneToFire = _true;
armor.bodyImmuneToFire = !_true;
armor.leggingsImmuneToFire = _true;
armor.bootsImmuneToFire = !_true;
armor.helmetPiglinNeutral = new LogicProcedure(_true ? "condition1" : null, _true);
armor.bodyPiglinNeutral = new LogicProcedure(_true ? "condition2" : null, _true);
armor.leggingsPiglinNeutral = new LogicProcedure(_true ? "condition3" : null, _true);
armor.bootsPiglinNeutral = new LogicProcedure(_true ? "condition4" : null, _true);
armor.equipSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
armor.onHelmetTick = new Procedure("procedure1");
armor.onBodyTick = new Procedure("procedure2");
armor.onLeggingsTick = new Procedure("procedure3");
armor.onBootsTick = new Procedure("procedure4");
armor.helmetName = modElement.getName() + " appendix1";
armor.bodyName = modElement.getName() + " appendix2";
armor.bootsName = modElement.getName() + " appendix3";
armor.leggingsName = modElement.getName() + " appendix4";
armor.creativeTab = new TabEntry(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllTabs(modElement.getWorkspace())));
armor.armorTextureFile = "armorTexture";
armor.maxDamage = 12;
armor.damageValueHelmet = 3;
armor.damageValueBody = 4;
armor.damageValueLeggings = 5;
armor.damageValueBoots = 6;
armor.enchantability = 7;
armor.toughness = 1.23;
armor.knockbackResistance = 3.148;
armor.repairItems = new ArrayList<>();
if (!emptyLists) {
armor.repairItems = new ArrayList<>(blocksAndItemsAndTags.stream()
.skip(_true ? 0 : ((long) (blocksAndItemsAndTags.size() / 4) * valueIndex))
.limit(blocksAndItemsAndTags.size() / 4)
.map(e -> new MItemBlock(modElement.getWorkspace(), e.getName())).toList());
armor.repairItems.add(new MItemBlock(modElement.getWorkspace(), "TAG:flowers"));
}
return armor;
} else if (ModElementType.PLANT.equals(modElement.getType())) {
Plant plant = new Plant(modElement);
plant.name = modElement.getName();
plant.plantType = new String[] { "normal", "growapable", "double", "normal" }[valueIndex];
plant.creativeTab = new TabEntry(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllTabs(modElement.getWorkspace())));
plant.texture = "test";
plant.textureBottom = "test2";
plant.itemTexture = emptyLists ? "" : "itest";
plant.particleTexture = emptyLists ? "" : "test3";
plant.growapableSpawnType = getRandomItem(random, ElementUtil.getDataListAsStringArray("planttypes"));
plant.suspiciousStewEffect = getRandomString(random,
ElementUtil.loadAllPotionEffects(modElement.getWorkspace()).stream().map(DataListEntry::getName)
.toList());
plant.suspiciousStewDuration = 24;
plant.growapableMaxHeight = 5;
plant.customBoundingBox = !_true;
plant.disableOffset = !_true;
plant.boundingBoxes = new ArrayList<>();
if (!emptyLists) {
int boxes = random.nextInt(4) + 1;
for (int i = 0; i < boxes; i++) {
IBlockWithBoundingBox.BoxEntry box = new IBlockWithBoundingBox.BoxEntry();
box.mx = new double[] { 0, 5 + i, 1.2, 7.1 }[valueIndex];
box.my = new double[] { 0, 2, 3.6, 12.2 }[valueIndex];
box.mz = new double[] { 0, 3.1, 0, 2.2 }[valueIndex];
box.Mx = new double[] { 16, 15.2, 4, 7.1 + i }[valueIndex];
box.My = new double[] { 16, 12.2, 16, 13 }[valueIndex];
box.Mz = new double[] { 16, 12, 2.4, 1.2 }[valueIndex];
box.subtract = new boolean[] { false, _true, _true, random.nextBoolean() }[valueIndex];
plant.boundingBoxes.add(box);
}
}
plant.hardness = 0.03;
plant.emissiveRendering = !_true;
plant.resistance = 3.45;
plant.luminance = 7;
plant.isReplaceable = !_true;
plant.forceTicking = !_true;
plant.hasTileEntity = !_true;
plant.isSolid = _true;
plant.specialInformation = new StringListProcedure(emptyLists ? null : "string1",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
plant.creativePickItem = new MItemBlock(modElement.getWorkspace(),
getRandomMCItem(random, blocks).getName());
plant.colorOnMap = getRandomItem(random, ElementUtil.getDataListAsStringArray("mapcolors"));
plant.offsetType = getRandomString(random, Arrays.asList("NONE", "XZ", "XYZ"));
plant.aiPathNodeType = getRandomItem(random, ElementUtil.getDataListAsStringArray("pathnodetypes"));
plant.unbreakable = _true;
plant.isCustomSoundType = !_true;
plant.soundOnStep = new StepSound(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadStepSounds()));
plant.breakSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
plant.stepSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
plant.placeSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
plant.hitSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
plant.fallSound = new Sound(modElement.getWorkspace(),
getRandomItem(random, ElementUtil.getAllSounds(modElement.getWorkspace())));
plant.customDrop = new MItemBlock(modElement.getWorkspace(),
getRandomMCItem(random, blocksAndItems).getName());
plant.dropAmount = 4;
plant.useLootTableForDrops = !_true;
plant.frequencyOnChunks = 13;
plant.patchSize = 46;
plant.generateAtAnyHeight = _true;
plant.generationType = getRandomItem(random, new String[] { "Grass", "Flower" });
plant.flammability = 5;
plant.fireSpreadSpeed = 12;
plant.speedFactor = 34.632;
plant.jumpFactor = 17.732;
plant.canBePlacedOn = new ArrayList<>();
if (!emptyLists) {
plant.canBePlacedOn.addAll(
blocks.stream().skip(_true ? 0 : ((blocks.size() / 4) * valueIndex)).limit(blocks.size() / 4)
.map(e -> new MItemBlock(modElement.getWorkspace(), e.getName())).toList());
}
plant.restrictionBiomes = new ArrayList<>();
if (!emptyLists) {
if (_true) {
plant.restrictionBiomes.add(new BiomeEntry(modElement.getWorkspace(), "#is_overworld"));
} else {
plant.restrictionBiomes.addAll(
biomes.stream().map(e -> new BiomeEntry(modElement.getWorkspace(), e.getName())).toList());
}
}
plant.onNeighbourBlockChanges = new Procedure("procedure7");
plant.onTickUpdate = new Procedure("procedure2");
plant.onDestroyedByPlayer = new Procedure("procedure3");
plant.onDestroyedByExplosion = new Procedure("procedure4");
plant.onStartToDestroy = new Procedure("procedure5");
plant.onEntityCollides = new Procedure("procedure6");
plant.onRightClicked = emptyLists ? new Procedure("actionresulttype1") : new Procedure("procedure1");
plant.onBlockAdded = new Procedure("procedure8");
plant.onBlockPlacedBy = new Procedure("procedure9");
plant.onRandomUpdateEvent = new Procedure("procedure10");
plant.onEntityWalksOn = new Procedure("procedure11");
plant.onHitByProjectile = new Procedure("procedure12");
plant.placingCondition = _true ? null : new Procedure("condition2");
plant.tintType = getRandomString(random,
Arrays.asList("No tint", "Grass", "Foliage", "Birch foliage", "Spruce foliage", "Default foliage",
"Water", "Sky", "Fog", "Water fog"));
if ("double".equals(plant.plantType)) {
plant.renderType = !"No tint".equals(plant.tintType) ? 120 : 12;
plant.customModelName = "Cross model";
} else {
plant.renderType = new int[] { 13, !"No tint".equals(plant.tintType) ? 120 : 12, 13,
!"No tint".equals(plant.tintType) ? 120 : 12 }[valueIndex];
plant.customModelName = new String[] { "Crop model", "Cross model", "Crop model",
"Cross model" }[valueIndex];
}
plant.isItemTinted = _true;
if (!emptyLists) {
plant.isBonemealable = true;
plant.isBonemealTargetCondition = new Procedure("condition3");
plant.bonemealSuccessCondition = new Procedure("condition4");
plant.onBonemealSuccess = new Procedure("procedure13");
}
return plant;
} else if (ModElementType.ITEM.equals(modElement.getType())) {
Item item = new Item(modElement);
item.name = modElement.getName();
item.rarity = getRandomString(random, Arrays.asList("COMMON", "UNCOMMON", "RARE", "EPIC"));
item.creativeTab = new TabEntry(modElement.getWorkspace(),
getRandomDataListEntry(random, ElementUtil.loadAllTabs(modElement.getWorkspace())));
item.stackSize = 52;
item.enchantability = 3;
item.useDuration = 8;
item.toolType = 1.43;
item.damageCount = 4;
item.destroyAnyBlock = _true;
item.inventorySize = 10;
item.inventoryStackSize = 42;
item.guiBoundTo = "<NONE>";
item.recipeRemainder = new MItemBlock(modElement.getWorkspace(),
emptyLists ? "" : getRandomMCItem(random, blocksAndItems).getName());
item.stayInGridWhenCrafting = _true;
item.damageOnCrafting = _true;
item.immuneToFire = _true;
item.glowCondition = new LogicProcedure(emptyLists ? "condition3" : null, _true);
item.onRightClickedInAir = new Procedure("procedure1");
item.onRightClickedOnBlock = emptyLists ? new Procedure("actionresulttype1") : new Procedure("procedure2");
item.onCrafted = new Procedure("procedure3");
item.onEntityHitWith = new Procedure("procedure4");
item.onItemInInventoryTick = new Procedure("procedure5");
item.onItemInUseTick = new Procedure("procedure6");
item.onStoppedUsing = new Procedure("procedure7");
item.onEntitySwing = new Procedure("procedure8");
item.onDroppedByPlayer = new Procedure("procedure9");
item.enableMeleeDamage = !_true;
item.damageVsEntity = 6.53;
item.specialInformation = new StringListProcedure(emptyLists ? null : "string1",
Arrays.asList("info 1", "info 2", "test, is this", "another one"));
item.texture = "test2";
item.renderType = 0;
item.customModelName = getRandomItem(random, ItemGUI.builtinitemmodels).getReadableName();