-
-
Notifications
You must be signed in to change notification settings - Fork 307
/
NMSImpl.java
2450 lines (2274 loc) · 112 KB
/
NMSImpl.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 net.citizensnpcs.nms.v1_18_R2.util;
import java.lang.invoke.MethodHandle;
import java.net.SocketAddress;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
import org.bukkit.craftbukkit.v1_18_R2.CraftSound;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_18_R2.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_18_R2.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftWither;
import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_18_R2.event.CraftPortalEvent;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryAnvil;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wither;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.HttpAuthenticationService;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
import com.mojang.util.UUIDTypeAdapter;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.ai.NavigatorParameters;
import net.citizensnpcs.api.ai.event.CancelReason;
import net.citizensnpcs.api.astar.pathfinder.DoorExaminer;
import net.citizensnpcs.api.command.CommandManager;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.event.DespawnReason;
import net.citizensnpcs.api.gui.ForwardingInventory;
import net.citizensnpcs.api.jnbt.ByteArrayTag;
import net.citizensnpcs.api.jnbt.ByteTag;
import net.citizensnpcs.api.jnbt.CompoundTag;
import net.citizensnpcs.api.jnbt.DoubleTag;
import net.citizensnpcs.api.jnbt.EndTag;
import net.citizensnpcs.api.jnbt.FloatTag;
import net.citizensnpcs.api.jnbt.IntArrayTag;
import net.citizensnpcs.api.jnbt.IntTag;
import net.citizensnpcs.api.jnbt.ListTag;
import net.citizensnpcs.api.jnbt.LongTag;
import net.citizensnpcs.api.jnbt.ShortTag;
import net.citizensnpcs.api.jnbt.StringTag;
import net.citizensnpcs.api.jnbt.Tag;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitInfo;
import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.api.util.EntityDim;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.nms.v1_18_R2.entity.ArmorStandController;
import net.citizensnpcs.nms.v1_18_R2.entity.AxolotlController;
import net.citizensnpcs.nms.v1_18_R2.entity.BatController;
import net.citizensnpcs.nms.v1_18_R2.entity.BeeController;
import net.citizensnpcs.nms.v1_18_R2.entity.BlazeController;
import net.citizensnpcs.nms.v1_18_R2.entity.CatController;
import net.citizensnpcs.nms.v1_18_R2.entity.CaveSpiderController;
import net.citizensnpcs.nms.v1_18_R2.entity.ChickenController;
import net.citizensnpcs.nms.v1_18_R2.entity.CodController;
import net.citizensnpcs.nms.v1_18_R2.entity.CowController;
import net.citizensnpcs.nms.v1_18_R2.entity.CreeperController;
import net.citizensnpcs.nms.v1_18_R2.entity.DolphinController;
import net.citizensnpcs.nms.v1_18_R2.entity.DrownedController;
import net.citizensnpcs.nms.v1_18_R2.entity.EnderDragonController;
import net.citizensnpcs.nms.v1_18_R2.entity.EndermanController;
import net.citizensnpcs.nms.v1_18_R2.entity.EndermiteController;
import net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC;
import net.citizensnpcs.nms.v1_18_R2.entity.EvokerController;
import net.citizensnpcs.nms.v1_18_R2.entity.FoxController;
import net.citizensnpcs.nms.v1_18_R2.entity.GhastController;
import net.citizensnpcs.nms.v1_18_R2.entity.GiantController;
import net.citizensnpcs.nms.v1_18_R2.entity.GlowSquidController;
import net.citizensnpcs.nms.v1_18_R2.entity.GoatController;
import net.citizensnpcs.nms.v1_18_R2.entity.GuardianController;
import net.citizensnpcs.nms.v1_18_R2.entity.GuardianElderController;
import net.citizensnpcs.nms.v1_18_R2.entity.HoglinController;
import net.citizensnpcs.nms.v1_18_R2.entity.HorseController;
import net.citizensnpcs.nms.v1_18_R2.entity.HorseDonkeyController;
import net.citizensnpcs.nms.v1_18_R2.entity.HorseMuleController;
import net.citizensnpcs.nms.v1_18_R2.entity.HorseSkeletonController;
import net.citizensnpcs.nms.v1_18_R2.entity.HorseZombieController;
import net.citizensnpcs.nms.v1_18_R2.entity.HumanController;
import net.citizensnpcs.nms.v1_18_R2.entity.IllusionerController;
import net.citizensnpcs.nms.v1_18_R2.entity.IronGolemController;
import net.citizensnpcs.nms.v1_18_R2.entity.LlamaController;
import net.citizensnpcs.nms.v1_18_R2.entity.MagmaCubeController;
import net.citizensnpcs.nms.v1_18_R2.entity.MushroomCowController;
import net.citizensnpcs.nms.v1_18_R2.entity.OcelotController;
import net.citizensnpcs.nms.v1_18_R2.entity.PandaController;
import net.citizensnpcs.nms.v1_18_R2.entity.ParrotController;
import net.citizensnpcs.nms.v1_18_R2.entity.PhantomController;
import net.citizensnpcs.nms.v1_18_R2.entity.PigController;
import net.citizensnpcs.nms.v1_18_R2.entity.PigZombieController;
import net.citizensnpcs.nms.v1_18_R2.entity.PiglinBruteController;
import net.citizensnpcs.nms.v1_18_R2.entity.PiglinController;
import net.citizensnpcs.nms.v1_18_R2.entity.PillagerController;
import net.citizensnpcs.nms.v1_18_R2.entity.PolarBearController;
import net.citizensnpcs.nms.v1_18_R2.entity.PufferFishController;
import net.citizensnpcs.nms.v1_18_R2.entity.RabbitController;
import net.citizensnpcs.nms.v1_18_R2.entity.RavagerController;
import net.citizensnpcs.nms.v1_18_R2.entity.SalmonController;
import net.citizensnpcs.nms.v1_18_R2.entity.SheepController;
import net.citizensnpcs.nms.v1_18_R2.entity.ShulkerController;
import net.citizensnpcs.nms.v1_18_R2.entity.SilverfishController;
import net.citizensnpcs.nms.v1_18_R2.entity.SkeletonController;
import net.citizensnpcs.nms.v1_18_R2.entity.SkeletonStrayController;
import net.citizensnpcs.nms.v1_18_R2.entity.SkeletonWitherController;
import net.citizensnpcs.nms.v1_18_R2.entity.SlimeController;
import net.citizensnpcs.nms.v1_18_R2.entity.SnowmanController;
import net.citizensnpcs.nms.v1_18_R2.entity.SpiderController;
import net.citizensnpcs.nms.v1_18_R2.entity.SquidController;
import net.citizensnpcs.nms.v1_18_R2.entity.StriderController;
import net.citizensnpcs.nms.v1_18_R2.entity.TraderLlamaController;
import net.citizensnpcs.nms.v1_18_R2.entity.TropicalFishController;
import net.citizensnpcs.nms.v1_18_R2.entity.TurtleController;
import net.citizensnpcs.nms.v1_18_R2.entity.VexController;
import net.citizensnpcs.nms.v1_18_R2.entity.VillagerController;
import net.citizensnpcs.nms.v1_18_R2.entity.VindicatorController;
import net.citizensnpcs.nms.v1_18_R2.entity.WanderingTraderController;
import net.citizensnpcs.nms.v1_18_R2.entity.WitchController;
import net.citizensnpcs.nms.v1_18_R2.entity.WitherController;
import net.citizensnpcs.nms.v1_18_R2.entity.WolfController;
import net.citizensnpcs.nms.v1_18_R2.entity.ZoglinController;
import net.citizensnpcs.nms.v1_18_R2.entity.ZombieController;
import net.citizensnpcs.nms.v1_18_R2.entity.ZombieHuskController;
import net.citizensnpcs.nms.v1_18_R2.entity.ZombieVillagerController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.AreaEffectCloudController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.BoatController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.DragonFireballController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.EggController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.EnderCrystalController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.EnderPearlController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.EnderSignalController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.EvokerFangsController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.FallingBlockController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.FireworkController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.FishingHookController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.GlowItemFrameController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ItemController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ItemFrameController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.LargeFireballController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.LeashController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.LlamaSpitController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.MarkerController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.MinecartChestController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.MinecartCommandController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.MinecartFurnaceController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.MinecartHopperController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.MinecartRideableController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.MinecartTNTController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.PaintingController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ShulkerBulletController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.SmallFireballController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.SnowballController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.SpectralArrowController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.TNTPrimedController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ThrownExpBottleController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ThrownPotionController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ThrownTridentController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.WitherSkullController;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.AxolotlTrait;
import net.citizensnpcs.trait.versioned.BeeTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.CatTrait;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.trait.versioned.FoxTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
import net.citizensnpcs.trait.versioned.PandaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PhantomTrait;
import net.citizensnpcs.trait.versioned.PiglinTrait;
import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.EmptyChannel;
import net.citizensnpcs.util.EntityPacketTracker;
import net.citizensnpcs.util.EntityPacketTracker.PacketAggregator;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.NMSBridge;
import net.citizensnpcs.util.PlayerAnimation;
import net.citizensnpcs.util.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerAdvancements;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ChunkMap.TrackedEntity;
import net.minecraft.server.level.ServerBossEvent;
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Mth;
import net.minecraft.world.Container;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Entity.RemovalReason;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.FlyingMoveControl;
import net.minecraft.world.entity.ai.control.LookControl;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.ai.goal.GoalSelector;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.animal.AbstractFish;
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
import net.minecraft.world.entity.animal.Cat;
import net.minecraft.world.entity.animal.Dolphin;
import net.minecraft.world.entity.animal.Panda;
import net.minecraft.world.entity.animal.PolarBear;
import net.minecraft.world.entity.animal.Pufferfish;
import net.minecraft.world.entity.animal.Rabbit;
import net.minecraft.world.entity.animal.Turtle;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
import net.minecraft.world.entity.boss.wither.WitherBoss;
import net.minecraft.world.entity.item.FallingBlockEntity;
import net.minecraft.world.entity.monster.EnderMan;
import net.minecraft.world.entity.monster.Shulker;
import net.minecraft.world.entity.monster.piglin.Piglin;
import net.minecraft.world.entity.projectile.FishingHook;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.inventory.AnvilMenu;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.dimension.end.EndDragonFight;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.level.pathfinder.Node;
import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.level.pathfinder.PathFinder;
import net.minecraft.world.level.portal.PortalInfo;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.scores.PlayerTeam;
@SuppressWarnings("unchecked")
public class NMSImpl implements NMSBridge {
public NMSImpl() {
loadEntityTypes();
}
@Override
public void activate(org.bukkit.entity.Entity entity) {
getHandle(entity).activatedTick = MinecraftServer.currentTick;
}
@SuppressWarnings("resource")
@Override
public boolean addEntityToWorld(org.bukkit.entity.Entity entity, SpawnReason custom) {
int viewDistance = -1;
ChunkMap chunkMap = null;
try {
if (entity instanceof Player) {
chunkMap = ((ServerChunkCache) getHandle(entity).level.getChunkSource()).chunkMap;
viewDistance = (int) PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER.invoke(chunkMap);
PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER.invoke(chunkMap, -1);
}
} catch (Throwable e) {
e.printStackTrace();
}
boolean success = getHandle(entity).level.addFreshEntity(getHandle(entity), custom);
try {
if (chunkMap != null) {
PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER.invoke(chunkMap, viewDistance);
}
} catch (Throwable e) {
e.printStackTrace();
}
return success;
}
@Override
public void addOrRemoveFromPlayerList(org.bukkit.entity.Entity entity, boolean remove) {
if (entity == null)
return;
ServerPlayer handle = (ServerPlayer) getHandle(entity);
if (handle.level == null)
return;
List<? extends net.minecraft.world.entity.player.Player> players = handle.level.players();
boolean changed = false;
if (remove && players.contains(handle)) {
players.remove(handle);
changed = true;
} else if (!remove && !players.contains(handle)) {
((List) players).add(handle);
changed = true;
}
if (!changed)
return;
try {
CHUNKMAP_UPDATE_PLAYER_STATUS.invoke(((ServerLevel) handle.level).getChunkSource().chunkMap, handle,
!remove);
} catch (Throwable e) {
e.printStackTrace();
}
// PlayerUpdateTask.addOrRemove(entity, remove);
}
@Override
public void attack(org.bukkit.entity.LivingEntity attacker, org.bukkit.entity.LivingEntity btarget) {
LivingEntity source = getHandle(attacker);
LivingEntity target = getHandle(btarget);
if (source instanceof ServerPlayer) {
((ServerPlayer) source).attack(target);
PlayerAnimation.ARM_SWING.play((Player) source.getBukkitEntity());
return;
}
if (source instanceof Mob) {
((Mob) source).doHurtTarget(target);
return;
}
float f = (float) (source.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE)
? source.getAttributeValue(Attributes.ATTACK_DAMAGE)
: 1f);
int i = 0;
f += EnchantmentHelper.getDamageBonus(source.getMainHandItem(), target.getMobType());
i += EnchantmentHelper.getKnockbackBonus(source);
boolean flag = target.hurt(DamageSource.mobAttack(source), f);
if (!flag)
return;
if (i > 0) {
target.knockback(-Math.sin(source.getYRot() * Math.PI / 180.0F) * i * 0.5F, 0.1D,
Math.cos(source.getYRot() * Math.PI / 180.0F) * i * 0.5F);
source.setDeltaMovement(source.getDeltaMovement().multiply(0.6, 1, 0.6));
}
int fireAspectLevel = EnchantmentHelper.getFireAspect(source);
if (fireAspectLevel > 0) {
target.setSecondsOnFire(fireAspectLevel * 4, false);
}
if (target instanceof ServerPlayer) {
ServerPlayer entityhuman = (ServerPlayer) target;
ItemStack itemstack = source.getMainHandItem();
ItemStack itemstack1 = entityhuman.isUsingItem() ? entityhuman.getUseItem() : ItemStack.EMPTY;
if (!itemstack.isEmpty() && !itemstack1.isEmpty()
&& itemstack.getItem() instanceof net.minecraft.world.item.AxeItem && itemstack1.is(Items.SHIELD)) {
float f2 = 0.25F + EnchantmentHelper.getBlockEfficiency(source) * 0.05F;
if (new Random().nextFloat() < f2) {
entityhuman.getCooldowns().addCooldown(Items.SHIELD, 100);
source.level.broadcastEntityEvent(entityhuman, (byte) 30);
}
}
}
EnchantmentHelper.doPostHurtEffects(source, target);
EnchantmentHelper.doPostDamageEffects(target, source);
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
MobAI ai = MobAI.from(handle);
if (ai == null)
return;
if (ai.getMoveControl() instanceof EntityMoveControl) {
((EntityMoveControl) ai.getMoveControl()).moving = false;
} else {
try {
MOVE_CONTROLLER_MOVING.invoke(ai.getMoveControl(), null);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
@Override
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
Entity handle = getHandle(entity);
Set<ServerPlayerConnection> linked = Sets.newIdentityHashSet();
ServerEntity tracker = new ServerEntity((ServerLevel) handle.level, handle, handle.getType().updateInterval(),
handle.getType().trackDeltas(), agg::send, linked);
Map<EquipmentSlot, ItemStack> equipment = Maps.newEnumMap(EquipmentSlot.class);
return new EntityPacketTracker() {
@Override
public void link(Player player) {
ServerPlayer p = (ServerPlayer) getHandle(player);
handle.unsetRemoved();
tracker.addPairing(p);
linked.add(p.connection);
agg.add(p.getUUID(), packet -> p.connection.send((Packet<?>) packet));
}
@Override
public void run() {
if (handle instanceof LivingEntity) {
boolean changed = false;
LivingEntity entity = (LivingEntity) handle;
for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemStack old = equipment.getOrDefault(slot, ItemStack.EMPTY);
ItemStack curr = entity.getItemBySlot(slot);
if (!changed && !ItemStack.matches(old, curr)) {
changed = true;
}
equipment.put(slot, curr);
}
if (changed) {
List<com.mojang.datafixers.util.Pair<EquipmentSlot, ItemStack>> vals = Lists.newArrayList();
for (EquipmentSlot slot : EquipmentSlot.values()) {
vals.add(com.mojang.datafixers.util.Pair.of(slot, equipment.get(slot)));
}
agg.send(new ClientboundSetEquipmentPacket(handle.getId(), vals));
}
}
tracker.sendChanges();
}
@Override
public void unlink(Player player) {
ServerPlayer p = (ServerPlayer) getHandle(player);
tracker.removePairing(p);
linked.remove(p.connection);
agg.removeConnection(p.getUUID());
}
@Override
public void unlinkAll(Consumer<Player> callback) {
handle.remove(RemovalReason.KILLED);
for (ServerPlayerConnection link : Lists.newArrayList(linked)) {
Player entity = link.getPlayer().getBukkitEntity();
unlink(entity);
if (callback != null) {
callback.accept(entity);
}
}
linked.clear();
}
};
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
if (Bukkit.isPrimaryThread())
throw new IllegalStateException("NMS.fillProfileProperties cannot be invoked from the main thread.");
MinecraftSessionService sessionService = ((CraftServer) Bukkit.getServer()).getServer().getSessionService();
if (!(sessionService instanceof YggdrasilMinecraftSessionService))
return sessionService.fillProfileProperties(profile, requireSecure);
YggdrasilAuthenticationService auth = ((YggdrasilMinecraftSessionService) sessionService)
.getAuthenticationService();
URL url = HttpAuthenticationService
.constantURL(getAuthServerBaseUrl() + UUIDTypeAdapter.fromUUID(profile.getId()));
url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(auth,
url, null, MinecraftProfilePropertiesResponse.class);
if (response == null)
return profile;
GameProfile result = new GameProfile(response.getId(), response.getName());
result.getProperties().putAll(response.getProperties());
profile.getProperties().putAll(response.getProperties());
return result;
}
public String getAuthServerBaseUrl() {
return Setting.AUTH_SERVER_URL.asString();
}
@Override
public BlockBreaker getBlockBreaker(org.bukkit.entity.Entity entity, org.bukkit.block.Block targetBlock,
BlockBreakerConfiguration config) {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
ServerBossEvent bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = ((WitherBoss) NMSImpl.getHandle(entity)).bossEvent;
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
EndDragonFight df = ((EnderDragon) NMSImpl.getHandle(entity)).getDragonFight();
if (df != null) {
bserver = df.dragonEvent;
}
}
} catch (Throwable e) {
e.printStackTrace();
}
if (bserver == null)
return null;
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
} catch (Throwable e) {
e.printStackTrace();
}
return ret;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
}
@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
ServerLevel world = ((CraftWorld) block.getWorld()).getHandle();
VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
return shape.isEmpty() ? BoundingBox.EMPTY : NMSBoundingBox.wrap(shape.bounds());
}
@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
MoveControl controller = handle instanceof Mob ? ((Mob) handle).getMoveControl()
: handle instanceof MobAI ? ((MobAI) handle).getMoveControl() : null;
if (controller == null || !controller.hasWanted())
return null;
return new Location(entity.getWorld(), controller.getWantedX(), controller.getWantedY(),
controller.getWantedZ());
}
@Override
public GameProfileRepository getGameProfileRepository() {
return ((CraftServer) Bukkit.getServer()).getServer().getProfileRepository();
}
@Override
public float getHeadYaw(org.bukkit.entity.Entity entity) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return entity.getLocation().getYaw();
return getHandle((org.bukkit.entity.LivingEntity) entity).getYHeadRot();
}
@Override
public double getHeight(org.bukkit.entity.Entity entity) {
return entity.getHeight();
}
@Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive())
return Float.NaN;
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
return handle.zza;
}
@Override
public CompoundTag getNBT(org.bukkit.inventory.ItemStack item) {
return convertNBT(CraftItemStack.asNMSCopy(item).getTag());
}
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public EntityPacketTracker getPacketTracker(org.bukkit.entity.Entity entity) {
ServerLevel server = (ServerLevel) getHandle(entity).level;
TrackedEntity entry = server.getChunkSource().chunkMap.entityMap.get(entity.getEntityId());
if (entry == null)
return null;
return new EntityPacketTracker() {
@Override
public void link(Player player) {
entry.updatePlayer((ServerPlayer) getHandle(player));
}
@Override
public void run() {
}
@Override
public void unlink(Player player) {
entry.removePlayer((ServerPlayer) getHandle(player));
}
@Override
public void unlinkAll(Consumer<Player> callback) {
entry.broadcastRemoved();
}
};
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, Entity::getBukkitEntity);
}
@Override
public GameProfile getProfile(Player player) {
return ((net.minecraft.world.entity.player.Player) getHandle(player)).getGameProfile();
}
@Override
public GameProfile getProfile(SkullMeta meta) {
if (SKULL_META_PROFILE == null) {
SKULL_META_PROFILE = NMS.getFirstGetter(meta.getClass(), GameProfile.class);
if (SKULL_META_PROFILE == null)
return null;
}
try {
return (GameProfile) SKULL_META_PROFILE.invoke(meta);
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
@Override
public String getSoundPath(Sound flag) throws CommandException {
try {
SoundEvent effect = CraftSound.getSoundEffect(flag);
if (effect == null)
throw new CommandException(Messages.INVALID_SOUND);
return effect.getLocation().getPath();
} catch (Throwable e) {
throw new CommandException(Messages.INVALID_SOUND);
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof org.bukkit.entity.LivingEntity))
return DEFAULT_SPEED;
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) npc.getEntity());
if (handle == null) {
}
return DEFAULT_SPEED;
// return (float)
// handle.getAttribute(Attributes.d).getValue();
}
@Override
public float getStepHeight(org.bukkit.entity.Entity entity) {
return NMSImpl.getHandle(entity).maxUpStep;
}
@Override
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
final NavigatorParameters params) {
List<Node> list = Lists.<Node> newArrayList(Iterables.<Vector, Node> transform(dest,
input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
Node last = list.size() > 0 ? list.get(list.size() - 1) : null;
final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true);
return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speed()));
}
@Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) {
return getTargetNavigator(entity, params,
input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speed()));
}
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
final Function<PathNavigation, Boolean> function) {
net.minecraft.world.entity.Entity raw = getHandle(entity);
raw.setOnGround(true);
// not sure of a better way around this - if onGround is false, then
// navigation won't execute, and calling entity.move doesn't
// entirely fix the problem.
final PathNavigation navigation = NMSImpl.getNavigation(entity);
final float oldWater = raw instanceof MobAI ? ((MobAI) raw).getPathfindingMalus(BlockPathTypes.WATER)
: ((Mob) raw).getPathfindingMalus(BlockPathTypes.WATER);
if (params.avoidWater() && oldWater >= 0) {
if (raw instanceof MobAI) {
((MobAI) raw).setPathfindingMalus(BlockPathTypes.WATER, oldWater + 1F);
} else {
((Mob) raw).setPathfindingMalus(BlockPathTypes.WATER, oldWater + 1F);
}
}
navigation.getNodeEvaluator().setCanOpenDoors(params.hasExaminer(DoorExaminer.class));
return new MCNavigator() {
float lastSpeed;
CancelReason reason;
private List<org.bukkit.block.Block> getBlocks(final org.bukkit.entity.Entity entity, Path path) {
List<org.bukkit.block.Block> blocks = Lists.newArrayList();
for (int i = 0; i < path.getNodeCount(); i++) {
Node pp = path.getNode(i);
blocks.add(entity.getWorld().getBlockAt(pp.x, pp.y, pp.z));
}
return blocks;
}
@Override
public CancelReason getCancelReason() {
return reason;
}
@Override
public Iterable<Vector> getPath() {
return new NavigationIterable(navigation);
}
@Override
public void stop() {
Path path = getPathEntity(navigation);
if (params.debug() && path != null) {
List<org.bukkit.block.Block> blocks = getBlocks(entity, path);
Util.sendBlockChanges(blocks, null);
}
if (oldWater >= 0) {
if (raw instanceof MobAI) {
((MobAI) raw).setPathfindingMalus(BlockPathTypes.WATER, oldWater);
} else {
((Mob) raw).setPathfindingMalus(BlockPathTypes.WATER, oldWater);
}
}
navigation.stop();
}
@Override
public boolean update() {
if (params.speed() != lastSpeed) {
Entity handle = getHandle(entity);
EntityDimensions size = null;
try {
size = (EntityDimensions) SIZE_FIELD_GETTER.invoke(handle);
if (handle instanceof AbstractHorse) {
SIZE_FIELD_SETTER.invoke(handle,
new EntityDimensions(Math.min(0.99F, size.width), size.height, false));
}
} catch (Throwable e) {
e.printStackTrace();
}
if (!function.apply(navigation)) {
reason = CancelReason.STUCK;
}
try {
SIZE_FIELD_SETTER.invoke(handle, size);
} catch (Throwable e) {
e.printStackTrace();
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
// make it just fit on 1 so hack around it a bit.
}
lastSpeed = params.speed();
}
if (params.debug() && !navigation.isDone()) {
Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION);
}
navigation.setSpeedModifier(params.speed());
return navigation.isDone();
}
};
}
@Override
public TargetNavigator getTargetNavigator(org.bukkit.entity.Entity entity, org.bukkit.entity.Entity target,
NavigatorParameters parameters) {
PathNavigation navigation = getNavigation(entity);
return navigation == null ? null : new MCTargetNavigator(entity, navigation, target, parameters);
}
@Override
public org.bukkit.entity.Entity getVehicle(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null)
return null;
Entity e = handle.getVehicle();
return e == handle || e == null ? null : e.getBukkitEntity();
}
@Override
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive())
return Float.NaN;
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
return handle.xxa;
}
@Override
public double getWidth(org.bukkit.entity.Entity entity) {
return entity.getWidth();
}
@Override
public float getYaw(org.bukkit.entity.Entity entity) {
return getHandle(entity).getYRot();
}
@Override
public boolean isOnGround(org.bukkit.entity.Entity entity) {
return NMSImpl.getHandle(entity).isOnGround();
}
@Override
public boolean isSolid(org.bukkit.block.Block in) {
BlockState data = ((CraftBlock) in).getNMS();
return data.isSuffocating(((CraftWorld) in.getWorld()).getHandle(),
new BlockPos(in.getX(), in.getY(), in.getZ()));
}
@Override
public boolean isValid(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
return handle.valid && handle.isAlive();
}
@Override
public void load(CommandManager manager) {
registerTraitWithCommand(manager, EnderDragonTrait.class);
registerTraitWithCommand(manager, AxolotlTrait.class);
registerTraitWithCommand(manager, BeeTrait.class);
registerTraitWithCommand(manager, BossBarTrait.class);
registerTraitWithCommand(manager, CatTrait.class);
registerTraitWithCommand(manager, FoxTrait.class);
registerTraitWithCommand(manager, LlamaTrait.class);
registerTraitWithCommand(manager, MushroomCowTrait.class);
registerTraitWithCommand(manager, ParrotTrait.class);
registerTraitWithCommand(manager, PandaTrait.class);
registerTraitWithCommand(manager, PiglinTrait.class);
registerTraitWithCommand(manager, PhantomTrait.class);
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, PufferFishTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);
registerTraitWithCommand(manager, VillagerTrait.class);
}
private void loadEntityTypes() {
EntityControllers.setEntityControllerForType(EntityType.AREA_EFFECT_CLOUD, AreaEffectCloudController.class);
EntityControllers.setEntityControllerForType(EntityType.ARROW, TippedArrowController.class);
EntityControllers.setEntityControllerForType(EntityType.ARMOR_STAND, ArmorStandController.class);
EntityControllers.setEntityControllerForType(EntityType.AXOLOTL, AxolotlController.class);
EntityControllers.setEntityControllerForType(EntityType.BAT, BatController.class);
EntityControllers.setEntityControllerForType(EntityType.BEE, BeeController.class);
EntityControllers.setEntityControllerForType(EntityType.BLAZE, BlazeController.class);
EntityControllers.setEntityControllerForType(EntityType.BOAT, BoatController.class);
EntityControllers.setEntityControllerForType(EntityType.CAT, CatController.class);
EntityControllers.setEntityControllerForType(EntityType.CAVE_SPIDER, CaveSpiderController.class);
EntityControllers.setEntityControllerForType(EntityType.CHICKEN, ChickenController.class);
EntityControllers.setEntityControllerForType(EntityType.COD, CodController.class);
EntityControllers.setEntityControllerForType(EntityType.COW, CowController.class);
EntityControllers.setEntityControllerForType(EntityType.CREEPER, CreeperController.class);
EntityControllers.setEntityControllerForType(EntityType.DOLPHIN, DolphinController.class);
EntityControllers.setEntityControllerForType(EntityType.DRAGON_FIREBALL, DragonFireballController.class);
EntityControllers.setEntityControllerForType(EntityType.DROPPED_ITEM, ItemController.class);
EntityControllers.setEntityControllerForType(EntityType.DROWNED, DrownedController.class);
EntityControllers.setEntityControllerForType(EntityType.EGG, EggController.class);
EntityControllers.setEntityControllerForType(EntityType.ELDER_GUARDIAN, GuardianElderController.class);
EntityControllers.setEntityControllerForType(EntityType.ENDER_CRYSTAL, EnderCrystalController.class);
EntityControllers.setEntityControllerForType(EntityType.ENDER_DRAGON, EnderDragonController.class);
EntityControllers.setEntityControllerForType(EntityType.ENDER_PEARL, EnderPearlController.class);
EntityControllers.setEntityControllerForType(EntityType.ENDER_SIGNAL, EnderSignalController.class);
EntityControllers.setEntityControllerForType(EntityType.ENDERMAN, EndermanController.class);
EntityControllers.setEntityControllerForType(EntityType.ENDERMITE, EndermiteController.class);
EntityControllers.setEntityControllerForType(EntityType.EVOKER, EvokerController.class);
EntityControllers.setEntityControllerForType(EntityType.EVOKER_FANGS, EvokerFangsController.class);
EntityControllers.setEntityControllerForType(EntityType.FALLING_BLOCK, FallingBlockController.class);
EntityControllers.setEntityControllerForType(EntityType.FIREWORK, FireworkController.class);
EntityControllers.setEntityControllerForType(EntityType.FIREBALL, LargeFireballController.class);
EntityControllers.setEntityControllerForType(EntityType.FISHING_HOOK, FishingHookController.class);
EntityControllers.setEntityControllerForType(EntityType.FOX, FoxController.class);
EntityControllers.setEntityControllerForType(EntityType.GHAST, GhastController.class);
EntityControllers.setEntityControllerForType(EntityType.GIANT, GiantController.class);
EntityControllers.setEntityControllerForType(EntityType.GOAT, GoatController.class);
EntityControllers.setEntityControllerForType(EntityType.GUARDIAN, GuardianController.class);
EntityControllers.setEntityControllerForType(EntityType.HORSE, HorseController.class);
EntityControllers.setEntityControllerForType(EntityType.DONKEY, HorseDonkeyController.class);
EntityControllers.setEntityControllerForType(EntityType.MULE, HorseMuleController.class);
EntityControllers.setEntityControllerForType(EntityType.SKELETON_HORSE, HorseSkeletonController.class);
EntityControllers.setEntityControllerForType(EntityType.ZOMBIE_HORSE, HorseZombieController.class);
EntityControllers.setEntityControllerForType(EntityType.HUSK, ZombieHuskController.class);
EntityControllers.setEntityControllerForType(EntityType.IRON_GOLEM, IronGolemController.class);
EntityControllers.setEntityControllerForType(EntityType.ILLUSIONER, IllusionerController.class);
EntityControllers.setEntityControllerForType(EntityType.ITEM_FRAME, ItemFrameController.class);
EntityControllers.setEntityControllerForType(EntityType.GLOW_ITEM_FRAME, GlowItemFrameController.class);
EntityControllers.setEntityControllerForType(EntityType.LEASH_HITCH, LeashController.class);
EntityControllers.setEntityControllerForType(EntityType.LLAMA, LlamaController.class);
EntityControllers.setEntityControllerForType(EntityType.TRADER_LLAMA, TraderLlamaController.class);
EntityControllers.setEntityControllerForType(EntityType.WANDERING_TRADER, WanderingTraderController.class);
EntityControllers.setEntityControllerForType(EntityType.LLAMA_SPIT, LlamaSpitController.class);
EntityControllers.setEntityControllerForType(EntityType.SPLASH_POTION, ThrownPotionController.class);
EntityControllers.setEntityControllerForType(EntityType.MARKER, MarkerController.class);
EntityControllers.setEntityControllerForType(EntityType.MAGMA_CUBE, MagmaCubeController.class);
EntityControllers.setEntityControllerForType(EntityType.MINECART, MinecartRideableController.class);
EntityControllers.setEntityControllerForType(EntityType.MINECART_CHEST, MinecartChestController.class);
EntityControllers.setEntityControllerForType(EntityType.MINECART_COMMAND, MinecartCommandController.class);
EntityControllers.setEntityControllerForType(EntityType.MINECART_FURNACE, MinecartFurnaceController.class);
EntityControllers.setEntityControllerForType(EntityType.MINECART_HOPPER, MinecartHopperController.class);
EntityControllers.setEntityControllerForType(EntityType.MINECART_TNT, MinecartTNTController.class);
EntityControllers.setEntityControllerForType(EntityType.MUSHROOM_COW, MushroomCowController.class);
EntityControllers.setEntityControllerForType(EntityType.OCELOT, OcelotController.class);
EntityControllers.setEntityControllerForType(EntityType.PANDA, PandaController.class);
EntityControllers.setEntityControllerForType(EntityType.PAINTING, PaintingController.class);
EntityControllers.setEntityControllerForType(EntityType.PARROT, ParrotController.class);
EntityControllers.setEntityControllerForType(EntityType.PHANTOM, PhantomController.class);
EntityControllers.setEntityControllerForType(EntityType.PILLAGER, PillagerController.class);
EntityControllers.setEntityControllerForType(EntityType.PIG, PigController.class);
EntityControllers.setEntityControllerForType(EntityType.PIGLIN, PiglinController.class);
EntityControllers.setEntityControllerForType(EntityType.PIGLIN_BRUTE, PiglinBruteController.class);
EntityControllers.setEntityControllerForType(EntityType.HOGLIN, HoglinController.class);
EntityControllers.setEntityControllerForType(EntityType.ZOMBIFIED_PIGLIN, PigZombieController.class);
EntityControllers.setEntityControllerForType(EntityType.ZOGLIN, ZoglinController.class);
EntityControllers.setEntityControllerForType(EntityType.POLAR_BEAR, PolarBearController.class);
EntityControllers.setEntityControllerForType(EntityType.PLAYER, HumanController.class);
EntityControllers.setEntityControllerForType(EntityType.PUFFERFISH, PufferFishController.class);
EntityControllers.setEntityControllerForType(EntityType.RABBIT, RabbitController.class);
EntityControllers.setEntityControllerForType(EntityType.RAVAGER, RavagerController.class);