Commit graph

167 commits

Author SHA1 Message Date
BruceChen
aebfcd93e4 fix: regenerate item/block palettes from server registry data for 1.21.9
MC 1.21.9 changed how some items and blocks are registered — 24 block
items (copper bars/chains/lanterns variants, potted azalea renames) and
additional blocks are now registered outside of Items.java/Blocks.java
field declarations, making the previous source-field-order-based palette
generation produce incorrect protocol IDs.

Regenerated ItemPalette1219.cs using server registries.json (1488 items,
up from 1464) and Palette1219.cs using blocks.json (1166 blocks with
correct state IDs). Added 37 new enum values to ItemType.cs (35 new +
DryShortGrass/DryTallGrass for backward compat) and 9 new values to
Material.cs.

Verified all item/block/entity identification against a 1.21.10 server.

Made-with: Cursor
2026-03-21 14:43:56 +08:00
BruceChen
88e9c671da feat: add version routing and metadata reading for MC 1.21.9
- Route block/entity/item/packet/metadata palettes to new 1219 variants
  for protocol >= 773, and raise upper-bound guards from MC_1_21_7 to
  MC_1_21_9 so terrain, inventory, and entity handling are enabled.
- Add DataTypes readers for three new entity metadata serializer types:
  CopperGolemState and WeatheringCopperState (both VarInt), and
  ResolvableProfile (composite: Either<GameProfile, Partial> with
  optional name/UUID/properties + PlayerSkin.Patch with 4 optional
  fields for body/cape/elytra texture ResourceLocations and model type).

Made-with: Cursor
2026-03-21 14:05:06 +08:00
BruceChen
67ad5fcf97 feat: add palettes for MC 1.21.9/1.21.10 (protocol 773)
- Palette1219.cs: 1053 blocks with new copper chests, copper golem
  statues, copper torches, shelves, oxidized lightning rods, iron chain
- EntityPalette1219.cs: 153 entities (+copper_golem at 27, mannequin at 82)
- ItemPalette1219.cs: 1464 items (generated via gen_item_palette.py)
- EntityMetadataPalette1219.cs: 37 serializers (COMPOUND_TAG removed,
  +CopperGolemState, WeatheringCopperState, ResolvableProfile)
- PacketPalette1219.cs: updated clientbound IDs for 4 new debug packets
  and GameTestHighlightPos, plus config CodeOfConduct/AcceptCodeOfConduct

Also update gen_entity_metadata_palette.py FIELD_TO_ENUM with the three
new serializer type mappings.

Made-with: Cursor
2026-03-21 14:04:56 +08:00
BruceChen
2af0409d00 feat: add MC 1.21.9/1.21.10 (protocol 773) version constants and enum values
Register protocol 773 for Minecraft 1.21.9 and 1.21.10 (which share the
same protocol as a hotfix release). Update MCHighestVersion to 1.21.10.

Add 49 new item types (copper tools/armor, shelves, copper chests,
copper golem statue variants, oxidized lightning rods, iron chain, etc.),
2 new entity types (CopperGolem, Mannequin), 38 new block materials,
3 new entity metadata serializer types (CopperGolemState,
WeatheringCopperState, ResolvableProfile), and 6 new packet types
(DebugBlockValue, DebugChunkValue, DebugEntityValue, DebugEvent,
GameTestHighlightPos, CodeOfConduct, AcceptCodeOfConduct).

Chain item/block renamed to IronChain in 1.21.9; old enum values
retained for backward compatibility with older palettes.

Made-with: Cursor
2026-03-21 14:04:42 +08:00
BruceChen
5e8d715358 feat: add MC 1.21.7/1.21.8 (protocol 772) support
1.21.7 and 1.21.8 share protocol 772. The only registry change from
1.21.6 is one new item (music_disc_lava_chicken). All other palettes
(blocks, entities, packets, entity metadata, structured components)
are unchanged and reuse 1.21.6 versions.

Changes:
- Add MC_1_21_7_Version (772) constant
- Add "1.21.7" / "1.21.8" version mappings in ProtocolHandler
- Add MusicDiscLavaChicken to ItemType enum
- Generate ItemPalette1217 (1416 items) for the new item palette
- Update all version upper-bound checks from MC_1_21_6 to MC_1_21_7
- Update MCHighestVersion to "1.21.8"

Made-with: Cursor
2026-03-21 13:10:30 +08:00
BruceChen
1b0e27fde7 feat: add palettes and version routing for MC 1.21.6
- ItemPalette1216: 1415 items (generated from decompiled Items.java)
- EntityPalette1216: 151 entities (HappyGhast at index 56, all after +1)
- Palette1216: block states (DriedGhast 32 states at 13826-13857, all after +32)
- PacketPalette1216: clientbound +3 (Waypoint, ClearDialog, ShowDialog),
  serverbound +2 (ChangeGameMode at 0x04 shifting all after, CustomClickAction at end),
  config clientbound +2 (ClearDialog, ShowDialog),
  config serverbound +1 (CustomClickAction)
