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

Fix regressions in player movement handling

Dieser Commit ist enthalten in:
Camotoy 2021-12-02 19:56:12 -05:00
Ursprung c3f146370e
Commit 9084c59003
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
6 geänderte Dateien mit 15 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -91,7 +91,7 @@ public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, Entit
private String identifier;
private float width;
private float height;
private float offset;
private float offset = 0.00001f;
private final List<EntityMetadataTranslator<? super T, ?, ?>> translators;
private Builder(EntityFactory<T> factory) {
@ -118,6 +118,11 @@ public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, Entit
return this;
}
public Builder<T> offset(float offset) {
this.offset = offset + 0.00001f;
return this;
}
/**
* Resets the identifier as well
*/

Datei anzeigen

@ -83,9 +83,9 @@ public class Entity {
/* Metadata about this specific entity */
@Setter(AccessLevel.NONE)
protected float boundingBoxHeight;
private float boundingBoxHeight;
@Setter(AccessLevel.NONE)
protected float boundingBoxWidth;
private float boundingBoxWidth;
@Setter(AccessLevel.NONE)
protected String nametag = "";
/* Metadata end */

Datei anzeigen

@ -45,9 +45,8 @@ public class AgeableEntity extends CreatureEntity {
dirtyMetadata.put(EntityData.SCALE, isBaby ? getBabySize() : getAdultSize());
setFlag(EntityFlag.BABY, isBaby);
// TODO save this?
dirtyMetadata.put(EntityData.BOUNDING_BOX_HEIGHT, definition.height() * (isBaby ? getBabySize() : getAdultSize()));
dirtyMetadata.put(EntityData.BOUNDING_BOX_WIDTH, definition.width() * (isBaby ? getBabySize() : getAdultSize()));
setBoundingBoxHeight(definition.height() * (isBaby ? getBabySize() : getAdultSize()));
setBoundingBoxWidth(definition.width() * (isBaby ? getBabySize() : getAdultSize()));
}
/**

Datei anzeigen

@ -44,8 +44,8 @@ public class PhantomEntity extends FlyingEntity {
float modelScale = 1f + 0.15f * size;
float boundsScale = (1f + (0.2f * size) / definition.width()) / modelScale;
dirtyMetadata.put(EntityData.BOUNDING_BOX_WIDTH, boundsScale * definition.width());
dirtyMetadata.put(EntityData.BOUNDING_BOX_HEIGHT, boundsScale * definition.height());
setBoundingBoxWidth(boundsScale * definition.width());
setBoundingBoxHeight(boundsScale * definition.height());
dirtyMetadata.put(EntityData.SCALE, modelScale);
}
}

Datei anzeigen

@ -58,7 +58,6 @@ import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.*;
import com.nukkitx.protocol.bedrock.data.command.CommandPermission;
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import com.nukkitx.protocol.bedrock.packet.*;
import com.nukkitx.protocol.bedrock.v471.Bedrock_v471;
@ -1057,7 +1056,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
private void setSneakingPose(boolean sneaking) {
this.pose = sneaking ? Pose.SNEAKING : Pose.STANDING;
playerEntity.getDirtyMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, sneaking ? 1.5f : playerEntity.getDefinition().height());
playerEntity.setBoundingBoxHeight(sneaking ? 1.5f : playerEntity.getDefinition().height());
playerEntity.setFlag(EntityFlag.SNEAKING, sneaking);
collisionManager.updatePlayerBoundingBox();
@ -1065,7 +1064,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
public void setSwimming(boolean swimming) {
this.pose = swimming ? Pose.SWIMMING : Pose.STANDING;
playerEntity.getDirtyMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, swimming ? 0.6f : playerEntity.getDefinition().height());
playerEntity.setBoundingBoxHeight(swimming ? 0.6f : playerEntity.getDefinition().height());
playerEntity.setFlag(EntityFlag.SWIMMING, swimming);
playerEntity.updateBedrockMetadata();
}

Datei anzeigen

@ -33,10 +33,10 @@ import com.nukkitx.math.vector.Vector3d;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.entity.EntityDefinitions;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@ -71,8 +71,6 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
session.confirmTeleport(packet.getPosition().toDouble().sub(0, EntityDefinitions.PLAYER.offset(), 0));
return;
}
// head yaw, pitch, head yaw
Vector3f rotation = Vector3f.from(packet.getRotation().getY(), packet.getRotation().getX(), packet.getRotation().getY());
float yaw = packet.getRotation().getY();
float pitch = packet.getRotation().getX();
float headYaw = packet.getRotation().getY();