Ignore invalid animations in ClientboundAnimatePacket (#4025)

This commit is contained in:
Konicai 2023-07-31 16:56:28 -04:00 committed by GitHub
parent 7725651726
commit d89b55e9ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@
package org.geysermc.geyser.translator.protocol.java.entity;
import com.github.steveice10.mc.protocol.data.game.entity.player.Animation;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundAnimatePacket;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.packet.AnimateEntityPacket;
@ -44,12 +45,17 @@ public class JavaAnimateTranslator extends PacketTranslator<ClientboundAnimatePa
@Override
public void translate(GeyserSession session, ClientboundAnimatePacket packet) {
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
if (entity == null)
if (entity == null) {
return;
}
Animation animation = packet.getAnimation();
if (animation == null) {
return;
}
AnimatePacket animatePacket = new AnimatePacket();
animatePacket.setRuntimeEntityId(entity.getGeyserId());
switch (packet.getAnimation()) {
switch (animation) {
case SWING_ARM:
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
if (entity.getEntityId() == session.getPlayerEntity().getEntityId()) {
@ -86,7 +92,7 @@ public class JavaAnimateTranslator extends PacketTranslator<ClientboundAnimatePa
animatePacket.setAction(AnimatePacket.Action.WAKE_UP);
break;
default:
// Unknown Animation
session.getGeyser().getLogger().debug("Unhandled java animation: " + animation);
return;
}