- Version routing in Protocol18.cs, PacketType18Handler.cs, EntityMetadataPalette.cs
  updated to select 1216 palettes for protocol >= 771
- EntityMetadataPalette reuses 1215 (EntityDataSerializers unchanged)

Made-with: Cursor
2026-03-21 11:44:12 +08:00
BruceChen
96a7e4a659 feat: add MC 1.21.6 (protocol 771) version constants and enum values
- Add protocol 771 constant MC_1_21_6_Version in Protocol18.cs
- Register 1.21.6 in ProtocolHandler (version map, supported list)
- Extend upper-bound checks from MC_1_21_5 to MC_1_21_6
- Add 19 new ItemType entries (16 colored Harnesses, DriedGhast,
  HappyGhastSpawnEgg, MusicDiscTears)
- Add HappyGhast to EntityType enum
- Add DriedGhast to Material enum
- Add new packet types: Waypoint, ClearDialog, ShowDialog (clientbound),
  ChangeGameMode, CustomClickAction (serverbound),
  ClearDialog, ShowDialog (config clientbound),
  CustomClickAction (config serverbound)

Made-with: Cursor
2026-03-21 11:34:20 +08:00
BruceChen
8df39ba74a feat: add MC 1.21.5 (protocol 770) support
Full protocol adaptation for Minecraft 1.21.5:

- Protocol version mapping: 770 -> 1.21.5
- Packet palette: AddExperienceOrb removed (S2C), TestInstanceBlockStatus
  added (S2C), SetTestBlock and TestInstanceBlockAction added (C2S)
- Entity metadata palette: 5 new serializer types (OptionalLivingEntityReference,
  CowVariant, WolfSoundVariant, PigVariant, ChickenVariant), OPTIONAL_UUID
  replaced by OPTIONAL_LIVING_ENTITY_REFERENCE
- Item palette: 11 new items (Bush, FireflyBush, DryShortGrass, DryTallGrass,
  Wildflowers, LeafLitter, CactusFlower, TestBlock, TestInstanceBlock,
  BlueEgg, BrownEgg)
- Entity palette: Potion split into SplashPotion and LingeringPotion
- Block palette: 9 new blocks (bush, cactus_flower, firefly_bush, leaf_litter,
  short_dry_grass, tall_dry_grass, test_block, test_instance_block, wildflowers)
- Structured components: 31 new components including tooltip_display, weapon,
  blocks_attacks, potion_duration_scale, provides_trim_material,
  provides_banner_patterns, break_sound, and 25 entity variant components;
  unbreakable changed from Bool to Unit; instrument changed to EitherHolder

Made-with: Cursor
2026-03-21 00:48:27 +08:00
BruceChen
f73148e5ec feat: add MC 1.21.4 (protocol 769) support
Add complete protocol 769 support for Minecraft 1.21.4:

- Version constants: Add 769 to supported versions, MC_1_21_4_Version constant,
  and version string mappings (including 1.21.3 -> 768 compatibility)
- Item palette: 10 new items (Resin series + Eyeblossom), generated ItemPalette1214
- Entity palette: Remove CreakingTransient (149 entities, down from 150)
- Block palette: 10 new blocks with correct blockstate ID ranges from server data
- Packet palette: Serverbound packet ID reshuffling - PickItem split into
  PickItemFromBlock/PickItemFromEntity, new PlayerLoaded packet inserted after
  PlayerInput, subsequent IDs shifted accordingly. Clientbound unchanged.
- PlayerLoaded: Send empty PlayerLoaded packet after JoinGame processing (>= 1.21.4)
- EntityMetadata/DataComponents: Reuse 1.20.6 palettes (unchanged registries)
- Update all version guard checks from MC_1_21_2 to MC_1_21_4

Made-with: Cursor
2026-03-20 23:51:56 +08:00
BruceChen
df833ae2a8 feat: add palettes and version constants for MC 1.21.2 (protocol 768)
Add item, entity, block, and metadata palettes for Minecraft 1.21.2:
- ItemPalette1212: 1375 items (42 new: pale oak set, colored bundles,
  creaking heart/spawn egg, banner patterns)
- EntityPalette1212: 150 entity types (boats split into per-wood-type
  entries, generic boat/chest_boat removed; added creaking,
  creaking_transient, pale oak boats)
- Palette1212 (blocks): 1084 block types with state IDs generated from
  official 1.21.2 data reports (24 new pale oak blocks, creaking heart,
  pale moss variants)
- EntityMetadataPalette: reuses 1206 (serializers unchanged in 1.21.2)

