mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix combat by sending the animate packet after damage (Closes #260)
This commit is contained in:
parent
03e11df58b
commit
9b487d7d03
2 changed files with 13 additions and 3 deletions
|
@ -33,6 +33,8 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerSwingArmPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Translator(packet = AnimatePacket.class)
|
||||
public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
|
||||
|
||||
|
@ -40,8 +42,12 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
|
|||
public void translate(AnimatePacket packet, GeyserSession session) {
|
||||
switch (packet.getAction()) {
|
||||
case SWING_ARM:
|
||||
ClientPlayerSwingArmPacket swingArmPacket = new ClientPlayerSwingArmPacket(Hand.MAIN_HAND);
|
||||
session.getDownstream().getSession().send(swingArmPacket);
|
||||
// Delay so entity damage can be processed first
|
||||
session.getConnector().getGeneralThreadPool().schedule(() ->
|
||||
session.getDownstream().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)),
|
||||
25,
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
break;
|
||||
case ITEM_RELEASE:
|
||||
if (packet.getActionType() == 0) {
|
||||
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0, 0, 0), BlockFace.DOWN);
|
||||
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(
|
||||
packet.getBlockPosition().getX(),
|
||||
packet.getBlockPosition().getY(),
|
||||
packet.getBlockPosition().getZ()
|
||||
), BlockFace.values()[packet.getFace()]);
|
||||
session.getDownstream().getSession().send(releaseItemPacket);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue