com.nukkitx.protocol.bedrock.packet.LevelEventPacket Java Examples

The following examples show how to use com.nukkitx.protocol.bedrock.packet.LevelEventPacket. 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: DoorSoundInteractionHandler.java    From Geyser with MIT License 5 votes vote down vote up
@Override
public void handleInteraction(GeyserSession session, Vector3f position, String identifier) {
    LevelEventPacket levelEventPacket = new LevelEventPacket();
    levelEventPacket.setType(LevelEventType.SOUND_DOOR);
    levelEventPacket.setPosition(position);
    levelEventPacket.setData(0);
    session.sendUpstreamPacket(levelEventPacket);
}
 
Example #2
Source File: LevelEventSerializer_v291.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelEventPacket packet) {
    int eventId = VarInts.readInt(buffer);
    packet.setType(events.get(eventId));
    if (packet.getType() == null) {
        log.debug("Unknown Level Event {} received", eventId);
    }
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setData(VarInts.readInt(buffer));
}
 
Example #3
Source File: LevelEventSerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelEventPacket packet) {
    int eventId = VarInts.readInt(buffer);
    packet.setType(events.get(eventId));
    if (packet.getType() == null) {
        log.debug("Unknown Level Event {} received", eventId);
    }
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setData(VarInts.readInt(buffer));
}
 
Example #4
Source File: LevelEventSerializer_v361.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelEventPacket packet) {
    int eventId = VarInts.readInt(buffer);
    packet.setType(events.get(eventId));
    if (packet.getType() == null) {
        log.debug("Unknown Level Event {} received", eventId);
    }
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setData(VarInts.readInt(buffer));
}
 
Example #5
Source File: LevelEventSerializer_v313.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelEventPacket packet) {
    int eventId = VarInts.readInt(buffer);
    packet.setType(events.get(eventId));
    if (packet.getType() == null) {
        log.debug("Unknown Level Event {} received", eventId);
    }
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setData(VarInts.readInt(buffer));
}
 
Example #6
Source File: LevelEventSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelEventPacket packet) {
    int eventId = VarInts.readInt(buffer);
    packet.setType(events.get(eventId));
    if (packet.getType() == null) {
        log.debug("Unknown Level Event {} received", eventId);
    }
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setData(VarInts.readInt(buffer));
}
 
Example #7
Source File: LevelEventSerializer_v388.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelEventPacket packet) {
    int eventId = VarInts.readInt(buffer);
    packet.setType(events.get(eventId));
    if (packet.getType() == null) {
        log.debug("Unknown Level Event {} received", eventId);
    }
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setData(VarInts.readInt(buffer));
}
 
Example #8
Source File: LevelEventSerializer_v354.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelEventPacket packet) {
    int eventId = VarInts.readInt(buffer);
    packet.setType(events.get(eventId));
    if (packet.getType() == null) {
        log.debug("Unknown Level Event {} received", eventId);
    }
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setData(VarInts.readInt(buffer));
}
 
Example #9
Source File: JavaRespawnTranslator.java    From Geyser with MIT License 5 votes vote down vote up
@Override
public void translate(ServerRespawnPacket packet, GeyserSession session) {
    Entity entity = session.getPlayerEntity();
    if (entity == null)
        return;

    float maxHealth = entity.getAttributes().containsKey(AttributeType.MAX_HEALTH) ? entity.getAttributes().get(AttributeType.MAX_HEALTH).getValue() : 20f;
    // Max health must be divisible by two in bedrock
    entity.getAttributes().put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(maxHealth, (maxHealth % 2 == 1 ? maxHealth + 1 : maxHealth)));

    session.getInventoryCache().setOpenInventory(null);

    SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
    playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
    session.sendUpstreamPacket(playerGameTypePacket);
    session.setGameMode(packet.getGamemode());

    LevelEventPacket stopRainPacket = new LevelEventPacket();
    stopRainPacket.setType(LevelEventType.STOP_RAIN);
    stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
    stopRainPacket.setPosition(Vector3f.ZERO);
    session.sendUpstreamPacket(stopRainPacket);

    if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) {
        DimensionUtils.switchDimension(session, packet.getDimension());
    } else {
        if (session.isManyDimPackets()) { //reloading world
            int fakeDim = entity.getDimension() == 0 ? -1 : 0;
            DimensionUtils.switchDimension(session, fakeDim);
            DimensionUtils.switchDimension(session, packet.getDimension());
        } else {
            // Handled in JavaPlayerPositionRotationTranslator
            session.setSpawned(false);
        }
    }
}
 
