Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-08 17:20:20 +01:00
Fix crash with GSit lay and use Java bed position data
Dieser Commit ist enthalten in:
Ursprung
a6cc28ee80
Commit
45984a57ac
@ -339,18 +339,6 @@ public class Entity {
|
||||
metadata.getFlags().setFlag(EntityFlag.SLEEPING, true);
|
||||
// Has to be a byte or it does not work
|
||||
metadata.put(EntityData.PLAYER_FLAGS, (byte) 2);
|
||||
if (entityId == session.getPlayerEntity().getEntityId()) {
|
||||
Vector3i lastInteractionPos = session.getLastInteractionPosition();
|
||||
metadata.put(EntityData.BED_POSITION, lastInteractionPos);
|
||||
if (session.getConnector().getConfig().isCacheChunks()) {
|
||||
int bed = session.getConnector().getWorldManager().getBlockAt(session, lastInteractionPos.getX(),
|
||||
lastInteractionPos.getY(), lastInteractionPos.getZ());
|
||||
// Bed has to be updated, or else player is floating in the air
|
||||
ChunkUtils.updateBlock(session, bed, lastInteractionPos);
|
||||
}
|
||||
} else {
|
||||
metadata.put(EntityData.BED_POSITION, Vector3i.from(position.getFloorX(), position.getFloorY() - 2, position.getFloorZ()));
|
||||
}
|
||||
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.2f);
|
||||
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.2f);
|
||||
} else if (metadata.getFlags().getFlag(EntityFlag.SLEEPING)) {
|
||||
@ -360,6 +348,17 @@ public class Entity {
|
||||
metadata.put(EntityData.PLAYER_FLAGS, (byte) 0);
|
||||
}
|
||||
break;
|
||||
case 13: // Bed Position
|
||||
Position bedPosition = (Position) entityMetadata.getValue();
|
||||
if (bedPosition != null) {
|
||||
metadata.put(EntityData.BED_POSITION, Vector3i.from(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ()));
|
||||
if (session.getConnector().getConfig().isCacheChunks()) {
|
||||
int bed = session.getConnector().getWorldManager().getBlockAt(session, bedPosition);
|
||||
// Bed has to be updated, or else player is floating in the air
|
||||
ChunkUtils.updateBlock(session, bed, bedPosition);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadat
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.VillagerData;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlags;
|
||||
@ -100,8 +101,8 @@ public class VillagerEntity extends AbstractMerchantEntity {
|
||||
float bedPositionSubtractorW = 0;
|
||||
float bedPositionSubtractorN = 0;
|
||||
if (session.getConnector().getConfig().isCacheChunks()) {
|
||||
Position bedLocation = new Position((int) position.getFloorX(), (int) position.getFloorY(), (int) position.getFloorZ());
|
||||
bedId = session.getConnector().getWorldManager().getBlockAt(session, bedLocation);
|
||||
Vector3i bedPosition = metadata.getPos(EntityData.BED_POSITION);
|
||||
bedId = session.getConnector().getWorldManager().getBlockAt(session, bedPosition);
|
||||
}
|
||||
String bedRotationZ = BlockTranslator.getJavaIdBlockMap().inverse().get(bedId);
|
||||
setRotation(rotation);
|
||||
|
@ -43,15 +43,21 @@ public class JavaSpawnPlayerTranslator extends PacketTranslator<ServerSpawnPlaye
|
||||
Vector3f position = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
|
||||
Vector3f rotation = Vector3f.from(packet.getYaw(), packet.getPitch(), packet.getYaw());
|
||||
|
||||
PlayerEntity entity = session.getEntityCache().getPlayerEntity(packet.getUuid());
|
||||
if (entity == null) {
|
||||
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid()));
|
||||
return;
|
||||
}
|
||||
PlayerEntity entity;
|
||||
if (packet.getUuid().equals(session.getPlayerEntity().getUuid())) {
|
||||
// Server is sending a fake version of the current player
|
||||
entity = new PlayerEntity(session.getPlayerEntity().getProfile(), packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), position, Vector3f.ZERO, rotation);
|
||||
} else {
|
||||
entity = session.getEntityCache().getPlayerEntity(packet.getUuid());
|
||||
if (entity == null) {
|
||||
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid()));
|
||||
return;
|
||||
}
|
||||
|
||||
entity.setEntityId(packet.getEntityId());
|
||||
entity.setPosition(position);
|
||||
entity.setRotation(rotation);
|
||||
entity.setEntityId(packet.getEntityId());
|
||||
entity.setPosition(position);
|
||||
entity.setRotation(rotation);
|
||||
}
|
||||
session.getEntityCache().cacheEntity(entity);
|
||||
|
||||
if (session.getUpstream().isInitialized()) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren