-
Notifications
You must be signed in to change notification settings - Fork 4
Data Pipeline
Aram edited this page Sep 11, 2025
·
1 revision
This section provides a view of the integrated BlueLib cache system, combining JSON deserialization, CODECs, CompoundTags, and DataComponentTypes for a robust preset storage and loading system.
The system allows you to:
- Easily define caches for different types.
- Serialize/deserialize them via JSON, NBT, or dynamic formats.
- Attach them to objects like
ItemStackor entities. - Reuse patterns across multiple types without duplicating code.
The following caches are included and fully integrated:
- IntRange – Stores integer ranges.
- FloatRange – Stores float ranges.
- DoubleRange – Stores double ranges.
- LongRange – Stores long ranges.
- ShortRange – Stores short ranges.
- ByteRange – Stores byte ranges.
-
BlockPos – Supports conversion between
BlockPosCacheandBlockPos. -
Vector2 (Float) – Supports conversion between
Vector2CacheandVector2f. -
Vector3 (Float) – Supports conversion between
Vector3CacheandVector3f. -
RGBAColor – Supports conversion between
RGBAColorCacheand a color object. -
RGBColor – Supports conversion between
RGBColorCacheand a color object.
-
JSON Deserializers
- Each cache has a custom deserializer to read JSON into the cache object.
- Ensures validation, default values, and consistent parsing across all cache types.
-
CODECs
- Each cache has a dedicated CODEC, bridging the cache with
DynamicandCompoundTag. - Handles automatic serialization/deserialization for Minecraft systems.
- Each cache has a dedicated CODEC, bridging the cache with
-
CompoundTags
-
writeToNBTandreadFromNBTmethods provide the foundation for persistent storage. - Ensures all cache objects can save/load to/from NBT.
-
-
DataComponentTypes
- Each cache has its own DataComponentType, registered for global access.
- Allows attaching caches to
ItemStack, entities, and other objects directly. - Uses the CODEC for persistence automatically.
Here is a typical workflow for a cache object:
JSON → Cache → CODEC → CompoundTag → DataComponentType → Object
And in code:
ExampleCache cache = GsonFactory.INSTANCE.fromJson(jsonString, ExampleCache.class);
Dynamic<?> dynamic = new Dynamic<>(NbtOps.INSTANCE, new CompoundTag());
ExampleCache fromCodec = ExampleCache.CODEC.parse(dynamic).getOrThrow(false, System.err::println);
ItemStack stack = new ItemStack(Items.DIAMOND);
stack.set(ExampleCache.EXAMPLE_CACHE_TYPE, cache);
ExampleCache stored = stack.get(ExampleCache.EXAMPLE_CACHE_TYPE);- Consistency – All caches use the same pattern for deserialization, storage, and attachment.
- Reusability – Add new cache types with minimal boilerplate.
- Persistence – DataComponentTypes and CODECs ensure caches are saved automatically.
-
Integration – Works seamlessly with Minecraft’s NBT system,
Dynamic, and Gson.
By integrating JSON deserializers, CODECs, CompoundTags, and DataComponentTypes, BlueLib provides a complete caching system for presets. This setup simplifies saving, loading, and attaching cache objects for mods and other systems, while maintaining type safety, consistency, and extensibility.
Variant Loader
Data Pipeline
Network & Packets
Logging
Markdown
Utility Classes
- Conversion
- Math
- Minecraft
- Schedular