Example #10
Source File: ComparatorSoundInteractHandler.java    From Geyser with MIT License 5 votes vote down vote up
@Override
public void handleInteraction(GeyserSession session, Vector3f position, String identifier) {
    boolean powered = identifier.contains("mode=compare");
    LevelEventPacket levelEventPacket = new LevelEventPacket();
    levelEventPacket.setPosition(position);
    levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER);
    levelEventPacket.setData(powered ? 500 : 550);
    session.sendUpstreamPacket(levelEventPacket);
}
 
Example #11
Source File: LeverSoundInteractionHandler.java    From Geyser with MIT License 5 votes vote down vote up
@Override
public void handleInteraction(GeyserSession session, Vector3f position, String identifier) {
    boolean powered = identifier.contains("powered=true");
    LevelEventPacket levelEventPacket = new LevelEventPacket();
    levelEventPacket.setPosition(position);
    levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER);
    levelEventPacket.setData(powered ? 600 : 500);
    session.sendUpstreamPacket(levelEventPacket);
}
 
Example #12
Source File: BedrockActionTranslator.java    From Geyser with MIT License 4 votes vote down vote up
@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;
    }
}
 
Example #13
Source File: LevelEventSerializer_v354.java    From Protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelEventPacket packet) {
    VarInts.writeInt(buffer, events.get(packet.getType()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getData());
}
 
Example #14
Source File: JavaPlayerActionAckTranslator.java    From Geyser with MIT License 4 votes vote down vote up
@Override
public void translate(ServerPlayerActionAckPacket packet, GeyserSession session) {
    LevelEventPacket levelEvent = new LevelEventPacket();
    switch (packet.getAction()) {
        case FINISH_DIGGING:
            double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(session.getBreakingBlock() == null ? 0 : session.getBreakingBlock().getId());
            if (session.getGameMode() != GameMode.CREATIVE && blockHardness != 0) {
                levelEvent.setType(LevelEventType.DESTROY);
                levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
                levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
                session.sendUpstreamPacket(levelEvent);
                session.setBreakingBlock(null);
            }
            ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
            break;
        case START_DIGGING:
            if (session.getGameMode() == GameMode.CREATIVE) {
                break;
            }
            blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(packet.getNewState().getId());
            levelEvent.setType(LevelEventType.BLOCK_START_BREAK);
            levelEvent.setPosition(Vector3f.from(
                    packet.getPosition().getX(),
                    packet.getPosition().getY(),
                    packet.getPosition().getZ()
            ));
            PlayerInventory inventory = session.getInventory();
            ItemStack item = inventory.getItemInHand();
            ItemEntry itemEntry = null;
            CompoundTag nbtData = new CompoundTag("");
            if (item != null) {
                itemEntry = ItemRegistry.getItem(item);
                nbtData = item.getNbt();
            }
            double breakTime = Math.ceil(BlockUtils.getBreakTime(blockHardness, packet.getNewState().getId(), itemEntry, nbtData, session) * 20);
            levelEvent.setData((int) (65535 / breakTime));
            session.setBreakingBlock(packet.getNewState());
            session.sendUpstreamPacket(levelEvent);
            break;
        case CANCEL_DIGGING:
            levelEvent.setType(LevelEventType.BLOCK_STOP_BREAK);
            levelEvent.setPosition(Vector3f.from(
                    packet.getPosition().getX(),
                    packet.getPosition().getY(),
                    packet.getPosition().getZ()
            ));
            levelEvent.setData(0);
            session.setBreakingBlock(null);
            session.sendUpstreamPacket(levelEvent);
            break;
    }
}
 
Example #15
Source File: LevelEventSerializer_v388.java    From Protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelEventPacket packet) {
    VarInts.writeInt(buffer, events.get(packet.getType()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getData());
}
 
Example #16
Source File: JavaBlockBreakAnimTranslator.java    From Geyser with MIT License 4 votes vote down vote up
@Override
public void translate(ServerBlockBreakAnimPacket packet, GeyserSession session) {
    BlockState state = session.getConnector().getWorldManager().getBlockAt(session, packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
    int breakTime = (int) (65535 / Math.ceil(BlockUtils.getBreakTime(BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(state.getId()), state.getId(), ItemEntry.AIR, new CompoundTag(""), null) * 20));
    LevelEventPacket levelEventPacket = new LevelEventPacket();
    levelEventPacket.setPosition(Vector3f.from(
            packet.getPosition().getX(),
            packet.getPosition().getY(),
            packet.getPosition().getZ()
    ));
    levelEventPacket.setType(LevelEventType.BLOCK_START_BREAK);

    switch (packet.getStage()) {
        case STAGE_1:
            levelEventPacket.setData(breakTime);
            break;
        case STAGE_2:
            levelEventPacket.setData(breakTime * 2);
            break;
        case STAGE_3:
            levelEventPacket.setData(breakTime * 3);
            break;
        case STAGE_4:
            levelEventPacket.setData(breakTime * 4);
            break;
        case STAGE_5:
            levelEventPacket.setData(breakTime * 5);
            break;
        case STAGE_6:
            levelEventPacket.setData(breakTime * 6);
            break;
        case STAGE_7:
            levelEventPacket.setData(breakTime * 7);
            break;
        case STAGE_8:
            levelEventPacket.setData(breakTime * 8);
            break;
        case STAGE_9:
            levelEventPacket.setData(breakTime * 9);
            break;
        case STAGE_10:
            levelEventPacket.setData(breakTime * 10);
            break;
        case RESET:
            levelEventPacket.setType(LevelEventType.BLOCK_STOP_BREAK);
            levelEventPacket.setData(0);
            break;
    }
    session.sendUpstreamPacket(levelEventPacket);
}
 
Example #17
Source File: LevelEventSerializer_v340.java    From Protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelEventPacket packet) {
    VarInts.writeInt(buffer, events.get(packet.getType()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getData());
}
 
Example #18
Source File: JavaPlayBuiltinSoundTranslator.java    From Geyser with MIT License 4 votes vote down vote up
@Override
public void translate(ServerPlayBuiltinSoundPacket packet, GeyserSession session) {
    String packetSound = packet.getSound().getName();

    SoundRegistry.SoundMapping soundMapping = SoundRegistry.fromJava(packetSound);
    if (soundMapping == null) {
        session.getConnector().getLogger().debug("[Builtin] Sound mapping " + packetSound + " not found - " + packet.toString());
        return;
    }

    if (soundMapping.isLevelEvent()) {
        LevelEventPacket levelEventPacket = new LevelEventPacket();
        levelEventPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
        levelEventPacket.setData(0);
        levelEventPacket.setType(LevelEventType.valueOf(soundMapping.getBedrock()));
        session.sendUpstreamPacket(levelEventPacket);
        return;
    }
    LevelSoundEventPacket soundPacket = new LevelSoundEventPacket();
    SoundEvent sound = SoundRegistry.toSoundEvent(soundMapping.getBedrock());
    if (sound == null) {
        sound = SoundRegistry.toSoundEvent(soundMapping.getBedrock());
    }
    if (sound == null) {
        sound = SoundRegistry.toSoundEvent(packetSound);
    }
    if (sound == null) {
        session.getConnector().getLogger().debug("[Builtin] Sound for original " + packetSound + " to mappings " + soundPacket
                        + " was not a playable level sound, or has yet to be mapped to an enum in "
                        + "NukkitX SoundEvent ");

    }
    soundPacket.setSound(sound);
    soundPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
    soundPacket.setIdentifier(soundMapping.getIdentifier());
    if (sound == SoundEvent.NOTE) {
        // Minecraft Wiki: 2^(x/12) = Java pitch where x is -12 to 12
        // Java sends the note value as above starting with -12 and ending at 12
        // Bedrock has a number for each type of note, then proceeds up the scale by adding to that number
        soundPacket.setExtraData(soundMapping.getExtraData() + (int)(Math.round((Math.log10(packet.getPitch()) / Math.log10(2)) * 12)) + 12);
    } else if (sound == SoundEvent.PLACE && soundMapping.getExtraData() == -1) {
        soundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(soundMapping.getIdentifier())));
        soundPacket.setIdentifier(":");
    } else {
        soundPacket.setExtraData(soundMapping.getExtraData());
    }


    soundPacket.setBabySound(false); // might need to adjust this in the future
    soundPacket.setRelativeVolumeDisabled(false);
    session.sendUpstreamPacket(soundPacket);
}
 
