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

Recalculate pose when using or leaving bed

Dieser Commit ist enthalten in:
creeper123123321 2019-04-27 17:21:01 -03:00
Ursprung d7eff51805
Commit 61b5c90aa7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
2 geänderte Dateien mit 8 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -194,7 +194,7 @@ public class MetadataRewriter {
return (entityFlags & 0x80) != 0;
}
private static int recalculatePlayerPose(int entityId, EntityTracker tracker) {
public static int recalculatePlayerPose(int entityId, EntityTracker tracker) {
byte flags = tracker.getEntityFlags(entityId);
// Mojang overrides the client-side pose updater, see OtherPlayerEntity#updateSize
int pose = 0; // standing

Datei anzeigen

@ -196,11 +196,13 @@ public class EntityPackets {
short animation = wrapper.passthrough(Type.UNSIGNED_BYTE);
if (animation == 2) { //Leave bed
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
tracker.setSleeping(wrapper.get(Type.VAR_INT, 0), false);
int entityId = wrapper.get(Type.VAR_INT, 0);
tracker.setSleeping(entityId, false);
PacketWrapper metadataPacket = wrapper.create(0x43);
metadataPacket.write(Type.VAR_INT, wrapper.get(Type.VAR_INT, 0));
metadataPacket.write(Type.VAR_INT, entityId);
List<Metadata> metadataList = new LinkedList<>();
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter.recalculatePlayerPose(entityId, tracker)));
metadataList.add(new Metadata(12, MetaType1_14.OptPosition, null));
metadataPacket.write(Types1_14.METADATA_LIST, metadataList);
metadataPacket.send(Protocol1_14To1_13_2.class);
@ -219,11 +221,13 @@ public class EntityPackets {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
tracker.setSleeping(wrapper.get(Type.VAR_INT, 0), true);
int entityId = wrapper.get(Type.VAR_INT, 0);
tracker.setSleeping(entityId, true);
Position position = wrapper.read(Type.POSITION);
List<Metadata> metadataList = new LinkedList<>();
metadataList.add(new Metadata(12, MetaType1_14.OptPosition, position));
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter.recalculatePlayerPose(entityId, tracker)));
wrapper.write(Types1_14.METADATA_LIST, metadataList);
}
});