From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/VillagerGolemModel.cpp | 90 +++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Minecraft.Client/VillagerGolemModel.cpp (limited to 'Minecraft.Client/VillagerGolemModel.cpp') diff --git a/Minecraft.Client/VillagerGolemModel.cpp b/Minecraft.Client/VillagerGolemModel.cpp new file mode 100644 index 00000000..aaeabd53 --- /dev/null +++ b/Minecraft.Client/VillagerGolemModel.cpp @@ -0,0 +1,90 @@ +#include "stdafx.h" +#include "..\Minecraft.World\net.minecraft.world.entity.animal.h" +#include "ModelPart.h" +#include "VillagerGolemModel.h" + +VillagerGolemModel::VillagerGolemModel(float g, float yOffset) +{ + int xTexSize = 128; + int yTexSize = 128; + + head = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); + head->setPos(0, 0 + yOffset, -2); + head->texOffs(0, 0)->addBox(-4, -12, -5.5f, 8, 10, 8, g); + head->texOffs(24, 0)->addBox(-1, -5.0f, -7.5f, 2, 4, 2, g); + + body = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); + body->setPos(0, 0 + yOffset, 0); + body->texOffs(0, 40)->addBox(-9, -2, -6, 18, 12, 11, g); + body->texOffs(0, 70)->addBox(-4.5f, 10, -3, 9, 5, 6, g + 0.5f); + + arm0 = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); + arm0->setPos(0, -7, 0); + arm0->texOffs(60, 21)->addBox(-13, -2.5f, -3, 4, 30, 6, g); + + arm1 = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); + arm1->setPos(0, -7, 0); + arm1->texOffs(60, 58)->addBox(9, -2.5f, -3, 4, 30, 6, g); + + leg0 = (new ModelPart(this, 0, 22))->setTexSize(xTexSize, yTexSize); + leg0->setPos(-4.0f, 18 + yOffset, 0); + leg0->texOffs(37, 0)->addBox(-3.5f, -3, -3, 6, 16, 5, g); + + leg1 = (new ModelPart(this, 0, 22))->setTexSize(xTexSize, yTexSize); + leg1->bMirror = true; + leg1->texOffs(60, 0)->setPos(5.0f, 18 + yOffset, 0); + leg1->addBox(-3.5f, -3, -3, 6, 16, 5, g); +} + +void VillagerGolemModel::render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) +{ + setupAnim(time, r, bob, yRot, xRot, scale); + + head->render(scale, usecompiled); + body->render(scale, usecompiled); + leg0->render(scale, usecompiled); + leg1->render(scale, usecompiled); + arm0->render(scale, usecompiled); + arm1->render(scale, usecompiled); +} + +void VillagerGolemModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, unsigned int uiBitmaskOverrideAnim) +{ + head->yRot = yRot / (float) (180 / PI); + head->xRot = xRot / (float) (180 / PI); + + leg0->xRot = (-1.5f * triangleWave(time, 13)) * r; + leg1->xRot = (1.5f * triangleWave(time, 13)) * r; + leg0->yRot = 0; + leg1->yRot = 0; +} + +void VillagerGolemModel::prepareMobModel(shared_ptr mob, float time, float r, float a) +{ + shared_ptr vg = dynamic_pointer_cast(mob); + int attackTick = vg->getAttackAnimationTick(); + if (attackTick > 0) + { + arm0->xRot = (-2.0f + 1.5f * triangleWave(attackTick - a, 10)); + arm1->xRot = (-2.0f + 1.5f * triangleWave(attackTick - a, 10)); + } + else + { + int offerFlowerTick = vg->getOfferFlowerTick(); + if (offerFlowerTick > 0) + { + arm0->xRot = -0.8f + 0.025f * triangleWave(offerFlowerTick, 70); + arm1->xRot = 0; + } + else + { + arm0->xRot = (-0.2f + 1.5f * triangleWave(time, 13)) * r; + arm1->xRot = (-0.2f - 1.5f * triangleWave(time, 13)) * r; + } + } +} + +float VillagerGolemModel::triangleWave(float bob, float period) +{ + return (abs(fmod(bob, period) - period * 0.5f) - period * 0.25f) / (period * 0.25f); +} \ No newline at end of file -- cgit v1.2.3