Fix movement issues #466 (#473)

This commit is contained in:
ForceUpdate1 2020-05-04 08:06:08 +02:00 committed by GitHub
parent f1c31d1c4d
commit d0a2f6ac27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View file

@ -40,10 +40,7 @@ import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.tcp.TcpSessionFactory; import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
import com.nukkitx.math.GenericMath; import com.nukkitx.math.GenericMath;
import com.nukkitx.math.TrigMath; import com.nukkitx.math.TrigMath;
import com.nukkitx.math.vector.Vector2f; import com.nukkitx.math.vector.*;
import com.nukkitx.math.vector.Vector2i;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.ContainerId; import com.nukkitx.protocol.bedrock.data.ContainerId;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting; import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
@ -474,7 +471,7 @@ public class GeyserSession implements CommandSender {
upstream.sendPacket(startGamePacket); upstream.sendPacket(startGamePacket);
} }
public boolean confirmTeleport(Vector3f position) { public boolean confirmTeleport(Vector3d position) {
if (teleportCache != null) { if (teleportCache != null) {
if (!teleportCache.canConfirm(position)) { if (!teleportCache.canConfirm(position)) {
GeyserConnector.getInstance().getLogger().debug("Unconfirmed Teleport " + teleportCache.getTeleportConfirmId() GeyserConnector.getInstance().getLogger().debug("Unconfirmed Teleport " + teleportCache.getTeleportConfirmId()

View file

@ -25,6 +25,7 @@
package org.geysermc.connector.network.session.cache; package org.geysermc.connector.network.session.cache;
import com.nukkitx.math.vector.Vector3d;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -39,7 +40,7 @@ public class TeleportCache {
private double x, y, z; private double x, y, z;
private int teleportConfirmId; private int teleportConfirmId;
public boolean canConfirm(Vector3f position) { public boolean canConfirm(Vector3d position) {
return (Math.abs(this.x - position.getX()) < ERROR && return (Math.abs(this.x - position.getX()) < ERROR &&
Math.abs(this.y - position.getY()) < ERROR_Y && Math.abs(this.y - position.getY()) < ERROR_Y &&
Math.abs(this.z - position.getZ()) < ERROR); Math.abs(this.z - position.getZ()) < ERROR);

View file

@ -25,6 +25,7 @@
package org.geysermc.connector.network.translators.bedrock; package org.geysermc.connector.network.translators.bedrock;
import com.nukkitx.math.vector.Vector3d;
import org.geysermc.common.ChatColor; import org.geysermc.common.ChatColor;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.PlayerEntity; import org.geysermc.connector.entity.PlayerEntity;
@ -63,7 +64,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
double javaY = packet.getPosition().getY() - EntityType.PLAYER.getOffset(); double javaY = packet.getPosition().getY() - EntityType.PLAYER.getOffset();
if (packet.isOnGround()) javaY = Math.ceil(javaY * 2) / 2; if (packet.isOnGround()) javaY = Math.ceil(javaY * 2) / 2;
Vector3f position = Vector3f.from(Double.parseDouble(Float.toString(packet.getPosition().getX())), javaY, Vector3d position = Vector3d.from(Double.parseDouble(Float.toString(packet.getPosition().getX())), javaY,
Double.parseDouble(Float.toString(packet.getPosition().getZ()))); Double.parseDouble(Float.toString(packet.getPosition().getZ())));
if(!session.confirmTeleport(position)){ if(!session.confirmTeleport(position)){
@ -82,7 +83,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
// head yaw, pitch, head yaw // head yaw, pitch, head yaw
Vector3f rotation = Vector3f.from(packet.getRotation().getY(), packet.getRotation().getX(), packet.getRotation().getY()); Vector3f rotation = Vector3f.from(packet.getRotation().getY(), packet.getRotation().getX(), packet.getRotation().getY());
entity.setPosition(position); entity.setPosition(packet.getPosition().sub(0, EntityType.PLAYER.getOffset(), 0));
entity.setRotation(rotation); entity.setRotation(rotation);
/* /*