Skip to content

Added EntityVelocityPacket & Added SoundEffectPacket #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ protected void registerPackets() {
clientBoundPacket(PLAY, 0x0B, AnimationPacket.class, new AnimationCodec());
clientBoundPacket(PLAY, 0x0C, SpawnPlayerPacket.class, new SpawnPlayerCodec());
clientBoundPacket(PLAY, 0x0D, CollectItemPacket.class, new CollectItemCodec());
clientBoundPacket(PLAY, 0x12, EntityVelocityPacket.class, new EntityVelocityCodec());
clientBoundPacket(PLAY, 0x13, EntityDestroyPacket.class, new EntityDestroyCodec());
clientBoundPacket(PLAY, 0x14, EntityPacket.class, new EntityCodec());
clientBoundPacket(PLAY, 0x15, EntityMovePacket.class, new EntityMoveCodec());
Expand All @@ -134,6 +135,7 @@ protected void registerPackets() {
clientBoundPacket(PLAY, 0x2F, SetExperiencePacket.class, new SetExperienceCodec());
clientBoundPacket(PLAY, 0x21, ChunkPacket.class, new ChunkCodec());
clientBoundPacket(PLAY, 0x26, ChunkBulkPacket.class, new ChunkBulkCodec());
clientBoundPacket(PLAY, 0x29, SoundEffectPacket.class, new SoundEffectCodec());
clientBoundPacket(PLAY, 0x32, ConfirmTransactionPacket.class, new ConfirmTransactionCodec());
clientBoundPacket(PLAY, 0x38, PlayerInfoPacket.class, new PlayerInfoCodec());
clientBoundPacket(PLAY, 0x40, KickPacket.class, new KickCodec());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is a component of Quartz Powered, this license makes sure any work
* associated with Quartz Powered, must follow the conditions of the license included.
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Quartz Powered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.quartzpowered.protocol.codec.v1_8_R1.play.client;

import org.quartzpowered.network.buffer.Buffer;
import org.quartzpowered.network.protocol.codec.Codec;
import org.quartzpowered.protocol.packet.play.client.EntityVelocityPacket;

public class EntityVelocityCodec implements Codec<EntityVelocityPacket> {
@Override
public void encode(Buffer buffer, EntityVelocityPacket packet) {
buffer.writeVarInt(packet.getEntityID());
buffer.writeShort(packet.getVelocityX());
buffer.writeShort(packet.getVelocityY());
buffer.writeShort(packet.getVelocityZ());
}

@Override
public void decode(Buffer buffer, EntityVelocityPacket packet) {
packet.setEntityID(buffer.readVarInt());
packet.setVelocityX(buffer.readShort());
packet.setVelocityY(buffer.readShort());
packet.setVelocityZ(buffer.readShort());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.quartzpowered.protocol.codec.v1_8_R1.play.client;

import org.quartzpowered.network.buffer.Buffer;
import org.quartzpowered.network.protocol.codec.Codec;
import org.quartzpowered.protocol.packet.play.client.SoundEffectPacket;

public class SoundEffectCodec implements Codec<SoundEffectPacket> {
@Override
public void encode(Buffer buffer, SoundEffectPacket packet) {
buffer.writeString(packet.getSoundName());
buffer.writeInt(packet.getEffectPositionX());
buffer.writeInt(packet.getEffectPositionY());
buffer.writeInt(packet.getEffectPositionZ());
buffer.writeFloat(packet.getVolume());
buffer.writeByte(packet.getPitch());
}

@Override
public void decode(Buffer buffer, SoundEffectPacket packet) {
packet.setSoundName(buffer.readString());
packet.setEffectPositionX(buffer.readInt());
packet.setEffectPositionY(buffer.readInt());
packet.setEffectPositionZ(buffer.readInt());
packet.setVolume(buffer.readFloat());
packet.setPitch(buffer.readByte());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is a component of Quartz Powered, this license makes sure any work
* associated with Quartz Powered, must follow the conditions of the license included.
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Quartz Powered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.quartzpowered.protocol.packet.play.client;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.quartzpowered.network.protocol.packet.Packet;
@Data
@EqualsAndHashCode(callSuper = true)
public class EntityVelocityPacket extends Packet {
private int entityID;
private int velocityX;
private int velocityY;
private int velocityZ;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is a component of Quartz Powered, this license makes sure any work
* associated with Quartz Powered, must follow the conditions of the license included.
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Quartz Powered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.quartzpowered.protocol.packet.play.client;


import lombok.Data;
import lombok.EqualsAndHashCode;
import org.quartzpowered.network.protocol.packet.Packet;

@Data
@EqualsAndHashCode(callSuper = true)
public class SoundEffectPacket extends Packet {
private String soundName;
private int effectPositionX;
private int effectPositionY;
private int effectPositionZ;
private double volume;
private int pitch;
}