-
Notifications
You must be signed in to change notification settings - Fork 285
/
Copy pathCarpetSettings.java
1172 lines (1033 loc) · 46.9 KB
/
CarpetSettings.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
package carpet;
import carpet.api.settings.CarpetRule;
import carpet.api.settings.RuleCategory;
import carpet.api.settings.Validators;
import carpet.api.settings.Validator;
import carpet.script.utils.AppStoreManager;
import carpet.settings.Rule;
import carpet.utils.Translations;
import carpet.utils.CommandHelper;
import carpet.utils.Messenger;
import carpet.utils.SpawnChunks;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerInterface;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.StructureBlockEntity;
import net.minecraft.world.level.block.piston.PistonStructureResolver;
import net.minecraft.world.level.border.BorderStatus;
import net.minecraft.world.level.border.WorldBorder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Optional;
import static carpet.api.settings.RuleCategory.BUGFIX;
import static carpet.api.settings.RuleCategory.COMMAND;
import static carpet.api.settings.RuleCategory.CREATIVE;
import static carpet.api.settings.RuleCategory.EXPERIMENTAL;
import static carpet.api.settings.RuleCategory.FEATURE;
import static carpet.api.settings.RuleCategory.OPTIMIZATION;
import static carpet.api.settings.RuleCategory.SURVIVAL;
import static carpet.api.settings.RuleCategory.TNT;
import static carpet.api.settings.RuleCategory.DISPENSER;
import static carpet.api.settings.RuleCategory.SCARPET;
import static carpet.api.settings.RuleCategory.CLIENT;
@SuppressWarnings({"CanBeFinal", "removal"}) // removal should be removed after migrating rules to the new system
public class CarpetSettings
{
public static final String carpetVersion = FabricLoader.getInstance().getModContainer("carpet").orElseThrow().getMetadata().getVersion().toString();
public static final String releaseTarget = "1.19.4";
public static final Logger LOG = LoggerFactory.getLogger("carpet");
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
public static final ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
public static int runPermissionLevel = 2;
public static Block structureBlockIgnoredBlock = Blocks.STRUCTURE_VOID;
private static class LanguageValidator extends Validator<String> {
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
if (!Translations.isValidLanguage(newValue))
{
Messenger.m(source, "r "+newValue+" is not a valid language");
return null;
}
CarpetSettings.language = newValue;
Translations.updateLanguage();
return newValue;
}
}
@Rule(
desc = "Sets the language for Carpet",
category = FEATURE,
options = {"en_us", "pt_br", "zh_cn", "zh_tw"},
strict = true, // the current system doesn't handle fallbacks and other, not defined languages would make unreadable mess. Change later
validate = LanguageValidator.class
)
public static String language = "en_us";
/*
These will be turned when events can be added / removed in code
Then also gotta remember to remove relevant rules
@Rule(
desc = "Turns on internal camera path tracing app",
extra = "Controlled via 'camera' command",
category = {COMMAND, SCARPET},
appSource = "camera"
)
public static boolean commandCamera = true;
@Rule(
desc = "Allows to add extra graphical debug information",
extra = "Controlled via 'overlay' command",
category = {COMMAND, SCARPET},
appSource = "overlay"
)
public static boolean commandOverlay = true;
@Rule(
desc = "Turns on extra information about mobs above and around them",
extra = "Controlled via 'ai_tracker' command",
category = {COMMAND, SCARPET},
appSource = "ai_tracker"
)
public static boolean commandAITracker = true;
@Rule(
desc = "Enables /draw commands",
extra = {
"... allows for drawing simple shapes or",
"other shapes which are sorta difficult to do normally"
},
appSource = "draw",
category = {FEATURE, SCARPET, COMMAND}
)
public static String commandDraw = "true";
@Rule(
desc = "Enables /distance command to measure in game distance between points",
extra = "Also enables brown carpet placement action if 'carpets' rule is turned on as well",
appSource = "distance",
category = {FEATURE, SCARPET, COMMAND}
)
public static String commandDistance = "true";
*/
private static class CarpetPermissionLevel extends Validator<String> {
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
if (source == null || source.hasPermission(4))
return newValue;
return null;
}
@Override
public String description()
{
return "This setting can only be set by admins with op level 4";
}
}
@Rule(
desc = "Carpet command permission level. Can only be set via .conf file",
category = CREATIVE,
validate = CarpetPermissionLevel.class,
options = {"ops", "2", "4"}
)
public static String carpetCommandPermissionLevel = "ops";
@Rule(desc = "Gbhs sgnf sadsgras fhskdpri!!!", category = EXPERIMENTAL)
public static boolean superSecretSetting = false;
@Rule(
desc = "Amount of delay ticks to use a nether portal in creative",
options = {"1", "40", "80", "72000"},
category = CREATIVE,
strict = false,
validate = OneHourMaxDelayLimit.class
)
public static int portalCreativeDelay = 1;
@Rule(
desc = "Amount of delay ticks to use a nether portal in survival",
options = {"1", "40", "80", "72000"},
category = SURVIVAL,
strict = false,
validate = OneHourMaxDelayLimit.class
)
public static int portalSurvivalDelay = 80;
private static class OneHourMaxDelayLimit extends Validator<Integer> {
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
return (newValue > 0 && newValue <= 72000) ? newValue : null;
}
@Override
public String description() { return "You must choose a value from 1 to 72000";}
}
@Rule(desc = "Dropping entire stacks works also from on the crafting UI result slot", category = {RuleCategory.BUGFIX, SURVIVAL})
public static boolean ctrlQCraftingFix = false;
@Rule(desc = "Parrots don't get of your shoulders until you receive proper damage", category = {SURVIVAL, FEATURE})
public static boolean persistentParrots = false;
/*@Rule(
desc = "Mobs growing up won't glitch into walls or go through fences",
category = BUGFIX,
validate = Validator.WIP.class
)
public static boolean growingUpWallJump = false;
@Rule(
desc = "Won't let mobs glitch into blocks when reloaded.",
extra = "Can cause slight differences in mobs behaviour",
category = {BUGFIX, EXPERIMENTAL},
validate = Validator.WIP.class
)
public static boolean reloadSuffocationFix = false;
*/
@Rule( desc = "Players absorb XP instantly, without delay", category = CREATIVE )
public static boolean xpNoCooldown = false;
public static class StackableShulkerBoxValidator extends Validator<String>
{
@Override
public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string)
{
if (newValue.matches("^[0-9]+$")) {
int value = Integer.parseInt(newValue);
if (value <= 64 && value >= 2) {
shulkerBoxStackSize = value;
return newValue;
}
}
if (newValue.equalsIgnoreCase("false")) {
shulkerBoxStackSize = 1;
return newValue;
}
if (newValue.equalsIgnoreCase("true")) {
shulkerBoxStackSize = 64;
return newValue;
}
return null;
}
@Override
public String description()
{
return "Value must either be true, false, or a number between 2-64";
}
}
@Rule(
desc = "Empty shulker boxes can stack when thrown on the ground.",
extra = ".. or when manipulated inside the inventories",
validate = StackableShulkerBoxValidator.class,
options = {"false", "true", "16"},
strict = false,
category = {SURVIVAL, FEATURE}
)
public static String stackableShulkerBoxes = "false";
public static int shulkerBoxStackSize = 1; // Referenced from Carpet extra
@Rule( desc = "Explosions won't destroy blocks", category = {CREATIVE, TNT} )
public static boolean explosionNoBlockDamage = false;
@Rule( desc = "Experience will drop from all experience barring blocks with any explosion type", category = {SURVIVAL, FEATURE})
public static boolean xpFromExplosions = false;
@Rule( desc = "Removes random TNT momentum when primed", category = {CREATIVE, TNT} )
public static boolean tntPrimerMomentumRemoved = false;
@Rule( desc = "TNT causes less lag when exploding in the same spot and in liquids", category = TNT)
public static boolean optimizedTNT = false;
private static class CheckOptimizedTntEnabledValidator<T> extends Validator<T>
{
@Override
public T validate(CommandSourceStack source, CarpetRule<T> currentRule, T newValue, String string) {
return optimizedTNT || currentRule.defaultValue().equals(newValue) ? newValue : null;
}
@Override
public String description() {
return "optimizedTNT must be enabled";
}
}
@Rule( desc = "Sets the tnt random explosion range to a fixed value", category = TNT, options = "-1", strict = false,
validate = {CheckOptimizedTntEnabledValidator.class, TNTRandomRangeValidator.class}, extra = "Set to -1 for default behavior")
public static double tntRandomRange = -1;
private static class TNTRandomRangeValidator extends Validator<Double> {
@Override
public Double validate(CommandSourceStack source, CarpetRule<Double> currentRule, Double newValue, String string) {
return newValue == -1 || newValue >= 0 ? newValue : null;
}
@Override
public String description() {
return "Cannot be negative, except for -1";
}
}
@Rule( desc = "Sets the horizontal random angle on TNT for debugging of TNT contraptions", category = TNT, options = "-1", strict = false,
validate = TNTAngleValidator.class, extra = "Set to -1 for default behavior")
public static double hardcodeTNTangle = -1.0D;
private static class TNTAngleValidator extends Validator<Double> {
@Override
public Double validate(CommandSourceStack source, CarpetRule<Double> currentRule, Double newValue, String string) {
return (newValue >= 0 && newValue < Math.PI * 2) || newValue == -1 ? newValue : null;
}
@Override
public String description() {
return "Must be between 0 and 2pi, or -1";
}
}
@Rule( desc = "Merges stationary primed TNT entities", category = TNT )
public static boolean mergeTNT = false;
@Rule(
desc = "Lag optimizations for redstone dust",
extra = {
"by Theosib",
".. also fixes some locational behaviours or vanilla redstone MC-11193",
"so behaviour of locational vanilla contraptions is not guaranteed"
},
category = {EXPERIMENTAL, OPTIMIZATION}
)
public static boolean fastRedstoneDust = false;
@Rule(desc = "Only husks spawn in desert temples", category = FEATURE)
public static boolean huskSpawningInTemples = false;
@Rule( desc = "Shulkers will respawn in end cities", category = FEATURE )
public static boolean shulkerSpawningInEndCities = false;
@Rule(
desc = "Piglins will respawn in bastion remnants",
extra = "Includes piglins, brutes, and a few hoglins",
category = FEATURE
)
public static boolean piglinsSpawningInBastions = false;
@Rule( desc = "TNT doesn't update when placed against a power source", category = {CREATIVE, TNT} )
public static boolean tntDoNotUpdate = false;
@Rule(
desc = "Prevents players from rubberbanding when moving too fast",
extra = {"... or being kicked out for 'flying'",
"Puts more trust in clients positioning",
"Increases player allowed mining distance to 32 blocks"
},
category = {CREATIVE, SURVIVAL}
)
public static boolean antiCheatDisabled = false;
private static class QuasiConnectivityValidator extends Validator<Integer> {
@Override
public Integer validate(CommandSourceStack source, CarpetRule<Integer> changingRule, Integer newValue, String userInput) {
int minRange = 0;
int maxRange = 1;
if (source == null) {
maxRange = Integer.MAX_VALUE;
} else {
for (Level level : source.getServer().getAllLevels()) {
maxRange = Math.max(maxRange, level.getHeight() - 1);
}
}
return (newValue >= minRange && newValue <= maxRange) ? newValue : null;
}
}
@Rule(
desc = "Pistons, droppers, and dispensers check for power to the block(s) above them.",
extra = { "Defines the range at which pistons, droppers, and dispensers check for 'quasi power'." },
category = CREATIVE,
validate = QuasiConnectivityValidator.class
)
public static int quasiConnectivity = 1;
@Rule(
desc = "Players can flip and rotate blocks when holding cactus",
extra = {
"Doesn't cause block updates when rotated/flipped",
"Applies to pistons, observers, droppers, repeaters, stairs, glazed terracotta etc..."
},
category = {CREATIVE, SURVIVAL, FEATURE}
)
public static boolean flippinCactus = false;
@Rule(
desc = "hoppers pointing to wool will count items passing through them",
extra = {
"Enables /counter command, and actions while placing red and green carpets on wool blocks",
"Use /counter <color?> reset to reset the counter, and /counter <color?> to query",
"In survival, place green carpet on same color wool to query, red to reset the counters",
"Counters are global and shared between players, 16 channels available",
"Items counted are destroyed, count up to one stack per tick per hopper"
},
category = {COMMAND, CREATIVE, FEATURE}
)
public static boolean hopperCounters = false;
@Rule(
desc = "Allows Budding Amethyst blocks to be moved",
extra = {
"Allow for them to be moved by pistons",
"as well as adds extra drop when mining with silk touch pickaxe"
},
category = FEATURE
)
public static boolean movableAmethyst = false;
@Rule( desc = "Guardians turn into Elder Guardian when struck by lightning", category = FEATURE )
public static boolean renewableSponges = false;
@Rule( desc = "Pistons can push block entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} )
public static boolean movableBlockEntities = false;
public enum ChainStoneMode {
TRUE, FALSE, STICK_TO_ALL;
public boolean enabled() {
return this != FALSE;
}
}
@Rule(
desc = "Chains will stick to each other on the long ends",
extra = {
"and will stick to other blocks that connect to them directly.",
"With stick_to_all: it will stick even if not visually connected"
},
category = {EXPERIMENTAL, FEATURE}
)
public static ChainStoneMode chainStone = ChainStoneMode.FALSE;
@Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE )
public static boolean desertShrubs = false;
@Rule( desc = "Silverfish drop a gravel item when breaking out of a block", category = FEATURE )
public static boolean silverFishDropGravel = false;
@Rule( desc = "summoning a lightning bolt has all the side effects of natural lightning", category = CREATIVE )
public static boolean summonNaturalLightning = false;
@Rule(desc = "Enables /spawn command for spawn tracking", category = COMMAND)
public static String commandSpawn = "ops";
@Rule(desc = "Enables /tick command to control game clocks", category = COMMAND)
public static String commandTick = "ops";
@Rule(
desc = "Enables /profile command to monitor game performance",
extra = "subset of /tick command capabilities",
category = COMMAND
)
public static String commandProfile = "true";
@Rule(
desc = "Required permission level for /perf command",
options = {"2", "4"},
category = CREATIVE
)
public static int perfPermissionLevel = 4;
@Rule(desc = "Enables /log command to monitor events via chat and overlays", category = COMMAND)
public static String commandLog = "true";
@Rule(
desc = "sets these loggers in their default configurations for all new players",
extra = "use csv, like 'tps,mobcaps' for multiple loggers, none for nothing",
category = {CREATIVE, SURVIVAL},
options = {"none", "tps", "mobcaps,tps"},
strict = false
)
public static String defaultLoggers = "none";
@Rule(
desc = "Enables /distance command to measure in game distance between points",
extra = "Also enables brown carpet placement action if 'carpets' rule is turned on as well",
category = COMMAND
)
public static String commandDistance = "true";
@Rule(
desc = "Enables /info command for blocks",
extra = {
"Also enables gray carpet placement action",
"if 'carpets' rule is turned on as well"
},
category = COMMAND
)
public static String commandInfo = "true";
@Rule(
desc = "Enables /perimeterinfo command",
extra = "... that scans the area around the block for potential spawnable spots",
category = COMMAND
)
public static String commandPerimeterInfo = "true";
@Rule(desc = "Enables /draw commands", extra = {"... allows for drawing simple shapes or","other shapes which are sorta difficult to do normally"}, category = COMMAND)
public static String commandDraw = "ops";
@Rule(
desc = "Enables /script command",
extra = "An in-game scripting API for Scarpet programming language",
category = {COMMAND, SCARPET}
)
public static String commandScript = "true";
private static class ModulePermissionLevel extends Validator<String> {
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
int permissionLevel = switch (newValue) {
case "false" -> 0;
case "true", "ops" -> 2;
case "0", "1", "2", "3", "4" -> Integer.parseInt(newValue);
default -> throw new IllegalArgumentException(); // already checked by previous validator
};
if (source != null && !source.hasPermission(permissionLevel))
return null;
CarpetSettings.runPermissionLevel = permissionLevel;
if (source != null)
CommandHelper.notifyPlayersCommandsChanged(source.getServer());
return newValue;
}
@Override
public String description() { return "When changing the rule, you must at least have the permission level you are trying to give it";}
}
@Rule(
desc = "Enables restrictions for arbitrary code execution with scarpet",
extra = {
"Users that don't have this permission level",
"won't be able to load apps or /script run.",
"It is also the permission level apps will",
"have when running commands with run()"
},
category = {SCARPET},
options = {"ops", "0", "1", "2", "3", "4"},
validate = {Validators.CommandLevel.class, ModulePermissionLevel.class}
)
public static String commandScriptACE = "ops";
@Rule(
desc = "Scarpet script from world files will autoload on server/world start ",
extra = "if /script is enabled",
category = SCARPET
)
public static boolean scriptsAutoload = true;
@Rule(
desc = "Enables scripts debugging messages in system log",
category = SCARPET
)
public static boolean scriptsDebugging = false;
@Rule(
desc = "Enables scripts optimization",
category = SCARPET
)
public static boolean scriptsOptimization = true;
private static class ScarpetAppStore extends Validator<String> {
@Override
public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String stringInput) {
if (newValue.equals(currentRule.value())) {
// Don't refresh the local repo if it's the same (world change), helps preventing hitting rate limits from github when
// getting suggestions. Pending is a way to invalidate the cache when it gets old, and investigating api usage further
return newValue;
}
if (newValue.equals("none")) {
AppStoreManager.setScarpetRepoLink(null);
} else {
if (newValue.endsWith("/"))
newValue = newValue.substring(0, newValue.length() - 1);
AppStoreManager.setScarpetRepoLink("https://api.github.com/repos/" + newValue + "/");
}
if (source != null)
CommandHelper.notifyPlayersCommandsChanged(source.getServer());
return newValue;
}
@Override
public String description() {
return "Appstore link should point to a valid github repository";
}
}
@Rule(
desc = "Location of the online repository of scarpet apps",
extra = {
"set to 'none' to disable.",
"Point to any github repo with scarpet apps",
"using <user>/<repo>/contents/<path...>"
},
category = SCARPET,
strict = false,
validate = ScarpetAppStore.class
)
public static String scriptsAppStore = "gnembon/scarpet/contents/programs";
@Rule(desc = "Enables /player command to control/spawn players", category = COMMAND)
public static String commandPlayer = "ops";
@Rule(desc = "Spawn offline players in online mode if online-mode player with specified name does not exist", category = COMMAND)
public static boolean allowSpawningOfflinePlayers = true;
@Rule(desc = "Allows to track mobs AI via /track command", category = COMMAND)
public static String commandTrackAI = "ops";
@Rule(desc = "Placing carpets may issue carpet commands for non-op players", category = SURVIVAL)
public static boolean carpets = false;
@Rule(
desc = "Glass can be broken faster with pickaxes",
category = SURVIVAL
)
public static boolean missingTools = false;
@Rule(desc = "fill/clone/setblock and structure blocks cause block updates", category = CREATIVE)
public static boolean fillUpdates = true;
@Rule(desc = "placing blocks cause block updates", category = CREATIVE)
public static boolean interactionUpdates = true;
@Rule(desc = "Disables breaking of blocks caused by flowing liquids", category = CREATIVE)
public static boolean liquidDamageDisabled = false;
@Rule(
desc = "smooth client animations with low tps settings",
extra = "works only in SP, and will slow down players",
category = {CREATIVE, SURVIVAL, CLIENT}
)
public static boolean smoothClientAnimations;
private static class PushLimitLimits extends Validator<Integer> {
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
return (newValue>0 && newValue <= 1024) ? newValue : null;
}
@Override
public String description() { return "You must choose a value from 1 to 1024";}
}
@Rule(
desc = "Customizable piston push limit",
options = {"10", "12", "14", "100"},
category = CREATIVE,
strict = false,
validate = PushLimitLimits.class
)
public static int pushLimit = PistonStructureResolver.MAX_PUSH_DEPTH;
@Rule(
desc = "Customizable powered rail power range",
options = {"9", "15", "30"},
category = CREATIVE,
strict = false,
validate = PushLimitLimits.class
)
public static int railPowerLimit = 9;
private static class FillLimitMigrator extends Validator<Integer>
{
@Override
public Integer validate(CommandSourceStack source, CarpetRule<Integer> changingRule, Integer newValue, String userInput)
{
if (source != null && source.getServer().overworld() != null)
{
GameRules.IntegerValue gamerule = source.getServer().getGameRules().getRule(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT);
if (gamerule.get() != newValue)
{
if (newValue == 32768 && changingRule.value() == newValue) // migration call, gamerule is different, update rule
{
Messenger.m(source, "g Syncing fillLimit rule with gamerule");
newValue = gamerule.get();
} else if (newValue != 32768 && gamerule.get() == 32768)
{
Messenger.m(source, "g Migrated value of fillLimit carpet rule to commandModificationBlockLimit gamerule");
gamerule.set(newValue, source.getServer());
}
}
}
return newValue;
}
@Override
public String description() { return "The value of this rule will be migrated to the gamerule";}
}
@Rule(
desc = "[Deprecated] Customizable fill/fillbiome/clone volume limit",
extra = "Use vanilla gamerule instead. This setting will be removed in 1.20.0",
options = {"32768", "250000", "1000000"},
category = CREATIVE,
strict = false,
validate = FillLimitMigrator.class
)
public static int fillLimit = 32768;
private static class ForceloadLimitValidator extends Validator<Integer>
{
@Override
public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string)
{
return (newValue > 0 && newValue <= 20000000) ? newValue : null;
}
@Override
public String description() { return "You must choose a value from 1 to 20M";}
}
@Rule(
desc = "Customizable forceload chunk limit",
options = {"256"},
category = CREATIVE,
strict = false,
validate = ForceloadLimitValidator.class
)
public static int forceloadLimit = 256;
@Rule(
desc = "Customizable maximal entity collision limits, 0 for no limits",
options = {"0", "1", "20"},
category = OPTIMIZATION,
strict = false,
validate = Validators.NonNegativeNumber.class
)
public static int maxEntityCollisions = 0;
@Rule(
desc = "Customizable server list ping (Multiplayer menu) playerlist sample limit",
options = {"0", "12", "20", "40"},
category = CREATIVE,
strict = false,
validate = Validators.NonNegativeNumber.class
)
public static int pingPlayerListLimit = 12;
/*
@Rule(
desc = "fixes water performance issues",
category = OPTIMIZATION,
validate = Validator.WIP.class
)
public static boolean waterFlow = true;
*/
@Rule(
desc = "Sets a different motd message on client trying to connect to the server",
extra = "use '_' to use the startup setting from server.properties",
options = "_",
strict = false,
category = CREATIVE
)
public static String customMOTD = "_";
@Rule(
desc = "Cactus in dispensers rotates blocks.",
extra = "Rotates block anti-clockwise if possible",
category = {FEATURE, DISPENSER}
)
public static boolean rotatorBlock = false;
private static class ViewDistanceValidator extends Validator<Integer>
{
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string)
{
if (currentRule.value().equals(newValue) || source == null)
{
return newValue;
}
if (newValue < 0 || newValue > 32)
{
Messenger.m(source, "r view distance has to be between 0 and 32");
return null;
}
MinecraftServer server = source.getServer();
if (server.isDedicatedServer())
{
int vd = (newValue >= 2)?newValue:((ServerInterface) server).getProperties().viewDistance;
if (vd != server.getPlayerList().getViewDistance())
server.getPlayerList().setViewDistance(vd);
return newValue;
}
else
{
Messenger.m(source, "r view distance can only be changed on a server");
return 0;
}
}
@Override
public String description() { return "You must choose a value from 0 (use server settings) to 32";}
}
@Rule(
desc = "Changes the view distance of the server.",
extra = "Set to 0 to not override the value in server settings.",
options = {"0", "12", "16", "32"},
category = CREATIVE,
strict = false,
validate = ViewDistanceValidator.class
)
public static int viewDistance = 0;
private static class SimulationDistanceValidator extends Validator<Integer>
{
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string)
{
if (currentRule.value().equals(newValue) || source == null)
{
return newValue;
}
if (newValue < 0 || newValue > 32)
{
Messenger.m(source, "r simulation distance has to be between 0 and 32");
return null;
}
MinecraftServer server = source.getServer();
if (server.isDedicatedServer())
{
int vd = (newValue >= 2)?newValue:((DedicatedServer) server).getProperties().simulationDistance;
if (vd != server.getPlayerList().getSimulationDistance())
server.getPlayerList().setSimulationDistance(vd);
return newValue;
}
else
{
Messenger.m(source, "r simulation distance can only be changed on a server");
return 0;
}
}
@Override
public String description() { return "You must choose a value from 0 (use server settings) to 32";}
}
@Rule(
desc = "Changes the simulation distance of the server.",
extra = "Set to 0 to not override the value in server settings.",
options = {"0", "12", "16", "32"},
category = CREATIVE,
strict = false,
validate = SimulationDistanceValidator.class
)
public static int simulationDistance = 0;
public static class ChangeSpawnChunksValidator extends Validator<Integer> {
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
if (source == null) return newValue;
if (newValue < 0 || newValue > 32)
{
Messenger.m(source, "r spawn chunk size has to be between 0 and 32");
return null;
}
if (currentRule.value().intValue() == newValue.intValue())
{
//must been some startup thing
return newValue;
}
ServerLevel currentOverworld = source.getServer().overworld();
if (currentOverworld != null)
{
SpawnChunks.changeSpawnSize(currentOverworld, newValue);
}
return newValue;
}
}
@Rule(
desc = "Changes size of spawn chunks",
extra = {"Defines new radius", "setting it to 0 - disables spawn chunks"},
category = CREATIVE,
strict = false,
options = {"0", "11"},
validate = ChangeSpawnChunksValidator.class
)
public static int spawnChunksSize = MinecraftServer.START_CHUNK_RADIUS;
public static class LightBatchValidator extends Validator<Integer> {
public static void applyLightBatchSizes(MinecraftServer server, int maxBatchSize)
{
for (ServerLevel world : server.getAllLevels())
{
//world.getChunkSource().getLightEngine().setTaskPerBatch(maxBatchSize);
}
}
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
if (source == null) return newValue;
if (newValue < 0)
{
Messenger.m(source, "r light batch size has to be at least 0");
return null;
}
if (currentRule.value().intValue() == newValue.intValue())
{
//must been some startup thing
return newValue;
}
applyLightBatchSizes(source.getServer(), newValue); // Apply new settings
return newValue;
}
}
@Rule(
desc = "Changes maximum light tasks batch size",
extra = {"Allows for a higher light suppression tolerance", "setting it to 5 - Default limit defined by the game"},
category = {EXPERIMENTAL, OPTIMIZATION},
strict = false,
options = {"5", "50", "100", "200"},
validate = LightBatchValidator.class
)
public static int lightEngineMaxBatchSize = 5;
public enum RenewableCoralMode {
FALSE,
EXPANDED,
TRUE;
}
@Rule(
desc = "Coral structures will grow with bonemeal from coral plants",
extra = "Expanded also allows growing from coral fans for sustainable farming outside of warm oceans",
category = FEATURE
)
public static RenewableCoralMode renewableCoral = RenewableCoralMode.FALSE;
@Rule(
desc = "Nether basalt generator without soul sand below ",
extra = " .. will convert into blackstone instead",
category = FEATURE
)
public static boolean renewableBlackstone = false;
@Rule(
desc = "Lava and water generate deepslate and cobbled deepslate instead below Y0",
category = FEATURE
)
public static boolean renewableDeepslate = false;
@Rule(desc = "fixes block placement rotation issue when player rotates quickly while placing blocks", category = RuleCategory.BUGFIX)
public static boolean placementRotationFix = false;
@Rule(desc = "Spawning requires much less CPU and Memory", category = OPTIMIZATION)
public static boolean lagFreeSpawning = false;
@Rule(
desc = "Increases for testing purposes number of blue skulls shot by the wither",
category = CREATIVE
)
public static boolean moreBlueSkulls = false;
@Rule(
desc = "Removes fog from client in the nether and the end",
extra = "Improves visibility, but looks weird",
category = CLIENT
)
public static boolean fogOff = false;
@Rule(
desc = "Creative No Clip",
extra = {
"On servers it needs to be set on both ",
"client and server to function properly.",
"Has no effect when set on the server only",
"Can allow to phase through walls",
"if only set on the carpet client side",
"but requires some trapdoor magic to",
"allow the player to enter blocks"
},
category = {CREATIVE, CLIENT}
)
public static boolean creativeNoClip = false;
public static boolean isCreativeFlying(Entity entity)
{
// #todo replace after merger to 1.17
return CarpetSettings.creativeNoClip && entity instanceof Player && (((Player) entity).isCreative()) && ((Player) entity).getAbilities().flying;
}
@Rule(
desc = "Creative flying speed multiplier",
extra = {
"Purely client side setting, meaning that",
"having it set on the decicated server has no effect",
"but this also means it will work on vanilla servers as well"
},
category = {CREATIVE, CLIENT},
strict = false,
validate = Validators.NonNegativeNumber.class
)
public static double creativeFlySpeed = 1.0;
@Rule(
desc = "Creative air drag",
extra = {
"Increased drag will slow down your flight",
"So need to adjust speed accordingly",
"With 1.0 drag, using speed of 11 seems to matching vanilla speeds.",
"Purely client side setting, meaning that",
"having it set on the decicated server has no effect",
"but this also means it will work on vanilla servers as well"
},
category = {CREATIVE, CLIENT},
strict = false,
validate = Validators.Probablity.class
)
public static double creativeFlyDrag = 0.09;
@Rule(
desc = "Removes obnoxious messages from the logs",
extra = {
"Doesn't display 'Maximum sound pool size 247 reached'",