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