diff --git a/src/main/java/net/minestom/server/entity/Entity.java b/src/main/java/net/minestom/server/entity/Entity.java index 018c28d37..7d9298bdb 100644 --- a/src/main/java/net/minestom/server/entity/Entity.java +++ b/src/main/java/net/minestom/server/entity/Entity.java @@ -75,7 +75,7 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission protected Entity vehicle; // Velocity - protected Vector velocity = new Vector(); // Movement in block per second + protected Vector velocity = new Vector(); // Movement in block per second protected boolean hasPhysics = true; protected double gravityDragPerTick; @@ -814,7 +814,7 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission /** * Changes the entity instance, i.e. spawns it. * - * @param instance the new instance of the entity + * @param instance the new instance of the entity * @param spawnPosition the spawn position for the entity. * @throws IllegalStateException if {@code instance} has not been registered in {@link InstanceManager} */ @@ -845,7 +845,9 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission * @param instance the new instance of the entity * @throws NullPointerException if {@code instance} is null * @throws IllegalStateException if {@code instance} has not been registered in {@link InstanceManager} + * @deprecated Use {@link Entity#setInstance(Instance, Position)} instead. */ + @Deprecated public void setInstance(@NotNull Instance instance) { setInstance(instance, this.position); } diff --git a/src/main/java/net/minestom/server/entity/EntityCreature.java b/src/main/java/net/minestom/server/entity/EntityCreature.java index adf594dd7..538338e76 100644 --- a/src/main/java/net/minestom/server/entity/EntityCreature.java +++ b/src/main/java/net/minestom/server/entity/EntityCreature.java @@ -69,15 +69,10 @@ public class EntityCreature extends LivingEntity implements NavigableEntity, Ent } @Override - public void setInstance(@NotNull Instance instance) { + public void setInstance(@NotNull Instance instance, @NotNull Position spawnPosition) { this.navigator.setPathFinder(new HydrazinePathFinder(navigator.getPathingEntity(), instance.getInstanceSpace())); - super.setInstance(instance); - } - - @Override - public void spawn() { - + super.setInstance(instance, spawnPosition); } @Override diff --git a/src/main/java/net/minestom/server/entity/LivingEntity.java b/src/main/java/net/minestom/server/entity/LivingEntity.java index b34d7fc46..58ff055e0 100644 --- a/src/main/java/net/minestom/server/entity/LivingEntity.java +++ b/src/main/java/net/minestom/server/entity/LivingEntity.java @@ -26,7 +26,6 @@ import net.minestom.server.utils.block.BlockIterator; import net.minestom.server.utils.time.CooldownUtils; import net.minestom.server.utils.time.TimeUnit; import net.minestom.server.utils.time.UpdateOption; -import net.minestom.server.utils.validate.Check; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -250,11 +249,6 @@ public class LivingEntity extends Entity implements EquipmentHandler { } } - @Override - public void spawn() { - - } - /** * Gets the amount of arrows in the entity. * @@ -723,10 +717,10 @@ public class LivingEntity extends Entity implements EquipmentHandler { * @return if the current entity has line of sight to the given one. */ public boolean hasLineOfSight(Entity entity) { - Vector start = getPosition().toVector().add(0D, getEyeHeight(), 0D); - Vector end = entity.getPosition().toVector().add(0D, getEyeHeight(), 0D); - Vector direction = end.subtract(start); - int maxDistance = (int) Math.ceil(direction.length()); + Vector start = getPosition().toVector().add(0D, getEyeHeight(), 0D); + Vector end = entity.getPosition().toVector().add(0D, getEyeHeight(), 0D); + Vector direction = end.subtract(start); + int maxDistance = (int) Math.ceil(direction.length()); Iterator it = new BlockIterator(start, direction.normalize(), 0D, maxDistance); while (it.hasNext()) { diff --git a/src/main/java/net/minestom/server/entity/Metadata.java b/src/main/java/net/minestom/server/entity/Metadata.java index 8d90adc3e..47e049df2 100644 --- a/src/main/java/net/minestom/server/entity/Metadata.java +++ b/src/main/java/net/minestom/server/entity/Metadata.java @@ -102,9 +102,7 @@ public class Metadata { } public static Value NBT(@NotNull NBT nbt) { - return new Value<>(TYPE_NBT, nbt, writer -> { - writer.writeNBT("", nbt); - }); + return new Value<>(TYPE_NBT, nbt, writer -> writer.writeNBT("", nbt)); } public static Value VillagerData(int villagerType,