Skip to content

feature(component): Data components, standalone IItemState, and metadata deprecation - #696

Open
geyesborg wants to merge 20 commits into
CleanroomMC:mainfrom
geyesborg:pr/data-components
Open

geyesborg wants to merge 20 commits into
CleanroomMC:mainfrom
geyesborg:pr/data-components

Conversation

@geyesborg

Copy link
Copy Markdown
Contributor

Cleanroom Version

0.7.7-alpha

Summary

Stacked on #684 (pr/wide-ids). Introduces Cleanroom's typed ItemStack Data Component architecture (com.cleanroommc.component.*), standalone IItemState (ItemStateContainer, ItemStateIdMap), and @Deprecated compatibility shims for legacy 4-bit block metadata and 16-bit item damage APIs.

Goals

  • Make Item a template for standalone IItemState instances (getStateId(), getOrdinal(), Item.ITEM_STATE_IDS, ItemStateContainer) mirroring Block -> IBlockState, while preserving stack.getItem() == Items.DYE identity for 1.12 mods.
  • Introduce a registry-backed DataComponentType<T> system (cleanroom:data_component_types) with lazy per-Item prototype maps (DataComponentMap) and per-ItemStack copy-on-write patches (PatchedDataComponentMap).
  • Separate ItemStack durability (DataComponents.DAMAGE, 32-bit int via getDamageValue/setDamageValue), standalone states on stacks (DataComponents.BLOCK_STATE, DataComponents.ITEM_STATE), and map IDs (DataComponents.MAP_ID) while keeping itemDamage synchronized for legacy callers.
  • Support DataComponentPredicate ([component=value,!removed] and state-property matching) across /give, /clear, /replaceitem, Ingredient, CraftingHelper, FurnaceRecipes, LootFunctionManager (set_components), and ItemPredicate.
  • Deprecate legacy metadata/damage methods (Block.getStateFromMeta, Block.getMetaFromState, ItemStack.getItemDamage, ItemStack.getMetadata) as compatibility shims.

Depends On

Description

  • Data Components (com.cleanroommc.component.*):
    • DataComponentType<T> with optional NbtCodec<T> and NetCodec<T>, registered in GameData.DATA_COMPONENT_TYPES (cleanroom:data_component_types).
    • Built-in components in DataComponents: MAX_STACK_SIZE, MAX_DAMAGE, DAMAGE, UNBREAKABLE, CUSTOM_NAME, LORE, CUSTOM_DATA, MAP_ID, LEGACY_VARIANT, BLOCK_STATE, and ITEM_STATE.
    • Unknown or temporarily unresolved component tags on ItemStack are retained verbatim in unknownComponentTags across load/save (and dropped if their namespace is removed via RetainedContent).
  • Standalone Item States (IItemState, ItemStateContainer, ItemStateIdMap):
    • Item.createItemState() builds an ItemStateContainer whose valid IItemState instances receive dense runtime IDs in Item.ITEM_STATE_IDS (ItemStateIdMap).
    • Declared on vanilla variant items (ItemDye, ItemCoal, ItemAppleGold, ItemFishFood, ItemSkull, ItemBanner, ItemBed) with Item.rebuildItemState() support in EnumHelper.addDyeColor.
  • Block-to-Item State Bridge (ItemBlock.stackFor, Block.getStateForDrop):
    • ItemBlock.stackFor(IBlockState) attaches DataComponents.BLOCK_STATE whenever a block state cannot round-trip through 4-bit getStateFromMeta (such as >16-state blocks or custom EnumDyeColor variants on wool, carpet, concrete, stained clay, and stained glass/panes).
  • Commands, Crafting, Villager Trades & Inventories:
    • DataComponentPredicate parses bracket syntax (item[component=value,!removed,prop=val]) for /give, /clear, and /replaceitem, and JSON "components" for recipes, advancements, and loot tables.
    • ItemStack.areItemStackTagsEqual, ItemStack.isItemEqual, PackedItems, Ingredient, FurnaceRecipes, TileEntityFurnace, MerchantRecipeList, SlotMerchantResult, EntityItem, and ItemHandlerHelper preserve and compare PatchedDataComponentMap entries.

Generated with Devin

@geyesborg
geyesborg force-pushed the pr/data-components branch 23 times, most recently from ee151e5 to 3a7721c Compare October 17, 2026 03:46
…mod retention, and world migration

- Lift block (4096), item (32000), biome (256), potion (256), enchantment (32767), villager profession (1024), and entity network ID caps to Integer.MAX_VALUE with deterministic runtime IDs and standalone IBlockState IDs (Block.BLOCK_STATE_IDS).
- Save chunk sections and 2D/3D biomes as string palettes (SectionBlockFormat, ChunkBiomes) with legacy Forge, JEID/REID, and NEID world migration (LegacyIds, LegacyIdWorlds).
- Synchronize and reconcile registry order on multiplayer handshake (RegistrySync).
- Retain missing-mod blocks, biomes, items, entities, tile entities, villager professions, enchantments, and world types with stand-ins (RetainedContent, RetentionFile, StandIns, MissingItem).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… records from LegacyIds during legacy/JEID/NEID migration

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…iveEffects and EnchantmentHelper retention

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… and FlowerPot saves and delegate BlockStateContainer.setDataFromNBT

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…otions in AreaEffectCloud/TippedArrow, and auto-rebuild Block states in EnumHelper.addEnum

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…and retain village crop names in StructureVillagePieces

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…and resolve BaseName/ColorName in TileEntityBanner

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…FlatGeneratorInfo and retain missing-mod player statistics in StatisticsManagerServer

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…etention helpers in RetainedContent and retain custom EntityPainting Motive

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…, unlocked recipes (RecipeBookServer), and unresolved block-state properties on registered blocks

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…rdSaveData and refactor EntityFallingBlock/EntityArrow to use RetainedContent.readRetainedBlockState

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ontent.readRetainedBlockState and retain DisplaySlots in ScoreboardSaveData

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ct, fix PotionUtils.appendEffects tag type, and centralize RetainedContent.isRemovedStatKey

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…eacon, preserve retained potions on picked-up EntityTippedArrow, and preserve retained BaseName on dropped/re-placed Banners

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…room.common.id, fold IdFormatContainer into CleanroomContainer, CommandRegistry, IdDataFixers, BiomeArrayTransformer)
…ep pr/wide-ids focused on Wide IDs and tag/palette storage
…flection, and replace global NBT equality patches with ItemStack tag normalization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant