Archived
0

новый пакет: EntityActionPacket

This commit is contained in:
2018-08-18 22:22:20 +03:00
parent c2aa48f14f
commit fcefba29ac
2 changed files with 46 additions and 0 deletions

View File

@@ -80,6 +80,7 @@ public enum State {
.put(0x0D, PlayerPositionPacket.class) .put(0x0D, PlayerPositionPacket.class)
.put(0x0E, PlayerPositionAndLookPacket.class) .put(0x0E, PlayerPositionAndLookPacket.class)
.put(0x0F, PlayerLookPacket.class) .put(0x0F, PlayerLookPacket.class)
.put(0x15, EntityActionPacket.class)
.put(0x1A, HeldItemChangePacket.class) .put(0x1A, HeldItemChangePacket.class)
.put(0x1D, AnimationPacket.class) .put(0x1D, AnimationPacket.class)
.build(), .build(),

View File

@@ -0,0 +1,45 @@
package mc.core.network.proto_1_12_2.packets;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import mc.core.network.CSPacket;
import mc.core.network.NetInputStream;
import java.util.Arrays;
@Getter
public class EntityActionPacket implements CSPacket {
@RequiredArgsConstructor
public enum Action {
START_SNEAKING(0),
STOP_SNEAKING(1),
LEAVE_BED(2), // Leave bed is only sent when the “Leave Bed” button is clicked on the sleep GUI, not when waking up due today time.
START_SPRINTING(3),
STOP_SPRINTING(4),
START_JUMP_WITH_HORSE(5),
STOP_JUMP_WITH_HORSE(6),
OPEN_HORSE_INVENTORY(7), // Open horse inventory is only sent when pressing the inventory key (default: E) while on a horse — all other methods of opening a horse's inventory (involving right-clicking or shift-right-clicking it) do not use this packet.
START_FLYING_WITH_ELYTRA(8);
public static Action getById(final int id) {
return Arrays.stream(Action.values())
.filter(action -> action.id == id)
.findFirst()
.orElse(null);
}
@Getter
private final int id;
}
private int entityId;
private Action action;
private int jumpBoost; // Only used by the “start jump with horse” action, in which case it ranges from 0 to 100. In all other cases it is 0.
@Override
public void readSelf(NetInputStream netStream) {
entityId = netStream.readVarInt();
action = Action.getById(netStream.readVarInt());
jumpBoost = netStream.readVarInt();
}
}