feat: Skulls worn by mobs/players now display on the armor layer
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "PlayerRenderer.h"
|
||||
#include "SkullTileRenderer.h"
|
||||
#include "../Minecraft.World/SkullTileEntity.h"
|
||||
#include "HumanoidMobRenderer.h"
|
||||
#include "HumanoidModel.h"
|
||||
#include "ModelPart.h"
|
||||
@@ -13,8 +14,15 @@
|
||||
#include "../Minecraft.World/net.minecraft.world.level.tile.h"
|
||||
#include "../Minecraft.World/net.minecraft.h"
|
||||
#include "../Minecraft.World/StringHelpers.h"
|
||||
#include "SkeletonHeadModel.h"
|
||||
#include "Textures.h"
|
||||
#include "Skins.h"
|
||||
|
||||
ResourceLocation PlayerRenderer::SKELETON_LOCATION = ResourceLocation(TN_MOB_SKELETON);
|
||||
ResourceLocation PlayerRenderer::WITHER_SKELETON_LOCATION = ResourceLocation(TN_MOB_WITHER_SKELETON);
|
||||
ResourceLocation PlayerRenderer::ZOMBIE_LOCATION = ResourceLocation(TN_MOB_ZOMBIE);
|
||||
ResourceLocation PlayerRenderer::CREEPER_LOCATION = ResourceLocation(TN_MOB_CREEPER);
|
||||
|
||||
static unsigned int nametagColorForIndex(int index)
|
||||
{
|
||||
static const unsigned int s_firstColors[] = {
|
||||
@@ -65,6 +73,7 @@ PlayerRenderer::PlayerRenderer() : LivingEntityRenderer( new HumanoidModel(0), 0
|
||||
|
||||
armorParts1 = new HumanoidModel(1.0f);
|
||||
armorParts2 = new HumanoidModel(0.5f);
|
||||
armorParts3 = new HumanoidModel(0.5f);
|
||||
}
|
||||
|
||||
unsigned int PlayerRenderer::getNametagColour(int index)
|
||||
@@ -93,8 +102,9 @@ int PlayerRenderer::prepareArmor(shared_ptr<LivingEntity> _player, int layer, fl
|
||||
if (dynamic_cast<ArmorItem *>(item))
|
||||
{
|
||||
ArmorItem *armorItem = dynamic_cast<ArmorItem *>(item);
|
||||
bindTexture(HumanoidMobRenderer::getArmorLocation(armorItem, layer));
|
||||
bindTexture(HumanoidMobRenderer::getArmorLocation(armorItem, layer));
|
||||
|
||||
SkullItem* skullItem = dynamic_cast<SkullItem*>(item);
|
||||
HumanoidModel *armor = layer == 2 ? armorParts2 : armorParts1;
|
||||
|
||||
armor->head->visible = layer == 0;
|
||||
@@ -131,6 +141,51 @@ int PlayerRenderer::prepareArmor(shared_ptr<LivingEntity> _player, int layer, fl
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (dynamic_cast<SkullItem*>(item)) {
|
||||
SkullItem* skullItem = dynamic_cast<SkullItem*>(item);
|
||||
HumanoidModel* armor = armorParts3;
|
||||
auto t = new SkeletonHeadModel(0, 0, 64, 64, 1);
|
||||
//armor->head->_init();
|
||||
armor->head = t->head;
|
||||
//armor->head->addHumanoidBox(-4, -8, -4, 8, 8, 8, 0.5); // Head
|
||||
|
||||
armor->head->visible = layer == 0;
|
||||
|
||||
armor->hair->visible = false;
|
||||
armor->body->visible = false;
|
||||
armor->arm0->visible = false;
|
||||
armor->arm1->visible = false;
|
||||
armor->leg0->visible = false;
|
||||
armor->leg1->visible = false;
|
||||
|
||||
switch (itemInstance->getAuxValue())
|
||||
{
|
||||
case SkullTileEntity::TYPE_WITHER:
|
||||
bindTexture(&WITHER_SKELETON_LOCATION);
|
||||
break;
|
||||
case SkullTileEntity::TYPE_ZOMBIE:
|
||||
bindTexture(&ZOMBIE_LOCATION);
|
||||
break;
|
||||
case SkullTileEntity::TYPE_CREEPER:
|
||||
bindTexture(&CREEPER_LOCATION);
|
||||
break;
|
||||
case SkullTileEntity::TYPE_CHAR:
|
||||
{
|
||||
bindTexture(&PlayerRenderer::DEFAULT_LOCATION);
|
||||
break;
|
||||
}
|
||||
case SkullTileEntity::TYPE_SKELETON:
|
||||
default:
|
||||
bindTexture(&SKELETON_LOCATION);
|
||||
break;
|
||||
}
|
||||
setArmor(armor);
|
||||
if (armor != nullptr) armor->attackTime = model->attackTime;
|
||||
if (armor != nullptr) armor->riding = model->riding;
|
||||
if (armor != nullptr) armor->young = model->young;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -366,7 +421,7 @@ void PlayerRenderer::additionalRendering(shared_ptr<LivingEntity> _mob, float a)
|
||||
|
||||
entityRenderDispatcher->itemInHandRenderer->renderItem(mob, headGear, 0);
|
||||
}
|
||||
else if (headGear->getItem()->id == Item::skull_Id)
|
||||
/*else if (headGear->getItem()->id == Item::skull_Id)
|
||||
{
|
||||
float s = 17 / 16.0f;
|
||||
glScalef(s, -s, -s);
|
||||
@@ -377,8 +432,8 @@ void PlayerRenderer::additionalRendering(shared_ptr<LivingEntity> _mob, float a)
|
||||
extra = headGear->getTag()->getString(L"SkullOwner");
|
||||
}
|
||||
SkullTileRenderer::instance->renderSkull(-0.5f, 0, -0.5f, Facing::UP, 180, headGear->getAuxValue(), extra);
|
||||
}
|
||||
|
||||
}*/
|
||||
//SkullTileRenderer::instance->renderSkull(-0.5f, 0, -0.5f, Facing::UP, 180, headGear->getAuxValue(), extra);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user