mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Add 1.17.1 support
This commit is contained in:
parent
a828a02499
commit
ea231bf52e
@ -66,8 +66,8 @@ public final class MinecraftServer {
|
||||
|
||||
public final static Logger LOGGER = LoggerFactory.getLogger(MinecraftServer.class);
|
||||
|
||||
public static final String VERSION_NAME = "1.17";
|
||||
public static final int PROTOCOL_VERSION = 755;
|
||||
public static final String VERSION_NAME = "1.17.1";
|
||||
public static final int PROTOCOL_VERSION = 756;
|
||||
|
||||
// Threads
|
||||
public static final String THREAD_NAME_BENCHMARK = "Ms-Benchmark";
|
||||
|
@ -371,7 +371,7 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
||||
if (!viewers.remove(player)) {
|
||||
return false;
|
||||
}
|
||||
player.getPlayerConnection().sendPacket(DestroyEntityPacket.of(getEntityId()));
|
||||
player.getPlayerConnection().sendPacket(new DestroyEntitiesPacket(getEntityId()));
|
||||
player.viewableEntities.remove(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -1140,7 +1140,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
if (instance == null)
|
||||
return;
|
||||
|
||||
DestroyEntityPacket destroyEntityPacket = DestroyEntityPacket.of(getEntityId());
|
||||
DestroyEntitiesPacket destroyEntitiesPacket = new DestroyEntitiesPacket(getEntityId());
|
||||
|
||||
final PlayerInfoPacket removePlayerPacket = getRemovePlayerToList();
|
||||
final PlayerInfoPacket addPlayerPacket = getAddPlayerToList();
|
||||
@ -1151,14 +1151,14 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
respawnPacket.isFlat = levelFlat;
|
||||
|
||||
playerConnection.sendPacket(removePlayerPacket);
|
||||
playerConnection.sendPacket(destroyEntityPacket);
|
||||
playerConnection.sendPacket(destroyEntitiesPacket);
|
||||
playerConnection.sendPacket(respawnPacket);
|
||||
playerConnection.sendPacket(addPlayerPacket);
|
||||
|
||||
{
|
||||
// Remove player
|
||||
sendPacketToViewers(removePlayerPacket);
|
||||
sendPacketToViewers(destroyEntityPacket);
|
||||
sendPacketToViewers(destroyEntitiesPacket);
|
||||
|
||||
// Show player again
|
||||
getViewers().forEach(player -> showPlayer(player.getPlayerConnection()));
|
||||
|
@ -18,7 +18,7 @@ import java.util.Objects;
|
||||
public class WindowListener {
|
||||
|
||||
public static void clickWindowListener(ClientClickWindowPacket packet, Player player) {
|
||||
final byte windowId = packet.windowId;
|
||||
final int windowId = packet.windowId;
|
||||
final AbstractInventory inventory = windowId == 0 ? player.getInventory() : player.getOpenInventory();
|
||||
if (inventory == null) {
|
||||
// Invalid packet
|
||||
|
@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ClientClickWindowPacket extends ClientPlayPacket {
|
||||
|
||||
public byte windowId;
|
||||
public int stateId;
|
||||
public short slot;
|
||||
public byte button;
|
||||
public ClickType clickType = ClickType.PICKUP;
|
||||
@ -20,6 +21,7 @@ public class ClientClickWindowPacket extends ClientPlayPacket {
|
||||
@Override
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
this.windowId = reader.readByte();
|
||||
this.stateId = reader.readVarInt();
|
||||
this.slot = reader.readShort();
|
||||
this.button = reader.readByte();
|
||||
this.clickType = ClickType.values()[reader.readVarInt()];
|
||||
@ -37,6 +39,7 @@ public class ClientClickWindowPacket extends ClientPlayPacket {
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeVarInt(stateId);
|
||||
writer.writeShort(slot);
|
||||
writer.writeByte(button);
|
||||
writer.writeVarInt(clickType.ordinal());
|
||||
|
@ -66,7 +66,7 @@ public class ServerPacketIdentifier {
|
||||
public static final int FACE_PLAYER = 0x37;
|
||||
public static final int PLAYER_POSITION_AND_LOOK = 0x38;
|
||||
public static final int UNLOCK_RECIPES = 0x39;
|
||||
public static final int DESTROY_ENTITY = 0x3A;
|
||||
public static final int DESTROY_ENTITIES = 0x3A;
|
||||
public static final int REMOVE_ENTITY_EFFECT = 0x3B;
|
||||
public static final int RESOURCE_PACK_SEND = 0x3C;
|
||||
public static final int RESPAWN = 0x3D;
|
||||
|
@ -6,31 +6,30 @@ import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DestroyEntityPacket implements ServerPacket {
|
||||
public class DestroyEntitiesPacket implements ServerPacket {
|
||||
|
||||
public int entityId;
|
||||
public int[] entityIds;
|
||||
|
||||
public DestroyEntityPacket() {
|
||||
public DestroyEntitiesPacket(int[] entityIds) {
|
||||
this.entityIds = entityIds;
|
||||
}
|
||||
|
||||
public static DestroyEntityPacket of(int entityId) {
|
||||
DestroyEntityPacket packet = new DestroyEntityPacket();
|
||||
packet.entityId = entityId;
|
||||
return packet;
|
||||
public DestroyEntitiesPacket(int entityId) {
|
||||
this(new int[]{entityId});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeVarIntArray(entityIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
this.entityId = reader.readVarInt();
|
||||
this.entityIds = reader.readVarIntArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ServerPacketIdentifier.DESTROY_ENTITY;
|
||||
return ServerPacketIdentifier.DESTROY_ENTITIES;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class SetSlotPacket implements ServerPacket {
|
||||
|
||||
public byte windowId;
|
||||
public int stateId;
|
||||
public short slot;
|
||||
public ItemStack itemStack;
|
||||
|
||||
@ -20,6 +21,7 @@ public class SetSlotPacket implements ServerPacket {
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeVarInt(stateId);
|
||||
writer.writeShort(slot);
|
||||
writer.writeItemStack(itemStack);
|
||||
}
|
||||
@ -27,6 +29,7 @@ public class SetSlotPacket implements ServerPacket {
|
||||
@Override
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
windowId = reader.readByte();
|
||||
stateId = reader.readVarInt();
|
||||
slot = reader.readShort();
|
||||
itemStack = reader.readItemStack();
|
||||
}
|
||||
|
@ -10,37 +10,43 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class WindowItemsPacket implements ServerPacket {
|
||||
|
||||
public byte windowId;
|
||||
public int stateId;
|
||||
public ItemStack[] items;
|
||||
public ItemStack carriedItem = ItemStack.AIR;
|
||||
|
||||
/**
|
||||
* Default constructor, required for reflection operations.
|
||||
*/
|
||||
public WindowItemsPacket() {}
|
||||
public WindowItemsPacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeVarInt(stateId);
|
||||
|
||||
if (items == null) {
|
||||
writer.writeShort((short) 0);
|
||||
return;
|
||||
}
|
||||
|
||||
writer.writeShort((short) items.length);
|
||||
for (ItemStack item : items) {
|
||||
writer.writeItemStack(item);
|
||||
writer.writeVarInt(0);
|
||||
} else {
|
||||
writer.writeVarInt(items.length);
|
||||
for (ItemStack item : items) {
|
||||
writer.writeItemStack(item);
|
||||
}
|
||||
}
|
||||
writer.writeItemStack(carriedItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
windowId = reader.readByte();
|
||||
stateId = reader.readVarInt();
|
||||
|
||||
short length = reader.readShort();
|
||||
final int length = reader.readVarInt();
|
||||
items = new ItemStack[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
items[i] = reader.readItemStack();
|
||||
}
|
||||
carriedItem = reader.readItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user