mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-28 22:47:41 +02:00
Fix pathfinding + cleanup
This commit is contained in:
parent
a0d5ac12bc
commit
e8e8022ec6
@ -75,7 +75,7 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission
|
|||||||
protected Entity vehicle;
|
protected Entity vehicle;
|
||||||
|
|
||||||
// Velocity
|
// 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 boolean hasPhysics = true;
|
||||||
|
|
||||||
protected double gravityDragPerTick;
|
protected double gravityDragPerTick;
|
||||||
@ -814,7 +814,7 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission
|
|||||||
/**
|
/**
|
||||||
* Changes the entity instance, i.e. spawns it.
|
* 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.
|
* @param spawnPosition the spawn position for the entity.
|
||||||
* @throws IllegalStateException if {@code instance} has not been registered in {@link InstanceManager}
|
* @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
|
* @param instance the new instance of the entity
|
||||||
* @throws NullPointerException if {@code instance} is null
|
* @throws NullPointerException if {@code instance} is null
|
||||||
* @throws IllegalStateException if {@code instance} has not been registered in {@link InstanceManager}
|
* @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) {
|
public void setInstance(@NotNull Instance instance) {
|
||||||
setInstance(instance, this.position);
|
setInstance(instance, this.position);
|
||||||
}
|
}
|
||||||
|
@ -69,15 +69,10 @@ public class EntityCreature extends LivingEntity implements NavigableEntity, Ent
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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()));
|
this.navigator.setPathFinder(new HydrazinePathFinder(navigator.getPathingEntity(), instance.getInstanceSpace()));
|
||||||
|
|
||||||
super.setInstance(instance);
|
super.setInstance(instance, spawnPosition);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void spawn() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,6 @@ import net.minestom.server.utils.block.BlockIterator;
|
|||||||
import net.minestom.server.utils.time.CooldownUtils;
|
import net.minestom.server.utils.time.CooldownUtils;
|
||||||
import net.minestom.server.utils.time.TimeUnit;
|
import net.minestom.server.utils.time.TimeUnit;
|
||||||
import net.minestom.server.utils.time.UpdateOption;
|
import net.minestom.server.utils.time.UpdateOption;
|
||||||
import net.minestom.server.utils.validate.Check;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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.
|
* 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.
|
* @return if the current entity has line of sight to the given one.
|
||||||
*/
|
*/
|
||||||
public boolean hasLineOfSight(Entity entity) {
|
public boolean hasLineOfSight(Entity entity) {
|
||||||
Vector start = getPosition().toVector().add(0D, getEyeHeight(), 0D);
|
Vector start = getPosition().toVector().add(0D, getEyeHeight(), 0D);
|
||||||
Vector end = entity.getPosition().toVector().add(0D, getEyeHeight(), 0D);
|
Vector end = entity.getPosition().toVector().add(0D, getEyeHeight(), 0D);
|
||||||
Vector direction = end.subtract(start);
|
Vector direction = end.subtract(start);
|
||||||
int maxDistance = (int) Math.ceil(direction.length());
|
int maxDistance = (int) Math.ceil(direction.length());
|
||||||
|
|
||||||
Iterator<BlockPosition> it = new BlockIterator(start, direction.normalize(), 0D, maxDistance);
|
Iterator<BlockPosition> it = new BlockIterator(start, direction.normalize(), 0D, maxDistance);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
@ -102,9 +102,7 @@ public class Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Value<NBT> NBT(@NotNull NBT nbt) {
|
public static Value<NBT> NBT(@NotNull NBT nbt) {
|
||||||
return new Value<>(TYPE_NBT, nbt, writer -> {
|
return new Value<>(TYPE_NBT, nbt, writer -> writer.writeNBT("", nbt));
|
||||||
writer.writeNBT("", nbt);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Value<int[]> VillagerData(int villagerType,
|
public static Value<int[]> VillagerData(int villagerType,
|
||||||
|
Loading…
Reference in New Issue
Block a user