com.nukkitx.protocol.bedrock.packet.PlayerActionPacket Java Examples
The following examples show how to use
com.nukkitx.protocol.bedrock.packet.PlayerActionPacket.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerActionSerializer_v354.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, PlayerActionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getAction().ordinal()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); }
Example #2
Source File: PlayerActionSerializer_v354.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, PlayerActionPacket packet) { packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setAction(Action.values()[VarInts.readInt(buffer)]); packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setFace(VarInts.readInt(buffer)); }
Example #3
Source File: PlayerActionSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, PlayerActionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getAction().ordinal()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); }
Example #4
Source File: PlayerActionSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, PlayerActionPacket packet) { packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setAction(Action.values()[VarInts.readInt(buffer)]); packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setFace(VarInts.readInt(buffer)); }
Example #5
Source File: PlayerActionSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, PlayerActionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getAction().ordinal()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); }
Example #6
Source File: PlayerActionSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, PlayerActionPacket packet) { packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setAction(Action.values()[VarInts.readInt(buffer)]); packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setFace(VarInts.readInt(buffer)); }
Example #7
Source File: PlayerActionSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, PlayerActionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getAction().ordinal()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); }
Example #8
Source File: PlayerActionSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, PlayerActionPacket packet) { packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setAction(Action.values()[VarInts.readInt(buffer)]); packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setFace(VarInts.readInt(buffer)); }
Example #9
Source File: PlayerActionSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, PlayerActionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getAction().ordinal()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); }
Example #10
Source File: PlayerActionSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, PlayerActionPacket packet) { packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setAction(Action.values()[VarInts.readInt(buffer)]); packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setFace(VarInts.readInt(buffer)); }
Example #11
Source File: PlayerActionSerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, PlayerActionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getAction().ordinal()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); }
Example #12
Source File: PlayerActionSerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, PlayerActionPacket packet) { packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setAction(Action.values()[VarInts.readInt(buffer)]); packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setFace(VarInts.readInt(buffer)); }
Example #13
Source File: PlayerActionSerializer_v291.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, PlayerActionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getAction().ordinal()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); }
Example #14
Source File: PlayerActionSerializer_v291.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, PlayerActionPacket packet) { packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setAction(Action.values()[VarInts.readInt(buffer)]); packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setFace(VarInts.readInt(buffer)); }
Example #15
Source File: BedrockActionTranslator.java From Geyser with MIT License | 4 votes |
@Override public void translate(PlayerActionPacket packet, GeyserSession session) { Entity entity = session.getPlayerEntity(); if (entity == null) return; Vector3i vector = packet.getBlockPosition(); Position position = new Position(vector.getX(), vector.getY(), vector.getZ()); switch (packet.getAction()) { case RESPAWN: // Don't put anything here as respawn is already handled // in BedrockRespawnTranslator break; case START_SWIMMING: ClientPlayerStatePacket startSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING); session.sendDownstreamPacket(startSwimPacket); break; case STOP_SWIMMING: ClientPlayerStatePacket stopSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING); session.sendDownstreamPacket(stopSwimPacket); break; case START_GLIDE: case STOP_GLIDE: ClientPlayerStatePacket glidePacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_ELYTRA_FLYING); session.sendDownstreamPacket(glidePacket); break; case START_SNEAK: ClientPlayerStatePacket startSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SNEAKING); session.sendDownstreamPacket(startSneakPacket); session.setSneaking(true); break; case STOP_SNEAK: ClientPlayerStatePacket stopSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SNEAKING); session.sendDownstreamPacket(stopSneakPacket); session.setSneaking(false); break; case START_SPRINT: ClientPlayerStatePacket startSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING); session.sendDownstreamPacket(startSprintPacket); session.setSprinting(true); break; case STOP_SPRINT: ClientPlayerStatePacket stopSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING); session.sendDownstreamPacket(stopSprintPacket); session.setSprinting(false); break; case DROP_ITEM: ClientPlayerActionPacket dropItemPacket = new ClientPlayerActionPacket(PlayerAction.DROP_ITEM, position, BlockFace.values()[packet.getFace()]); session.sendDownstreamPacket(dropItemPacket); break; case STOP_SLEEP: ClientPlayerStatePacket stopSleepingPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.LEAVE_BED); session.sendDownstreamPacket(stopSleepingPacket); break; case BLOCK_INTERACT: // Handled in BedrockInventoryTransactionTranslator break; case START_BREAK: ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.values()[packet.getFace()]); session.sendDownstreamPacket(startBreakingPacket); break; case CONTINUE_BREAK: LevelEventPacket continueBreakPacket = new LevelEventPacket(); continueBreakPacket.setType(LevelEventType.PUNCH_BLOCK); continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock() == null ? BlockTranslator.AIR : session.getBreakingBlock())); continueBreakPacket.setPosition(packet.getBlockPosition().toFloat()); session.sendUpstreamPacket(continueBreakPacket); break; case ABORT_BREAK: ClientPlayerActionPacket abortBreakingPacket = new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING, new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.DOWN); session.sendDownstreamPacket(abortBreakingPacket); break; case STOP_BREAK: // Handled in BedrockInventoryTransactionTranslator break; case DIMENSION_CHANGE_SUCCESS: if (session.getPendingDimSwitches().decrementAndGet() == 0) { //sometimes the client doesn't feel like loading PlayStatusPacket spawnPacket = new PlayStatusPacket(); spawnPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN); session.sendUpstreamPacket(spawnPacket); entity.updateBedrockAttributes(session); session.getEntityCache().updateBossBars(); } break; case JUMP: session.setJumping(true); session.getConnector().getGeneralThreadPool().schedule(() -> { session.setJumping(false); }, 1, TimeUnit.SECONDS); break; } }