Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-28 09:00:11 +01:00
Fix GSit's lay position
Dieser Commit ist enthalten in:
Ursprung
45984a57ac
Commit
590dcbd5b1
@ -31,10 +31,12 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility;
|
|||||||
import com.github.steveice10.mc.protocol.data.message.TextMessage;
|
import com.github.steveice10.mc.protocol.data.message.TextMessage;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||||
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
|
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
|
||||||
import com.nukkitx.protocol.bedrock.data.command.CommandPermission;
|
import com.nukkitx.protocol.bedrock.data.command.CommandPermission;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityLinkData;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityLinkData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AddPlayerPacket;
|
import com.nukkitx.protocol.bedrock.packet.AddPlayerPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||||
@ -168,6 +170,17 @@ public class PlayerEntity extends LivingEntity {
|
|||||||
movePlayerPacket.setRotation(getBedrockRotation());
|
movePlayerPacket.setRotation(getBedrockRotation());
|
||||||
movePlayerPacket.setOnGround(isOnGround);
|
movePlayerPacket.setOnGround(isOnGround);
|
||||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL);
|
movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL);
|
||||||
|
// If the player is moved while sleeping, we have to adjust their y, so it appears
|
||||||
|
// correctly on Bedrock. This fixes GSit's lay.
|
||||||
|
if (metadata.getFlags().getFlag(EntityFlag.SLEEPING)) {
|
||||||
|
Vector3i bedPosition = metadata.getPos(EntityData.BED_POSITION);
|
||||||
|
if (bedPosition != null && (bedPosition.getY() == 0 || bedPosition.distanceSquared(position.toInt()) > 4)) {
|
||||||
|
// Force the player movement by using a teleport
|
||||||
|
movePlayerPacket.setPosition(Vector3f.from(position.getX(), position.getY() - entityType.getOffset() + 0.2f, position.getZ()));
|
||||||
|
movePlayerPacket.setMode(MovePlayerPacket.Mode.TELEPORT);
|
||||||
|
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.UNKNOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
session.sendUpstreamPacket(movePlayerPacket);
|
session.sendUpstreamPacket(movePlayerPacket);
|
||||||
if (leftParrot != null) {
|
if (leftParrot != null) {
|
||||||
leftParrot.moveRelative(session, relX, relY, relZ, rotation, true);
|
leftParrot.moveRelative(session, relX, relY, relZ, rotation, true);
|
||||||
|
@ -100,8 +100,8 @@ public class VillagerEntity extends AbstractMerchantEntity {
|
|||||||
int bedId = 0;
|
int bedId = 0;
|
||||||
float bedPositionSubtractorW = 0;
|
float bedPositionSubtractorW = 0;
|
||||||
float bedPositionSubtractorN = 0;
|
float bedPositionSubtractorN = 0;
|
||||||
if (session.getConnector().getConfig().isCacheChunks()) {
|
Vector3i bedPosition = metadata.getPos(EntityData.BED_POSITION);
|
||||||
Vector3i bedPosition = metadata.getPos(EntityData.BED_POSITION);
|
if (session.getConnector().getConfig().isCacheChunks() && bedPosition != null) {
|
||||||
bedId = session.getConnector().getWorldManager().getBlockAt(session, bedPosition);
|
bedId = session.getConnector().getWorldManager().getBlockAt(session, bedPosition);
|
||||||
}
|
}
|
||||||
String bedRotationZ = BlockTranslator.getJavaIdBlockMap().inverse().get(bedId);
|
String bedRotationZ = BlockTranslator.getJavaIdBlockMap().inverse().get(bedId);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren