mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -04:00
wip many more outgoing and incoming packets
This commit is contained in:
parent
9ad656712e
commit
0bdc2d0bb3
@ -32,6 +32,10 @@ public class PacketEncryptionKeyRequest implements ClientboundPacket {
|
||||
publicKey = buffer.readBytes(buffer.readShort()); // read length, then the bytes
|
||||
verifyToken = buffer.readBytes(buffer.readShort()); // read length, then the bytes
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
serverId = buffer.readString();
|
||||
publicKey = buffer.readBytes(buffer.readVarInt()); // read length, then the bytes
|
||||
verifyToken = buffer.readBytes(buffer.readVarInt()); // read length, then the bytes
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,13 @@ public class PacketEncryptionResponse implements ServerboundPacket {
|
||||
buffer.writeBytes(secret);
|
||||
buffer.writeShort((short) token.length);
|
||||
buffer.writeBytes(token);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeVarInt(secret.length);
|
||||
buffer.writeBytes(secret);
|
||||
buffer.writeVarInt(token.length);
|
||||
buffer.writeBytes(token);
|
||||
break;
|
||||
}
|
||||
//buffer.writeString(username);
|
||||
return buffer;
|
||||
|
@ -34,6 +34,7 @@ public class PacketChatMessage implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CHAT_MESSAGE));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeString(message);
|
||||
break;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public class PacketClickWindow implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CLICK_WINDOW));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeByte(windowId);
|
||||
buffer.writeShort(slot);
|
||||
buffer.writeByte(action.getButton());
|
||||
|
@ -38,11 +38,15 @@ public class PacketClientSettings implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CLIENT_SETTINGS));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeString(locale.getName()); // locale
|
||||
buffer.writeByte(renderDistance); // render Distance
|
||||
buffer.writeByte((byte) 0x00); // chat settings (nobody uses them)
|
||||
buffer.writeBoolean(true); // chat colors
|
||||
//skip this if not 1.7.10
|
||||
if (v == ProtocolVersion.VERSION_1_7_10) {
|
||||
buffer.writeByte((byte) Difficulty.NORMAL.getId()); // difficulty
|
||||
}
|
||||
buffer.writeBoolean(true); // cape
|
||||
break;
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public class PacketClientStatus implements ServerboundPacket {
|
||||
case VERSION_1_7_10:
|
||||
buffer.writeByte((byte) status.getId());
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeVarInt((byte) status.getId());
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public class PacketCloseWindowSending implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CLOSE_WINDOW));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeByte(windowId);
|
||||
break;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public class PacketConfirmTransaction implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_WINDOW_CONFIRMATION));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeByte(windowId);
|
||||
buffer.writeShort(actionNumber);
|
||||
buffer.writeBoolean(accepted);
|
||||
|
@ -37,6 +37,7 @@ public class PacketCreativeInventoryAction implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CREATIVE_INVENTORY_ACTION));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeShort(slot);
|
||||
buffer.writeSlot(v, clickedItem);
|
||||
break;
|
||||
|
@ -36,6 +36,7 @@ public class PacketEnchantItem implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CLICK_WINDOW_BUTTON));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeByte(windowId);
|
||||
buffer.writeByte(buttonId);
|
||||
break;
|
||||
|
@ -21,9 +21,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketHeldItemChangeSending implements ServerboundPacket {
|
||||
|
||||
private final byte slot;
|
||||
private final short slot;
|
||||
|
||||
public PacketHeldItemChangeSending(byte slot) {
|
||||
public PacketHeldItemChangeSending(short slot) {
|
||||
this.slot = slot;
|
||||
log();
|
||||
}
|
||||
@ -39,7 +39,8 @@ public class PacketHeldItemChangeSending implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_HELD_ITEM_CHANGE));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
buffer.writeByte(slot);
|
||||
case VERSION_1_8:
|
||||
buffer.writeShort(slot);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
|
@ -36,6 +36,9 @@ public class PacketKeepAliveResponse implements ServerboundPacket {
|
||||
case VERSION_1_7_10:
|
||||
buffer.writeInteger(id);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeVarInt(id);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public class PacketPlayerAbilitiesSending implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CLIENT_SETTINGS));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
byte flags = 0;
|
||||
if (creative) {
|
||||
flags |= 0b1;
|
||||
|
@ -50,6 +50,15 @@ public class PacketPlayerBlockPlacement implements ServerboundPacket {
|
||||
buffer.writeByte(direction);
|
||||
buffer.writeSlot(v, item);
|
||||
|
||||
buffer.writeByte(cursorX);
|
||||
buffer.writeByte(cursorY);
|
||||
buffer.writeByte(cursorZ);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writePosition(position);
|
||||
buffer.writeByte(direction);
|
||||
buffer.writeSlot(v, item);
|
||||
|
||||
buffer.writeByte(cursorX);
|
||||
buffer.writeByte(cursorY);
|
||||
buffer.writeByte(cursorZ);
|
||||
|
@ -48,7 +48,15 @@ public class PacketPlayerDigging implements ServerboundPacket {
|
||||
buffer.writeBlockPositionByte(position);
|
||||
}
|
||||
buffer.writeByte(face);
|
||||
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeByte((byte) status.getId());
|
||||
if (position == null) {
|
||||
buffer.writeLong(0L);
|
||||
} else {
|
||||
buffer.writePosition(position);
|
||||
}
|
||||
buffer.writeByte(face);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
|
@ -39,6 +39,17 @@ public class PacketPlayerPositionAndRotationSending implements ServerboundPacket
|
||||
log();
|
||||
}
|
||||
|
||||
public PacketPlayerPositionAndRotationSending(double x, double feetY, double z, float yaw, float pitch, boolean onGround) {
|
||||
this.x = x;
|
||||
this.feetY = feetY;
|
||||
this.headY = feetY - 1.62F;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
this.onGround = onGround;
|
||||
log();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OutPacketBuffer write(ProtocolVersion v) {
|
||||
@ -53,6 +64,14 @@ public class PacketPlayerPositionAndRotationSending implements ServerboundPacket
|
||||
buffer.writeFloat(pitch);
|
||||
buffer.writeBoolean(onGround);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeDouble(x);
|
||||
buffer.writeDouble(feetY);
|
||||
buffer.writeDouble(z);
|
||||
buffer.writeFloat(yaw);
|
||||
buffer.writeFloat(pitch);
|
||||
buffer.writeBoolean(onGround);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -35,6 +35,15 @@ public class PacketPlayerPositionSending implements ServerboundPacket {
|
||||
log();
|
||||
}
|
||||
|
||||
public PacketPlayerPositionSending(double x, double feetY, double z, boolean onGround) {
|
||||
this.x = x;
|
||||
this.feetY = feetY;
|
||||
this.headY = feetY - 1.62F;
|
||||
this.z = z;
|
||||
this.onGround = onGround;
|
||||
log();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OutPacketBuffer write(ProtocolVersion v) {
|
||||
@ -47,6 +56,12 @@ public class PacketPlayerPositionSending implements ServerboundPacket {
|
||||
buffer.writeDouble(z);
|
||||
buffer.writeBoolean(onGround);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeDouble(x);
|
||||
buffer.writeDouble(feetY);
|
||||
buffer.writeDouble(z);
|
||||
buffer.writeBoolean(onGround);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public class PacketPlayerRotationSending implements ServerboundPacket {
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_PLAYER_ROTATION));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
buffer.writeFloat(yaw);
|
||||
buffer.writeFloat(pitch);
|
||||
buffer.writeBoolean(onGround);
|
||||
|
@ -45,6 +45,18 @@ public class PacketSteerVehicle implements ServerboundPacket {
|
||||
buffer.writeBoolean(jump);
|
||||
buffer.writeBoolean(unmount);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeFloat(sideways);
|
||||
buffer.writeFloat(forward);
|
||||
byte flags = 0;
|
||||
if (jump) {
|
||||
flags |= 0x1;
|
||||
}
|
||||
if (unmount) {
|
||||
flags |= 0x2;
|
||||
}
|
||||
buffer.writeByte(flags);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.protocol.packets.serverbound.play;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
||||
@ -21,9 +22,17 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketTabCompleteSending implements ServerboundPacket {
|
||||
final String text;
|
||||
final BlockPosition position;
|
||||
|
||||
public PacketTabCompleteSending(String text) {
|
||||
this.text = text;
|
||||
position = null;
|
||||
log();
|
||||
}
|
||||
|
||||
public PacketTabCompleteSending(String text, BlockPosition position) {
|
||||
this.text = text;
|
||||
this.position = position;
|
||||
log();
|
||||
}
|
||||
|
||||
@ -34,6 +43,15 @@ public class PacketTabCompleteSending implements ServerboundPacket {
|
||||
case VERSION_1_7_10:
|
||||
buffer.writeString(text);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeString(text);
|
||||
if (position == null) {
|
||||
buffer.writeBoolean(false);
|
||||
} else {
|
||||
buffer.writeBoolean(true);
|
||||
buffer.writePosition(position);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.protocol.packets.serverbound.play;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.TextComponent;
|
||||
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||
@ -22,9 +23,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketUpdateSignSending implements ServerboundPacket {
|
||||
final BlockPosition position;
|
||||
final String[] lines;
|
||||
final TextComponent[] lines;
|
||||
|
||||
public PacketUpdateSignSending(BlockPosition position, String[] lines) {
|
||||
public PacketUpdateSignSending(BlockPosition position, TextComponent[] lines) {
|
||||
this.position = position;
|
||||
this.lines = lines;
|
||||
log();
|
||||
@ -38,7 +39,13 @@ public class PacketUpdateSignSending implements ServerboundPacket {
|
||||
case VERSION_1_7_10:
|
||||
buffer.writeBlockPositionByte(position);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
buffer.writeString(lines[i]);
|
||||
buffer.writeString(lines[i].getRawMessage());
|
||||
}
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeBlockPositionByte(position);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
buffer.writeChatComponent(lines[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.protocol.packets.serverbound.play;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Entity;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Location;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
||||
@ -23,16 +24,26 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
public class PacketUseEntity implements ServerboundPacket {
|
||||
final int entityId;
|
||||
final Click click;
|
||||
final Location location;
|
||||
|
||||
public PacketUseEntity(Entity entity, Click click) {
|
||||
this.entityId = entity.getId();
|
||||
this.click = click;
|
||||
location = null;
|
||||
log();
|
||||
}
|
||||
|
||||
public PacketUseEntity(int entityId, Click click) {
|
||||
this.entityId = entityId;
|
||||
this.click = click;
|
||||
location = null;
|
||||
log();
|
||||
}
|
||||
|
||||
public PacketUseEntity(int entityId, Click click, Location location) {
|
||||
this.entityId = entityId;
|
||||
this.click = click;
|
||||
this.location = location;
|
||||
log();
|
||||
}
|
||||
|
||||
@ -45,6 +56,16 @@ public class PacketUseEntity implements ServerboundPacket {
|
||||
buffer.writeInteger(entityId);
|
||||
buffer.writeByte((byte) click.getId());
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
buffer.writeInteger(entityId);
|
||||
buffer.writeByte((byte) click.getId());
|
||||
if (click == Click.INTERACT_AT) {
|
||||
// position
|
||||
buffer.writeFloat((float) location.getX());
|
||||
buffer.writeFloat((float) location.getY());
|
||||
buffer.writeFloat((float) location.getZ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
@ -56,7 +77,8 @@ public class PacketUseEntity implements ServerboundPacket {
|
||||
|
||||
public enum Click {
|
||||
RIGHT(0),
|
||||
LEFT(1);
|
||||
LEFT(1),
|
||||
INTERACT_AT(2);
|
||||
|
||||
final int id;
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
package de.bixilon.minosoft.protocol.protocol;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.TextComponent;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Location;
|
||||
import de.bixilon.minosoft.game.datatypes.inventory.Slot;
|
||||
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
||||
import de.bixilon.minosoft.nbt.tag.CompoundTag;
|
||||
@ -154,7 +153,7 @@ public class OutByteBuffer {
|
||||
writeString(j.toString());
|
||||
}
|
||||
|
||||
public void writePosition(Location location) {
|
||||
public void writePosition(BlockPosition location) {
|
||||
writeLong((((long) location.getX() & 0x3FFFFFF) << 38) | (((long) location.getZ() & 0x3FFFFFF) << 12) | ((long) location.getY() & 0xFFF));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user