Updated skin box hiding logic

Updated skin box hiding logic after testing a newer version PCK-Studio revealing the original logic wasn't accurate, also removed code that added arm and tool offsets to held items as it was not working correctly.
This commit is contained in:
Langtanium
2026-04-28 19:21:07 -07:00
parent 28f0110339
commit 878547dec8
5 changed files with 13 additions and 56 deletions

View File

@@ -109,7 +109,7 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox)
pNewBox = new ModelPart(this, static_cast<int>(pBox->fU), static_cast<int>(pBox->fV));
pNewBox->visible=false;
if (pBox->fM > 0) pNewBox->bMirror = true; // check if this box has the mirror flag
if (pBox->fA > 0) pNewBox->hideWithHelmet = true; // check if this box has the "hide when helmet is worn" flag
pNewBox->hideWithArmor = (unsigned int)pBox->fA; // add the "hide when armor is worn" bit flags
pNewBox->addHumanoidBox(pBox->fX, pBox->fY, pBox->fZ, pBox->fW, pBox->fH, pBox->fD, scale);
// 4J-PB - don't compile here, since the lighting isn't set up. It'll be compiled on first use.
//pNewBox->compile(1.0f/16.0f);

View File

@@ -286,7 +286,6 @@ void ItemInHandRenderer::renderItem(shared_ptr<LivingEntity> mob, shared_ptr<Ite
float xo = 0.0f;
float yo = 0.3f;
float zo = 0.0f;
// Re position height of held item if skin is small
@@ -302,39 +301,8 @@ void ItemInHandRenderer::renderItem(shared_ptr<LivingEntity> mob, shared_ptr<Ite
}
}
// Change height of held item by tool0 and arm0 offset
shared_ptr<Player> player = dynamic_pointer_cast<Player>(mob);
vector<SKIN_OFFSET *>* pModelOffsets = nullptr;
if (player != nullptr)
pModelOffsets = player->GetModelOffsets();
if (pModelOffsets != nullptr)
{
for( SKIN_OFFSET *pModelOffset : *pModelOffsets )
{
switch (pModelOffset->ePart)
{
case eBodyOffset_Arm0:
if(pModelOffset->fD == 1)
xo += pModelOffset->fO / 16.0f;
else if(pModelOffset->fD == 2)
zo += pModelOffset->fO / 16.0f;
else if(pModelOffset->fD == 3)
yo += pModelOffset->fO / 16.0f;
break;
case eBodyOffset_Tool0:
if(pModelOffset->fD == 1)
xo += pModelOffset->fO / 16.0f;
else if(pModelOffset->fD == 2)
zo += pModelOffset->fO / 16.0f;
else if(pModelOffset->fD == 3)
yo += pModelOffset->fO / 16.0f;
break;
}
}
}
glEnable(GL_RESCALE_NORMAL);
glTranslatef(-xo, -yo, -zo);
glTranslatef(-xo, -yo, 0);
float s = 1.5f;
glScalef(s, s, s);

View File

@@ -13,7 +13,7 @@ void ModelPart::_init()
compiled=false;
bMirror = false;
visible = true;
hideWithHelmet = false;
hideWithArmor = 0L;
isArmorPart1 = false;
neverRender = false;
x=y=z = 0.0f;

View File

@@ -16,7 +16,7 @@ public:
float xRot, yRot, zRot;
bool bMirror;
bool visible;
bool hideWithHelmet;
unsigned int hideWithArmor;
bool isArmorPart1;
bool neverRender;
vector <Cube *> cubes;

View File

@@ -270,25 +270,6 @@ void PlayerRenderer::render(shared_ptr<Entity> _mob, double x, double y, double
shared_ptr<ItemInstance> itemLeggings = mob->inventory->getArmor(1);
shared_ptr<ItemInstance> itemBoots = mob->inventory->getArmor(0);
// Hide armor layer of skin if corresponnding piece of armor is worn - Langtanium
if (itemChestplate != nullptr && resModel->texHeight == 64)
{
resModel->bodyArmor->visible=false;
resModel->armArmor0->visible=false;
resModel->armArmor1->visible=false;
}
if (itemLeggings != nullptr && resModel->texHeight == 64)
{
resModel->belt->visible=false;
resModel->legging0->visible=false;
resModel->legging1->visible=false;
}
if (itemBoots != nullptr && resModel->texHeight == 64)
{
resModel->boot0->visible=false;
resModel->boot1->visible=false;
}
// 4J-PB - any additional parts to turn on for this player (skin dependent)
vector<ModelPart *> *pAdditionalModelParts=mob->GetAdditionalModelParts();
//turn them on
@@ -296,7 +277,15 @@ void PlayerRenderer::render(shared_ptr<Entity> _mob, double x, double y, double
{
for(ModelPart *pModelPart : *pAdditionalModelParts)
{
if (itemHelmet == nullptr || !pModelPart->hideWithHelmet) // Hide the skin boxes that have the "hide when helmet is worn" flag - Langtanium
if (itemHelmet != nullptr && pModelPart->hideWithArmor&(1<<0)) // Hide the skin boxes that have the "hide when helmet is worn" bit flag - Langtanium
pModelPart->visible=false;
else if (itemChestplate != nullptr && pModelPart->hideWithArmor&(1<<1)) // Hide the skin boxes that have the "hide when chestplate is worn" bit flag - Langtanium
pModelPart->visible=false;
else if (itemLeggings != nullptr && pModelPart->hideWithArmor&(1<<2)) // Hide the skin boxes that have the "hide when leggings are worn" bit flag - Langtanium
pModelPart->visible=false;
else if (itemBoots != nullptr && pModelPart->hideWithArmor&(1<<3)) // Hide the skin boxes that have the "hide when boots are worn" bit flag - Langtanium
pModelPart->visible=false;
else
pModelPart->visible=true;
}
}