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

Fix combat by sending the animate packet after damage (Closes #260)

Dieser Commit ist enthalten in:
RednedEpic 2020-04-03 17:20:14 -05:00
Ursprung 03e11df58b
Commit 9b487d7d03
2 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -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.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerSwingArmPacket;
import com.nukkitx.protocol.bedrock.packet.AnimatePacket; import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
import java.util.concurrent.TimeUnit;
@Translator(packet = AnimatePacket.class) @Translator(packet = AnimatePacket.class)
public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> { public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
@ -40,8 +42,12 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
public void translate(AnimatePacket packet, GeyserSession session) { public void translate(AnimatePacket packet, GeyserSession session) {
switch (packet.getAction()) { switch (packet.getAction()) {
case SWING_ARM: case SWING_ARM:
ClientPlayerSwingArmPacket swingArmPacket = new ClientPlayerSwingArmPacket(Hand.MAIN_HAND); // Delay so entity damage can be processed first
session.getDownstream().getSession().send(swingArmPacket); session.getConnector().getGeneralThreadPool().schedule(() ->
session.getDownstream().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)),
25,
TimeUnit.MILLISECONDS
);
break; break;
} }
} }

Datei anzeigen

@ -61,7 +61,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
break; break;
case ITEM_RELEASE: case ITEM_RELEASE:
if (packet.getActionType() == 0) { 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); session.getDownstream().getSession().send(releaseItemPacket);
} }
break; break;