3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-25 15:50:14 +01:00

Implement player movement

Dieser Commit ist enthalten in:
RednedEpic 2019-09-13 19:37:06 -05:00 committet von RednedEpic
Ursprung 03bf12ee65
Commit a69aa8ebdb
3 geänderte Dateien mit 31 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -121,7 +121,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
return true;
}
return false;
return translateAndDefault(packet);
}
@Override

Datei anzeigen

@ -65,6 +65,7 @@ import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
import com.nukkitx.protocol.bedrock.packet.MobEquipmentPacket;
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
import com.nukkitx.protocol.bedrock.packet.PlayerActionPacket;
import com.nukkitx.protocol.bedrock.packet.TextPacket;
import lombok.Getter;
@ -72,6 +73,7 @@ import org.geysermc.connector.network.translators.bedrock.BedrockActionTranslato
import org.geysermc.connector.network.translators.bedrock.BedrockAnimateTranslator;
import org.geysermc.connector.network.translators.bedrock.BedrockCommandRequestTranslator;
import org.geysermc.connector.network.translators.bedrock.BedrockMobEquipmentTranslator;
import org.geysermc.connector.network.translators.bedrock.BedrockMovePlayerTranslator;
import org.geysermc.connector.network.translators.bedrock.BedrockTextTranslator;
import org.geysermc.connector.network.translators.inventory.GenericInventoryTranslator;
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
@ -182,6 +184,7 @@ public class TranslatorsInit {
Registry.registerBedrock(TextPacket.class, new BedrockTextTranslator());
Registry.registerBedrock(MobEquipmentPacket.class, new BedrockMobEquipmentTranslator());
Registry.registerBedrock(PlayerActionPacket.class, new BedrockActionTranslator());
Registry.registerBedrock(MovePlayerPacket.class, new BedrockMovePlayerTranslator());
itemTranslator = new ItemTranslator();

Datei anzeigen

@ -0,0 +1,26 @@
package org.geysermc.connector.network.translators.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPacket> {
@Override
public void translate(MovePlayerPacket packet, GeyserSession session) {
Entity entity = session.getPlayerEntity();
if (entity == null)
return;
// TODO: Implement collision support
ClientPlayerPositionRotationPacket playerPositionRotationPacket = new ClientPlayerPositionRotationPacket(
packet.isOnGround(), packet.getPosition().getX(), Math.ceil((packet.getPosition().getY() - EntityType.PLAYER.getOffset()) * 2) / 2,
packet.getPosition().getZ(), packet.getRotation().getY(), packet.getRotation().getX());
entity.moveAbsolute(packet.getPosition(), packet.getRotation());
session.getDownstream().getSession().send(playerPositionRotationPacket);
}
}