This commit is contained in:
ItzSonicFaner 2026-03-30 17:30:26 +03:00
parent 30b352594b
commit 2be90366ba
6 changed files with 78 additions and 58 deletions

View file

@ -1,13 +1,13 @@
#include "stdafx.h"
#include "../../Minecraft.h"
#include "../../ScreenSizeCalculator.h"
#include "../../EntityRenderDispatcher.h"
#include "../../PlayerRenderer.h"
#include "../../HumanoidModel.h"
#include "../../Lighting.h"
#include "../../ModelPart.h"
#include "../../Options.h"
#include "../../../Minecraft.World/net.minecraft.world.entity.player.h"
#include "..\..\Minecraft.h"
#include "..\..\ScreenSizeCalculator.h"
#include "..\..\EntityRenderDispatcher.h"
#include "..\..\PlayerRenderer.h"
#include "..\..\HumanoidModel.h"
#include "..\..\Lighting.h"
#include "..\..\ModelPart.h"
#include "..\..\Options.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "Skins.h"
#include "UIControl_PlayerSkinPreview.h"
#include <string>
@ -259,7 +259,7 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou
glPushMatrix();
glDisable(GL_CULL_FACE);
HumanoidModel *model;
HumanoidModel *model = static_cast<HumanoidModel *>(renderer->getModel());
Textures *textures = Minecraft::GetInstance()->textures;
int skinId = textures->loadMemTexture(m_customTextureUrl, m_backupTexture) - 37;
@ -267,14 +267,14 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou
{
if (textures->getHeight(m_customTextureUrl, m_backupTexture) == 64)
model = static_cast<HumanoidModel *>(renderer->getNewModelSlim());
else if (textures->getHeight(m_customTextureUrl, m_backupTexture) == 32)
else
model = static_cast<HumanoidModel *>(renderer->getModelSlim());
}
else
{
if (textures->getHeight(m_customTextureUrl, m_backupTexture) == 64)
model = static_cast<HumanoidModel *>(renderer->getNewModel());
else if (textures->getHeight(m_customTextureUrl, m_backupTexture) == 32)
else
model = static_cast<HumanoidModel *>(renderer->getModel());
}

View file

@ -1,7 +1,7 @@
#pragma once
#include "UIControl.h"
#include "../../Textures.h"
#include "..\..\Textures.h"
class ModelPart;
class EntityRenderer;

View file