Example #19
Source File: LevelEventSerializer_v313.java    From Protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelEventPacket packet) {
    VarInts.writeInt(buffer, events.get(packet.getType()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getData());
}
 
Example #20
Source File: JavaSpawnParticleTranslator.java    From Geyser with MIT License 4 votes vote down vote up
@Override
public void translate(ServerSpawnParticlePacket packet, GeyserSession session) {
    LevelEventPacket particle = new LevelEventPacket();
    switch (packet.getParticle().getType()) {
        case BLOCK:
            particle.setType(LevelEventType.DESTROY);
            particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
            particle.setData(BlockTranslator.getBedrockBlockId(((BlockParticleData) packet.getParticle().getData()).getBlockState()));
            session.sendUpstreamPacket(particle);
            break;
        case FALLING_DUST:
            //In fact, FallingDustParticle should have data like DustParticle,
            //but in MCProtocol, its data is BlockState(1).
            particle.setType(LevelEventType.PARTICLE_FALLING_DUST);
            particle.setData(BlockTranslator.getBedrockBlockId(((FallingDustParticleData)packet.getParticle().getData()).getBlockState()));
            particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
            session.sendUpstreamPacket(particle);
            break;
        case ITEM:
            ItemStack javaItem = ((ItemParticleData)packet.getParticle().getData()).getItemStack();
            ItemData bedrockItem = ItemTranslator.translateToBedrock(session, javaItem);
            int id = bedrockItem.getId();
            short damage = bedrockItem.getDamage();
            particle.setType(LevelEventType.PARTICLE_ITEM_BREAK);
            particle.setData(id << 16 | damage);
            particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
            session.sendUpstreamPacket(particle);
            break;
        case DUST:
            DustParticleData data = (DustParticleData)packet.getParticle().getData();
            int r = (int) (data.getRed()*255);
            int g = (int) (data.getGreen()*255);
            int b = (int) (data.getBlue()*255);
            particle.setType(LevelEventType.PARTICLE_FALLING_DUST);
            particle.setData(((0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff));
            particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
            session.sendUpstreamPacket(particle);
            break;
        default:
            LevelEventType typeParticle = EffectRegistry.getParticleLevelEventType(packet.getParticle().getType());
            if (typeParticle != null) {
                particle.setType(typeParticle);
                particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
                session.sendUpstreamPacket(particle);
            } else {
                String stringParticle = EffectRegistry.getParticleString(packet.getParticle().getType());
                if (stringParticle != null) {
                    SpawnParticleEffectPacket stringPacket = new SpawnParticleEffectPacket();
                    stringPacket.setIdentifier(stringParticle);
                    stringPacket.setDimensionId(session.getPlayerEntity().getDimension());
                    stringPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
                    session.sendUpstreamPacket(stringPacket);
                }
            }
            break;
    }
}
 
Example #21
Source File: LevelEventSerializer_v361.java    From Protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelEventPacket packet) {
    VarInts.writeInt(buffer, events.get(packet.getType()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getData());
}
 
Example #22
Source File: LevelEventSerializer_v332.java    From Protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelEventPacket packet) {
    VarInts.writeInt(buffer, events.get(packet.getType()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getData());
}
 
Example #23
Source File: LevelEventSerializer_v291.java    From Protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelEventPacket packet) {
    VarInts.writeInt(buffer, events.get(packet.getType()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getData());
}