Fix Entity Teleportation and cancel velocity if teleported

Uses correct setPositionRotation for Entity teleporting instead of setLocation
as this is how Vanilla teleports entities.

Cancel any pending motion when teleported.
This commit is contained in:
Aikar
2020-08-25 20:45:36 -04:00
parent 74de6853f4
commit aebf9e869b
6 changed files with 144 additions and 109 deletions

View File

@@ -61,7 +61,15 @@
Entity entity = EntityType.loadEntityRecursive(nbttagcompound, world, EntitySpawnReason.SPAWNER, (entity1) -> {
entity1.moveTo(d0, d1, d2, entity1.getYRot(), entity1.getXRot());
@@ -157,13 +178,27 @@
@@ -143,6 +164,7 @@
return;
}
+ entity.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; preserve entity motion from tag
entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F);
if (entity instanceof Mob) {
Mob entityinsentient = (Mob) entity;
@@ -157,13 +179,27 @@
((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, (SpawnGroupData) null);
}
@@ -91,7 +99,7 @@
this.delay(world, pos);
return;
}
@@ -174,7 +209,7 @@
@@ -174,7 +210,7 @@
((Mob) entity).spawnAnim();
}
@@ -100,7 +108,7 @@
}
}
@@ -202,7 +237,13 @@
@@ -202,7 +238,13 @@
}
public void load(@Nullable Level world, BlockPos pos, CompoundTag nbt) {
@@ -114,7 +122,7 @@
boolean flag = nbt.contains("SpawnData", 10);
if (flag) {
@@ -225,9 +266,15 @@
@@ -225,9 +267,15 @@
this.spawnPotentials = SimpleWeightedRandomList.single(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData());
}
@@ -132,7 +140,7 @@
this.spawnCount = nbt.getShort("SpawnCount");
}
@@ -244,9 +291,20 @@
@@ -244,9 +292,20 @@
}
public CompoundTag save(CompoundTag nbt) {