Skip to content

Commit

Permalink
Fix initial movement speed (GeyserMC#751)
Browse files Browse the repository at this point in the history
Bedrock clients move very fast by default until they get an attribute packet correcting the speed.
  • Loading branch information
Heath123 authored Jun 8, 2020
1 parent bafe7d4 commit 1da130a
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@
import com.nukkitx.math.vector.*;
import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.ContainerId;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
import com.nukkitx.protocol.bedrock.data.GameRuleData;
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.data.*;
import com.nukkitx.protocol.bedrock.packet.*;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
Expand All @@ -61,6 +58,7 @@
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.entity.attribute.AttributeType;
import org.geysermc.connector.inventory.PlayerInventory;
import org.geysermc.connector.network.remote.RemoteServer;
import org.geysermc.connector.network.session.auth.AuthData;
Expand All @@ -82,6 +80,8 @@
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -220,6 +220,15 @@ public void connect(RemoteServer remoteServer) {
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
upstream.sendPacket(playStatusPacket);

UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket();
attributesPacket.setRuntimeEntityId(getPlayerEntity().getGeyserId());
List<Attribute> attributes = new ArrayList<>();
// Default move speed
// Bedrock clients move very fast by default until they get an attribute packet correcting the speed
attributes.add(new Attribute("minecraft:movement", 0.0f, 1024f, 0.1f, 0.1f));
attributesPacket.setAttributes(attributes);
upstream.sendPacket(attributesPacket);
}

public void fetchOurSkin(PlayerListPacket.Entry entry) {
Expand Down

0 comments on commit 1da130a

Please sign in to comment.