diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/ChatMessageCodec.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/ChatMessageCodec.java index 2dc2c4a..c7b153b 100644 --- a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/ChatMessageCodec.java +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/ChatMessageCodec.java @@ -31,6 +31,7 @@ import org.quartzpowered.protocol.data.ChatPosition; import org.quartzpowered.protocol.data.component.TextComponent; import org.quartzpowered.protocol.packet.play.client.ChatMessagePacket; +import org.quartzpowered.protocol.packet.play.server.BlockPlacePacket; public class ChatMessageCodec implements Codec { @Override diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/OpenWindowCodec.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/OpenWindowCodec.java index 6993bce..276f475 100644 --- a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/OpenWindowCodec.java +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/client/OpenWindowCodec.java @@ -39,8 +39,6 @@ public void encode(Buffer buffer, OpenWindowPacket packet) { buffer.writeByte(1 /*TODO*/); buffer.writeString(packet.getType().getTitle()); - System.out.println(packet.getType().getTitle()); - buffer.writeString(packet.getTitle().toJson()); if(packet.getType().equals(WindowType.CHEST)) buffer.writeByte(packet.getSlots()); @@ -48,8 +46,6 @@ public void encode(Buffer buffer, OpenWindowPacket packet) { buffer.writeByte(packet.getType().getSize()); if(packet.getEntityId() != 0) buffer.writeInt(packet.getEntityId()); - - System.out.println(packet.getType()); } @Override diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/server/BlockPlaceCodec.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/server/BlockPlaceCodec.java new file mode 100644 index 0000000..c7e161d --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/server/BlockPlaceCodec.java @@ -0,0 +1,66 @@ +/* + * 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.server; + +import org.quartzpowered.network.buffer.Buffer; +import org.quartzpowered.network.protocol.codec.Codec; +import org.quartzpowered.protocol.packet.play.server.BlockPlacePacket; + +public class BlockPlaceCodec implements Codec { + @Override + public void encode(Buffer buffer, BlockPlacePacket packet) { + + buffer.writeLong(packet.getLocation()); + buffer.writeByte(packet.getFace()); + buffer.writeShort(packet.getBlockId()); + buffer.writeByte(packet.getBlockCount()); + buffer.writeShort(packet.getBlockDamage()); + buffer.writeByte((byte) 0/*Placeholder*/); + buffer.writeByte(packet.getCursorX()); + buffer.writeByte(packet.getCursorY()); + buffer.writeByte(packet.getCursorZ()); + + } + + @Override + public void decode(Buffer buffer, BlockPlacePacket packet) { + + packet.setLocation(buffer.readLong()); + packet.setFace(buffer.readByte()); + int id = buffer.readShort(); + packet.setBlockId(id); + if(id != -1) { + packet.setBlockCount(buffer.readByte()); + packet.setBlockDamage(buffer.readShort()); + buffer.readByte(); + } + packet.setCursorX(buffer.readByte()); + packet.setCursorY(buffer.readByte()); + packet.setCursorZ(buffer.readByte()); + + } +} diff --git a/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/server/CreativeInventoryActionCodec.java b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/server/CreativeInventoryActionCodec.java new file mode 100644 index 0000000..37e99a4 --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/codec/v1_8_R1/play/server/CreativeInventoryActionCodec.java @@ -0,0 +1,63 @@ +/* + * 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.server; + +import org.quartzpowered.network.buffer.Buffer; +import org.quartzpowered.network.protocol.codec.Codec; +import org.quartzpowered.protocol.packet.play.server.BlockPlacePacket; +import org.quartzpowered.protocol.packet.play.server.CreativeInventoryActionPacket; + +public class CreativeInventoryActionCodec implements Codec { + @Override + public void encode(Buffer buffer, CreativeInventoryActionPacket packet) { + buffer.writeShort(packet.getSlot()); + buffer.writeShort(packet.getId()); + if(packet.getId() != -1) { + buffer.writeByte(packet.getCount()); + buffer.writeShort(packet.getDamage()); + if(packet.getNbt() != 0) { + /* TODO NBT DATA */ + } + } + } + + @Override + public void decode(Buffer buffer, CreativeInventoryActionPacket packet) { + packet.setSlot(buffer.readShort()); + short id = buffer.readShort(); + packet.setId(id); + if(id != -1) { + packet.setCount(buffer.readByte()); + packet.setDamage(buffer.readShort()); + byte nbt = buffer.readByte(); + packet.setNbt(nbt); + if(nbt != 0) { + /* TODO NBT DATA */ + } + } + } +} diff --git a/src/main/java/org/quartzpowered/protocol/packet/play/server/BlockPlacePacket.java b/src/main/java/org/quartzpowered/protocol/packet/play/server/BlockPlacePacket.java new file mode 100644 index 0000000..ef45145 --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/packet/play/server/BlockPlacePacket.java @@ -0,0 +1,44 @@ +/* + * 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.server; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.quartzpowered.network.protocol.packet.Packet; + +@Data +@EqualsAndHashCode(callSuper = true) +public class BlockPlacePacket extends Packet { + private long location; + private byte face; + private int blockId; + private int blockCount; + private int blockDamage; + private byte cursorX; + private byte cursorY; + private byte cursorZ; +} diff --git a/src/main/java/org/quartzpowered/protocol/packet/play/server/CreativeInventoryActionPacket.java b/src/main/java/org/quartzpowered/protocol/packet/play/server/CreativeInventoryActionPacket.java new file mode 100644 index 0000000..de9d3e6 --- /dev/null +++ b/src/main/java/org/quartzpowered/protocol/packet/play/server/CreativeInventoryActionPacket.java @@ -0,0 +1,42 @@ +/* + * 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.server; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.quartzpowered.network.protocol.packet.Packet; +import org.quartzpowered.protocol.data.EntityAction; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreativeInventoryActionPacket extends Packet { + private short slot; + private short id; + private byte count; + private short damage; + private byte nbt; +} diff --git a/src/main/java/org/quartzpowered/server/Server.java b/src/main/java/org/quartzpowered/server/Server.java index 918aaff..72f7f83 100644 --- a/src/main/java/org/quartzpowered/server/Server.java +++ b/src/main/java/org/quartzpowered/server/Server.java @@ -39,13 +39,13 @@ import org.quartzpowered.engine.object.component.Player; import org.quartzpowered.network.server.NetworkServer; import org.quartzpowered.network.session.Session; -import org.quartzpowered.protocol.data.Difficulty; -import org.quartzpowered.protocol.data.Dimension; -import org.quartzpowered.protocol.data.Gamemode; +import org.quartzpowered.protocol.data.*; +import org.quartzpowered.protocol.data.component.TextComponent; import org.quartzpowered.protocol.data.info.PlayerInfo; import org.quartzpowered.protocol.data.info.PlayerInfoAction; import org.quartzpowered.protocol.packet.login.client.LoginResponsePacket; import org.quartzpowered.protocol.packet.play.client.*; +import org.quartzpowered.protocol.packet.play.server.BlockPlacePacket; import org.quartzpowered.server.event.player.PlayerLoginEvent; import org.quartzpowered.server.event.player.PlayerQuitEvent; import org.quartzpowered.server.network.HandshakeHandler; @@ -198,6 +198,7 @@ public void onPlayerLogin(PlayerLoginEvent event) { session.getAttributes().set(PlayHandler.PLAYER_OBJECT, playerObject); }); + } @Handler