3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 00:00:41 +01:00

Fix Strider cold state when riding and removing of the RIDING flag when a parent is killed

Dieser Commit ist enthalten in:
rtm516 2020-07-03 22:55:54 +01:00
Ursprung ab71bf0727
Commit da96a5b19c
3 geänderte Dateien mit 41 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -146,6 +146,12 @@ public class Entity {
public boolean despawnEntity(GeyserSession session) {
if (!valid) return true;
for (long passenger : passengers) {
Entity entity = session.getEntityCache().getEntityByJavaId(passenger);
entity.getMetadata().getFlags().setFlag(EntityFlag.RIDING, false);
entity.updateBedrockMetadata(session);
}
RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket();
removeEntityPacket.setUniqueEntityId(geyserId);
session.sendUpstreamPacket(removeEntityPacket);

Datei anzeigen

@ -29,11 +29,14 @@ package org.geysermc.connector.entity.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
public class StriderEntity extends AnimalEntity {
private boolean shaking = false;
public StriderEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
super(entityId, geyserId, entityType, position, motion, rotation);
@ -44,8 +47,7 @@ public class StriderEntity extends AnimalEntity {
@Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 17) {
metadata.getFlags().setFlag(EntityFlag.BREATHING, !(boolean) entityMetadata.getValue());
metadata.getFlags().setFlag(EntityFlag.SHAKING, (boolean) entityMetadata.getValue());
shaking = (boolean) entityMetadata.getValue();
}
if (entityMetadata.getId() == 18) {
metadata.getFlags().setFlag(EntityFlag.SADDLED, (boolean) entityMetadata.getValue());
@ -53,4 +55,32 @@ public class StriderEntity extends AnimalEntity {
super.updateBedrockMetadata(entityMetadata, session);
}
@Override
public void updateBedrockMetadata(GeyserSession session) {
// Make sure they are not shaking when riding another entity
// Needs to copy the parent state
if (metadata.getFlags().getFlag(EntityFlag.RIDING)) {
boolean parentShaking = false;
for (Entity ent : session.getEntityCache().getEntities().values()) {
if (ent.getPassengers().contains(entityId) && ent instanceof StriderEntity) {
parentShaking = ent.getMetadata().getFlags().getFlag(EntityFlag.SHAKING);
break;
}
}
metadata.getFlags().setFlag(EntityFlag.BREATHING, !parentShaking);
metadata.getFlags().setFlag(EntityFlag.SHAKING, parentShaking);
} else {
metadata.getFlags().setFlag(EntityFlag.BREATHING, !shaking);
metadata.getFlags().setFlag(EntityFlag.SHAKING, shaking);
}
// Update the passengers if we have any
for (long passenger : passengers) {
session.getEntityCache().getEntityByJavaId(passenger).updateBedrockMetadata(session);
}
super.updateBedrockMetadata(session);
}
}

Datei anzeigen

@ -101,6 +101,9 @@ public class JavaEntitySetPassengersTranslator extends PacketTranslator<ServerEn
this.updateOffset(passenger, entity.getEntityType(), session, false, false, (passengers.size() > 1));
}
// Force an update to the passenger metadata
passenger.updateBedrockMetadata(session);
}
if (entity.getEntityType() == EntityType.HORSE) {