@ -5,9 +5,9 @@
#include "ModelPart.h"
#include "EntityRenderDispatcher.h"
#include "MultiPlayerLocalPlayer.h"
#include "../Minecraft.World/Arrow.h"
#include "../Minecraft.World/Mth.h"
#include "../Minecraft.World/Player.h"
#include "..\Minecraft.World\Arrow.h"
#include "..\Minecraft.World\Mth.h"
#include "..\Minecraft.World\Player.h"
#include "Skins.h"
ResourceLocation LivingEntityRenderer::ENCHANT_GLINT_LOCATION = ResourceLocation(TN__BLUR__MISC_GLINT);
@ -56,13 +56,12 @@ void LivingEntityRenderer::render(shared_ptr<Entity> _mob, double x, double y, d
shared_ptr<LivingEntity> mob = dynamic_pointer_cast<LivingEntity>(_mob);
shared_ptr<Player> player = dynamic_pointer_cast<Player>(_mob);
Model *resModel;
Model *resModel = static_cast<HumanoidModel *>(model);
if (mob == nullptr)
{
return;
}
app.DebugPrintf("LivingEntityRenderer::render called for type %d\n", _mob->GetType());
glPushMatrix();
glDisable(GL_CULL_FACE);
@ -70,26 +69,26 @@ void LivingEntityRenderer::render(shared_ptr<Entity> _mob, double x, double y, d
if (player != nullptr)
{
Textures *textures = Minecraft::GetInstance()->textures;
int skinId = player->getPlayerDefaultSkin() - 1;
int defaultSkin = player->getPlayerDefaultSkin() + 35;
int skinId = player->getCustomSkin() - 1;
int defaultSkin = player->getCustomSkin() + 35;
if (slim[skinId] == true)
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newModelSlim);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(modelSlim);
}
else
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newModel);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(model);
}
}
else
resModel = model;
resModel = static_cast<HumanoidModel *>(model);
resModel->attackTime = getAttackAnim(mob, a);
if (armor != nullptr) armor->attackTime = resModel->attackTime;
@ -282,31 +281,31 @@ void LivingEntityRenderer::render(shared_ptr<Entity> _mob, double x, double y, d
void LivingEntityRenderer::renderModel(shared_ptr<LivingEntity> mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale)
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(mob);
Model *resModel;
Model *resModel = static_cast<HumanoidModel *>(model);
if (player != nullptr)
{
Textures *textures = Minecraft::GetInstance()->textures;
int skinId = player->getPlayerDefaultSkin() - 1;
int defaultSkin = player->getPlayerDefaultSkin() + 35;
int skinId = player->getCustomSkin() - 1;
int defaultSkin = player->getCustomSkin() + 35;
if (slim[skinId] == true)
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newModelSlim);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(modelSlim);
}
else
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newModel);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(model);
}
}
else
resModel = model;
resModel = static_cast<HumanoidModel *>(model);
bindTexture(mob);
if (!mob->isInvisible())
@ -380,31 +379,31 @@ void LivingEntityRenderer::additionalRendering(shared_ptr<LivingEntity> mob, flo
void LivingEntityRenderer::renderArrows(shared_ptr<LivingEntity> mob, float a)
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(mob);
Model *resModel;
Model *resModel = static_cast<HumanoidModel *>(model);
if (player != nullptr)
{
Textures *textures = Minecraft::GetInstance()->textures;
int skinId = player->getPlayerDefaultSkin() - 1;
int defaultSkin = player->getPlayerDefaultSkin() + 35;
int skinId = player->getCustomSkin() - 1;
int defaultSkin = player->getCustomSkin() + 35;
if (slim[skinId] == true)
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newModelSlim);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(modelSlim);
}
else
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newModel);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(model);
}
}
else
resModel = model;
resModel = static_cast<HumanoidModel *>(model);
int arrowCount = mob->getArrowCount();
@ -417,7 +416,8 @@ void LivingEntityRenderer::renderArrows(shared_ptr<LivingEntity> mob, float a)
{
glPushMatrix();
ModelPart *modelPart = resModel->getRandomModelPart(random);
ModelPart *modelPart;
modelPart = resModel->getRandomModelPart(random);
Cube *cube = modelPart->cubes[random.nextInt(modelPart->cubes.size())];
modelPart->translateTo(1 / 16.0f);

View file

@ -1,7 +1,7 @@
#pragma once
#include "ResourceLocation.h"
#include "EntityRenderer.h"
#include "../Minecraft.World/LivingEntity.h"
#include "..\Minecraft.World\LivingEntity.h"
class LivingEntity;

View file

@ -6,13 +6,13 @@
#include "ModelPart.h"
#include "LocalPlayer.h"
#include "MultiPlayerLocalPlayer.h"
#include "EntityRenderDispatcher.h"
#include "../Minecraft.World/net.minecraft.world.entity.h"
#include "../Minecraft.World/net.minecraft.world.entity.player.h"
#include "../Minecraft.World/net.minecraft.world.item.h"
#include "../Minecraft.World/net.minecraft.world.level.tile.h"
#include "../Minecraft.World/net.minecraft.h"
#include "../Minecraft.World/StringHelpers.h"
#include "entityRenderDispatcher.h"
#include "..\Minecraft.World\net.minecraft.world.entity.h"
#include "..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "..\Minecraft.World\net.minecraft.world.item.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\Minecraft.World\net.minecraft.h"
#include "..\Minecraft.World\StringHelpers.h"
#include "Skins.h"
static unsigned int nametagColorForIndex(int index)
@ -164,7 +164,7 @@ void PlayerRenderer::render(shared_ptr<Entity> _mob, double x, double y, double
// 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<Player> mob = dynamic_pointer_cast<Player>(_mob);
HumanoidModel *resModel;
HumanoidModel *resModel = static_cast<HumanoidModel *>(model);
if(mob == nullptr) return;
if(mob->hasInvisiblePrivilege()) return;
@ -179,19 +179,19 @@ void PlayerRenderer::render(shared_ptr<Entity> _mob, double x, double y, double
{
if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newHumanoidModelSlim);
else if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(humanoidModelSlim);
}
else
{
if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newHumanoidModel);
else if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(humanoidModel);
}
}
else
resModel = humanoidModel;
resModel = static_cast<HumanoidModel *>(model);
/*if (mob != nullptr && newHumanoidModelSlim != nullptr && (mob->getCustomSkin() >= 10 && mob->getCustomSkin() <= 18)) resModel = newHumanoidModelSlim;
else if (mob != nullptr && newHumanoidModel != nullptr && (mob->getCustomSkin() >= 2 && mob->getCustomSkin() <= 9)) resModel = newHumanoidModel;
@ -298,7 +298,7 @@ void PlayerRenderer::additionalRendering(shared_ptr<LivingEntity> _mob, float a)
// 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<Player> mob = dynamic_pointer_cast<Player>(_mob);
HumanoidModel *resModel;
HumanoidModel *resModel = static_cast<HumanoidModel *>(model);
if (mob != nullptr)
{
@ -310,19 +310,19 @@ void PlayerRenderer::additionalRendering(shared_ptr<LivingEntity> _mob, float a)
{
if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newHumanoidModelSlim);
else if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(humanoidModelSlim);
}
else
{
if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newHumanoidModel);
else if (textures->getHeight(mob->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(humanoidModel);
}
}
else
resModel = humanoidModel;
resModel = static_cast<HumanoidModel *>(model);
/*if (mob != nullptr && newHumanoidModelSlim != nullptr && (mob->getCustomSkin() >= 10 && mob->getCustomSkin() <= 18)) resModel = newHumanoidModelSlim;
else if (mob != nullptr && newHumanoidModel != nullptr && (mob->getCustomSkin() >= 2 && mob->getCustomSkin() <= 9)) resModel = newHumanoidModel;
@ -581,7 +581,7 @@ void PlayerRenderer::scale(shared_ptr<LivingEntity> player, float a)
void PlayerRenderer::renderHand()
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(Minecraft::GetInstance()->player);
HumanoidModel *resModel;
HumanoidModel *resModel = static_cast<HumanoidModel *>(model);
if (player != nullptr)
{
@ -593,19 +593,19 @@ void PlayerRenderer::renderHand()
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newHumanoidModelSlim);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(humanoidModelSlim);
}
else
{
if (textures->getHeight(player->customTextureUrl, defaultSkin) == 64)
resModel = static_cast<HumanoidModel *>(newHumanoidModel);
else if (textures->getHeight(player->customTextureUrl, defaultSkin) == 32)
else
resModel = static_cast<HumanoidModel *>(humanoidModel);
}
}
else
resModel = humanoidModel;
resModel = static_cast<HumanoidModel *>(model);
/*if (player != nullptr && newHumanoidModelSlim != nullptr && (player->getCustomSkin() >= 10 && player->getCustomSkin() <= 18)) resModel = newHumanoidModelSlim;
else if (player != nullptr && newHumanoidModel != nullptr && (player->getCustomSkin() >= 2 && player->getCustomSkin() <= 9)) resModel = newHumanoidModel;
@ -621,6 +621,26 @@ void PlayerRenderer::renderHand()
// 4J-PB - does this skin have its arm0 disabled? (Dalek, etc)
if((resModel->m_uiAnimOverrideBitmask&(1<<HumanoidModel::eAnim_DisableRenderArm0))==0)
resModel->arm0->render(1 / 16.0f,true);
//Render custom skin boxes on viewmodel - Botch
vector<ModelPart*>* additionalModelParts = Minecraft::GetInstance()->player->GetAdditionalModelParts();
if (!additionalModelParts) return; //If there are no custom boxes, return. This fixes bug where the game will crash if you select a skin with no additional boxes.
vector<ModelPart*> armchildren = resModel->arm0->children;
std::unordered_set<ModelPart*> additionalModelPartSet(additionalModelParts->begin(), additionalModelParts->end());
for (const auto& x : armchildren) {
if (x) {
if (additionalModelPartSet.find(x) != additionalModelPartSet.end()) { //This is to verify box is still actually on current skin - Botch
glPushMatrix();
//We need to transform to match offset of arm - Botch
glTranslatef(-5 * 0.0625f, 2 * 0.0625f, 0);
glRotatef(0.1 * (180.0f / PI), 0, 0, 1);
x->visible = true;
x->render(1.0f / 16.0f, true);
x->visible = false;
glPopMatrix();
}
}
}
}
void PlayerRenderer::setupPosition(shared_ptr<LivingEntity> _mob, double x, double y, double z)
@ -682,4 +702,4 @@ ResourceLocation *PlayerRenderer::getTextureLocation(shared_ptr<Entity> entity)
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(entity);
return new ResourceLocation(static_cast<_TEXTURE_NAME>(player->getTexture()));
}
}

View file

@ -1,6 +1,6 @@
#pragma once
#include "MobRenderer.h"
#include "../Minecraft.World/Player.h"
#include "..\Minecraft.World\Player.h"
class HumanoidModel;