mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Added more components + added item palette reference
This commit is contained in:
parent
76e873ed54
commit
49319fe781
44 changed files with 667 additions and 29 deletions
|
|
@ -1,11 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||
|
||||
public abstract class StructuredComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry)
|
||||
public abstract class StructuredComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||
{
|
||||
protected DataTypes DataTypes { get; private set; } = dataTypes;
|
||||
protected SubComponentRegistry SubComponentRegistry { get; private set; } = subComponentRegistry;
|
||||
protected ItemPalette ItemPalette { get; private set; } = itemPalette;
|
||||
|
||||
public abstract void Parse(Queue<byte> data);
|
||||
public abstract Queue<byte> Serialize();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
|
||||
|
||||
public abstract class StructuredComponentRegistry(SubComponentRegistry subComponentRegistry, DataTypes dataTypes)
|
||||
public abstract class StructuredComponentRegistry(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||
{
|
||||
private Dictionary<string, Type> ComponentParsers { get; } = new();
|
||||
private Dictionary<int, string> IdToComponent { get; } = new();
|
||||
|
|
@ -32,7 +33,7 @@ public abstract class StructuredComponentRegistry(SubComponentRegistry subCompon
|
|||
if (ComponentParsers.TryGetValue(name, out var type))
|
||||
{
|
||||
var component =
|
||||
Activator.CreateInstance(type, dataTypes, subComponentRegistry) as StructuredComponent
|
||||
Activator.CreateInstance(type, dataTypes, itemPalette, subComponentRegistry) as StructuredComponent
|
||||
?? throw new InvalidOperationException($"Could not instantiate a parser for a structured component type {name}");
|
||||
|
||||
component.Parse(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue