mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Ignore invalid animations in ClientboundAnimatePacket (#4025)
This commit is contained in:
parent
7725651726
commit
d89b55e9ac
1 changed files with 9 additions and 3 deletions
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.geyser.translator.protocol.java.entity;
|
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 com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundAnimatePacket;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.AnimateEntityPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AnimateEntityPacket;
|
||||||
|
@ -44,12 +45,17 @@ public class JavaAnimateTranslator extends PacketTranslator<ClientboundAnimatePa
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ClientboundAnimatePacket packet) {
|
public void translate(GeyserSession session, ClientboundAnimatePacket packet) {
|
||||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||||
if (entity == null)
|
if (entity == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
Animation animation = packet.getAnimation();
|
||||||
|
if (animation == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AnimatePacket animatePacket = new AnimatePacket();
|
AnimatePacket animatePacket = new AnimatePacket();
|
||||||
animatePacket.setRuntimeEntityId(entity.getGeyserId());
|
animatePacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
switch (packet.getAnimation()) {
|
switch (animation) {
|
||||||
case SWING_ARM:
|
case SWING_ARM:
|
||||||
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
|
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
|
||||||
if (entity.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
if (entity.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||||
|
@ -86,7 +92,7 @@ public class JavaAnimateTranslator extends PacketTranslator<ClientboundAnimatePa
|
||||||
animatePacket.setAction(AnimatePacket.Action.WAKE_UP);
|
animatePacket.setAction(AnimatePacket.Action.WAKE_UP);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Unknown Animation
|
session.getGeyser().getLogger().debug("Unhandled java animation: " + animation);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue