dye color + count structured components
This commit is contained in:
parent
d29824798b
commit
79e0f9c6dc
@ -70,3 +70,23 @@ pub struct Property {
|
||||
pub value: String,
|
||||
pub signature: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum DyeColor {
|
||||
White,
|
||||
Orange,
|
||||
Magenta,
|
||||
LightBlue,
|
||||
Yellow,
|
||||
Lime,
|
||||
Pink,
|
||||
Gray,
|
||||
LightGray,
|
||||
Cyan,
|
||||
Purple,
|
||||
Blue,
|
||||
Brown,
|
||||
Green,
|
||||
Red,
|
||||
Black,
|
||||
}
|
||||
|
318
src/data/slot.rs
318
src/data/slot.rs
@ -6,7 +6,7 @@ use uuid::Uuid;
|
||||
|
||||
use crate::ServerError;
|
||||
|
||||
use super::{IdOr, IdSet, Property, component::TextComponent, sound::SoundEvent};
|
||||
use super::{DyeColor, IdOr, IdSet, Property, component::TextComponent, sound::SoundEvent};
|
||||
|
||||
pub const SLOT_COMPONENT_LENGTH: u16 = 96;
|
||||
|
||||
@ -164,24 +164,7 @@ pub struct BannerLayer {
|
||||
pub pattern_type: i32,
|
||||
pub asset_id: Option<String>,
|
||||
pub translation_key: Option<String>,
|
||||
/// Can be one of the following:
|
||||
/// - 0 - White
|
||||
/// - 1 - Orange
|
||||
/// - 2 - Magenta
|
||||
/// - 3 - Light Blue
|
||||
/// - 4 - Yellow
|
||||
/// - 5 - Lime
|
||||
/// - 6 - Pink
|
||||
/// - 7 - Gray
|
||||
/// - 8 - Light Gray
|
||||
/// - 9 - Cyan
|
||||
/// - 10 - Purple
|
||||
/// - 11 - Blue
|
||||
/// - 12 - Brown
|
||||
/// - 13 - Green
|
||||
/// - 14 - Red
|
||||
/// - 15 - Black
|
||||
pub color: u8,
|
||||
pub color: DyeColor,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -229,52 +212,52 @@ pub struct DamageReduction {
|
||||
/// https://minecraft.wiki/w/Java_Edition_protocol/Slot_data#Structured_components
|
||||
#[derive(Clone, EnumIndex)]
|
||||
pub enum StructuredComponent {
|
||||
CustomData(DynNBT),
|
||||
CustomData(DynNBT), // 0
|
||||
/// 1 - 99
|
||||
MaxStackSize(i32),
|
||||
MaxDamage(i32),
|
||||
Damage(i32),
|
||||
Unbreakable,
|
||||
CustomName(TextComponent),
|
||||
ItemName(TextComponent),
|
||||
ItemModel(String),
|
||||
Lore(TextComponent),
|
||||
MaxStackSize(i32), // 1
|
||||
MaxDamage(i32), // 2
|
||||
Damage(i32), // 3
|
||||
Unbreakable, // 4
|
||||
CustomName(TextComponent), // 5
|
||||
ItemName(TextComponent), // 6
|
||||
ItemModel(String), // 7
|
||||
Lore(TextComponent), // 8
|
||||
/// Can be one of the following:
|
||||
/// - 0 - Common (white)
|
||||
/// - 1 - Uncommon (yellow)
|
||||
/// - 2 - Rare (aqua)
|
||||
/// - 3 - Epic (pink)
|
||||
Rarity(u8),
|
||||
Rarity(u8), // 9
|
||||
/// Key: The ID of the enchantment in the enchantment registry. \
|
||||
/// Value: The level of the enchantment.
|
||||
Enchantments(Vec<(u64, i32)>),
|
||||
CanPlaceOn(Vec<BlockPredicate>),
|
||||
CanBreak(Vec<BlockPredicate>),
|
||||
AttributeModifiers(Vec<AttributeModifier>),
|
||||
Enchantments(Vec<(u64, i32)>), // 10
|
||||
CanPlaceOn(Vec<BlockPredicate>), // 11
|
||||
CanBreak(Vec<BlockPredicate>), // 12
|
||||
AttributeModifiers(Vec<AttributeModifier>), // 13
|
||||
/// Floats, Flags, Strings, Colors
|
||||
CustomModelData(Vec<f32>, Vec<bool>, Vec<String>, Vec<i32>),
|
||||
CustomModelData(Vec<f32>, Vec<bool>, Vec<String>, Vec<i32>), // 14
|
||||
/// Parameters:
|
||||
/// - Hide Tooltip
|
||||
/// - The IDs of data components in the minecraft:data_component_type registry to hide.
|
||||
TooltipDisplay(bool, Vec<u64>),
|
||||
TooltipDisplay(bool, Vec<u64>), // 15
|
||||
/// Accumulated anvil usage cost.
|
||||
/// The client displays "Too Expensive" if the value is greater than 40 and
|
||||
/// the player is not in creative mode (more specifically,
|
||||
/// if they don't have the insta-build flag enabled).
|
||||
/// This behavior can be overridden by setting the level
|
||||
/// with the Set Container Property packet.
|
||||
RepairCost(i32),
|
||||
RepairCost(i32), // 16
|
||||
/// Marks the item as non-interactive on the creative inventory (the first 5 rows of items). \
|
||||
/// This is used internally by the client on the paper icon in the saved hot-bars tab.
|
||||
CreativeSlotLock,
|
||||
EnchantmentGlintOverride(bool),
|
||||
CreativeSlotLock, // 17
|
||||
EnchantmentGlintOverride(bool), // 18
|
||||
/// Marks the projectile as intangible (cannot be picked-up).
|
||||
IntangibleProjectile,
|
||||
IntangibleProjectile, // 19
|
||||
/// Parameters:
|
||||
/// - Nutrition, Non-negative
|
||||
/// - How much saturation will be given after consuming the item.
|
||||
/// - Whether the item can always be eaten, even at full hunger.
|
||||
Food(u32, f32, bool),
|
||||
Food(u32, f32, bool), // 20
|
||||
/// Animation: 0: none, 1: eat, 2: drink, 3: block, 4: bow, 5: spear, 6: crossbow, 7: spyglass, 8: toot_horn, 9: brush
|
||||
Consumable {
|
||||
consume_seconds: f32,
|
||||
@ -282,26 +265,26 @@ pub enum StructuredComponent {
|
||||
sound: IdOr<SoundEvent>,
|
||||
has_particles: bool,
|
||||
effects: Vec<ConsumeEffect>,
|
||||
},
|
||||
UseRemainder(Slot),
|
||||
}, // 21
|
||||
UseRemainder(Slot), // 22
|
||||
/// Group of items to apply the cooldown to. Only present if Has cooldown group is true; otherwise defaults to the item's identifier.
|
||||
UseCooldown {
|
||||
seconds: f32,
|
||||
group: Option<String>,
|
||||
},
|
||||
}, // 23
|
||||
/// Parameter - Types, Tag specifying damage types the item is immune to. Not prefixed by '#'!.
|
||||
DamageResistant(String),
|
||||
DamageResistant(String), // 24
|
||||
Tool {
|
||||
rules: Vec<ToolRule>,
|
||||
default_mining_speed: f32,
|
||||
damage_per_block: i32,
|
||||
},
|
||||
}, // 25
|
||||
Weapon {
|
||||
damage_per_attack: i32,
|
||||
disable_blocking_for_seconds: f32,
|
||||
},
|
||||
}, // 26
|
||||
// Opaque internal value controlling how expensive enchantments may be offered.
|
||||
Enchantable(i32),
|
||||
Enchantable(i32), // 27
|
||||
Equippable {
|
||||
slot: u8,
|
||||
equip_sound: IdOr<SoundEvent>,
|
||||
@ -311,14 +294,14 @@ pub enum StructuredComponent {
|
||||
dispensable: bool,
|
||||
swappable: bool,
|
||||
damage_on_hurt: bool,
|
||||
},
|
||||
}, // 28
|
||||
/// Items that can be combined with this item in an anvil to repair it.
|
||||
Repairable(IdSet),
|
||||
Repairable(IdSet), // 29
|
||||
/// Makes the item function like elytra.
|
||||
Glider,
|
||||
TooltipStyle(String),
|
||||
Glider, // 30
|
||||
TooltipStyle(String), // 31
|
||||
/// Makes the item function like a totem of undying.
|
||||
DeathProtection(Vec<ConsumeEffect>),
|
||||
DeathProtection(Vec<ConsumeEffect>), // 32
|
||||
BlockAttacks {
|
||||
block_delay_seconds: f32,
|
||||
disable_cooldown_scale: f32,
|
||||
@ -329,38 +312,38 @@ pub enum StructuredComponent {
|
||||
bypassed_by: Option<String>,
|
||||
block_sound: Option<IdOr<SoundEvent>>,
|
||||
disable_sound: Option<IdOr<SoundEvent>>,
|
||||
},
|
||||
}, // 33
|
||||
/// The enchantments stored in this enchanted book.
|
||||
/// Key: The ID of the enchantment in the enchantment registry. \
|
||||
/// Value: The level of the enchantment.
|
||||
StoredEnchantments(Vec<(u64, i32)>),
|
||||
DyedColor(i32),
|
||||
MapColor(i32),
|
||||
MapId(i32),
|
||||
MapDecorations(DynNBT),
|
||||
StoredEnchantments(Vec<(u64, i32)>), // 34
|
||||
DyedColor(i32), // 35
|
||||
MapColor(i32), // 36
|
||||
MapId(i32), // 37
|
||||
MapDecorations(DynNBT), // 38
|
||||
/// Type of post processing. Can be either:
|
||||
/// - 0 - Lock
|
||||
/// - 1 - Scale
|
||||
MapPostProcessing(u8),
|
||||
MapPostProcessing(u8), // 39
|
||||
/// Projectiles loaded into a charged crossbow.
|
||||
ChargedProjectiles(Vec<Slot>),
|
||||
BundleContents(Vec<Slot>),
|
||||
ChargedProjectiles(Vec<Slot>), // 40
|
||||
BundleContents(Vec<Slot>), // 41
|
||||
PotionContents {
|
||||
potion_id: Option<u64>,
|
||||
custom_color: Option<i32>,
|
||||
custom_effects: Vec<PotionEffect>,
|
||||
custom_name: String,
|
||||
},
|
||||
}, // 42
|
||||
/// Parameter - Effect Multiplier
|
||||
PotionDurationScale(f32),
|
||||
PotionDurationScale(f32), // 43
|
||||
/// Key - The ID of the effect in the potion effect type registry.
|
||||
/// Value - The duration of the effect.
|
||||
SuspiciousStewEffects(Vec<(u64, i32)>),
|
||||
SuspiciousStewEffects(Vec<(u64, i32)>), // 44
|
||||
/// Parameter - Pages
|
||||
/// Page:
|
||||
/// - The raw text of the page
|
||||
/// - The content after passing through chat filters
|
||||
WritableBookContent(Vec<(String, Option<String>)>),
|
||||
WritableBookContent(Vec<(String, Option<String>)>), // 45
|
||||
WrittenBookContent {
|
||||
raw_title: String,
|
||||
filtered_title: Option<String>,
|
||||
@ -371,183 +354,81 @@ pub enum StructuredComponent {
|
||||
/// - The content after passing through chat filters
|
||||
pages: Vec<(String, Option<String>)>,
|
||||
resolved: bool,
|
||||
},
|
||||
}, // 46
|
||||
/// Armor's trim pattern and color
|
||||
Trim(IdOr<TrimMaterial>, IdOr<TrimPattern>),
|
||||
DebugStrickState(DynNBT),
|
||||
EntityData(DynNBT),
|
||||
BucketEntityData(DynNBT),
|
||||
BlockEntityData(DynNBT),
|
||||
Instrument(IdOr<Instrument>),
|
||||
ProvidesTrimMaterial(ProvidesTrimMaterial),
|
||||
Trim(IdOr<TrimMaterial>, IdOr<TrimPattern>), // 47
|
||||
DebugStrickState(DynNBT), // 48
|
||||
EntityData(DynNBT), // 49
|
||||
BucketEntityData(DynNBT), // 50
|
||||
BlockEntityData(DynNBT), // 51
|
||||
Instrument(IdOr<Instrument>), // 52
|
||||
ProvidesTrimMaterial(ProvidesTrimMaterial), // 53
|
||||
/// Between 0 and 4.
|
||||
OminousBottleAmplifier(u8),
|
||||
JukeboxPlayable(JukeboxPlayable),
|
||||
OminousBottleAmplifier(u8), // 54
|
||||
JukeboxPlayable(JukeboxPlayable), // 55
|
||||
/// A pattern identifier like #minecraft:pattern_item/globe
|
||||
ProvidesBannerPatterns(String),
|
||||
Recipes(DynNBT),
|
||||
ProvidesBannerPatterns(String), // 56
|
||||
Recipes(DynNBT), // 57
|
||||
LodestoneTracker {
|
||||
has_global_position: bool,
|
||||
dimension: String,
|
||||
position: (f64, f64, f64),
|
||||
tracked: bool,
|
||||
},
|
||||
FireworkExplosion(FireworkExplosion),
|
||||
}, // 58
|
||||
FireworkExplosion(FireworkExplosion), // 59
|
||||
Fireworks {
|
||||
flight_duration: i32,
|
||||
explosions: Vec<FireworkExplosion>,
|
||||
},
|
||||
}, // 60
|
||||
Profile {
|
||||
name: Option<String>,
|
||||
unique_id: Option<Uuid>,
|
||||
properties: Vec<Property>,
|
||||
},
|
||||
NoteBlockSound(String),
|
||||
BannerPatterns(Vec<BannerLayer>),
|
||||
/// Can be one of the following:
|
||||
/// - 0 - White
|
||||
/// - 1 - Orange
|
||||
/// - 2 - Magenta
|
||||
/// - 3 - Light Blue
|
||||
/// - 4 - Yellow
|
||||
/// - 5 - Lime
|
||||
/// - 6 - Pink
|
||||
/// - 7 - Gray
|
||||
/// - 8 - Light Gray
|
||||
/// - 9 - Cyan
|
||||
/// - 10 - Purple
|
||||
/// - 11 - Blue
|
||||
/// - 12 - Brown
|
||||
/// - 13 - Green
|
||||
/// - 14 - Red
|
||||
/// - 15 - Black
|
||||
BaseColor(u8),
|
||||
}, // 61
|
||||
NoteBlockSound(String), // 62
|
||||
BannerPatterns(Vec<BannerLayer>), // 63
|
||||
BaseColor(DyeColor), // 64
|
||||
/// The ID of the items in the item registry.
|
||||
PotDecorations([u64; 4]),
|
||||
PotDecorations([u64; 4]), // 65
|
||||
/// Items inside a container of any type.
|
||||
Container(Vec<Slot>),
|
||||
BlockState(Vec<(String, String)>),
|
||||
Bees(Vec<HiveBee>),
|
||||
Lock(String),
|
||||
ContainerLoot(DynNBT),
|
||||
BreakSound(IdOr<SoundEvent>),
|
||||
VillagerVariant(u64),
|
||||
WolfVariant(u64),
|
||||
WolfSoundVariant(u64),
|
||||
WolfCollar(u8),
|
||||
Container(Vec<Slot>), // 66
|
||||
BlockState(Vec<(String, String)>), // 67
|
||||
Bees(Vec<HiveBee>), // 68
|
||||
Lock(String), // 69
|
||||
ContainerLoot(DynNBT), // 70
|
||||
BreakSound(IdOr<SoundEvent>), // 71
|
||||
VillagerVariant(u64), // 72
|
||||
WolfVariant(u64), // 73
|
||||
WolfSoundVariant(u64), // 74
|
||||
WolfCollar(u8), // 75
|
||||
/// 0: red, 1: snow
|
||||
FoxVariant(u8),
|
||||
FoxVariant(u8), // 76
|
||||
/// 0: small, 1: medium, 2: large.
|
||||
SalmonSize(u8),
|
||||
ParrotVariant(u64),
|
||||
SalmonSize(u8), // 77
|
||||
ParrotVariant(u64), // 78
|
||||
/// 0: kob, 1: sunstreak, 2: snooper, 3: dasher, 4: brinely, 5: spotty, 6: flopper, 7: stripey, 8: glitter, 9: blockfish, 10: betty, 11: clayfish.
|
||||
TropicalFishPattern(u8),
|
||||
/// Can be one of the following:
|
||||
/// - 0 - White
|
||||
/// - 1 - Orange
|
||||
/// - 2 - Magenta
|
||||
/// - 3 - Light Blue
|
||||
/// - 4 - Yellow
|
||||
/// - 5 - Lime
|
||||
/// - 6 - Pink
|
||||
/// - 7 - Gray
|
||||
/// - 8 - Light Gray
|
||||
/// - 9 - Cyan
|
||||
/// - 10 - Purple
|
||||
/// - 11 - Blue
|
||||
/// - 12 - Brown
|
||||
/// - 13 - Green
|
||||
/// - 14 - Red
|
||||
/// - 15 - Black
|
||||
TropicalFishBaseColor(u8),
|
||||
/// Can be one of the following:
|
||||
/// - 0 - White
|
||||
/// - 1 - Orange
|
||||
/// - 2 - Magenta
|
||||
/// - 3 - Light Blue
|
||||
/// - 4 - Yellow
|
||||
/// - 5 - Lime
|
||||
/// - 6 - Pink
|
||||
/// - 7 - Gray
|
||||
/// - 8 - Light Gray
|
||||
/// - 9 - Cyan
|
||||
/// - 10 - Purple
|
||||
/// - 11 - Blue
|
||||
/// - 12 - Brown
|
||||
/// - 13 - Green
|
||||
/// - 14 - Red
|
||||
/// - 15 - Black
|
||||
TropicalFishPatternColor(u8),
|
||||
TropicalFishPattern(u8), // 79
|
||||
TropicalFishBaseColor(DyeColor), // 80
|
||||
TropicalFishPatternColor(DyeColor), // 81
|
||||
/// 0: red, 1: brown.
|
||||
MooshroomVariant(u8),
|
||||
MooshroomVariant(u8), // 82
|
||||
/// 0: brown, 1: white, 2: black, 3: white splotched, 4: gold, 5: salt, 6: evil.
|
||||
RabbitVariant(u8),
|
||||
PigVariant(u64),
|
||||
CowVariant(u64),
|
||||
ChickenVariant(ChickenVariant),
|
||||
FrogVariant(u64),
|
||||
RabbitVariant(u8), // 83
|
||||
PigVariant(u64), // 84
|
||||
CowVariant(u64), // 85
|
||||
ChickenVariant(ChickenVariant), // 86
|
||||
FrogVariant(u64), // 87
|
||||
/// 0: white, 1: creamy, 2: chestnut, 3: brown, 4: black, 5: gray, 6: dark brown.
|
||||
HorseVariant(u8),
|
||||
PaintingVariant(PaintingVariant),
|
||||
HorseVariant(u8), // 88
|
||||
PaintingVariant(PaintingVariant), // 89
|
||||
/// 0: creamy, 1: white, 2: brown, 3: gray.
|
||||
LlamaVariant(u8),
|
||||
LlamaVariant(u8), // 90
|
||||
/// 0: lucy, 1: wild, 2: gold, 3: cyan, 4: blue.
|
||||
AxolotlVariant(u8),
|
||||
CatVariant(u64),
|
||||
/// Can be one of the following:
|
||||
/// - 0 - White
|
||||
/// - 1 - Orange
|
||||
/// - 2 - Magenta
|
||||
/// - 3 - Light Blue
|
||||
/// - 4 - Yellow
|
||||
/// - 5 - Lime
|
||||
/// - 6 - Pink
|
||||
/// - 7 - Gray
|
||||
/// - 8 - Light Gray
|
||||
/// - 9 - Cyan
|
||||
/// - 10 - Purple
|
||||
/// - 11 - Blue
|
||||
/// - 12 - Brown
|
||||
/// - 13 - Green
|
||||
/// - 14 - Red
|
||||
/// - 15 - Black
|
||||
CatCollar(u8),
|
||||
/// Can be one of the following:
|
||||
/// - 0 - White
|
||||
/// - 1 - Orange
|
||||
/// - 2 - Magenta
|
||||
/// - 3 - Light Blue
|
||||
/// - 4 - Yellow
|
||||
/// - 5 - Lime
|
||||
/// - 6 - Pink
|
||||
/// - 7 - Gray
|
||||
/// - 8 - Light Gray
|
||||
/// - 9 - Cyan
|
||||
/// - 10 - Purple
|
||||
/// - 11 - Blue
|
||||
/// - 12 - Brown
|
||||
/// - 13 - Green
|
||||
/// - 14 - Red
|
||||
/// - 15 - Black
|
||||
SheepColor(u8),
|
||||
/// Can be one of the following:
|
||||
/// - 0 - White
|
||||
/// - 1 - Orange
|
||||
/// - 2 - Magenta
|
||||
/// - 3 - Light Blue
|
||||
/// - 4 - Yellow
|
||||
/// - 5 - Lime
|
||||
/// - 6 - Pink
|
||||
/// - 7 - Gray
|
||||
/// - 8 - Light Gray
|
||||
/// - 9 - Cyan
|
||||
/// - 10 - Purple
|
||||
/// - 11 - Blue
|
||||
/// - 12 - Brown
|
||||
/// - 13 - Green
|
||||
/// - 14 - Red
|
||||
/// - 15 - Black
|
||||
ShulkerColor(u8),
|
||||
AxolotlVariant(u8), // 91
|
||||
CatVariant(u64), // 92
|
||||
CatCollar(DyeColor), // 93
|
||||
SheepColor(DyeColor), // 94
|
||||
ShulkerColor(DyeColor), // 95
|
||||
}
|
||||
|
||||
pub trait ReadWriteSlotComponent: DataReader + DataWriter {
|
||||
@ -561,6 +442,7 @@ impl ReadWriteSlotComponent for Packet {
|
||||
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn write_slot_component(&mut self, val: &StructuredComponent) -> Result<(), ServerError> {
|
||||
self.write_usize_varint(val.enum_index())?;
|
||||
|
||||
@ -602,6 +484,7 @@ impl ReadWriteSlot for Packet {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn write_slot(&mut self, val: Option<Slot>) -> Result<(), ServerError> {
|
||||
if let Some(val) = val {
|
||||
self.write_varint(val.amount)?;
|
||||
@ -661,6 +544,7 @@ impl ReadWriteHashedSlot for Packet {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn write_hashed_slot(&mut self, val: Option<HashedSlot>) -> Result<(), ServerError> {
|
||||
if let Some(val) = val {
|
||||
self.write_varint(val.amount)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user