Skip to content

Commit

Permalink
Update clientbound packet ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Tides committed Nov 15, 2023
1 parent 92be879 commit 08e5cc6
Show file tree
Hide file tree
Showing 74 changed files with 159 additions and 94 deletions.
10 changes: 10 additions & 0 deletions Obsidian/Net/MinecraftStream.Writing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,16 @@ internal async Task WriteRecipeAsync(string name, IRecipe recipe)
}
}

[WriteMethod]
public void WriteChunkBiomes(ChunkBiome chunkBiome)
{
this.WriteInt(chunkBiome.X);
this.WriteInt(chunkBiome.Z);

this.WriteVarInt(chunkBiome.Data.Length);
this.WriteByteArray(chunkBiome.Data);
}

[WriteMethod]
public void WriteRecipes(IDictionary<string, IRecipe> recipes)
{
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/DisconnectPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class DisconnectPacket : IClientboundPacket

public DisconnectPacket(ChatMessage reason, ClientState state)
{
Id = state == ClientState.Configuration ? 0x01 : state == ClientState.Play ? 0x1A : 0x00;
Id = state == ClientState.Configuration ? 0x01 : state == ClientState.Play ? 0x1B : 0x00;
Reason = reason;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public partial class AcknowledgeBlockChangePacket : IClientboundPacket
[Field(0), VarLength]
public int SequenceID { get; init; }

public int Id => 0x06;
public int Id => 0x05;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Clear()
Stats.Clear();
}

public int Id => 0x06;
public int Id => 0x04;
}

public readonly struct Statistic
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/BlockActionPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public partial class BlockActionPacket : IClientboundPacket
[Field(3), VarLength]
public int BlockType { get; init; }

public int Id => 0x09;
public int Id => 0x08;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class BlockEntityDataPacket : IClientboundPacket
[Field(2)]
public INbtTag NBTData { get; init; }

public int Id => 0x08;
public int Id => 0x07;
}

// https://wiki.vg/Protocol#Block_Entity_Data
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/BlockUpdatePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class BlockUpdatePacket : IClientboundPacket
[Field(1), VarLength]
public int BlockId { get; }

public int Id => 0x0A;
public int Id => 0x09;

