Skip to content

Commit

Permalink
Add Set Recipe Book State packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Czompi committed Jan 12, 2022
1 parent 4b32728 commit ab54d87
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Obsidian/Net/Packets/Play/Serverbound/ERecipeBookType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Obsidian.Net.Packets.Play.Serverbound;

public enum ERecipeBookType
{
Crafting,
Furnace,
BlastFurnace,
Smoker
}
34 changes: 34 additions & 0 deletions Obsidian/Net/Packets/Play/Serverbound/SetRecipeBookState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.Extensions.Logging;
using Obsidian.Entities;
using Obsidian.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Obsidian.Net.Packets.Play.Serverbound;

public partial class SetRecipeBookState : IServerboundPacket
{
[Field(0), VarLength, ActualType(typeof(int))]
public ERecipeBookType BookId { get; private set; }

[Field(1)]
public bool BookOpen { get; private set; }

[Field(2)]
public bool FilterActive { get; private set; }

public int Id => 0x1E;

public SetRecipeBookState()
{
}

public ValueTask HandleAsync(Server server, Player player)
{
return ValueTask.CompletedTask;
}

}
6 changes: 5 additions & 1 deletion Obsidian/Utilities/ClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void RegisterHandlers()
//Packets.TryAdd(0x1C, new EntityAction()); !
//Packets.TryAdd(0x1D, SteerVehicle);
//Packets.TryAdd(0x1E, new SetDisplayedRecipe()); !
//Packets.TryAdd(0x1F, SetRecipeBookState);
//Packets.TryAdd(0x1F, new SetRecipeBookState()); !
//Packets.TryAdd(0x20, new NameItem()); !
//Packets.TryAdd(0x21, ResourcePackStatus);
//Packets.TryAdd(0x22, AdvancementTab);
Expand Down Expand Up @@ -125,6 +125,10 @@ public async Task HandlePlayPackets(int id, byte[] data, Client client)
await HandleFromPoolAsync<EntityAction>(data, client);
break;

case 0x1E:
await HandleFromPoolAsync<SetRecipeBookState>(data, client);
break;

case 0x1F:
await HandleFromPoolAsync<SetDisplayedRecipe>(data, client);
break;
Expand Down

0 comments on commit ab54d87

Please sign in to comment.