Skip to content

Commit

Permalink
more reliable NMS teleport path for players
Browse files Browse the repository at this point in the history
works even while mounted ... also fix up pom issues for Paper and shading
  • Loading branch information
mcmonkey4eva committed Feb 23, 2021
1 parent 9c63797 commit 964969e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
<pattern>org.json</pattern>
<shadedPattern>com.denizenscript.shaded.org.json</shadedPattern>
</relocation>
<relocation>
<pattern>org.yaml</pattern>
<shadedPattern>com.denizenscript.shaded.org.yaml</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
Expand Down
6 changes: 0 additions & 6 deletions paper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
<artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ else if (337.5 <= yaw && yaw < 360.0) {

public abstract void move(Entity entity, Vector vector);

public abstract void teleport(Entity entity, Vector vector);
public abstract void teleport(Entity entity, Location loc);

public abstract BoundingBox getBoundingBox(Entity entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public void spawnAt(Location location) {
else if (entity != null && isUnique()) {
entity.teleport(location);
if (entity.getWorld().equals(location.getWorld())) { // Force the teleport through (for things like mounts)
NMSHandler.getEntityHelper().teleport(entity, location.toVector());
NMSHandler.getEntityHelper().teleport(entity, location);
}
}
else {
Expand Down Expand Up @@ -869,7 +869,7 @@ else if (isFake) {
else {
entity.teleport(location);
if (entity.getWorld().equals(location.getWorld())) { // Force the teleport through (for things like mounts)
NMSHandler.getEntityHelper().teleport(entity, location.toVector());
NMSHandler.getEntityHelper().teleport(entity, location);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public void move(Entity entity, Vector vector) {
}

@Override
public void teleport(Entity entity, Vector vector) {
public void teleport(Entity entity, Location vector) {
((CraftEntity) entity).getHandle().setPosition(vector.getX(), vector.getY(), vector.getZ());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public void move(Entity entity, Vector vector) {
}

@Override
public void teleport(Entity entity, Vector vector) {
public void teleport(Entity entity, Location vector) {
((CraftEntity) entity).getHandle().setPosition(vector.getX(), vector.getY(), vector.getZ());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public void rotate(Entity entity, float yaw, float pitch) {
Location location = entity.getLocation();
location.setYaw(yaw);
location.setPitch(pitch);
entity.teleport(location);
teleport(entity, location);
}
else if (entity instanceof LivingEntity) {
if (entity instanceof EnderDragon) {
Expand Down Expand Up @@ -506,7 +506,7 @@ public void look(Entity entity, float yaw, float pitch) {
handle.pitch = pitch;
}
else {
Debug.echoError("Cannot set look direction for unspawned entitity " + entity.getUniqueId());
Debug.echoError("Cannot set look direction for unspawned entity " + entity.getUniqueId());
}
}

Expand Down Expand Up @@ -578,8 +578,14 @@ public void move(Entity entity, Vector vector) {
}

@Override
public void teleport(Entity entity, Vector vector) {
((CraftEntity) entity).getHandle().setPosition(vector.getX(), vector.getY(), vector.getZ());
public void teleport(Entity entity, Location loc) {
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.yaw = loc.getYaw();
nmsEntity.pitch = loc.getPitch();
if (nmsEntity instanceof EntityPlayer) {
nmsEntity.teleportAndSync(loc.getX(), loc.getY(), loc.getZ());
}
nmsEntity.setPosition(loc.getX(), loc.getY(), loc.getZ());
}

@Override
Expand Down

0 comments on commit 964969e

Please sign in to comment.