mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 13:08:19 +01:00
Update client/server packets id
This commit is contained in:
parent
8820123f15
commit
b8d1966ce4
@ -298,7 +298,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
UpdateTagListEvent event = new UpdateTagListEvent(tags);
|
||||
callEvent(UpdateTagListEvent.class, event);
|
||||
|
||||
this.playerConnection.sendPacket(tags);
|
||||
// TODO send tags
|
||||
//this.playerConnection.sendPacket(tags);
|
||||
}
|
||||
// Tags end
|
||||
|
||||
|
@ -237,7 +237,7 @@ public abstract class Chunk implements Viewable, Tickable, DataContainer {
|
||||
* @return a new chunk data packet
|
||||
*/
|
||||
@NotNull
|
||||
protected abstract ChunkDataPacket createFreshPacket();
|
||||
public abstract ChunkDataPacket createChunkPacket();
|
||||
|
||||
/**
|
||||
* Creates a copy of this chunk, including blocks state id, custom block id, biomes, update data.
|
||||
@ -383,29 +383,6 @@ public abstract class Chunk implements Viewable, Tickable, DataContainer {
|
||||
this.columnarSpace = columnarSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link ChunkDataPacket} which should contain the full chunk.
|
||||
*
|
||||
* @return a fresh full chunk data packet
|
||||
*/
|
||||
public ChunkDataPacket getFreshFullDataPacket() {
|
||||
ChunkDataPacket fullDataPacket = createFreshPacket();
|
||||
fullDataPacket.fullChunk = true;
|
||||
return fullDataPacket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link ChunkDataPacket} which should contain the non-full chunk.
|
||||
*
|
||||
* @return a fresh non-full chunk data packet
|
||||
*/
|
||||
@NotNull
|
||||
public ChunkDataPacket getFreshPartialDataPacket() {
|
||||
ChunkDataPacket fullDataPacket = createFreshPacket();
|
||||
fullDataPacket.fullChunk = false;
|
||||
return fullDataPacket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the light packet of this chunk.
|
||||
*
|
||||
@ -522,16 +499,16 @@ public abstract class Chunk implements Viewable, Tickable, DataContainer {
|
||||
return;
|
||||
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
playerConnection.sendPacket(getLightPacket());
|
||||
playerConnection.sendPacket(getFreshFullDataPacket());
|
||||
//playerConnection.sendPacket(getLightPacket());
|
||||
playerConnection.sendPacket(createChunkPacket());
|
||||
}
|
||||
|
||||
public synchronized void sendChunk() {
|
||||
if (!isLoaded()) {
|
||||
return;
|
||||
}
|
||||
sendPacketToViewers(getLightPacket());
|
||||
sendPacketToViewers(getFreshFullDataPacket());
|
||||
//sendPacketToViewers(getLightPacket());
|
||||
sendPacketToViewers(createChunkPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -541,14 +518,14 @@ public abstract class Chunk implements Viewable, Tickable, DataContainer {
|
||||
*/
|
||||
public synchronized void sendChunkUpdate(@NotNull Player player) {
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
playerConnection.sendPacket(getFreshFullDataPacket());
|
||||
playerConnection.sendPacket(createChunkPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a full {@link ChunkDataPacket} to all chunk viewers.
|
||||
*/
|
||||
public synchronized void sendChunkUpdate() {
|
||||
PacketUtils.sendGroupedPacket(getViewers(), getFreshFullDataPacket());
|
||||
PacketUtils.sendGroupedPacket(getViewers(), createChunkPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -575,8 +552,7 @@ public abstract class Chunk implements Viewable, Tickable, DataContainer {
|
||||
*/
|
||||
@NotNull
|
||||
protected ChunkDataPacket createChunkSectionUpdatePacket(int section) {
|
||||
ChunkDataPacket chunkDataPacket = getFreshPartialDataPacket();
|
||||
chunkDataPacket.fullChunk = false;
|
||||
ChunkDataPacket chunkDataPacket = createChunkPacket();
|
||||
int[] sections = new int[CHUNK_SECTION_COUNT];
|
||||
sections[section] = 1;
|
||||
chunkDataPacket.sections = sections;
|
||||
|
@ -386,7 +386,7 @@ public class DynamicChunk extends Chunk {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ChunkDataPacket createFreshPacket() {
|
||||
public ChunkDataPacket createChunkPacket() {
|
||||
ChunkDataPacket packet = cachedPacket.get();
|
||||
if (packet != null && cachedPacketTime == getLastChangeTime()) {
|
||||
return packet;
|
||||
|
@ -257,7 +257,7 @@ public class ChunkBatch implements Batch<ChunkCallback> {
|
||||
*/
|
||||
private void updateChunk(@NotNull Instance instance, Chunk chunk, IntSet updatedSections, @Nullable ChunkCallback callback, boolean safeCallback) {
|
||||
// Refresh chunk for viewers
|
||||
ChunkDataPacket chunkDataPacket = chunk.getFreshPartialDataPacket();
|
||||
ChunkDataPacket chunkDataPacket = chunk.createChunkPacket();
|
||||
int[] sections = new int[Chunk.CHUNK_SECTION_COUNT];
|
||||
for (int section : updatedSections)
|
||||
sections[section] = 1;
|
||||
|
@ -11,29 +11,30 @@ public class ClientPlayPacketsHandler extends ClientPacketsHandler {
|
||||
register(0x04, ClientStatusPacket::new);
|
||||
register(0x05, ClientSettingsPacket::new);
|
||||
register(0x06, ClientTabCompletePacket::new);
|
||||
register(0x08, ClientClickWindowButtonPacket::new);
|
||||
register(0x09, ClientClickWindowPacket::new);
|
||||
register(0x0A, ClientCloseWindowPacket::new);
|
||||
register(0x0B, ClientPluginMessagePacket::new);
|
||||
register(0x0C, ClientEditBookPacket::new);
|
||||
register(0x0D, ClientQueryEntityNbtPacket::new);
|
||||
register(0x0E, ClientInteractEntityPacket::new);
|
||||
register(0x0F, ClientGenerateStructurePacket::new);
|
||||
register(0x10, ClientKeepAlivePacket::new);
|
||||
register(0x07, ClientClickWindowButtonPacket::new);
|
||||
register(0x08, ClientClickWindowPacket::new);
|
||||
register(0x09, ClientCloseWindowPacket::new);
|
||||
register(0x0A, ClientPluginMessagePacket::new);
|
||||
register(0x0B, ClientEditBookPacket::new);
|
||||
register(0x0C, ClientQueryEntityNbtPacket::new);
|
||||
register(0x0D, ClientInteractEntityPacket::new);
|
||||
register(0x0E, ClientGenerateStructurePacket::new);
|
||||
register(0x0F, ClientKeepAlivePacket::new);
|
||||
|
||||
// 0x11 packet not used server-side
|
||||
register(0x12, ClientPlayerPositionPacket::new);
|
||||
register(0x13, ClientPlayerPositionAndRotationPacket::new);
|
||||
register(0x14, ClientPlayerRotationPacket::new);
|
||||
register(0x15, ClientPlayerPacket::new);
|
||||
register(0x16, ClientVehicleMovePacket::new);
|
||||
register(0x17, ClientSteerBoatPacket::new);
|
||||
register(0x18, ClientPickItemPacket::new);
|
||||
register(0x19, ClientCraftRecipeRequest::new);
|
||||
register(0x1A, ClientPlayerAbilitiesPacket::new);
|
||||
register(0x1B, ClientPlayerDiggingPacket::new);
|
||||
register(0x1C, ClientEntityActionPacket::new);
|
||||
register(0x1D, ClientSteerVehiclePacket::new);
|
||||
// 0x10 packet not used server-side
|
||||
register(0x11, ClientPlayerPositionPacket::new);
|
||||
register(0x12, ClientPlayerPositionAndRotationPacket::new);
|
||||
register(0x13, ClientPlayerRotationPacket::new);
|
||||
register(0x14, ClientPlayerPacket::new);
|
||||
register(0x15, ClientVehicleMovePacket::new);
|
||||
register(0x16, ClientSteerBoatPacket::new);
|
||||
register(0x17, ClientPickItemPacket::new);
|
||||
register(0x18, ClientCraftRecipeRequest::new);
|
||||
register(0x19, ClientPlayerAbilitiesPacket::new);
|
||||
register(0x1A, ClientPlayerDiggingPacket::new);
|
||||
register(0x1B, ClientEntityActionPacket::new);
|
||||
register(0x1C, ClientSteerVehiclePacket::new);
|
||||
//register(0x1D, PONG); // TODO pong packet
|
||||
register(0x1E, ClientSetRecipeBookStatePacket::new);
|
||||
register(0x1F, ClientSetDisplayedRecipePacket::new);
|
||||
|
||||
|
@ -56,59 +56,59 @@ public class ServerPacketIdentifier {
|
||||
public static final int OPEN_BOOK = 0x2D;
|
||||
public static final int OPEN_WINDOW = 0x2E;
|
||||
public static final int OPEN_SIGN_EDITOR = 0x2F;
|
||||
public static final int CRAFT_RECIPE_RESPONSE = 0x30;
|
||||
public static final int PLAYER_ABILITIES = 0x31;
|
||||
public static final int END_COMBAT_EVENT = 0x32;
|
||||
public static final int ENTER_COMBAT_EVENT = 0x33;
|
||||
public static final int DEATH_COMBAT_EVENT = 0x34;
|
||||
public static final int PLAYER_INFO = 0x35;
|
||||
public static final int FACE_PLAYER = 0x36;
|
||||
public static final int PLAYER_POSITION_AND_LOOK = 0x37;
|
||||
public static final int UNLOCK_RECIPES = 0x38;
|
||||
public static final int DESTROY_ENTITY = 0x39;
|
||||
public static final int REMOVE_ENTITY_EFFECT = 0x3A;
|
||||
public static final int RESOURCE_PACK_SEND = 0x3B;
|
||||
public static final int RESPAWN = 0x3C;
|
||||
public static final int ENTITY_HEAD_LOOK = 0x3D;
|
||||
public static final int MULTI_BLOCK_CHANGE = 0x3E;
|
||||
public static final int SELECT_ADVANCEMENT_TAB = 0x3F;
|
||||
public static final int ACTION_BAR = 0x40;
|
||||
public static final int WORLD_BORDER_CENTER = 0x41;
|
||||
public static final int WORLD_BORDER_LERP_SIZE = 0x42;
|
||||
public static final int WORLD_BORDER_SIZE = 0x43;
|
||||
public static final int WORLD_BORDER_WARNING_DELAY = 0x44;
|
||||
public static final int WORLD_BORDER_WARNING_REACH = 0x45;
|
||||
public static final int CAMERA = 0x46;
|
||||
public static final int HELD_ITEM_CHANGE = 0x47;
|
||||
public static final int UPDATE_VIEW_POSITION = 0x48;
|
||||
public static final int UPDATE_VIEW_DISTANCE = 0x49; // Not used by the dedicated server
|
||||
public static final int SPAWN_POSITION = 0x4A;
|
||||
public static final int DISPLAY_SCOREBOARD = 0x4B;
|
||||
public static final int ENTITY_METADATA = 0x4C;
|
||||
public static final int ATTACH_ENTITY = 0x4D;
|
||||
public static final int ENTITY_VELOCITY = 0x4E;
|
||||
public static final int ENTITY_EQUIPMENT = 0x4F;
|
||||
public static final int SET_EXPERIENCE = 0x50;
|
||||
public static final int UPDATE_HEALTH = 0x51;
|
||||
public static final int SCOREBOARD_OBJECTIVE = 0x52;
|
||||
public static final int SET_PASSENGERS = 0x53;
|
||||
public static final int TEAMS = 0x54;
|
||||
public static final int UPDATE_SCORE = 0x55;
|
||||
public static final int SET_TITLE_SUBTITLE = 0x56;
|
||||
public static final int TIME_UPDATE = 0x57;
|
||||
public static final int SET_TITLE_TEXT = 0x58;
|
||||
public static final int SET_TITLE_TIME = 0x59;
|
||||
public static final int ENTITY_SOUND_EFFECT = 0x5A;
|
||||
public static final int SOUND_EFFECT = 0x5B;
|
||||
public static final int STOP_SOUND = 0x5C;
|
||||
public static final int PLAYER_LIST_HEADER_AND_FOOTER = 0x5D;
|
||||
public static final int NBT_QUERY_RESPONSE = 0x5E;
|
||||
public static final int COLLECT_ITEM = 0x5F;
|
||||
public static final int ENTITY_TELEPORT = 0x60;
|
||||
public static final int ADVANCEMENTS = 0x61;
|
||||
public static final int ENTITY_PROPERTIES = 0x62;
|
||||
public static final int ENTITY_EFFECT = 0x63;
|
||||
public static final int DECLARE_RECIPES = 0x64;
|
||||
public static final int TAGS = 0x65;
|
||||
|
||||
public static final int PING = 0x30;
|
||||
public static final int CRAFT_RECIPE_RESPONSE = 0x31;
|
||||
public static final int PLAYER_ABILITIES = 0x32;
|
||||
public static final int END_COMBAT_EVENT = 0x33;
|
||||
public static final int ENTER_COMBAT_EVENT = 0x34;
|
||||
public static final int DEATH_COMBAT_EVENT = 0x35;
|
||||
public static final int PLAYER_INFO = 0x36;
|
||||
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 REMOVE_ENTITY_EFFECT = 0x3B;
|
||||
public static final int RESOURCE_PACK_SEND = 0x3C;
|
||||
public static final int RESPAWN = 0x3D;
|
||||
public static final int ENTITY_HEAD_LOOK = 0x3E;
|
||||
public static final int MULTI_BLOCK_CHANGE = 0x3F;
|
||||
public static final int SELECT_ADVANCEMENT_TAB = 0x40;
|
||||
public static final int ACTION_BAR = 0x41;
|
||||
public static final int WORLD_BORDER_CENTER = 0x42;
|
||||
public static final int WORLD_BORDER_LERP_SIZE = 0x43;
|
||||
public static final int WORLD_BORDER_SIZE = 0x44;
|
||||
public static final int WORLD_BORDER_WARNING_DELAY = 0x45;
|
||||
public static final int WORLD_BORDER_WARNING_REACH = 0x46;
|
||||
public static final int CAMERA = 0x47;
|
||||
public static final int HELD_ITEM_CHANGE = 0x48;
|
||||
public static final int UPDATE_VIEW_POSITION = 0x49;
|
||||
public static final int UPDATE_VIEW_DISTANCE = 0x4A; // Not used by the dedicated server
|
||||
public static final int SPAWN_POSITION = 0x4B;
|
||||
public static final int DISPLAY_SCOREBOARD = 0x4C;
|
||||
public static final int ENTITY_METADATA = 0x4D;
|
||||
public static final int ATTACH_ENTITY = 0x4E;
|
||||
public static final int ENTITY_VELOCITY = 0x4F;
|
||||
public static final int ENTITY_EQUIPMENT = 0x50;
|
||||
public static final int SET_EXPERIENCE = 0x51;
|
||||
public static final int UPDATE_HEALTH = 0x52;
|
||||
public static final int SCOREBOARD_OBJECTIVE = 0x53;
|
||||
public static final int SET_PASSENGERS = 0x54;
|
||||
public static final int TEAMS = 0x55;
|
||||
public static final int UPDATE_SCORE = 0x56;
|
||||
public static final int SET_TITLE_SUBTITLE = 0x57;
|
||||
public static final int TIME_UPDATE = 0x58;
|
||||
public static final int SET_TITLE_TEXT = 0x59;
|
||||
public static final int SET_TITLE_TIME = 0x5A;
|
||||
public static final int ENTITY_SOUND_EFFECT = 0x5B;
|
||||
public static final int SOUND_EFFECT = 0x5C;
|
||||
public static final int STOP_SOUND = 0x5D;
|
||||
public static final int PLAYER_LIST_HEADER_AND_FOOTER = 0x5E;
|
||||
public static final int NBT_QUERY_RESPONSE = 0x5F;
|
||||
public static final int COLLECT_ITEM = 0x60;
|
||||
public static final int ENTITY_TELEPORT = 0x61;
|
||||
public static final int ADVANCEMENTS = 0x62;
|
||||
public static final int ENTITY_PROPERTIES = 0x63;
|
||||
public static final int ENTITY_EFFECT = 0x64;
|
||||
public static final int DECLARE_RECIPES = 0x65;
|
||||
public static final int TAGS = 0x66;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
||||
private static final BlockManager BLOCK_MANAGER = MinecraftServer.getBlockManager();
|
||||
public static final TemporaryPacketCache CACHE = new TemporaryPacketCache(5, TimeUnit.MINUTES);
|
||||
|
||||
public boolean fullChunk;
|
||||
public Biome[] biomes;
|
||||
public int chunkX, chunkZ;
|
||||
|
||||
@ -79,12 +78,11 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(chunkX);
|
||||
writer.writeInt(chunkZ);
|
||||
writer.writeBoolean(fullChunk);
|
||||
|
||||
int mask = 0;
|
||||
ByteBuf blocks = Unpooled.buffer(MAX_BUFFER_SIZE);
|
||||
for (byte i = 0; i < CHUNK_SECTION_COUNT; i++) {
|
||||
if (fullChunk || (sections.length == CHUNK_SECTION_COUNT && sections[i] != 0)) {
|
||||
if (false || (sections.length == CHUNK_SECTION_COUNT && sections[i] != 0)) {
|
||||
final Section section = paletteStorage.getSections()[i];
|
||||
if (section == null) {
|
||||
// Section not loaded
|
||||
@ -118,8 +116,10 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
||||
);
|
||||
}
|
||||
|
||||
// Biome data
|
||||
if (fullChunk) {
|
||||
// Biomes
|
||||
if (biomes == null || biomes.length == 0) {
|
||||
writer.writeVarInt(0);
|
||||
} else {
|
||||
writer.writeVarInt(biomes.length);
|
||||
for (Biome biome : biomes) {
|
||||
writer.writeVarInt(biome.getId());
|
||||
@ -162,7 +162,6 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
chunkX = reader.readInt();
|
||||
chunkZ = reader.readInt();
|
||||
fullChunk = reader.readBoolean();
|
||||
|
||||
int mask = reader.readVarInt();
|
||||
try {
|
||||
@ -171,12 +170,10 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
||||
heightmapsNBT = (NBTCompound) reader.readTag();
|
||||
|
||||
// Biomes
|
||||
if (fullChunk) {
|
||||
int[] biomesIds = reader.readVarIntArray();
|
||||
this.biomes = new Biome[biomesIds.length];
|
||||
for (int i = 0; i < biomesIds.length; i++) {
|
||||
this.biomes[i] = MinecraftServer.getBiomeManager().getById(biomesIds[i]);
|
||||
}
|
||||
int[] biomesIds = reader.readVarIntArray();
|
||||
this.biomes = new Biome[biomesIds.length];
|
||||
for (int i = 0; i < biomesIds.length; i++) {
|
||||
this.biomes[i] = MinecraftServer.getBiomeManager().getById(biomesIds[i]);
|
||||
}
|
||||
|
||||
// Data
|
||||
|
@ -10,12 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class SpawnPositionPacket implements ServerPacket {
|
||||
|
||||
public int x, y, z;
|
||||
public float angle;
|
||||
|
||||
public SpawnPositionPacket() {}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeBlockPosition(x, y, z);
|
||||
writer.writeFloat(angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,6 +26,7 @@ public class SpawnPositionPacket implements ServerPacket {
|
||||
x = pos.getX();
|
||||
y = pos.getY();
|
||||
z = pos.getZ();
|
||||
angle = reader.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user