Figura icon indicating copy to clipboard operation
Figura copied to clipboard

(Feature Request) Physics mod Compatibility

Open SkyTheNerd opened this issue 2 years ago • 1 comments

In Physics mod 1.0.0, Figura worked with the Physics mod, but as in 2.0.0 and above, it stopped working, but since physics mod 2.1.3, the creator added a ragdoll API.

It would be pretty cool to see it work again!

Edit: Forgot to mention you can obtain the source code on his patron and you download the mod here

SkyTheNerd avatar Sep 06 '21 19:09 SkyTheNerd

Would like to see this as well!

Here's some more API info that I got from the physics mod's discord server:

The basic thing is: You get cubes (from the model) and you need to connect the cubes together to form a ragdoll

if (model instanceof ChickenModel) { 
    AgeableListModel animal = (AgeableListModel) model;
    Iterator<ModelPart> head = animal.headParts().iterator();
    Counter counter = new Counter();
    
    int headOffset = 0;
    int beakOffset = RagdollMapper.getCuboids(ragdoll, head.next(), counter);
    int wattleOffset = RagdollMapper.getCuboids(ragdoll, head.next(), counter);
    
    while (head.hasNext()) {
        RagdollMapper.getCuboids(ragdoll, head.next(), counter);
    }

    Iterator<ModelPart> body = animal.bodyParts().iterator();
    int bodyOffset = counter.count;
    int rightLegOffset = RagdollMapper.getCuboids(ragdoll, body.next(), counter);
    int leftLegOffset = RagdollMapper.getCuboids(ragdoll, body.next(), counter);
    int rightWingOffset = RagdollMapper.getCuboids(ragdoll, body.next(), counter);
    int leftWingOffset = RagdollMapper.getCuboids(ragdoll, body.next(), counter);
    
    ragdoll.addConnection(beakOffset, headOffset, true);  // THIS PART HERE CONNECTS THE CUBES TOGETHER
    ragdoll.addConnection(wattleOffset, headOffset, true);
    ragdoll.addConnection(headOffset, bodyOffset);
    ragdoll.addConnection(rightLegOffset, bodyOffset);
    ragdoll.addConnection(leftLegOffset, bodyOffset);
    ragdoll.addConnection(rightWingOffset, bodyOffset);
    ragdoll.addConnection(leftWingOffset, bodyOffset);
    
    while (body.hasNext()) {
        RagdollMapper.getCuboids(ragdoll, body.next(), counter); // THIS HERE SIMPLY ATTACHES ANY ADDITIONAL PARTS
    }
}

If you don't know the order of the cubes or which cubes belong to which body part you can use:

RagdollMapper.printModelParts(model);

And whenever you call an entity (and you have ragdolls enabled) it will print its model parts A creeper for example will print this: head: 0 right_front_leg: 1 right_hind_leg: 2 left_hind_leg: 3 body: 4 left_front_leg: 5

NobleDraconian avatar Jun 12 '22 06:06 NobleDraconian