MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / Entity_SetModel

Function Entity_SetModel

src/Entity.c:122–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122void Entity_SetModel(struct Entity* e, const cc_string* model) {
123 cc_string name, scale;
124 Vec3_Set(e->ModelScale, 1,1,1);
125 String_UNSAFE_Separate(model, '|', &name, &scale);
126
127 /* 'giant' model kept for backwards compatibility */
128 if (String_CaselessEqualsConst(&name, "giant")) {
129 name = String_FromReadonly("humanoid");
130 Vec3_Set(e->ModelScale, 2,2,2);
131 }
132
133 e->ModelBlock = BLOCK_AIR;
134 e->Model = Model_Get(&name);
135 if (!e->Model) Entity_SetBlockModel(e, &name);
136
137 Entity_ParseScale(e, &scale);
138 Entity_UpdateModelBounds(e);
139
140 if (e->Flags & ENTITY_FLAG_HAS_MODELVB)
141 Gfx_DeleteDynamicVb(&e->ModelVB);
142}
143
144void Entity_UpdateModelBounds(struct Entity* e) {
145 struct Model* model = e->Model;

Callers 4

Entity_InitFunction · 0.85
Model_UnregisterFunction · 0.85
ModelCommand_ExecuteFunction · 0.85
CPE_ChangeModelFunction · 0.85

Calls 8

String_UNSAFE_SeparateFunction · 0.85
String_FromReadonlyFunction · 0.85
Model_GetFunction · 0.85
Entity_SetBlockModelFunction · 0.85
Entity_ParseScaleFunction · 0.85
Entity_UpdateModelBoundsFunction · 0.85
Gfx_DeleteDynamicVbFunction · 0.70

Tested by

no test coverage detected