Commit graph

1755 commits

Author SHA1 Message Date
BruceChen
e1cb18c6f8 fix: add EntityMetadataPalette1206 for correct 1.20.6+ entity metadata parsing
1.20.6 introduced three new EntityDataSerializer types compared to 1.20.4:
- PARTICLES (id 18) - list of particles, inserted after PARTICLE
- WOLF_VARIANT (id 23) - wolf variant holder, inserted after CAT_VARIANT
- ARMADILLO_STATE (id 28) - armadillo state, inserted after SNIFFER_STATE

These insertions shifted subsequent serializer IDs, causing the 1.19.4
palette (EntityMetadataPalette1194) to misidentify metadata types on
1.20.6+ servers. This could lead to incorrect byte consumption and
potential packet parse failures when entities with affected metadata
types (e.g. wolves, armadillos, area effect clouds with particles)
were present.

Changes:
- Add Particles, WolfVariant, ArmadilloState to EntityMetaDataType enum
- Create EntityMetadataPalette1206 with correct 31-entry ID mapping
- Route 1.20.6+ to the new palette in EntityMetadataPalette.GetPalette()
- Add read logic for the three new types in DataTypes.cs

Verified on 1.21.1 vanilla server: cat, wolf, frog, armadillo, painting
entities all spawn without metadata parse errors.

Made-with: Cursor
2026-03-20 01:43:48 +08:00
BruceChen
ee02974abe fix: Explosion packet parsing and update attribute fallback for 1.21
Fix the Explosion packet handler that was truncating reads at the
knockback fields, leaving BlockInteraction, particles, and SoundEvent
bytes unconsumed for 1.20.4+. The old commented-out code had three bugs:
conditional particle read (should always read both small and large),
reading SoundEvent as a plain string (it's a Holder<SoundEvent> encoded
as VarInt id + optional inline DIRECT_STREAM_CODEC), and an incorrect
fixedRange version gate. Verified against decompiled ClientboundExplodePacket
from both 1.20.6 and 1.21.1 — the wire format is identical across versions.

Update LoadDefaultAttributes() fallback to match the 1.21.1 registry
order (31 attributes), adding 9 new entries: burning_time,
explosion_knockback_resistance, mining_efficiency, movement_efficiency,
oxygen_bonus, sneaking_speed, submerged_mining_speed,
sweeping_damage_ratio, and water_movement_efficiency. This fallback is
only used when the server omits the attribute RegistryData packet.

Made-with: Cursor
2026-03-20 01:29:18 +08:00
BruceChen
c23c229eb2 feat: protocol 767 (1.21) packet handling and AttributeSubComponent update
- Add AttributeSubComponent121 that uses ResourceLocation(string) instead
  of UUID+Name, matching the 1.21 attribute modifier wire format change.
  Register it in SubComponentRegistry121 via new ReplaceSubComponent method.
- Add ProjectilePower packet handler: reads 1 double (accelerationPower)
  for 1.21+, or 3 doubles (xPower/yPower/zPower) for 1.20.6.
- Add CustomReportDetails and ServerLinks packet handlers in both Play
  and Configuration phases, consuming all fields to prevent byte offset
  errors on 1.21 servers.

Made-with: Cursor
2026-03-20 01:22:25 +08:00
BruceChen
2fb09342a3 feat: add ItemPalette121 and new 1.21 music disc item types
Add ItemPalette121.cs with item ID mappings for MC 1.21 (protocol 767).
Add three new music disc entries to ItemType enum: MusicDiscCreator,
MusicDiscCreatorMusicBox, and MusicDiscPrecipice, introduced in 1.21.

Made-with: Cursor
2026-03-20 01:22:16 +08:00
BruceChen
cc10f4effa refactor: StructuredComponents batch 5 audit — remove redundant count fields
Audited batch 5 components (ChargedProjectiles, BundleContents, Container,
WritableBookContent, BlockState, PotDecorations) against official 1.20.6
decompiled STREAM_CODEC definitions. All network encodings were correct.

Removed redundant NumberOfItems/NumberOfPages/NumberOfProperties fields from
ContainerComponent, WritableBlookContentComponent, BlockStateComponent, and
PotDecorationsComponent. Serialize now uses the actual collection .Count
instead of a potentially stale cached value, matching the pattern already
used by ContainerComponent's Serialize and other components.

Also modernized loop style (foreach with deconstruction where applicable)
and fixed a typo in an exception message ("setialize" -> "serialize").

Made-with: Cursor
2026-03-20 00:45:50 +08:00
BruceChen
5e416d6b72 fix: StructuredComponents batch 4 audit — CustomName, ItemName, Lore use NBT encoding
In 1.20.6+, ComponentSerialization.STREAM_CODEC uses
ByteBufCodecs.fromCodecWithRegistries (NBT tag format), not plain string.
The previous implementation incorrectly used ReadNextString/GetString
for custom_name (5), item_name (6), and lore (7) components.

Fixed all three to use ReadNextNbt/GetNbt, preserving raw NBT data for
round-trip serialization while still extracting readable text via
ChatParser.ParseText(Dictionary).

Other batch 4 components (custom_data, entity_data, bucket_entity_data,
block_entity_data, debug_stick_state, map_decorations, recipes, lock,
container_loot, intangible_projectile — all NBT; hide_additional_tooltip,
hide_tooltip, fire_resistant, creative_slot_lock — all Unit/Empty;
note_block_sound — ResourceLocation string) were verified correct.

Made-with: Cursor
2026-03-20 00:33:50 +08:00
BruceChen
c689343371 fix: StructuredComponents batch 3 audit — EnchantmentGlintOverrideComponent type correction
Audited all 14 simple binary components (batch 3): max_stack_size,
max_damage, damage, unbreakable, rarity, custom_model_data, repair_cost,
enchantment_glint_override, ominous_bottle_amplifier, dyed_color,
map_color, map_id, map_post_processing, base_color.

Found and fixed 1 bug:
- EnchantmentGlintOverrideComponent: was reading/writing VarInt but the
  official STREAM_CODEC uses ByteBufCodecs.BOOL (single byte boolean).
  Changed property type from int to bool, Parse from ReadNextVarInt to
  ReadNextBool, and Serialize from GetVarInt to GetBool.

All other 13 components matched the official 1.20.6 STREAM_CODEC
definitions exactly.

Verified in-game: connected to 1.20.6 vanilla server, received items
with enchantment_glint_override=true/false, dyed_color, map_color,
map_id, base_color, unbreakable, rarity, custom_model_data, repair_cost,
damage, max_damage. All parsed and serialized correctly with no errors.

Made-with: Cursor
2026-03-20 00:25:28 +08:00
BruceChen
4944497f5a fix: StructuredComponents batch 2 audit — BlockPredicate and PropertySubComponent serialization
Audited all 8 batch-2 components (enchantments, stored_enchantments,
can_place_on, can_break, lodestone_tracker, firework_explosion, fireworks,
banner_patterns, suspicious_stew_effects, bees) against official 1.20.6
decompiled STREAM_CODEC definitions.

Found and fixed 3 bugs in BlockPredicate/PropertySubComponent:

1. BlockPredicateSubcomponent.Serialize(): missing HasNbt bool write.
   Parse reads the bool but Serialize skipped writing it, causing all
   subsequent fields to be offset by one byte.

2. BlockPredicateSubcomponent.Serialize(): missing Properties list count
   VarInt write. Parse reads VarInt count before iterating, but Serialize
   only wrote the elements without the preceding count.

3. PropertySubComponent: RangedMatcher min/max values must use Optional
   encoding (Bool prefix + conditional String), matching the official
   ByteBufCodecs.either(ExactMatcher, RangedMatcher) where RangedMatcher
   uses ByteBufCodecs.optional(STRING_UTF8) for both min and max fields.
   Previously read/wrote plain Strings unconditionally.

Remaining 6 components (enchantments, stored_enchantments, lodestone_tracker,
firework_explosion, fireworks, banner_patterns, suspicious_stew_effects, bees)
verified correct — no changes needed.

Made-with: Cursor
2026-03-20 00:19:08 +08:00
BruceChen
a36ba23ba6 fix: StructuredComponents batch 1 audit — TrimComponent, ProfileComponent, WrittenBookContent, and NBT serialization
Audited all 8 high-complexity structured components against official 1.20.6
decompiled STREAM_CODEC definitions. Found and fixed bugs in 3 components
plus a systemic NBT serialization issue:

TrimComponent (ID 35):
- Serialize had TrimPatternType and ShowInTooltip incorrectly nested inside
  the TrimMaterialType==0 branch; moved them outside to match Parse logic
- Description fields (TrimMaterial.description, TrimPattern.description) were
  read/written as String but official codec uses ComponentSerialization
  (NBT Tag format); changed to ReadNextNbt/GetNbt

ProfileComponent (ID 46):
- Serialize was missing the HasUniqueId Bool prefix before UUID
- Serialize only wrote properties when count > 0 but omitted the VarInt count
  prefix entirely when empty; now always writes VarInt count

WrittenBookContentComponent (ID 34):
- Page content uses Filterable<Component> where Component is NBT-encoded via
  ComponentSerialization.STREAM_CODEC, not plain String; changed Parse to use
  ReadNextNbt and Serialize to use GetNbt
- Added RawContentNbt/FilteredContentNbt fields to BookPage record for
  round-trip NBT preservation
- Removed unnecessary ChatParser.ParseText on title (it's a plain string)

DataTypes.GetNbt:
- Added TAG_String root support for 1.20.4+ (chat components like "Page 1"
  are encoded as TAG_String, not TAG_Compound)
- Fixed root name handling: versions >= 1.20.2 omit the root compound name,
  but GetNbt was unconditionally writing it

Components confirmed correct (no changes needed):
- FoodComponentComponent (ID 20), ToolComponent (ID 22),
  InstrumentComponent (ID 40), PotionContentsComponent (ID 31),
  AttributeModifiersComponent (ID 12)

Made-with: Cursor
2026-03-20 00:09:05 +08:00
BruceChen
79a0dff8cd Fix enchantment name display for 1.20.6 structured components
EnchantmentsComponent (used by both regular and stored enchantments)
was directly casting the registry VarInt ID to the Enchantments enum
via (Enchantments)id. However, the Enchantments enum is ordered
alphabetically (AquaAffinity=0, BaneOfArthropods=1, ..., Sharpness=32)
while the 1.20.6 registry uses a completely different order
(protection=0, fire_protection=1, ..., sharpness=13). This caused all
enchantment names to display incorrectly (e.g. Sharpness V shown as
"Unknown Enchantment with ID: 32").

Changes:
- Parse now uses EnchantmentMapping.GetEnchantmentByRegistryId1206()
  to properly map registry IDs to enum values via the existing
  1.20.6+ mapping table
- Serialize now uses EnchantmentMapping.GetRegistryId1206ByEnchantment()
  to convert enum values back to registry IDs (reverse lookup)
- Fixed translation key prefix: "Enchantments.minecraft." (wrong) ->
  "enchantment.minecraft." (matches en_us.json resource keys)
- Fixed 3 long-standing typos in the Enchantments enum that prevented
  translation lookup from matching resource keys:
  - DepthStrieder -> DepthStrider (depth_strieder vs depth_strider)
  - Efficency -> Efficiency (efficency vs efficiency)
  - Loyality -> Loyalty (loyality vs loyalty)

Verified on vanilla 1.20.6 server: items with sharpness, efficiency,
unbreaking, fortune, mending, and bane_of_arthropods all display
correct localized names (锋利, 效率, 耐久, 时运, 经验修补, 节肢杀手).

Made-with: Cursor
2026-03-19 02:01:15 +08:00
BruceChen
1e2b853b14 Fix PotionContentsComponent and InstrumentComponent serialization for 1.20.6
Both components had incorrect Parse/Serialize implementations that would
cause packet deserialization misalignment when encountered in-game.

PotionContentsComponent (3 bugs):
- Serialize unconditionally wrote VarInt(PotionId) and Int(CustomColor)
  even when HasPotionId/HasCustomColor was false. The official format
  (PotionContents.STREAM_CODEC) uses Optional encoding: Bool(hasValue)
  followed by the value only when true. The extra bytes caused all
  subsequent fields in the packet to be read at wrong offsets.
- Serialize omitted the VarInt(count) prefix for the custom effects list.
  The official codec uses ByteBufCodecs.list() which always writes a
  VarInt count header before the list elements.
- Also fixed typo: PotiononId -> PotionId.

InstrumentComponent (3 bugs):
- The official Instrument.STREAM_CODEC uses ByteBufCodecs.holder() which
  encodes as VarInt(holderId): 0 = inline data, N>0 = registry ref (N-1).
  The SoundEvent field inside uses the same holder pattern. The old code
  unconditionally read SoundName (ResourceLocation) and HasFixedRange/
  FixedRange even when SoundEventHolderId != 0 (registry reference case
  has no inline data).
- UseDuration was read/written as Float, but the official codec uses
  ByteBufCodecs.VAR_INT. This caused a 4-byte vs variable-length
  mismatch that would shift all subsequent data.
- HasFixedRange was read unconditionally when SoundEventHolderId == 0,
  but FixedRange was also read unconditionally. The official SoundEvent
  DIRECT_STREAM_CODEC uses Optional<Float> encoding: Bool(hasValue)
  followed by Float only when true.

These components are used for potion items and goat horns respectively.
Verified against official 1.20.6 decompiled source:
- net.minecraft.world.item.alchemy.PotionContents (STREAM_CODEC)
- net.minecraft.world.item.Instrument (STREAM_CODEC/DIRECT_STREAM_CODEC)
- net.minecraft.sounds.SoundEvent (STREAM_CODEC/DIRECT_STREAM_CODEC)
- net.minecraft.network.codec.ByteBufCodecs (holder/optional/list)

Made-with: Cursor
2026-03-19 01:44:23 +08:00
BruceChen
56f2426c1f Fix StructuredComponent serialization correctness for 1.20.6
Audited all 58 StructuredComponent subclasses against the official Minecraft
1.20.6 decompiled source to verify Parse()/Serialize() symmetry. Found and
fixed four bugs across four components:

1. ContainerComponent: Parse() skipped null item slots (empty slots in a
   container) but Serialize() looped NumberOfItems times using Items[i],
   causing IndexOutOfRangeException when any slot was empty. The official
   ItemContainerContents uses OPTIONAL_STREAM_CODEC which serializes empty
   slots as VarInt(0). Fixed: Parse now stores all slots including nulls,
   Serialize uses Items.Count and iterates all entries. GetItemSlot(null)
   correctly writes VarInt(0) for empty slots.

2. ChargedProjectilesComponent: Used Items.OfType<Item>() in Serialize()
   which silently dropped null entries, causing the serialized count to
   differ from the written VarInt header. The official ChargedProjectiles
   uses STREAM_CODEC (non-optional, no empty slots allowed). Fixed: Items
   list is now List<Item> (non-nullable), Parse defensively skips nulls,
   Serialize writes Items.Count matching the actual list.

3. BundleContentsComponent: Same issue as ChargedProjectilesComponent.
   Applied the same fix pattern.

4. FoodComponentComponent: Two type mismatches vs the official
   FoodProperties.DIRECT_STREAM_CODEC:
   - Saturation was declared as bool and read with ReadNextBool (1 byte),
     but the protocol sends it as float (4 bytes). This caused all
     subsequent fields in the component to be read at wrong offsets,
     corrupting CanAlwaysEat, SecondsToEat, and the effects list.
   - NumberOfEffects was serialized with GetFloat() instead of GetVarInt(),
     writing 4 bytes of IEEE 754 float instead of a variable-length integer.
   Fixed both Parse and Serialize to use correct types.

Also removed redundant NumberOfItems/NumberOfEffects fields from components
where the count is derivable from the list length, and replaced
ArgumentNullException with cleaner patterns.

Tested end-to-end on vanilla 1.20.6 server: item receiving (diamond_sword,
golden_apple, diamond_pickaxe), inventory slot movement (click to pick up
and place), and inventory listing all work correctly with no server-side
protocol errors.

Made-with: Cursor
2026-03-19 01:37:56 +08:00
BruceChen
b692b13bbc Fix EntityProperties crash and add default attribute registry fallback
After the previous commit (99ac3d0) moved attribute lookup from a hardcoded
dictionary to the dynamic RegistryData, MCC would crash immediately upon
joining a vanilla 1.20.6 server with:

  System.ArgumentException: An item with the same key has already been added.
  Key: unknown

Root cause: When KnownDataPacks negotiation tells the server that MCC already
has the "minecraft" data pack, the server skips sending RegistryData for
registries it considers "known" — including minecraft:attribute. This left
the dynamic attribute map empty, so every VarInt attribute ID resolved to
"unknown". The EntityProperties packet often contains multiple attributes
(e.g. armor, max_health, movement_speed), and `keys.Add("unknown", ...)` on
the second "unknown" attribute threw ArgumentException.

Two fixes applied:

1. World.GetAttributeNameById(): When the dynamic attribute map is empty
   (server didn't send the registry), automatically load the vanilla 1.20.6
   default attribute order (22 entries matching Attributes.java registration
   order). This mirrors the pattern used for dimensions where defaults are
   loaded when RegistryData is not sent. If a modded server sends a custom
   attribute registry, the dynamic map takes precedence.

2. Protocol18.cs EntityProperties handler: Change `keys.Add(propertyKey,
   propertyValue2)` to `keys[propertyKey] = propertyValue2` to tolerate
   duplicate keys defensively, in case an unknown attribute ID still appears.

Tested: MCC now connects to a vanilla 1.20.6 offline-mode server, stays
online for 6+ minutes with no crashes or disconnections. Verified: chat
messages received, inventory listing (item names/counts correct), entity
detection, TPS query, and health query all work correctly.

Made-with: Cursor
2026-03-19 01:26:20 +08:00
BruceChen
99ac3d028a Dynamically parse minecraft:attribute registry from server RegistryData
In 1.20.6+, EntityProperties packets reference attributes by VarInt registry
IDs instead of string names. Previously, a hardcoded dictionary of 22 attribute
entries (matching the vanilla 1.20.6 registry) was used to map these IDs back
to names. This works for vanilla servers but would fail silently for modded
servers that add custom attributes — any unknown ID would be reported as
"unknown".

This commit replaces the hardcoded attribute dictionary with dynamic registry
parsing, following the same pattern already used for dimension_type and
chat_type registries:

- World.cs: Add static `attributeIdMap` field, `SetAttributeIdMap()` and
  `GetAttributeNameById()` methods for storing/querying attribute names by
  their VarInt registry IDs.

- Protocol18.cs (RegistryData handler): When the server sends a
  `minecraft:attribute` registry during the Configuration phase, parse all
  entries and store the ID→name mapping. The `minecraft:` prefix is stripped
  from entry names to match the format used in EntityProperties packets
  (e.g. "minecraft:generic.armor" → "generic.armor").

- Protocol18.cs (EntityProperties handler): Remove the hardcoded 22-entry
  `attributeDictionary` and use `World.GetAttributeNameById()` instead.
  Unknown IDs still fall back to "unknown" for safety.

Also closes issue #4 (Disconnect packet extra boolean) — verified that both
Play and Configuration phase Disconnect handlers already use `ReadNextChat()`
(NBT format since 1.20.4+), matching the 1.20.6 protocol spec. No code
changes needed; updated tracking document to mark as closed.

Made-with: Cursor
2026-03-19 01:12:18 +08:00
BruceChen
967f67190c Add FileInputBot for non-interactive debugging and fix NbtToString crash
FileInputBot (ChatBots/FileInputBot.cs):
- New ChatBot that monitors a text file (default: mcc_input.txt) for
  commands, enabling MCC control from Cursor Shell or any non-interactive
  environment where stdin is not available
- Activated by setting MCC_FILE_INPUT env var (e.g. MCC_FILE_INPUT=1)
- Polls every ~500ms for new lines appended to the file
- Lines starting with "/" are sent as server chat/commands
- Other lines are executed as MCC internal commands (same as console input)
- File path overridable via MCC_INPUT_FILE env var

McClient.cs:
- Load FileInputBot when MCC_FILE_INPUT environment variable is set

ChatParser.cs - NbtToString:
- Fix InvalidCastException when NBT "text" or nameless root tag values
  are Int32 instead of String (happens with 1.20.6 SystemChat packets
  containing numeric values in the chat component tree)
- Replace direct (string) casts with ?.ToString() ?? string.Empty

Made-with: Cursor
2026-03-19 00:45:51 +08:00
BruceChen
8eac21b4a4 Wire up 1.20.6 structured components to Item and fix GetItemSlot serialization
In 1.20.6+, items use structured components instead of NBT for metadata.
Previously, ReadNextItemSlot parsed the components but never stored them
on the Item instance, leaving DisplayName/Lores/Damage/Enchantments all
empty. GetItemSlot also still used the pre-1.20.6 format (bool + VarInt +
byte + NBT), causing the server to reject any item operation packets.

Changes:

Item.cs:
- Add List<StructuredComponent>? Components field to hold the raw
  component list for round-trip serialization
- DisplayName property: read from CustomNameComponent (with
  ItemNameComponent as fallback) when Components is present
- Lores property: read from LoreNameComponent1206 when Components is
  present
- Damage property: read from DamageComponent when Components is present
- Add EnchantmentList property: read from EnchantmentsComponent (covers
  both normal and StoredEnchantmentsComponent for enchanted books)
- ToFullString(): use EnchantmentList with EnchantmentMapping for display
  when available, fall back to NBT path for older versions
- Add CloneWithCount() method that preserves both NBT and Components

DataTypes.cs - ReadNextItemSlot:
- Assign parsed strcturedComponentsToAdd to item.Components

DataTypes.cs - GetItemSlot:
- Add 1.20.6+ branch: write VarInt(count) + VarInt(itemId) + component
  counts + serialized components (using each component's TypeId and
  Serialize() method)
- Empty slot sends VarInt(0) per the 1.20.6 protocol spec

StructuredComponent.cs:
- Add int TypeId property (default -1) to store the registry type ID
  assigned during parsing, enabling round-trip serialization

StructuredComponentRegistry.cs:
- Set component.TypeId = id after instantiation in ParseComponent()

McClient.cs:
- Replace manual Item constructor calls (new Item(type, count, nbt))
  with Item.CloneWithCount() to preserve Components during inventory
  operations like slot moves, stack splits, and right-click placement

Made-with: Cursor
2026-03-19 00:34:10 +08:00
BruceChen
bb18399523 Use dynamic dimension registry lookup in JoinGame and Respawn packets
The JoinGame and Respawn packet handlers for 1.20.6+ used hardcoded
switch expressions to map dimension type VarInt IDs to names:
  0 => overworld, 1 => overworld_caves, 2 => the_end, 3 => the_nether

This only works for vanilla servers with exactly 4 default dimensions.
Modded servers (Forge/Fabric/NeoForge) or servers with custom
datapacks can register additional dimensions with IDs beyond 0-3,
causing the switch to fall through to the default "overworld" for
any non-vanilla dimension. This means players in modded dimensions
would have incorrect world parameters (height, lighting, etc.).

Fix: Replace both hardcoded switch expressions with
World.GetDimensionNameById(), which looks up the VarInt ID in
the dimension ID map populated during the RegistryData phase.

Also fixes two pre-existing issues in the SetDimension dispatch:
- JoinGame (pre-1.20.2 path): The `case < MC_1_20_6_Version` guard
  was technically correct within its enclosing `if` block, but
  changed to `default` for clarity and future-proofing.
- Respawn: The `case <= MC_1_20_6_Version` guard excluded protocol
  versions above 766 (e.g. 1.21 / protocol 767), meaning
  SetDimension was never called for those versions. Changed to
  `default` so all versions >= 1.19 properly update the dimension.

Made-with: Cursor
2026-03-19 00:13:57 +08:00
BruceChen
41a701b6b2 Fix RegistryData parsing and KnownDataPacks negotiation for 1.20.6
Two critical issues in the 1.20.6 configuration phase that could cause
connection instability and packet desync:

1. RegistryData: The handler used an early `break` when it encountered
   a registryId other than "minecraft:dimension_type" or
   "minecraft:chat_type". This skipped reading the remaining entries
   for that registry, leaving unconsumed data in the packet buffer.
   Subsequent packet reads would start at the wrong offset, causing
   cascading parse failures and eventual disconnection.

   Fix: Always read all entries (entryId + hasData + optional NBT)
   for every registry, regardless of whether we process it. For
   dimension_type entries, if the server sends inline NBT data (i.e.
   non-vanilla dimensions from mods/datapacks), parse and store
   the dimension directly via World.StoreOneDimension(). Only fall
   back to hardcoded defaults when no dimension data was received.

2. KnownDataPacks: The client echoed back ALL packs the server
   listed, including non-vanilla ones. This told the server "I have
   these packs cached" when the client actually did not, so the
   server would skip sending full registry data for those packs.
   The result: incomplete registries for modded/datapack content.

   Fix: Filter the response to only include packs with the
   "minecraft" namespace. Non-vanilla packs are omitted, forcing
   the server to send their full registry data inline.

Also adds supporting methods to World.cs:
- SetDimensionIdMap(): Store VarInt ID -> dimension name mapping
  from RegistryData entries (needed by JoinGame/Respawn)
- GetDimensionNameById(): Look up dimension name by numeric ID
- HasAnyDimension(): Check if any dimensions were loaded from
  server-provided data

Made-with: Cursor
2026-03-19 00:13:22 +08:00
BruceChen
a7a95d991c Fix EntityProperties attribute ID mapping for 1.20.6
The 1.20.6 EntityProperties packet sends attribute IDs as VarInts
instead of strings. The existing mapping dictionary had three issues:

1. IDs 5/6/7 used the wrong prefix "generic." but the official
   1.20.6 registry uses "player." for these attributes:
   - 5: player.block_break_speed (was generic.block_break_speed)
   - 6: player.block_interaction_range (was generic.block_interaction_range)
   - 7: player.entity_interaction_range (was generic.entity_interaction_range)

2. IDs 22-24 (submerged_mining_speed, sweeping_damage_ratio,
   water_movement_efficiency) do not exist in the 1.20.6 attribute
   registry — they were introduced in 1.21. Their presence could
   cause incorrect attribute resolution.

3. Direct dictionary indexing (attributeDictionary[id]) throws
   KeyNotFoundException if the server sends an unknown attribute ID,
   crashing the packet handler. Replaced with TryGetValue and a
   safe fallback to "unknown".

Made-with: Cursor
2026-03-19 00:12:06 +08:00
BruceChen
ff1c570a78 Handle non-interactive terminal environments gracefully
When MCC runs in non-interactive terminals (e.g. CI runners, IDE
embedded shells, piped input), several Console APIs throw exceptions
because there is no real console attached.

Changes:
- Program.cs: Wrap Console.KeyAvailable / Console.ReadKey in
  HandleFailure() with try-catch so MCC does not crash on startup
  failure in headless environments.
- Chunk.cs: Wrap Console.BufferWidth / BufferHeight in try-catch
  with fallback values (120x50) to prevent exceptions when rendering
  chunk maps without a console buffer.
- Map.cs: Same treatment for the map rendering path - use safe
  fallback values when Console.BufferWidth/Height are unavailable.
- ReplayHandler.cs: Replace Array.Reverse() (returns void in newer
  .NET) with .AsEnumerable().Reverse() to fix compilation with
  .NET 10 SDK where the void return breaks the fluent chain.

Made-with: Cursor
2026-03-19 00:11:13 +08:00
breadbyte
494be0930b
Merge branch 'master' into 1.20.6 2025-12-02 00:06:16 +08:00
Anon
8b20973b02 Temporarily removed WebSocket bot because of a false positive virus detection. I will make it in to a standalone bot later. 2025-05-22 13:56:27 +02:00
Tasuku Bobcorn
19781985f7 Fix reading window items packet in versions below 1.17.1 2025-04-29 13:56:38 +08:00
Anon
2409de2a2f
Fix prevent AntiCheat Block Breaking (In Scripts)
Fix prevent AntiCheat Block Breaking (In Scripts)
2024-12-25 16:56:07 +01:00
breadbyte
a5ab30f3da Fix session cache serializer failure 2024-12-25 01:28:28 +08:00
Anon
7152072598 Ported to .NET 8 2024-12-22 13:20:04 +01:00
Anon
f83e7c5707 Preliminary 1.21 Support 2024-12-06 16:45:48 +01:00
vinicius
d0c9695a79 Fixed bug in SetDimension method of World class, where it would crash if joining a paper server. Added error handling. 2024-12-05 02:13:21 +00:00
Anon
7bd213a154 Fixed the potion component crash 2024-12-04 21:25:22 +01:00
Anon
0da4a718cb Implemented all structured components, renamed them all to a better format 2024-10-05 13:37:52 +02:00
Anon
4dea688ca2 Added more structured components 2024-09-11 20:58:24 +02:00
Anon
49319fe781 Added more components + added item palette reference 2024-09-11 20:35:23 +02:00
Anon
76e873ed54 WIP: Added some strctured components 2024-09-11 19:12:31 +02:00
breadbyte
27e66433cd
Hotfix for 'minecraft:chat_type' not present in the dictionary (#2794) 2024-09-07 03:45:45 +08:00
Anon
63b027d84a First Version of Structured Components 2024-09-01 20:42:39 +02:00
breadbyte
c69cdaddbf [skip ci] fix issue 2779 2024-08-14 18:49:09 +08:00
a08381
efe23eb1f9 add Yggdrasil authlib multi-user selection. 2024-08-11 01:43:46 +08:00
breadbyte
ca966a464c
Ensure that the cached version of MCC is refreshed every update (#2760)
fixes #2758

this happened because we added sentry in a future release, but the cache was using an old executable, so it couldn't find the assembly.
2024-07-14 01:46:43 +08:00
breadbyte
c50b360eae
Fix minor bugs (#2759)
* add miscellaneous fixes

* Fixed connecting to server when compression threshold is set to 0

The client assumes that 0 means disabled, when on a notchian (vanilla) server, it is possible to set the compression threshold to 0 (compress all packets).

* Try to capture all exceptions through Sentry

No exceptions are being logged through Sentry, so be more aggressive when sending exceptions

(cherry picked from commit eb1c2f5e771760fb3be32ffea79f8292adca92f1)

* Call OnSpawnPlayer packet when a player is spawned using the SpawnEntity packet

references #2721

(cherry picked from commit ef28ae09ac89e8988dd612de61f2849a9f0e528c)
2024-07-14 01:30:16 +08:00
Anon
5a6fd577e5 Inventory, Terrain and Entity handling 2024-07-02 11:08:46 +02:00
Anon
58a5260b5b Merge branch 'master' of github.com:milutinke/Minecraft-Console-Client into 1.20.6 2024-06-30 11:57:57 +02:00
Anon
67e36a92d2 First working version, not fully tested 2024-06-30 11:26:41 +02:00
breadbyte
08551097c6
Add Sentry Error Tracking (#2670)
* Add Sentry Error Tracking

* Omit personally identifiable information and add additional sentry context

* Remove debug message

* Make sentry opt-out and add related notices and strings

Also add Minecraft Version to error context

* Update build to send release info to sentry

* Adjust sentry error tracking

- Send the user-friendly Minecraft Version in the error logs
- Capture exceptions in more parts of the application

We now capture exceptions from the following locations:
- Protocol18 (1.8+) Packet errors
- Errors during client initialization phase (When client is about to start, session keys are NEVER sent to sentry)

* Make Sentry DSN configurable and repository-specific

The Sentry DSN will automatically be filled out on the main repository through the Github Actions build.

* Update build-and-release.yml

Update sed command

* style: change variable name

nitpick, just to make it a little bit more descriptive

* Add Sentry branding in README.

* remove old code (merge conflict)
2024-06-22 06:41:13 +08:00
breadbyte
8756ff5b3c
[skip ci] Miscellaneous scripting QoL improvements and fixes (#2740)
* Update CI to detect the word "skipci"

* Make script compilation errors more verbose

Rather than just giving the line in which the error has been found, return the actual text content of the line itself

* Attempt to bubble up errors in the script chain, so it says the reason for any NotRun errors.

The exception message gets eaten up when the script is running, and an exception happens.

Also put in a default result message for the CmdResult, instead of having it default to null.

* Trim the whitespace off returned script compilation error line
2024-06-22 06:40:23 +08:00
Anon
08c5c15557 1.20.6 - Not working yet 2024-06-16 01:19:09 +02:00
Anon
8270a2d9a3
Item Mappings for 1.8 - 1.12 + Crash Fix
Item Mappings for 1.8 - 1.12 + Crash Fix
2024-06-08 21:34:33 +00:00
yaggod
d0caf4c9ee fixed typo in word heAlper lol 2024-04-16 21:21:08 +03:00
oldkingOK
bf54def51f
Fix(PacketType18Handler.cs): 1.20 Packet Palette (#2715) 2024-03-20 14:10:06 +08:00
breadbyte
f5c7a2801f Add an extra autorelog guard on HandleFailure 2024-03-17 02:10:14 +08:00
breadbyte
dc71332dd3 fix mcc not showing the disconnect message
The fix is to remove the ParseText call from the OnConnectionLost call, as the ReadNextChat function already calls ParseText. Calling ParseText on an unparsable string returns an empty string, therefore the disconnect message never gets propagated to the user.
2024-03-17 02:09:20 +08:00