From b2f61bdb7a6fb459a68ce8ee0ce25c7b18b6ee66 Mon Sep 17 00:00:00 2001 From: Gal Bartal Date: Sat, 30 May 2015 19:40:24 +0300 Subject: [PATCH 1/3] Added EntityVelocityPacket --- .../network/protocol/codec/NoopCodec.java | 26 ++++++++++ .../codec/v1_8_R1/ProtocolV1_8_R1.java | 1 + .../play/client/EntityVelocityCodec.java | 49 +++++++++++++++++++ .../play/client/EntityVelocityPacket.java | 39 +++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/EntityVelocityCodec.java create mode 100644 src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java diff --git a/src/main/java/org/quartzpowered/network/protocol/codec/NoopCodec.java b/src/main/java/org/quartzpowered/network/protocol/codec/NoopCodec.java index cba7209..d7247e1 100644 --- a/src/main/java/org/quartzpowered/network/protocol/codec/NoopCodec.java +++ b/src/main/java/org/quartzpowered/network/protocol/codec/NoopCodec.java @@ -1,3 +1,29 @@ +/* + * 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.network.protocol.codec; import org.quartzpowered.network.buffer.Buffer; diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java index 317fc3b..4eca747 100644 --- a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java @@ -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()); diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/EntityVelocityCodec.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/EntityVelocityCodec.java new file mode 100644 index 0000000..b674ce0 --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/EntityVelocityCodec.java @@ -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 { + @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()); + } +} diff --git a/src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java b/src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java new file mode 100644 index 0000000..3528a2d --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java @@ -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 short velocityX; + private short velocityY; + private short velocityZ; +} From 1d6dfd10dc03094f1f5b00313dec3c6d3c06fc7e Mon Sep 17 00:00:00 2001 From: Gal Bartal Date: Sun, 31 May 2015 16:37:37 +0300 Subject: [PATCH 2/3] Added SoundEffectPacket --- .../codec/v1_8_R1/ProtocolV1_8_R1.java | 1 + .../v1_8_R1/play/client/SoundEffectCodec.java | 53 +++++++++++++++++++ .../packet/play/client/SoundEffectPacket.java | 43 +++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java create mode 100644 src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java index 4eca747..ccbe602 100644 --- a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/ProtocolV1_8_R1.java @@ -135,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()); diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java new file mode 100644 index 0000000..657eec2 --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java @@ -0,0 +1,53 @@ +/* + * 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.SoundEffectPacket; + +public class SoundEffectCodec implements Codec { + @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()); + } +} diff --git a/src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java b/src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java new file mode 100644 index 0000000..9a4cf64 --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java @@ -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 float volume; + private byte pitch; +} From a123e4f569f7c7fecdfa5c83f6c5d3eb94ded41e Mon Sep 17 00:00:00 2001 From: Gal Bartal Date: Sun, 31 May 2015 16:54:03 +0300 Subject: [PATCH 3/3] Changed --- .../v1_8_R1/play/client/SoundEffectCodec.java | 26 ------------------- .../play/client/EntityVelocityPacket.java | 6 ++--- .../packet/play/client/SoundEffectPacket.java | 4 +-- 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java index 657eec2..fcd857a 100644 --- a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/SoundEffectCodec.java @@ -1,29 +1,3 @@ -/* - * 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; diff --git a/src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java b/src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java index 3528a2d..656c206 100644 --- a/src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java +++ b/src/main/java/org/quartzpowered/protocol/packet/play/client/EntityVelocityPacket.java @@ -33,7 +33,7 @@ @EqualsAndHashCode(callSuper = true) public class EntityVelocityPacket extends Packet { private int entityID; - private short velocityX; - private short velocityY; - private short velocityZ; + private int velocityX; + private int velocityY; + private int velocityZ; } diff --git a/src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java b/src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java index 9a4cf64..b949117 100644 --- a/src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java +++ b/src/main/java/org/quartzpowered/protocol/packet/play/client/SoundEffectPacket.java @@ -38,6 +38,6 @@ public class SoundEffectPacket extends Packet { private int effectPositionX; private int effectPositionY; private int effectPositionZ; - private float volume; - private byte pitch; + private double volume; + private int pitch; }