An implementation the plain Entity entity. @since 1.0 @see Entity
| 32 | * @see Entity |
| 33 | */ |
| 34 | public class JetEntity implements Entity { |
| 35 | |
| 36 | private static final AtomicInteger NEXT_ENTITY_ID = new AtomicInteger(); // FIXME: Not the best solution |
| 37 | private static final Logger LOGGER = LoggerFactory.getLogger(JetEntity.class); |
| 38 | |
| 39 | private final JetMinecraftServer server; |
| 40 | |
| 41 | private final Key entityType; |
| 42 | private final int entityId; |
| 43 | |
| 44 | private final Identity identity; |
| 45 | private final Pointers pointers; |
| 46 | |
| 47 | private @NonNull JetWorld world; |
| 48 | private @NonNull Position position; |
| 49 | private @NonNull Vector velocity = Vector.zero(); |
| 50 | |
| 51 | /** |
| 52 | * Constructs the {@linkplain JetEntity entity}. |
| 53 | * |
| 54 | * @param entityType an identifier of a type of the entity |
| 55 | * @param uniqueId a unique identifier of the entity |
| 56 | * @param position an initial position that the entity should spawn at |
| 57 | * @param world an initial world that the entity should spawn in |
| 58 | * @param server the server that the entity should be part of |
| 59 | * @since 1.0 |
| 60 | */ |
| 61 | public JetEntity(@NonNull Key entityType, @NonNull UUID uniqueId, @NonNull Position position, |
| 62 | @NonNull JetWorld world, @NonNull JetMinecraftServer server) { |
| 63 | this( |
| 64 | entityType, uniqueId, |
| 65 | Pointers.builder() |
| 66 | .withStatic(Identity.UUID, uniqueId) |
| 67 | .build(), |
| 68 | position, world, server |
| 69 | ); |
| 70 | // TODO: Add this entity to world entity set, but only if it not a player |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Constructs an {@linkplain JetEntity entity}. |
| 75 | * |
| 76 | * @param entityType an identifier of a type of the entity |
| 77 | * @param uniqueId a unique identifier of the entity |
| 78 | * @param pointers a pointers of the entity |
| 79 | * @param position an initial position that the entity should spawn at |
| 80 | * @param world an initial world that the entity should spawn in |
| 81 | * @param server the server that the entity should be part of |
| 82 | * @since 1.0 |
| 83 | */ |
| 84 | public JetEntity(@NonNull Key entityType, @NonNull UUID uniqueId, @NonNull Pointers pointers, |
| 85 | @NonNull Position position, @NonNull JetWorld world, @NonNull JetMinecraftServer server) { |
| 86 | this.entityType = Objects.requireNonNull(entityType, "entity type"); |
| 87 | this.identity = Identity.identity(Objects.requireNonNull(uniqueId, "unique identifier")); |
| 88 | this.pointers = Objects.requireNonNull(pointers, "pointers"); |
| 89 | this.entityId = NEXT_ENTITY_ID.getAndIncrement(); |
| 90 | this.position = Objects.requireNonNull(position, "position"); |
| 91 | this.world = Objects.requireNonNull(world, "world"); |