public BlockUpdatePacket(Vector position, int block)
{
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/BossBarPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class BossBarPacket : IClientboundPacket
[Field(0)]
public BossBarAction Action { get; }

public int Id => 0x0B;
public int Id => 0x0A;

public BossBarPacket(BossBarAction action)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Obsidian.Net.Packets.Play.Clientbound;
public sealed partial class BundleDelimiterPacket : IClientboundPacket
{
public int Id => 0x00;

public void Serialize(MinecraftStream stream) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class ChangeDifficultyPacket : IClientboundPacket
[Field(1)]
public bool DifficultyLocked { get; init; }

public int Id => 0x0C;
public int Id => 0x0B;

public ChangeDifficultyPacket(Difficulty difficulty)
{
Expand Down
10 changes: 10 additions & 0 deletions Obsidian/Net/Packets/Play/Clientbound/ChunkBatchFinishedPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Obsidian.Serialization.Attributes;

namespace Obsidian.Net.Packets.Play.Clientbound;
public sealed partial class ChunkBatchFinishedPacket : IClientboundPacket
{
[Field(0), VarLength]
public int BatchSize { get; init; }

public int Id => 0x0C;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Obsidian.Net.Packets.Play.Clientbound;
public sealed partial class ChunkBatchStartPacket : IClientboundPacket
{
public int Id => 0x0D;

//TODO FIX SOURCE GENS WITH PACKETS THAT HAVE NO FIELDS
public void Serialize(MinecraftStream stream) { }
}
19 changes: 19 additions & 0 deletions Obsidian/Net/Packets/Play/Clientbound/ChunkBiomesPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Obsidian.Serialization.Attributes;

namespace Obsidian.Net.Packets.Play.Clientbound;
public sealed partial class ChunkBiomesPacket : IClientboundPacket
{
[Field(0)]
public required List<ChunkBiome> ChunkBiomes { get; init; }

public int Id => 0x0E;
}

public readonly struct ChunkBiome
{
public required int X { get; init; }

public required int Z { get; init; }

public required byte[] Data { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class ChunkDataAndUpdateLightPacket : IClientboundPacket
{
public Chunk Chunk { get; }

public int Id => 0x24;
public int Id => 0x25;

public ChunkDataAndUpdateLightPacket(Chunk chunk)
{
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/ClearTitlesPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public sealed partial class ClearTitlesPacket : IClientboundPacket
[Field(0)]
public bool Reset { get; init; }

public int Id => 0x0E;
public int Id => 0x0F;
}
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/CommandsPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class CommandsPacket : IClientboundPacket
[Field(1), VarLength]
public int RootIndex { get; }

public int Id => 0x10;
public int Id => 0x11S;

Check failure on line 15 in Obsidian/Net/Packets/Play/Clientbound/CommandsPacket.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 15 in Obsidian/Net/Packets/Play/Clientbound/CommandsPacket.cs

View workflow job for this annotation

GitHub Actions / build

Invalid token ';' in class, record, struct, or interface member declaration

Check failure on line 15 in Obsidian/Net/Packets/Play/Clientbound/CommandsPacket.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 15 in Obsidian/Net/Packets/Play/Clientbound/CommandsPacket.cs

View workflow job for this annotation

GitHub Actions / build

Invalid token ';' in class, record, struct, or interface member declaration

public void AddNode(CommandNode node)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public sealed partial class DeleteMessagePacket : IClientboundPacket
[Field(1)]
public byte[] Signature { get; init; }

public int Id => 0x19;
public int Id => 0x1A;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public sealed partial class DisguisedChatMessage : IClientboundPacket
[Field(4)]
public ChatMessage TargetName { get; init; }

public int Id => 0x1B;
public int Id => 0x1C;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public partial class DisplayObjectivePacket : IClientboundPacket
[Field(1), FixedLength(16)]
public string ScoreName { get; init; }

public int Id => 0x51;
public int Id => 0x53;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class EntityAnimationPacket : IClientboundPacket
[Field(1), ActualType(typeof(byte))]
public EntityAnimationType Animation { get; init; }

public int Id => 0x04;
public int Id => 0x03;
}

public enum EntityAnimationType : byte
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class EntityEffectPacket : IClientboundPacket
[Field(6), Condition("HasFactorData")]
public NbtCompound FactorCodec { get; init; }

public int Id => 0x6C;
public int Id => 0x6E;

public EntityEffectPacket(int entityId, int effectId, int duration)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ public partial class EntitySoundEffectPacket : IClientboundPacket
[Field(8)]
public long Seed { get; init; } = Globals.Random.Next();

public int Id => 0x61;
public int Id => 0x63;
}
6 changes: 3 additions & 3 deletions Obsidian/Net/Packets/Play/Clientbound/ExplosionPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public partial class ExplosionPacket : IClientboundPacket
[Field(2)]
public ExplosionRecord[] Records { get; init; }

[Field(3), DataFormat(typeof(float))]
public VectorF PlayerMotion { get; init; }
[Field(3)]
public Velocity PlayerMotion { get; init; }

public int Id => 0x1D;
public int Id => 0x1E;
}

public readonly struct ExplosionRecord
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/GameEventPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class GameEventPacket : IClientboundPacket
[Field(1)]
public float Value { get; }

public int Id => 0x1F;
public int Id => 0x20;

public GameEventPacket(ChangeGameStateReason reason)
{
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/LoginPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ public partial class LoginPacket : IClientboundPacket
[Field(19), VarLength]
public int PortalCooldown { get; init; }

public int Id => 0x28;
public int Id => 0x29;
}
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/LookAtPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial class LookAtPacket : IClientboundPacket
[Field(4), VarLength, ActualType(typeof(int)), Condition(nameof(IsEntity))]
public AimType AimEntity { get; set; }

public int Id => 0x3B;
public int Id => 0x3D;
}

public enum AimType : int
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/OpenBookPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public partial class OpenBookPacket : IClientboundPacket
[Field(0), ActualType(typeof(int)), VarLength]
public Hand Hand { get; set; }

public int Id => 0x2F;
public int Id => 0x30;
}
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/OpenScreenPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class OpenScreenPacket : IClientboundPacket
[Field(2)]
public ChatMessage Title { get; }

public int Id => 0x30;
public int Id => 0x31;

public OpenScreenPacket(BaseContainer inventory, int windowId)
{
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/ParticlePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public partial class ParticlePacket : IClientboundPacket
[Field(8)]
public ParticleData Data { get; init; }

public int Id => 0x26;
public int Id => 0x27;
}
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/Play/Clientbound/PickupItemPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public partial class PickupItemPacket : IClientboundPacket
[Field(2), VarLength]
public int PickupItemCount { get; init; }

public int Id => 0x67;
public int Id => 0x6A;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class PlaceGhostRecipePacket : IClientboundPacket
[Field(1)]
public string RecipeId { get; }

public int Id => 0x33;
public int Id => 0x35;

public PlaceGhostRecipePacket(sbyte windowId, string recipeId)
{
Expand Down
11 changes: 6 additions & 5 deletions Obsidian/Net/Packets/Play/Clientbound/PlayerChatMessagePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@

namespace Obsidian.Net.Packets.Play.Clientbound;

//TODO this changed implement later
public partial class PlayerChatMessagePacket : IClientboundPacket
{
[Field(0)]
public required PlayerChatMessageHeader Header { get; init; }

[Field(1), VarLength]
public required List<PreviousMessage> PreviousMessages { get; init; }

[Field(2)]
[Field(1)]
public required PlayerChatMessageBody Body { get; init; }

[Field(2), VarLength]
public required List<PreviousMessage> PreviousMessages { get; init; }

[Field(3)]
public required PlayerChatMessageNetworkTarget NetworkTarget { get; init; }

public int Id => 0x35;
public int Id => 0x37;

public void Serialize(MinecraftStream stream)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public sealed partial class PlayerInfoRemovePacket : IClientboundPacket
[Field(0)]
public List<Guid> UUIDs { get; init; }

public int Id => 0x39;
public int Id => 0x3B;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class PlayerInfoUpdatePacket : IClientboundPacket
[Field(1)]
public Dictionary<Guid, List<InfoAction>> Actions { get; set; } = new();

public int Id => 0x3A;
public int Id => 0x3C;

public PlayerInfoUpdatePacket(Dictionary<Guid, List<InfoAction>> infoActions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public partial class RemoveEntitiesPacket : IClientboundPacket
[Field(0), VarLength]
public List<int> Entities { get; private set; } = new();

public int Id => 0x3E;
public int Id => 0x40;

public RemoveEntitiesPacket(params int[] entities)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class RemoveEntityEffectPacket : IClientboundPacket
[Field(1), VarLength]
public int EffectId { get; init; }

public int Id => 0x3F;
public int Id => 0x41;

public RemoveEntityEffectPacket(int entityId, int effectId)
{
Expand Down
28 changes: 14 additions & 14 deletions Obsidian/Net/Packets/Play/Clientbound/RespawnPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ public partial class RespawnPacket : IClientboundPacket
[Field(6)]
public bool IsFlat { get; init; }

[Field(7)]
public bool HasDeathLocation { get; init; }

[Field(8), Condition(nameof(HasDeathLocation))]
public string DeathDimensionName { get; init; }

[Field(9), Condition(nameof(HasDeathLocation))]
public VectorF DeathLocation { get; init; }

[Field(10), VarLength]
public int PortalCooldown { get; init; }

/// <summary>
/// In the Notchian implementation, this is context dependent:<br/>
/// <br/>
/// normal respawns(after death) keep no data;<br/>
/// exiting the end poem/credits keeps the attributes;<br/>
/// other dimension changes(portals or teleports) keep all data.
/// </summary>
[Field(7), ActualType(typeof(sbyte))]
[Field(11), ActualType(typeof(sbyte))]
public DataKept DataKept { get; init; }

[Field(8)]
public bool HasDeathLocation { get; init; }

[Field(9), Condition(nameof(HasDeathLocation))]
public string DeathDimensionName { get; init; }

[Field(10), Condition(nameof(HasDeathLocation))]
public VectorF DeathLocation { get; init; }

[Field(11), VarLength]
public int PortalCooldown { get; init; }

public int Id => 0x41;
public int Id => 0x43;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public partial class SetActionBarTextPacket : IClientboundPacket
[Field(0)]
public required string Text { get; init; }

public int Id => 0x46;
public int Id => 0x48;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public partial class SetBlockDestroyStagePacket : IClientboundPacket
[Field(2)]
public sbyte DestroyStage { get; init; }

public int Id => 0x07;
public int Id => 0x06;
}
Loading

0 comments on commit 08e5cc6

Please sign in to comment.