Updated version infrastructure:
- Protocol18.cs: MC_1_21_2_Version = 768, palette switch routing
- ProtocolHandler.cs: version mapping 1.21.2 <-> 768
- Program.cs: MCHighestVersion bumped to 1.21.2
- ItemType.cs, EntityType.cs, Material.cs: new enum entries

Note: packet palette, structured components, and protocol handler
changes for 1.21.2 are not yet implemented — this commit covers
palette/registry groundwork only.

Made-with: Cursor
2026-03-20 03:02:43 +08:00
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
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
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
breadbyte
494be0930b
Merge branch 'master' into 1.20.6 2025-12-02 00:06:16 +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
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
5a6fd577e5 Inventory, Terrain and Entity handling 2024-07-02 11:08:46 +02:00
Anon
67e36a92d2 First working version, not fully tested 2024-06-30 11:26:41 +02:00
Anon
08c5c15557 1.20.6 - Not working yet 2024-06-16 01:19:09 +02:00
Roman Danilov
df9443381b Done auxiliary methods for Direction 2024-03-05 21:49:29 +05:00
Roman Danilov
91ef890bb6 Auxiliary class for Direction, preparation for autodetection of the broken side of the block 2024-03-05 20:30:58 +05:00
ReinforceZwei
4546e6946e 1.20.4: Update entity, item and block palette 2024-02-11 18:13:48 +08:00
Anon
790e0bfe55 Implemented 1.20.3 2024-01-30 12:51:47 +01:00
Anon
4f957cee7e 1.20.2 Implementation, not tested 2023-11-15 15:42:27 +01:00
Spongecade
c3fa413b4e
[skip ci] Update Minecraft wiki links to new domain (#2593) 2023-10-07 17:59:08 +08:00
Anon
272900d52e Added slab handling for 1.20/.1
Added Farm bot crops handling for 1.20/.1
Added utilities for Containers/Inventories
Added bot movement lock to prevent multiple bots that use movements from running at the same time.
General code improvements.
2023-06-23 16:25:18 +02:00
Anon
ae7ce35cc8 Fully Implemented 1.20 2023-06-08 19:27:28 +02:00
Anon
64eb48f46d Removed 1.13, because it's not possible to walk under slabs 2023-05-20 13:28:24 +02:00
Anon
852be6e90d Fixed 1.19.3 2023-05-20 13:11:37 +02:00
Anon
97af063d79 Removed a comment 2023-05-16 23:25:29 +02:00
Anon
c7597e8822 Added slab handling 1.13-1.19.4 2023-05-16 23:19:31 +02:00
Anon
0b98628572 Added 1.8 entity handling 2023-03-28 13:39:18 +02:00
ReinforceZwei
21cd24e056 Implement 1.8 Entity MetaData 2023-03-27 18:22:50 +08:00
ReinforceZwei
750295b1e3 Clean up entity metadata palette 2023-03-24 20:51:10 +08:00
ReinforceZwei
f4ad24746c Wire up entity metadata palette 2023-03-24 19:46:25 +08:00
Anon
1a22002bde Fixed entity metadata, fixed a crash with Hurt Data packet, fixed a crash when someone flew by with elyra, added Entity Metadata Palettes (not used yet, requires further work) 2023-03-23 23:41:41 +01:00
Anon
2e55a6bc85 Added palettes 2023-03-21 23:31:10 +01:00
BruceChen
957054eb12 1.19.3 entity & inventory & terrain support 2023-01-14 22:18:05 +08:00
BruceChen
ced65122f1 Trim 2023-01-14 21:07:09 +08:00
BruceChen
ba0d9ba3fc merge brigadier-dev into milutinke:1.19.3 2023-01-14 20:42:15 +08:00
Milutinke
bb160d6d84 Server Data and Profileless Chat message packets implemented. ChatPreview packet removed. Message Header packet set only to 1.19.2. Chat Message packet partially implemented. 2022-12-21 12:51:27 +01:00
Tasuku Bobcorn
1a47eddb8f
Fixed entity yaw and pitch
Fixed number value type during calculation of entity yaw & pitch
2022-12-15 17:47:46 +08:00
BruceChen
5e11ed3896 Tooltip support & Bug fix 2022-12-11 13:00:19 +08:00
BruceChen
892999ac98 Merge into master 2022-12-06 20:32:46 +08:00
BruceChen
84cf749344 Implement command completion suggestions. 2022-12-06 15:50:17 +08:00
BruceChen
ef39e8329c [SKIP_BUILD] Change file encoding to UTF-8 with BOM 2022-11-28 13:55:05 +08:00
BruceChen
077e3a5e9f
Crowdin localization support (#2310)
* Switching to use resource files

* Update Crowdin configuration file

* Code cleanup
2022-10-28 11:13:20 +08:00