-
Notifications
You must be signed in to change notification settings - Fork 13
Playerless Ragdolls
Playerless ragdolls are detached dummy ragdolls with no live player behind them. They can be spawned directly or created from an active player ragdoll.
RagdollAPI.spawnPlayerless(level, position, headingDegrees);
RagdollAPI.spawnPlayerless(level, position, headingDegrees, velocity);
RagdollAPI.spawnPlayerless(level, position, headingDegrees, profile, velocity);
RagdollAPI.spawnPlayerless(level, position, headingDegrees, profile, velocity,
despawnRule, limbs);headingDegrees uses Minecraft's yaw-style direction.
Playerless ragdolls use PlayerlessDespawnRule:
PlayerlessDespawnRule.defaultRule();
PlayerlessDespawnRule.never();
PlayerlessDespawnRule.afterTicks(ticks);
PlayerlessDespawnRule.belowSpeed(metersPerSecond);For playerless ragdolls created from an active player ragdoll:
PlayerlessRagdollSession corpse =
RagdollAPI.detachActive(player, PlayerlessDespawnRule.never());Addon mods can capture a player's render-relevant equipment into a detached snapshot and apply it to a playerless ragdoll. The snapshot is visual state only: vanilla hand/armor slots plus supported optional equipment slots. It is not the player's full inventory.
RagdollEquipmentSnapshot snapshot =
RagdollAPI.captureEquipment(player, RagdollEquipmentScope.ALL);
RagdollAPI.applyEquipmentSnapshot(level, rootSubLevelId, snapshot);RagdollEquipmentScope controls what gets captured:
RagdollEquipmentScope.VANILLA;
RagdollEquipmentScope.OPTIONAL_MODS;
RagdollEquipmentScope.ALL;Snapshots can be merged when capture timing differs between vanilla and optional equipment systems:
RagdollEquipmentSnapshot vanilla =
RagdollAPI.captureEquipment(player, RagdollEquipmentScope.VANILLA);
RagdollEquipmentSnapshot optional =
RagdollAPI.captureEquipment(player, RagdollEquipmentScope.OPTIONAL_MODS);
RagdollEquipmentSnapshot combined = vanilla.merge(optional);
RagdollAPI.applyEquipmentSnapshot(level, rootSubLevelId, combined);Snapshots can also be filtered against an item pool before re-applying them. This is useful for addon mods with lootable mannequins, corpses, or other detached ragdolls whose visual gear should disappear as matching items are removed.
RagdollEquipmentSnapshot visible = snapshot.filteredByAvailableItems(items);
RagdollAPI.applyEquipmentSnapshot(level, rootSubLevelId, visible);setGrabDisabled(level, partSubLevelId, true) can disable the grab-drag mechanic
for a specific part.