-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathEntity.java
More file actions
1383 lines (1239 loc) · 43.7 KB
/
Copy pathEntity.java
File metadata and controls
1383 lines (1239 loc) · 43.7 KB
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 org.bukkit.entity;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import io.papermc.paper.datacomponent.DataComponentView;
import io.papermc.paper.entity.LookAnchor;
import io.papermc.paper.entity.RemovalReason;
import io.papermc.paper.math.Angle;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.event.HoverEventSource;
import net.kyori.adventure.util.TriState;
import org.bukkit.Chunk; // Paper
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Nameable;
import org.bukkit.Server;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.command.CommandSender;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRemoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Directional;
import org.bukkit.metadata.Metadatable;
import org.bukkit.persistence.PersistentDataHolder;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a base entity in the world
* <p>
* Not all methods are guaranteed to work/may have side effects when
* {@link #isInWorld()} is false.
*/
public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, HoverEventSource<HoverEvent.ShowEntity>, net.kyori.adventure.sound.Sound.Emitter, net.kyori.adventure.sound.Sound.Source.Provider, DataComponentView {
/**
* Gets the entity's current position
*
* @return a new copy of Location containing the position of this entity
*/
@NotNull
public Location getLocation();
/**
* Stores the entity's current position in the provided Location object.
* <p>
* If the provided Location is null this method does nothing and returns
* null.
*
* @param loc the location to copy into
* @return The Location object provided or null
*/
@Contract("null -> null; !null -> !null")
@Nullable
public Location getLocation(@Nullable Location loc);
/**
* Sets this entity's velocity in meters per tick
*
* @param velocity New velocity to travel with
*/
public void setVelocity(@NotNull Vector velocity);
/**
* Gets this entity's current velocity
*
* @return Current traveling velocity of this entity
*/
@NotNull
public Vector getVelocity();
/**
* Gets the entity's height
*
* @return height of entity
*/
public double getHeight();
/**
* Gets the entity's width
*
* @return width of entity
*/
public double getWidth();
/**
* Gets the entity's current bounding box.
* <p>
* The returned bounding box reflects the entity's current location and
* size.
*
* @return the entity's current bounding box
*/
@NotNull
public BoundingBox getBoundingBox();
/**
* Returns true if the entity is supported by a block. This value is a
* state updated by the server and is not recalculated unless the entity
* moves.
*
* @return True if entity is on ground.
* @see Player#isOnGround()
*/
public boolean isOnGround();
/**
* Returns true if the entity is in water.
*
* @return <code>true</code> if the entity is in water.
*/
public boolean isInWater();
/**
* Gets the current world this entity resides in
*
* @return World
*/
@NotNull
public World getWorld();
/**
* Sets the entity's rotation.
* <p>
* Note that if the entity is affected by AI, it may override this rotation.
*
* @param yaw the yaw
* @param pitch the pitch
* @see #setRotation(Angle, Angle)
*/
public void setRotation(float yaw, float pitch);
/**
* Sets the entity's rotation.
* <p>
* Note that if the entity is affected by AI, it may override this rotation.
*
* @param yaw the yaw
* @param pitch the pitch
*/
void setRotation(@NotNull Angle yaw, @NotNull Angle pitch);
// Paper start - Teleport API
/**
* Teleports this entity to the given location.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause this to return false. This behavior may
* change in future versions.
*
* @param location New location to teleport this entity to
* @param teleportFlags Flags to be used in this teleportation
* @return <code>true</code> if the teleport was successful
*/
default boolean teleport(@NotNull Location location, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags) {
return this.teleport(location, TeleportCause.PLUGIN, teleportFlags);
}
/**
* Teleports this entity to the given location.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause this to return false. This behavior may
* change in future versions.
*
* @param location New location to teleport this entity to
* @param cause The cause of this teleportation
* @param teleportFlags Flags to be used in this teleportation
* @return <code>true</code> if the teleport was successful
*/
boolean teleport(@NotNull Location location, @NotNull TeleportCause cause, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags);
/**
* Causes the entity to look towards the given position.
*
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param entityAnchor What part of the entity should face the given position
*/
void lookAt(double x, double y, double z, @NotNull LookAnchor entityAnchor);
/**
* Causes the entity to look towards the given position.
*
* @param position Position to look at in the player's current world
* @param entityAnchor What part of the entity should face the given position
*/
default void lookAt(@NotNull io.papermc.paper.math.Position position, @NotNull LookAnchor entityAnchor) {
this.lookAt(position.x(), position.y(), position.z(), entityAnchor);
}
// Paper end - Teleport API
/**
* Teleports this entity to the given location.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause this to return false. This behavior may
* change in future versions.
*
* @param location New location to teleport this entity to
* @return <code>true</code> if the teleport was successful
*/
public boolean teleport(@NotNull Location location);
/**
* Teleports this entity to the given location.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause this to return false. This behavior may
* change in future versions.
*
* @param location New location to teleport this entity to
* @param cause The cause of this teleportation
* @return <code>true</code> if the teleport was successful
*/
public boolean teleport(@NotNull Location location, @NotNull TeleportCause cause);
/**
* Teleports this entity to the target Entity.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause this to return false. This behavior may
* change in future versions.
*
* @param destination Entity to teleport this entity to
* @return <code>true</code> if the teleport was successful
*/
public boolean teleport(@NotNull Entity destination);
/**
* Teleports this entity to the target Entity.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause this to return false. This behavior may
* change in future versions.
*
* @param destination Entity to teleport this entity to
* @param cause The cause of this teleportation
* @return <code>true</code> if the teleport was successful
*/
public boolean teleport(@NotNull Entity destination, @NotNull TeleportCause cause);
// Paper start
/**
* Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause the future to return false. This behavior may
* change in future versions.
*
* @param loc Location to teleport to
* @return A future that will be completed with the result of the teleport
*/
default java.util.concurrent.@NotNull CompletableFuture<Boolean> teleportAsync(final @NotNull Location loc) {
return this.teleportAsync(loc, TeleportCause.PLUGIN);
}
/**
* Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause the future to return false. This behavior may
* change in future versions.
*
* @param loc Location to teleport to
* @param cause Reason for teleport
* @return A future that will be completed with the result of the teleport
*/
default java.util.concurrent.@NotNull CompletableFuture<Boolean> teleportAsync(final @NotNull Location loc, final @NotNull TeleportCause cause) {
final class Holder {
static final io.papermc.paper.entity.TeleportFlag[] EMPTY_FLAGS = new io.papermc.paper.entity.TeleportFlag[0];
}
return this.teleportAsync(loc, cause, Holder.EMPTY_FLAGS);
}
/**
* Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause the future to return false. This behavior may
* change in future versions.
*
* @param loc Location to teleport to
* @param teleportFlags Flags to be used in this teleportation
* @return A future that will be completed with the result of the teleport
*/
default java.util.concurrent.@NotNull CompletableFuture<Boolean> teleportAsync(@NotNull Location loc, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags) {
return this.teleportAsync(loc, TeleportCause.PLUGIN, teleportFlags);
}
/**
* Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.
* <p>
* Note: This uses default in game behavior for teleportation, especially in regard to handling
* passengers and vehicles across dimensions. It should be noted at this moment, teleporting a {@link Player}
* with passengers across dimensions is not supported and will cause the future to return false. This behavior may
* change in future versions.
*
* @param loc Location to teleport to
* @param cause Reason for teleport
* @param teleportFlags Flags to be used in this teleportation
*
* @return A future that will be completed with the result of the teleport
*/
java.util.concurrent.@NotNull CompletableFuture<Boolean> teleportAsync(@NotNull Location loc, @NotNull TeleportCause cause, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags);
// Paper end
/**
* Returns a list of entities within a bounding box centered around this
* entity
*
* @param x 1/2 the size of the box along x axis
* @param y 1/2 the size of the box along y axis
* @param z 1/2 the size of the box along z axis
* @return {@code List<Entity>} List of entities nearby
*/
@NotNull
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z);
/**
* Returns the network protocol ID for this entity. This is
* not to be used as an identifier for the entity except in
* network-related operations. Use {@link #getUniqueId()} as
* an entity identifier instead.
*
* @return the network protocol ID
* @see #getUniqueId()
*/
public int getEntityId();
/**
* Returns the entity's current fire ticks (ticks before the entity stops
* being on fire).
*
* @return int fireTicks
*/
public int getFireTicks();
/**
* Returns the entity's maximum fire ticks.
*
* @return int maxFireTicks
*/
public int getMaxFireTicks();
/**
* Sets the entity's current fire ticks (ticks before the entity stops
* being on fire).
*
* @param ticks Current ticks remaining
*/
public void setFireTicks(int ticks);
/**
* Sets if the entity has visual fire (it will always appear to be on fire).
*
* @deprecated This method doesn't allow visually extinguishing a burning entity,
* use {@link #setVisualFire(TriState)} instead
* @param fire whether visual fire is enabled
*/
@Deprecated
void setVisualFire(boolean fire);
/**
* Sets if the entity has visual fire (it will always appear to be on fire).
* <ul>
* <li>{@link TriState#NOT_SET} – will revert the entity's visual fire to default</li>
* <li>{@link TriState#TRUE} – will make the entity appear to be on fire</li>
* <li>{@link TriState#FALSE} – will make the entity appear to be not on fire</li>
* </ul>
*
* @param fire a TriState value representing the state of the visual fire.
*/
void setVisualFire(@NotNull TriState fire);
/**
* Gets if the entity has visual fire (it will always appear to be on fire).
*
* @deprecated This method can't properly reflect the three possible states of visual fire,
* use {@link #getVisualFire()} instead
* @return whether visual fire is enabled
*/
@Deprecated
boolean isVisualFire();
/**
* Retrieves the visual fire state of the entity.
*
* @return A TriState indicating the current visual fire state.
*/
@NotNull
TriState getVisualFire();
/**
* Returns the entity's current freeze ticks (amount of ticks the entity has
* been in powdered snow).
*
* @return int freeze ticks
*/
int getFreezeTicks();
/**
* Returns the entity's maximum freeze ticks (amount of ticks before it will
* be fully frozen)
*
* @return int max freeze ticks
*/
int getMaxFreezeTicks();
/**
* Sets the entity's current freeze ticks (amount of ticks the entity has
* been in powdered snow).
*
* @param ticks Current ticks
*/
void setFreezeTicks(int ticks);
/**
* Gets if the entity is fully frozen (it has been in powdered snow for max
* freeze ticks).
*
* @return freeze status
*/
boolean isFrozen();
/**
* Sets whether the entity is invisible or not.
* <p>
* This setting is undefined for non-living entities like boats or paintings.
* Non-living entities that are marked as invisible through this method may e.g. only hide their shadow.
* To hide such entities from players completely, see {@link Player#hideEntity(org.bukkit.plugin.Plugin, Entity)}.
*
* @param invisible If the entity is invisible
*/
void setInvisible(boolean invisible);
/**
* Gets whether the entity is invisible or not.
*
* @return Whether the entity is invisible
*/
boolean isInvisible();
/**
* Sets this entity no physics status.
*
* @param noPhysics boolean indicating if the entity should not have physics.
*/
void setNoPhysics(boolean noPhysics);
/**
* Gets if this entity has no physics.
*
* @return true if the entity does not have physics.
*/
boolean hasNoPhysics();
/**
* Gets if the entity currently has its freeze ticks locked
* to a set amount.
* <p>
* This is only set by plugins
*
* @return locked or not
*/
boolean isFreezeTickingLocked();
/**
* Sets if the entity currently has its freeze ticks locked,
* preventing default vanilla freeze tick modification.
*
* @param locked prevent vanilla modification or not
*/
void lockFreezeTicks(boolean locked);
/**
* Mark the entity's removal.
*
* @throws UnsupportedOperationException if you try to remove a {@link Player} use {@link Player#kick(net.kyori.adventure.text.Component)} in this case instead
*/
public void remove();
/**
* Gets the cause used for this entity's remove event.
*
* @return the remove event cause, or null if this entity has not been removed or no event cause was supplied
*/
@Nullable
EntityRemoveEvent.Cause getRemoveEventCause();
/**
* {@return the reason this entity was removed}
*/
@Nullable RemovalReason getRemovalReason();
/**
* Returns true if this entity has been marked for removal.
*
* @return True if it is dead.
*/
public boolean isDead();
/**
* Returns false if the entity has died, been despawned for some other
* reason, or has not been added to the world.
*
* @return True if valid.
*/
public boolean isValid();
/**
* Gets the {@link Server} that contains this Entity
*
* @return Server instance running this Entity
*/
@Override
@NotNull
public Server getServer();
/**
* Returns true if the entity gets persisted.
* <p>
* By default all entities are persistent. An entity will also not get
* persisted, if it is riding an entity that is not persistent.
* <p>
* The persistent flag on players controls whether or not to save their
* playerdata file when they quit. If a player is directly or indirectly
* riding a non-persistent entity, the vehicle at the root and all its
* passengers won't get persisted.
* <p>
* <b>This should not be confused with
* {@link LivingEntity#setRemoveWhenFarAway(boolean)} which controls
* despawning of living entities. </b>
*
* @return true if this entity is persistent
*/
public boolean isPersistent();
/**
* Sets whether or not the entity gets persisted.
*
* @param persistent the persistence status
* @see #isPersistent()
*/
public void setPersistent(boolean persistent);
/**
* Gets the primary passenger of a vehicle. For vehicles that could have
* multiple passengers, this will only return the primary passenger.
*
* @return an entity
* @deprecated entities may have multiple passengers, use
* {@link #getPassengers()}
*/
@Deprecated(since = "1.11.2")
@Nullable
public Entity getPassenger();
/**
* Set the passenger of a vehicle.
*
* @param passenger The new passenger.
* @return false if it could not be done for whatever reason
* @deprecated entities may have multiple passengers, use
* {@link #addPassenger(org.bukkit.entity.Entity)}
*/
@Deprecated(since = "1.11.2")
public boolean setPassenger(@NotNull Entity passenger);
/**
* Gets a list of passengers of this vehicle.
* <p>
* The returned list will not be directly linked to the entity's current
* passengers, and no guarantees are made as to its mutability.
*
* @return list of entities corresponding to current passengers.
*/
@NotNull
public List<Entity> getPassengers();
/**
* Add a passenger to the vehicle.
*
* @param passenger The passenger to add
* @return false if it could not be done for whatever reason
*/
public boolean addPassenger(@NotNull Entity passenger);
/**
* Remove a passenger from the vehicle.
*
* @param passenger The passenger to remove
* @return false if it could not be done for whatever reason
*/
public boolean removePassenger(@NotNull Entity passenger);
/**
* Check if a vehicle has passengers.
*
* @return True if the vehicle has no passengers.
*/
public boolean isEmpty();
/**
* Eject any passenger.
*
* @return True if there was a passenger.
*/
public boolean eject();
/**
* Gets the {@link ItemStack} that a player would select / create (in creative mode)
* when using the pick block action on this entity.
*
* @return item stack result or an empty item stack
*/
@NotNull
ItemStack getPickItemStack();
/**
* Returns the distance this entity has fallen
*
* @return The distance.
*/
public float getFallDistance();
/**
* Sets the fall distance for this entity
*
* @param distance The new distance.
*/
public void setFallDistance(float distance);
/**
* Record the last {@link EntityDamageEvent} inflicted on this entity
*
* @param event a {@link EntityDamageEvent}
* @deprecated method is for internal use only and will be removed
*/
@ApiStatus.Internal
@Deprecated(since = "1.20.4", forRemoval = true)
public void setLastDamageCause(@Nullable EntityDamageEvent event);
/**
* Retrieve the last {@link EntityDamageEvent} inflicted on this entity.
* This event may have been cancelled.
*
* @return the last known {@link EntityDamageEvent} or null if hitherto
* unharmed
*/
@Nullable
public EntityDamageEvent getLastDamageCause();
/**
* Returns a unique and persistent id for this entity
*
* @return unique id
*/
@NotNull
public UUID getUniqueId();
/**
* Gets the amount of ticks this entity has lived for.
* <p>
* This is the equivalent to "age" in entities.
*
* @return Age of entity
*/
public int getTicksLived();
/**
* Sets the amount of ticks this entity has lived for.
* <p>
* This is the equivalent to "age" in entities. May not be less than one
* tick.
*
* @param value Age of entity
*/
public void setTicksLived(int value);
/**
* Performs the specified {@link EntityEffect} for this entity.
* <p>
* This will be viewable to all players near the entity.
* <p>
* If the effect is not applicable to this class of entity, it will not play.
*
* @param effect Effect to play.
*/
public void playEffect(@NotNull EntityEffect effect);
/**
* Get the type of the entity.
*
* @return The entity type.
*/
@NotNull
public EntityType getType();
/**
* Get the {@link SoundCategory} this entity will use when playing its sounds.
*
* @return the sound category for this entity
*/
@NotNull
SoundCategory getSoundCategory();
/**
* Get the {@link Sound} this entity makes while swimming.
*
* @return the swimming sound
*/
@NotNull
public Sound getSwimSound();
/**
* Get the {@link Sound} this entity makes when splashing in water. For most
* entities, this is just {@link Sound#ENTITY_GENERIC_SPLASH}.
*
* @return the splash sound
*/
@NotNull
public Sound getSwimSplashSound();
/**
* Get the {@link Sound} this entity makes when splashing in water at high
* speeds. For most entities, this is just {@link Sound#ENTITY_GENERIC_SPLASH}.
*
* @return the splash sound
*/
@NotNull
public Sound getSwimHighSpeedSplashSound();
/**
* Returns whether this entity is inside a vehicle.
*
* @return True if the entity is in a vehicle.
*/
public boolean isInsideVehicle();
/**
* Leave the current vehicle. If the entity is currently in a vehicle (and
* is removed from it), true will be returned, otherwise false will be
* returned.
*
* @return True if the entity was in a vehicle.
*/
public boolean leaveVehicle();
/**
* Get the vehicle that this entity is inside. If there is no vehicle,
* null will be returned.
*
* @return The current vehicle.
*/
@Nullable
public Entity getVehicle();
/**
* Sets whether or not to display the mob's custom name client side. The
* name will be displayed above the mob similarly to a player.
* <p>
* This value has no effect on players, they will always display their
* name.
*
* @param flag custom name or not
*/
public void setCustomNameVisible(boolean flag);
/**
* Gets whether or not the mob's custom name is displayed client side.
* <p>
* This value has no effect on players, they will always display their
* name.
*
* @return if the custom name is displayed
*/
public boolean isCustomNameVisible();
/**
* Sets whether or not this entity is visible by default.
*
* If this entity is not visible by default, then
* {@link Player#showEntity(org.bukkit.plugin.Plugin, org.bukkit.entity.Entity)}
* will need to be called before the entity is visible to a given player.
*
* @param visible default visibility status
*/
public void setVisibleByDefault(boolean visible);
/**
* Gets whether or not this entity is visible by default.
*
* If this entity is not visible by default, then
* {@link Player#showEntity(org.bukkit.plugin.Plugin, org.bukkit.entity.Entity)}
* will need to be called before the entity is visible to a given player.
*
* @return default visibility status
*/
public boolean isVisibleByDefault();
/**
* Get all players that are currently tracking this entity.
* <p>
* 'Tracking' means that this entity has been sent to the player and that
* they are receiving updates on its state. Note that the client's {@code
* 'Entity Distance'} setting does not affect the range at which entities
* are tracked.
*
* @return the players tracking this entity, or an empty set if none
*/
@NotNull
Set<Player> getTrackedBy();
/**
* Checks to see if a player is currently tracking this entity.
*
* @param player the player to check
* @return if the player is currently tracking this entity
* @see #getTrackedBy()
*/
boolean isTrackedBy(@NotNull Player player);
/**
* Sets whether the entity has a team colored (default: white) glow.
*
* <b>nb: this refers to the 'Glowing' entity property, not whether a
* glowing potion effect is applied</b>
*
* @param flag if the entity is glowing
*/
void setGlowing(boolean flag);
/**
* Gets whether the entity is glowing or not.
*
* <b>nb: this refers to the 'Glowing' entity property, not whether a
* glowing potion effect is applied</b>
*
* @return whether the entity is glowing
*/
boolean isGlowing();
/**
* Sets whether the entity is invulnerable or not.
* <p>
* When an entity is invulnerable it can only be damaged by players in
* creative mode.
*
* @param flag if the entity is invulnerable
*/
public void setInvulnerable(boolean flag);
/**
* Gets whether the entity is invulnerable or not.
*
* @return whether the entity is
*/
public boolean isInvulnerable();
/**
* Gets whether the entity is silent or not.
*
* @return whether the entity is silent.
*/
public boolean isSilent();
/**
* Sets whether the entity is silent or not.
* <p>
* When an entity is silent it will not produce any sound.
*
* @param flag if the entity is silent
*/
public void setSilent(boolean flag);
/**
* Returns whether gravity applies to this entity.
*
* @return whether gravity applies
*/
boolean hasGravity();
/**
* Sets whether gravity applies to this entity.
*
* @param gravity whether gravity should apply
*/
void setGravity(boolean gravity);
/**
* Returns the default acceleration due to gravity (in blocks per tick). Ignores {@link Entity#hasGravity()}.
*
* @return the default acceleration due to gravity
*/
double getDefaultGravity();
/**
* Returns the acceleration due to gravity (in blocks per tick). If {@link Entity#hasGravity()} is true, returns 0.
*
* @return the acceleration due to gravity
*/
double getGravity();
/**
* Returns the air drag factor applied to this entity.
*
* @return the air drag factor
*/
float getAirDrag();
/**
* Gets the period of time (in ticks) before this entity can use a portal.
*
* @return portal cooldown ticks
*/
int getPortalCooldown();
/**
* Sets the period of time (in ticks) before this entity can use a portal.
*
* @param cooldown portal cooldown ticks
*/
void setPortalCooldown(int cooldown);
/**
* Returns a set of tags for this entity.
* <br>
* Entities can have no more than 1024 tags.
*
* @return a set of tags for this entity
*/
@NotNull
Set<String> getScoreboardTags();
/**
* Add a tag to this entity.
* <br>
* Entities can have no more than 1024 tags.
*
* @param tag the tag to add
* @return true if the tag was successfully added
*/
boolean addScoreboardTag(@NotNull String tag);
/**
* Removes a given tag from this entity.
*
* @param tag the tag to remove
* @return true if the tag was successfully removed
*/
boolean removeScoreboardTag(@NotNull String tag);
/**
* Returns the reaction of the entity when moved by a piston.
*
* @return reaction
*/
@NotNull
PistonMoveReaction getPistonMoveReaction();
/**
* Get the closest cardinal {@link BlockFace} direction an entity is
* currently facing.
* <br>
* This will not return any non-cardinal directions such as
* {@link BlockFace#UP} or {@link BlockFace#DOWN}.
* <br>
* {@link Hanging} entities will override this call and thus their behavior
* may be different.
*
* @return the entity's current cardinal facing.
* @see Hanging
* @see Directional#getFacing()
*/
@NotNull
BlockFace getFacing();