Update to 1.17.1-pre1

This commit is contained in:
Camotoy 2021-06-20 12:35:34 -04:00
parent 7248769028
commit 9db4bbca57
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
6 changed files with 43 additions and 14 deletions

View file

@ -5,7 +5,7 @@
<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>1.17-SNAPSHOT</version>
<version>1.17.1-pre1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MCProtocolLib</name>

View file

@ -12,12 +12,12 @@ public final class MinecraftConstants {
/**
* Current supported game version.
*/
public static final String GAME_VERSION = "1.17";
public static final String GAME_VERSION = "1.17.1-pre1";
/**
* Current supported protocol version.
*/
public static final int PROTOCOL_VERSION = 755;
public static final int PROTOCOL_VERSION = (1 << 30) | 36;
// General Key Constants

View file

@ -1,6 +1,5 @@
package com.github.steveice10.mc.protocol.packet.ingame.client.window;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.packetlib.io.NetInput;
import com.github.steveice10.packetlib.io.NetOutput;
import com.github.steveice10.packetlib.packet.Packet;
@ -8,11 +7,13 @@ import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.With;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Data
@With
@ -20,22 +21,36 @@ import java.io.IOException;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
public class ClientEditBookPacket implements Packet {
private @NonNull ItemStack book;
private boolean signing;
private int slot;
private List<String> pages;
private @Nullable String title;
@Override
public void read(NetInput in) throws IOException {
this.book = ItemStack.read(in);
this.signing = in.readBoolean();
this.slot = in.readVarInt();
this.pages = new ArrayList<>();
int pagesSize = in.readVarInt();
for (int i = 0; i < pagesSize; i++) {
this.pages.add(in.readString());
}
if (in.readBoolean()) {
this.title = in.readString();
} else {
this.title = null;
}
}
@Override
public void write(NetOutput out) throws IOException {
ItemStack.write(out, this.book);
out.writeBoolean(this.signing);
out.writeVarInt(slot);
out.writeVarInt(this.pages.size());
for (String page : this.pages) {
out.writeString(page);
}
out.writeBoolean(this.title != null);
if (this.title != null) {
out.writeString(title);
}
}
@Override

View file

@ -17,6 +17,7 @@ import com.github.steveice10.packetlib.packet.Packet;
import io.netty.util.collection.IntObjectHashMap;
import io.netty.util.collection.IntObjectMap;
import lombok.*;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.Map;
@ -29,13 +30,14 @@ public class ClientWindowActionPacket implements Packet {
public static final int CLICK_OUTSIDE_NOT_HOLDING_SLOT = -999;
private int windowId;
private int stateId;
private int slot;
private WindowAction action;
private WindowActionParam param;
private ItemStack carriedItem;
private @NonNull Map<Integer, ItemStack> changedSlots;
public ClientWindowActionPacket(int windowId, int slot, WindowAction action, WindowActionParam param, ItemStack carriedItem, Map<Integer, ItemStack> changedSlots) {
public ClientWindowActionPacket(int windowId, int stateId, int slot, WindowAction action, WindowActionParam param, ItemStack carriedItem, @NotNull Map<Integer, ItemStack> changedSlots) {
if((param == DropItemParam.LEFT_CLICK_OUTSIDE_NOT_HOLDING || param == DropItemParam.RIGHT_CLICK_OUTSIDE_NOT_HOLDING)
&& slot != -CLICK_OUTSIDE_NOT_HOLDING_SLOT) {
throw new IllegalArgumentException("Slot must be " + CLICK_OUTSIDE_NOT_HOLDING_SLOT
@ -43,6 +45,7 @@ public class ClientWindowActionPacket implements Packet {
}
this.windowId = windowId;
this.stateId = stateId;
this.slot = slot;
this.action = action;
this.param = param;
@ -53,6 +56,7 @@ public class ClientWindowActionPacket implements Packet {
@Override
public void read(NetInput in) throws IOException {
this.windowId = in.readByte();
this.stateId = in.readVarInt();
this.slot = in.readShort();
byte param = in.readByte();
this.action = MagicValues.key(WindowAction.class, in.readByte());
@ -86,6 +90,7 @@ public class ClientWindowActionPacket implements Packet {
@Override
public void write(NetOutput out) throws IOException {
out.writeByte(this.windowId);
out.writeVarInt(this.stateId);
out.writeShort(this.slot);
int param = MagicValues.value(Integer.class, this.param);

View file

@ -20,12 +20,14 @@ import java.io.IOException;
@AllArgsConstructor
public class ServerSetSlotPacket implements Packet {
private int windowId;
private int stateId;
private int slot;
private ItemStack item;
@Override
public void read(NetInput in) throws IOException {
this.windowId = in.readUnsignedByte();
this.stateId = in.readVarInt();
this.slot = in.readShort();
this.item = ItemStack.read(in);
}
@ -33,6 +35,7 @@ public class ServerSetSlotPacket implements Packet {
@Override
public void write(NetOutput out) throws IOException {
out.writeByte(this.windowId);
out.writeVarInt(this.stateId);
out.writeShort(this.slot);
ItemStack.write(out, this.item);
}

View file

@ -21,24 +21,30 @@ import java.io.IOException;
@AllArgsConstructor
public class ServerWindowItemsPacket implements Packet {
private int windowId;
private int stateId;
private @NonNull ItemStack[] items;
private ItemStack carriedItem;
@Override
public void read(NetInput in) throws IOException {
this.windowId = in.readUnsignedByte();
this.items = new ItemStack[in.readShort()];
this.stateId = in.readVarInt();
this.items = new ItemStack[in.readVarInt()];
for(int index = 0; index < this.items.length; index++) {
this.items[index] = ItemStack.read(in);
}
this.carriedItem = ItemStack.read(in);
}
@Override
public void write(NetOutput out) throws IOException {
out.writeByte(this.windowId);
out.writeShort(this.items.length);
out.writeVarInt(this.stateId);
out.writeVarInt(this.items.length);
for(ItemStack item : this.items) {
ItemStack.write(out, item);
}
ItemStack.write(out, this.carriedItem);
}
@Override