Skip to content

Creating Ragdoll Data

sekwah41 edited this page Dec 19, 2018 · 14 revisions

The ragdoll file consists of a few parts. This page will break down each section. You should know how to use JSON but it should be pretty self explanatory.

Important

If you are trying to reference files from vanilla there is the problem of files and fields changing (such as body part names in the file) so for the main files we will be creating a mapping index for simplified names for each. Atm this only supports models and entities listed in this file(change branch for forge when supported). If you need to use a vanilla model you are free to copy any data from the minecraft.json inside SekCPhysics if I don't have it all mapped by then.

Ragdoll Data

Main file

{
  "com.sekwah.spookymod.entity.Herobrine": {
    ...
  },
  "com.sekwah.bathtime.entity.RubberDuck": {
    ...
  }
}

The entityPackage can be just used for a placeholder for others to inherit if needed. For example in minecraft.json EntityBiped sets up the main biped data for the others to use but is not actually used itsself (As no entity would die that is able to trigger it)

If you are adding data for an entity though you will have to supply the full package and class name for the entity e.g. com.sekwah.modid.entity.BigScaryMonster would go where entityPackage is. This causes on the client side the entity to invalidate isself so the death rotation animation is not played, however items will still drop and it will be alive server side until it dies a few ticks later.

Ragdoll JSON

"com.sekwah.angleworld.entity.TriangleMan": {
    "texture": ["modid", "texture/location.png"],
    "centerHeightOffset" : 24,
    "entityScale" : 1,
    "skeletonPoints":{
      "leftBottom" : [2,-23,0],
      "rightBottom" : [-2,-23,0],
      "top" : [0,7,0]
    },
    "constraints":[
      ["leftBottom", "rightBottom"],
      ["leftBottom", "top"],
      ["rightBottom", "top"]
    ],
    "triangles":{
      "body": ["top", "leftBottom", "rightBottom"]
    },
    "modelData":{
      ...
    }
  }

Registration order and overwriting entries

Names must be unique within the same file however if they are from different files the last one to register will overwrite the others so if you have a mod that alters the player or a mobs model you can overwrite the data for that entity just by making one yourself.

Inheritance behavior

You can only inherit data from entries within the same file and if the file you are inheriting from has all of the necessary tags you can leave the rest of the entry blank or overwrite some :)

Needed Data

If these are missing a RagdollInvalidDataException will be thrown and the ragdoll will be ignored. Even if you supply them but leave them empty it will be fine

  • skeletonPoints - The points of the ragdoll physics will be applied to
  • constraints - Array of pairs of skeletonPoint names creating lines that try to keep the two points a fixed distance apart

Optional Data

  • modelData - Info on how to render the model over the ragdoll
  • centerHeightOffset - Spawning height off the ground
  • entityScale - Scales everything including SkeletonPoint hitbox sizes
  • texture - Location of the resource to use for the model