Skip to content
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

Revert "Revert "Added BlockPlacePacket and CreativeInventoryActionPac… #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
@@ -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<ChatMessagePacket> {
@Override
Original file line number Diff line number Diff line change
@@ -39,17 +39,13 @@ 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());
else
buffer.writeByte(packet.getType().getSize());
if(packet.getEntityId() != 0)
buffer.writeInt(packet.getEntityId());

System.out.println(packet.getType());
}

@Override
Original file line number Diff line number Diff line change
@@ -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<BlockPlacePacket> {
@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());

}
}
Original file line number Diff line number Diff line change
@@ -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<CreativeInventoryActionPacket> {
@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 */
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
7 changes: 4 additions & 3 deletions src/main/java/org/quartzpowered/server/Server.java
Original file line number Diff line number Diff line change
@@ -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