Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Fix sleeping on older Minecraft server versions (#2049)
BED_POSITION is enough to trigger sleep.
Dieser Commit ist enthalten in:
Ursprung
d41d8b0ebf
Commit
3d4fff8dee
@ -331,15 +331,12 @@ public class Entity {
|
|||||||
case 6: // Pose change
|
case 6: // Pose change
|
||||||
if (entityMetadata.getValue().equals(Pose.SLEEPING)) {
|
if (entityMetadata.getValue().equals(Pose.SLEEPING)) {
|
||||||
metadata.getFlags().setFlag(EntityFlag.SLEEPING, true);
|
metadata.getFlags().setFlag(EntityFlag.SLEEPING, true);
|
||||||
// Has to be a byte or it does not work
|
|
||||||
metadata.put(EntityData.PLAYER_FLAGS, (byte) 2);
|
|
||||||
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.2f);
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.2f);
|
||||||
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.2f);
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.2f);
|
||||||
} else if (metadata.getFlags().getFlag(EntityFlag.SLEEPING)) {
|
} else if (metadata.getFlags().getFlag(EntityFlag.SLEEPING)) {
|
||||||
metadata.getFlags().setFlag(EntityFlag.SLEEPING, false);
|
metadata.getFlags().setFlag(EntityFlag.SLEEPING, false);
|
||||||
metadata.put(EntityData.BOUNDING_BOX_WIDTH, getEntityType().getWidth());
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, getEntityType().getWidth());
|
||||||
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, getEntityType().getHeight());
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, getEntityType().getHeight());
|
||||||
metadata.put(EntityData.PLAYER_FLAGS, (byte) 0);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,13 @@ public class LivingEntity extends Entity {
|
|||||||
// Bed has to be updated, or else player is floating in the air
|
// Bed has to be updated, or else player is floating in the air
|
||||||
ChunkUtils.updateBlock(session, bed, bedPosition);
|
ChunkUtils.updateBlock(session, bed, bedPosition);
|
||||||
}
|
}
|
||||||
|
// Indicate that the player should enter the sleep cycle
|
||||||
|
// Has to be a byte or it does not work
|
||||||
|
// (Bed position is what actually triggers sleep - "pose" is only optional)
|
||||||
|
metadata.put(EntityData.PLAYER_FLAGS, (byte) 2);
|
||||||
|
} else {
|
||||||
|
// Player is no longer sleeping
|
||||||
|
metadata.put(EntityData.PLAYER_FLAGS, (byte) 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,11 @@ public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerEntityMetadataPacket packet, GeyserSession session) {
|
public void translate(ServerEntityMetadataPacket packet, GeyserSession session) {
|
||||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
Entity entity;
|
||||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||||
entity = session.getPlayerEntity();
|
entity = session.getPlayerEntity();
|
||||||
|
} else {
|
||||||
|
entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||||
}
|
}
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren