-
Notifications
You must be signed in to change notification settings - Fork 0
BloodSampleUtil
#BioForge #BioForge_V2_0 #Build_V0_54T #AddonDevelopment #LegacyUpdated
#Extra
BloodSampleUtil is a utility class that simplifies reading and writing blood sample data to items (needles, bone marrow, split bones, etc.). It wraps the lower‑level NbtObfuscator to handle the specific format required for blood: amount, type, source name, and source UUID.
You do not need to use this class directly unless you are developing add‑ons or modifying the mod. The standard BioForge items already use it internally.
- Needles - when drawing blood from an entity.
- Bone Saw - when extracting a Split Bone.
- Centrifuge & Decalcification Fluid - when copying blood data from input to output.
- Reagent Vials - when reading blood data to determine the reaction.
boolean hasBlood = BloodSampleUtil.hasBlood(itemStack);Returns true if the item contains any blood data (obfuscated).
ObfuscatedData data = BloodSampleUtil.getData(itemStack);Returns an ObfuscatedData record with the following fields:
| Field | Type | Description |
|---|---|---|
amount |
int |
Blood amount (0-100). |
typeName |
String |
Blood type name (e.g., "A_POSITIVE"). |
sourceName |
String |
Display name of the source entity. |
subjectUUID |
UUID |
UUID of the source entity (may be null). |
If no data is present, returns null.
BloodSampleUtil.setData(itemStack, amount, bloodType, sourceName, subjectUUID);-
amount- blood amount to store. -
bloodType- aBloodTypeenum value. -
sourceName- the name of the entity the blood came from. -
subjectUUID- the entity’s UUID (can benull).
The data is obfuscated using NbtObfuscator.write(...).
BloodSampleUtil.clear(itemStack);Removes any blood data from the item.
BloodSampleUtil.copy(fromStack, toStack);Copies the blood data (amount, type, source name, UUID) from one item stack to another. If the source has no data, the target is cleared.
BloodSampleUtil.appendSampleTooltip(itemStack, tooltipList,
emptyKey, filledKey, sourceKey, extraKey);Used by items like needles and bone marrow to add consistent tooltips:
-
emptyKey- translation key when no blood. -
filledKey- translation key when blood is present. -
sourceKey- translation key for the source name line (e.g.,"item.bioforge.needle.tooltip.source"). -
extraKey- optional extra line (e.g.,"item.bioforge.bone_marrow.tooltip.processed").
It also automatically appends reagent knowledge (Anti‑A, Anti‑B, Anti‑D results) if the player has tested that subject.
// Store blood after a successful draw
BloodSampleUtil.setData(stack, newBlood, bloodType,
sourceName, subjectUUID);
// Read back for tooltip
ObfuscatedData data = BloodSampleUtil.getData(stack);
if (data != null) {
int amount = data.amount();
BloodType type = BloodType.fromName(data.typeName());
String source = data.sourceName();
}BloodSampleUtil is a convenience layer on top of NbtObfuscator. The underlying NBT structure is still obfuscated - you cannot read the blood data with /data get or external inventory viewers.
-
NbtObfuscator.write(tag, amount, typeName, sourceName, subjectUUID)is used internally. -
NbtObfuscator.read(tag)returns anObfuscatedDatarecord thatBloodSampleUtilsimply returns as‑is.
- If you add a new item that should carry blood data, use
BloodSampleUtilto handle reading/writing. - Do not store blood data in plain NBT - always use the obfuscated methods.
- The
ObfuscatedDatarecord is immutable and safe to pass around.
BioForge V2.0
Catalogues
- Item Catalogue
- Block and Machine Catalogue
- Mechanics Index
- Mutation Catalogue
- Symptom Catalogue
- Transmission Catalogue
- Command Catalogue
Research
- Research Tablet Progression
- CRISPR Programming
- Vaccine Maker Pages and Inventory
- Vaccines and Immunity
- Containment and PPE
Customization
- Modpack Maker Guide
- Addon Developer Guide
- BioForge addon creation guide
- Localization and Translation
Project