mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-22 00:36:53 +00:00
chore: format Minecraft.Client
This commit is contained in:
@@ -13,61 +13,60 @@
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.h"
|
||||
#include "../../../Minecraft.World/Util/StringHelpers.h"
|
||||
|
||||
const unsigned int PlayerRenderer::s_nametagColors[MINECRAFT_NET_MAX_PLAYERS] =
|
||||
{
|
||||
0xff000000, // WHITE (represents the "white" player, but using black as the colour)
|
||||
0xff33cc33, // GREEN
|
||||
0xffcc3333, // RED
|
||||
0xff3333cc, // BLUE
|
||||
#ifndef __PSVITA__ // only 4 player on Vita
|
||||
0xffcc33cc, // PINK
|
||||
0xffcc6633, // ORANGE
|
||||
0xffcccc33, // YELLOW
|
||||
0xff33dccc, // TURQUOISE
|
||||
const unsigned int PlayerRenderer::s_nametagColors[MINECRAFT_NET_MAX_PLAYERS] =
|
||||
{
|
||||
0xff000000, // WHITE (represents the "white" player, but using black as
|
||||
// the colour)
|
||||
0xff33cc33, // GREEN
|
||||
0xffcc3333, // RED
|
||||
0xff3333cc, // BLUE
|
||||
#ifndef __PSVITA__ // only 4 player on Vita
|
||||
0xffcc33cc, // PINK
|
||||
0xffcc6633, // ORANGE
|
||||
0xffcccc33, // YELLOW
|
||||
0xff33dccc, // TURQUOISE
|
||||
#endif
|
||||
};
|
||||
|
||||
const std::wstring PlayerRenderer::MATERIAL_NAMES[5] = { L"cloth", L"chain", L"iron", L"diamond", L"gold" };
|
||||
const std::wstring PlayerRenderer::MATERIAL_NAMES[5] = {
|
||||
L"cloth", L"chain", L"iron", L"diamond", L"gold"};
|
||||
|
||||
PlayerRenderer::PlayerRenderer() : MobRenderer( new HumanoidModel(0), 0.5f )
|
||||
{
|
||||
humanoidModel = (HumanoidModel *) model;
|
||||
PlayerRenderer::PlayerRenderer() : MobRenderer(new HumanoidModel(0), 0.5f) {
|
||||
humanoidModel = (HumanoidModel*)model;
|
||||
|
||||
armorParts1 = new HumanoidModel(1.0f);
|
||||
armorParts2 = new HumanoidModel(0.5f);
|
||||
}
|
||||
|
||||
unsigned int PlayerRenderer::getNametagColour(int index)
|
||||
{
|
||||
if( index >= 0 && index < MINECRAFT_NET_MAX_PLAYERS)
|
||||
{
|
||||
return s_nametagColors[index];
|
||||
}
|
||||
return 0xFF000000;
|
||||
unsigned int PlayerRenderer::getNametagColour(int index) {
|
||||
if (index >= 0 && index < MINECRAFT_NET_MAX_PLAYERS) {
|
||||
return s_nametagColors[index];
|
||||
}
|
||||
return 0xFF000000;
|
||||
}
|
||||
|
||||
int PlayerRenderer::prepareArmor(std::shared_ptr<Mob> _player, int layer, float a)
|
||||
{
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in our version
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(_player);
|
||||
int PlayerRenderer::prepareArmor(std::shared_ptr<Mob> _player, int layer,
|
||||
float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(_player);
|
||||
|
||||
// 4J-PB - need to disable rendering armour for some special skins (Daleks)
|
||||
unsigned int uiAnimOverrideBitmask=player->getAnimOverrideBitmask();
|
||||
if(uiAnimOverrideBitmask&(1<<HumanoidModel::eAnim_DontRenderArmour))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// 4J-PB - need to disable rendering armour for some special skins (Daleks)
|
||||
unsigned int uiAnimOverrideBitmask = player->getAnimOverrideBitmask();
|
||||
if (uiAnimOverrideBitmask & (1 << HumanoidModel::eAnim_DontRenderArmour)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemInstance> itemInstance = player->inventory->getArmor(3 - layer);
|
||||
if (itemInstance != NULL)
|
||||
{
|
||||
Item *item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem *>(item))
|
||||
{
|
||||
ArmorItem *armorItem = dynamic_cast<ArmorItem *>(item);
|
||||
bindTexture(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex] + L"_" + _toString<int>(layer == 2 ? 2 : 1) + L".png");
|
||||
std::shared_ptr<ItemInstance> itemInstance =
|
||||
player->inventory->getArmor(3 - layer);
|
||||
if (itemInstance != NULL) {
|
||||
Item* item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem*>(item)) {
|
||||
ArmorItem* armorItem = dynamic_cast<ArmorItem*>(item);
|
||||
bindTexture(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex] +
|
||||
L"_" + _toString<int>(layer == 2 ? 2 : 1) + L".png");
|
||||
|
||||
HumanoidModel *armor = layer == 2 ? armorParts2 : armorParts1;
|
||||
HumanoidModel* armor = layer == 2 ? armorParts2 : armorParts1;
|
||||
|
||||
armor->head->visible = layer == 0;
|
||||
armor->hair->visible = layer == 0;
|
||||
@@ -78,197 +77,196 @@ int PlayerRenderer::prepareArmor(std::shared_ptr<Mob> _player, int layer, float
|
||||
armor->leg1->visible = layer == 2 || layer == 3;
|
||||
|
||||
setArmor(armor);
|
||||
if (armor != NULL) armor->attackTime = model->attackTime;
|
||||
if (armor != NULL) armor->riding = model->riding;
|
||||
if (armor != NULL) armor->young = model->young;
|
||||
if (armor != NULL) armor->attackTime = model->attackTime;
|
||||
if (armor != NULL) armor->riding = model->riding;
|
||||
if (armor != NULL) armor->young = model->young;
|
||||
|
||||
float brightness = SharedConstants::TEXTURE_LIGHTING ? 1 : player->getBrightness(a);
|
||||
if (armorItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH)
|
||||
{
|
||||
int color = armorItem->getColor(itemInstance);
|
||||
float red = (float) ((color >> 16) & 0xFF) / 0xFF;
|
||||
float green = (float) ((color >> 8) & 0xFF) / 0xFF;
|
||||
float blue = (float) (color & 0xFF) / 0xFF;
|
||||
glColor3f(brightness * red, brightness * green, brightness * blue);
|
||||
float brightness = SharedConstants::TEXTURE_LIGHTING
|
||||
? 1
|
||||
: player->getBrightness(a);
|
||||
if (armorItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH) {
|
||||
int color = armorItem->getColor(itemInstance);
|
||||
float red = (float)((color >> 16) & 0xFF) / 0xFF;
|
||||
float green = (float)((color >> 8) & 0xFF) / 0xFF;
|
||||
float blue = (float)(color & 0xFF) / 0xFF;
|
||||
glColor3f(brightness * red, brightness * green,
|
||||
brightness * blue);
|
||||
|
||||
if (itemInstance->isEnchanted()) return 0x1f;
|
||||
return 0x10;
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
}
|
||||
if (itemInstance->isEnchanted()) return 0x1f;
|
||||
return 0x10;
|
||||
} else {
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
}
|
||||
|
||||
if (itemInstance->isEnchanted()) return 0xf;
|
||||
if (itemInstance->isEnchanted()) return 0xf;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
void PlayerRenderer::prepareSecondPassArmor(std::shared_ptr<Mob> _player, int layer, float a)
|
||||
{
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in our version
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(_player);
|
||||
std::shared_ptr<ItemInstance> itemInstance = player->inventory->getArmor(3 - layer);
|
||||
if (itemInstance != NULL)
|
||||
{
|
||||
Item *item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem *>(item))
|
||||
{
|
||||
ArmorItem *armorItem = dynamic_cast<ArmorItem *>(item);
|
||||
bindTexture(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex] + L"_" + _toString<int>(layer == 2 ? 2 : 1) + L"_b.png");
|
||||
void PlayerRenderer::prepareSecondPassArmor(std::shared_ptr<Mob> _player,
|
||||
int layer, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(_player);
|
||||
std::shared_ptr<ItemInstance> itemInstance =
|
||||
player->inventory->getArmor(3 - layer);
|
||||
if (itemInstance != NULL) {
|
||||
Item* item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem*>(item)) {
|
||||
ArmorItem* armorItem = dynamic_cast<ArmorItem*>(item);
|
||||
bindTexture(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex] +
|
||||
L"_" + _toString<int>(layer == 2 ? 2 : 1) + L"_b.png");
|
||||
|
||||
float brightness = SharedConstants::TEXTURE_LIGHTING ? 1 : player->getBrightness(a);
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
}
|
||||
}
|
||||
float brightness = SharedConstants::TEXTURE_LIGHTING
|
||||
? 1
|
||||
: player->getBrightness(a);
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
|
||||
{
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
void PlayerRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
|
||||
if(mob->hasInvisiblePrivilege()) return;
|
||||
if (mob->hasInvisiblePrivilege()) return;
|
||||
|
||||
std::shared_ptr<ItemInstance> item = mob->inventory->getSelected();
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = item != NULL ? 1 : 0;
|
||||
if (item != NULL)
|
||||
{
|
||||
if (mob->getUseItemDuration() > 0)
|
||||
{
|
||||
UseAnim anim = item->getUseAnimation();
|
||||
if (anim == UseAnim_block)
|
||||
{
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = 3;
|
||||
}
|
||||
else if (anim == UseAnim_bow)
|
||||
{
|
||||
armorParts1->bowAndArrow = armorParts2->bowAndArrow = humanoidModel->bowAndArrow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 4J added, for 3rd person view of eating
|
||||
if( item != NULL && mob->getUseItemDuration() > 0 && item->getUseAnimation() == UseAnim_eat )
|
||||
{
|
||||
// These factors are largely lifted from ItemInHandRenderer to try and keep the 3rd person eating animation as similar as possible
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand =
|
||||
humanoidModel->holdingRightHand = item != NULL ? 1 : 0;
|
||||
if (item != NULL) {
|
||||
if (mob->getUseItemDuration() > 0) {
|
||||
UseAnim anim = item->getUseAnimation();
|
||||
if (anim == UseAnim_block) {
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand =
|
||||
humanoidModel->holdingRightHand = 3;
|
||||
} else if (anim == UseAnim_bow) {
|
||||
armorParts1->bowAndArrow = armorParts2->bowAndArrow =
|
||||
humanoidModel->bowAndArrow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 4J added, for 3rd person view of eating
|
||||
if (item != NULL && mob->getUseItemDuration() > 0 &&
|
||||
item->getUseAnimation() == UseAnim_eat) {
|
||||
// These factors are largely lifted from ItemInHandRenderer to try and
|
||||
// keep the 3rd person eating animation as similar as possible
|
||||
float t = (mob->getUseItemDuration() - a + 1);
|
||||
float swing = 1 - (t / item->getUseDuration());
|
||||
armorParts1->eating = armorParts2->eating = humanoidModel->eating = true;
|
||||
armorParts1->eating_t = armorParts2->eating_t = humanoidModel->eating_t = t;
|
||||
armorParts1->eating_swing = armorParts2->eating_swing = humanoidModel->eating_swing = swing;
|
||||
}
|
||||
else
|
||||
{
|
||||
armorParts1->eating = armorParts2->eating = humanoidModel->eating = false;
|
||||
}
|
||||
armorParts1->eating = armorParts2->eating = humanoidModel->eating =
|
||||
true;
|
||||
armorParts1->eating_t = armorParts2->eating_t =
|
||||
humanoidModel->eating_t = t;
|
||||
armorParts1->eating_swing = armorParts2->eating_swing =
|
||||
humanoidModel->eating_swing = swing;
|
||||
} else {
|
||||
armorParts1->eating = armorParts2->eating = humanoidModel->eating =
|
||||
false;
|
||||
}
|
||||
|
||||
armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking = mob->isSneaking();
|
||||
armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking =
|
||||
mob->isSneaking();
|
||||
|
||||
double yp = y - mob->heightOffset;
|
||||
if (mob->isSneaking() && (std::dynamic_pointer_cast<LocalPlayer>(mob) == NULL))
|
||||
{
|
||||
if (mob->isSneaking() &&
|
||||
(std::dynamic_pointer_cast<LocalPlayer>(mob) == NULL)) {
|
||||
yp -= 2 / 16.0f;
|
||||
}
|
||||
|
||||
// Check if an idle animation is needed
|
||||
if(mob->getAnimOverrideBitmask()&(1<<HumanoidModel::eAnim_HasIdle))
|
||||
{
|
||||
if(mob->isIdle())
|
||||
{
|
||||
humanoidModel->idle=true;
|
||||
armorParts1->idle=true;
|
||||
armorParts2->idle=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
humanoidModel->idle=false;
|
||||
armorParts1->idle=false;
|
||||
armorParts2->idle=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humanoidModel->idle=false;
|
||||
armorParts1->idle=false;
|
||||
armorParts2->idle=false;
|
||||
}
|
||||
// Check if an idle animation is needed
|
||||
if (mob->getAnimOverrideBitmask() & (1 << HumanoidModel::eAnim_HasIdle)) {
|
||||
if (mob->isIdle()) {
|
||||
humanoidModel->idle = true;
|
||||
armorParts1->idle = true;
|
||||
armorParts2->idle = true;
|
||||
} else {
|
||||
humanoidModel->idle = false;
|
||||
armorParts1->idle = false;
|
||||
armorParts2->idle = false;
|
||||
}
|
||||
} else {
|
||||
humanoidModel->idle = false;
|
||||
armorParts1->idle = false;
|
||||
armorParts2->idle = false;
|
||||
}
|
||||
|
||||
// 4J-PB - any additional parts to turn on for this player (skin dependent)
|
||||
std::vector<ModelPart *> *pAdditionalModelParts=mob->GetAdditionalModelParts();
|
||||
//turn them on
|
||||
if(pAdditionalModelParts!=NULL)
|
||||
{
|
||||
for(AUTO_VAR(it, pAdditionalModelParts->begin()); it != pAdditionalModelParts->end(); ++it)
|
||||
{
|
||||
ModelPart *pModelPart=*it;
|
||||
// 4J-PB - any additional parts to turn on for this player (skin dependent)
|
||||
std::vector<ModelPart*>* pAdditionalModelParts =
|
||||
mob->GetAdditionalModelParts();
|
||||
// turn them on
|
||||
if (pAdditionalModelParts != NULL) {
|
||||
for (AUTO_VAR(it, pAdditionalModelParts->begin());
|
||||
it != pAdditionalModelParts->end(); ++it) {
|
||||
ModelPart* pModelPart = *it;
|
||||
|
||||
pModelPart->visible=true;
|
||||
}
|
||||
}
|
||||
pModelPart->visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
MobRenderer::render(mob, x, yp, z, rot, a);
|
||||
|
||||
// turn them off again
|
||||
if(pAdditionalModelParts && pAdditionalModelParts->size()!=0)
|
||||
{
|
||||
for(AUTO_VAR(it, pAdditionalModelParts->begin()); it != pAdditionalModelParts->end(); ++it)
|
||||
{
|
||||
ModelPart *pModelPart=*it;
|
||||
|
||||
pModelPart->visible=false;
|
||||
}
|
||||
}
|
||||
armorParts1->bowAndArrow = armorParts2->bowAndArrow = humanoidModel->bowAndArrow = false;
|
||||
armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking = false;
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = 0;
|
||||
// turn them off again
|
||||
if (pAdditionalModelParts && pAdditionalModelParts->size() != 0) {
|
||||
for (AUTO_VAR(it, pAdditionalModelParts->begin());
|
||||
it != pAdditionalModelParts->end(); ++it) {
|
||||
ModelPart* pModelPart = *it;
|
||||
|
||||
pModelPart->visible = false;
|
||||
}
|
||||
}
|
||||
armorParts1->bowAndArrow = armorParts2->bowAndArrow =
|
||||
humanoidModel->bowAndArrow = false;
|
||||
armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking =
|
||||
false;
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand =
|
||||
humanoidModel->holdingRightHand = 0;
|
||||
}
|
||||
|
||||
void PlayerRenderer::renderName(std::shared_ptr<Mob> _mob, double x, double y, double z)
|
||||
{
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
void PlayerRenderer::renderName(std::shared_ptr<Mob> _mob, double x, double y,
|
||||
double z) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
|
||||
if (Minecraft::renderNames() && mob != entityRenderDispatcher->cameraEntity
|
||||
&& !mob->isInvisibleTo(Minecraft::GetInstance()->player) ) // 4J-JEV: Todo, move to LivingEntityRenderer.
|
||||
{
|
||||
if (Minecraft::renderNames() &&
|
||||
mob != entityRenderDispatcher->cameraEntity &&
|
||||
!mob->isInvisibleTo(
|
||||
Minecraft::GetInstance()
|
||||
->player)) // 4J-JEV: Todo, move to LivingEntityRenderer.
|
||||
{
|
||||
float size = 1.60f;
|
||||
float s = 1 / 60.0f * size;
|
||||
double dist = mob->distanceToSqr(entityRenderDispatcher->cameraEntity);
|
||||
|
||||
float maxDist = mob->isSneaking() ? 32.0f : 64.0f;
|
||||
|
||||
if (dist < maxDist * maxDist)
|
||||
{
|
||||
// Truncate display names longer than 16 char
|
||||
if (dist < maxDist * maxDist) {
|
||||
// Truncate display names longer than 16 char
|
||||
std::wstring msg = mob->getDisplayName();
|
||||
if (msg.length() > 16)
|
||||
{
|
||||
msg.resize(16);
|
||||
msg += L"...";
|
||||
}
|
||||
if (msg.length() > 16) {
|
||||
msg.resize(16);
|
||||
msg += L"...";
|
||||
}
|
||||
|
||||
if (mob->isSneaking())
|
||||
{
|
||||
if ( app.GetGameSettings(eGameSetting_DisplayHUD)==0 )
|
||||
{
|
||||
// 4J-PB - turn off gamertag render
|
||||
return;
|
||||
}
|
||||
if (mob->isSneaking()) {
|
||||
if (app.GetGameSettings(eGameSetting_DisplayHUD) == 0) {
|
||||
// 4J-PB - turn off gamertag render
|
||||
return;
|
||||
}
|
||||
|
||||
if(app.GetGameHostOption(eGameHostOption_Gamertags)==0)
|
||||
{
|
||||
// turn off gamertags if the host has set them off
|
||||
return;
|
||||
}
|
||||
if (app.GetGameHostOption(eGameHostOption_Gamertags) == 0) {
|
||||
// turn off gamertags if the host has set them off
|
||||
return;
|
||||
}
|
||||
|
||||
Font *font = getFont();
|
||||
Font* font = getFont();
|
||||
glPushMatrix();
|
||||
glTranslatef((float) x + 0, (float) y + 2.3f, (float) z);
|
||||
glTranslatef((float)x + 0, (float)y + 2.3f, (float)z);
|
||||
glNormal3f(0, 1, 0);
|
||||
|
||||
glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
@@ -277,20 +275,20 @@ void PlayerRenderer::renderName(std::shared_ptr<Mob> _mob, double x, double y, d
|
||||
glScalef(-s, -s, s);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glTranslatef(0, (float) 0.25f / s, 0);
|
||||
glTranslatef(0, (float)0.25f / s, 0);
|
||||
glDepthMask(false);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tesselator *t = Tesselator::getInstance();
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
t->begin();
|
||||
int w = font->width(msg) / 2;
|
||||
t->color(0.0f, 0.0f, 0.0f, 0.25f);
|
||||
t->vertex((float)(-w - 1), (float)( -1), (float)( 0));
|
||||
t->vertex((float)(-w - 1), (float)( +8), (float)( 0));
|
||||
t->vertex((float)(+w + 1), (float)( +8), (float)( 0));
|
||||
t->vertex((float)(+w + 1), (float)( -1), (float)( 0));
|
||||
t->vertex((float)(-w - 1), (float)(-1), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1), (float)(0));
|
||||
t->end();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDepthMask(true);
|
||||
@@ -299,76 +297,72 @@ void PlayerRenderer::renderName(std::shared_ptr<Mob> _mob, double x, double y, d
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glPopMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mob->isSleeping())
|
||||
{
|
||||
renderNameTag(mob, msg, x, y - 1.5f, z, 64, s_nametagColors[mob->getPlayerIndex()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderNameTag(mob, msg, x, y, z, 64, s_nametagColors[mob->getPlayerIndex()]);
|
||||
} else {
|
||||
if (mob->isSleeping()) {
|
||||
renderNameTag(mob, msg, x, y - 1.5f, z, 64,
|
||||
s_nametagColors[mob->getPlayerIndex()]);
|
||||
} else {
|
||||
renderNameTag(mob, msg, x, y, z, 64,
|
||||
s_nametagColors[mob->getPlayerIndex()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a)
|
||||
{
|
||||
MobRenderer::additionalRendering(_mob,a);
|
||||
void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
||||
MobRenderer::additionalRendering(_mob, a);
|
||||
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
|
||||
std::shared_ptr<ItemInstance> headGear = mob->inventory->getArmor(3);
|
||||
if (headGear != NULL)
|
||||
{
|
||||
// don't render the pumpkin for the skins
|
||||
unsigned int uiAnimOverrideBitmask = mob->getSkinAnimOverrideBitmask( mob->getCustomSkin());
|
||||
if (headGear != NULL) {
|
||||
// don't render the pumpkin for the skins
|
||||
unsigned int uiAnimOverrideBitmask =
|
||||
mob->getSkinAnimOverrideBitmask(mob->getCustomSkin());
|
||||
|
||||
if((uiAnimOverrideBitmask&(1<<HumanoidModel::eAnim_DontRenderArmour))==0)
|
||||
{
|
||||
glPushMatrix();
|
||||
humanoidModel->head->translateTo(1 / 16.0f);
|
||||
if ((uiAnimOverrideBitmask &
|
||||
(1 << HumanoidModel::eAnim_DontRenderArmour)) == 0) {
|
||||
glPushMatrix();
|
||||
humanoidModel->head->translateTo(1 / 16.0f);
|
||||
|
||||
if(headGear->getItem()->id < 256)
|
||||
{
|
||||
if (TileRenderer::canRender(Tile::tiles[headGear->id]->getRenderShape()))
|
||||
{
|
||||
float s = 10 / 16.0f;
|
||||
glTranslatef(-0 / 16.0f, -4 / 16.0f, 0 / 16.0f);
|
||||
glRotatef(90, 0, 1, 0);
|
||||
glScalef(s, -s, s);
|
||||
}
|
||||
if (headGear->getItem()->id < 256) {
|
||||
if (TileRenderer::canRender(
|
||||
Tile::tiles[headGear->id]->getRenderShape())) {
|
||||
float s = 10 / 16.0f;
|
||||
glTranslatef(-0 / 16.0f, -4 / 16.0f, 0 / 16.0f);
|
||||
glRotatef(90, 0, 1, 0);
|
||||
glScalef(s, -s, s);
|
||||
}
|
||||
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(mob, headGear, 0);
|
||||
}
|
||||
else if (headGear->getItem()->id == Item::skull_Id)
|
||||
{
|
||||
float s = 17 / 16.0f;
|
||||
glScalef(s, -s, -s);
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(
|
||||
mob, headGear, 0);
|
||||
} else if (headGear->getItem()->id == Item::skull_Id) {
|
||||
float s = 17 / 16.0f;
|
||||
glScalef(s, -s, -s);
|
||||
|
||||
std::wstring extra = L"";
|
||||
if (headGear->hasTag() && headGear->getTag()->contains(L"SkullOwner"))
|
||||
{
|
||||
extra = headGear->getTag()->getString(L"SkullOwner");
|
||||
}
|
||||
SkullTileRenderer::instance->renderSkull(-0.5f, 0, -0.5f, Facing::UP, 180, headGear->getAuxValue(), extra);
|
||||
}
|
||||
std::wstring extra = L"";
|
||||
if (headGear->hasTag() &&
|
||||
headGear->getTag()->contains(L"SkullOwner")) {
|
||||
extra = headGear->getTag()->getString(L"SkullOwner");
|
||||
}
|
||||
SkullTileRenderer::instance->renderSkull(
|
||||
-0.5f, 0, -0.5f, Facing::UP, 180, headGear->getAuxValue(),
|
||||
extra);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
// need to add a custom texture for deadmau5
|
||||
if (mob != NULL && app.isXuidDeadmau5( mob->getXuid() ) && bindTexture(mob->customTextureUrl, L"" ))
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
float yr = (mob->yRotO + (mob->yRot - mob->yRotO) * a) - (mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a);
|
||||
// need to add a custom texture for deadmau5
|
||||
if (mob != NULL && app.isXuidDeadmau5(mob->getXuid()) &&
|
||||
bindTexture(mob->customTextureUrl, L"")) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
float yr = (mob->yRotO + (mob->yRot - mob->yRotO) * a) -
|
||||
(mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a);
|
||||
float xr = mob->xRotO + (mob->xRot - mob->xRotO) * a;
|
||||
glPushMatrix();
|
||||
glRotatef(yr, 0, 1, 0);
|
||||
@@ -380,116 +374,107 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a)
|
||||
|
||||
float s = 8 / 6.0f;
|
||||
glScalef(s, s, s);
|
||||
humanoidModel->renderEars(1 / 16.0f,true);
|
||||
humanoidModel->renderEars(1 / 16.0f, true);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
//4J-PB
|
||||
// if (bindTexture(mob->cloakTexture, L"" ))
|
||||
if (bindTexture(mob->customTextureUrl2, L"" ) && !mob->isInvisible())
|
||||
{
|
||||
// 4J-PB
|
||||
// if (bindTexture(mob->cloakTexture, L"" ))
|
||||
if (bindTexture(mob->customTextureUrl2, L"") && !mob->isInvisible()) {
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0, 2 / 16.0f);
|
||||
|
||||
double xd = (mob->xCloakO + (mob->xCloak - mob->xCloakO) * a) - (mob->xo + (mob->x - mob->xo) * a);
|
||||
double yd = (mob->yCloakO + (mob->yCloak - mob->yCloakO) * a) - (mob->yo + (mob->y - mob->yo) * a);
|
||||
double zd = (mob->zCloakO + (mob->zCloak - mob->zCloakO) * a) - (mob->zo + (mob->z - mob->zo) * a);
|
||||
double xd = (mob->xCloakO + (mob->xCloak - mob->xCloakO) * a) -
|
||||
(mob->xo + (mob->x - mob->xo) * a);
|
||||
double yd = (mob->yCloakO + (mob->yCloak - mob->yCloakO) * a) -
|
||||
(mob->yo + (mob->y - mob->yo) * a);
|
||||
double zd = (mob->zCloakO + (mob->zCloak - mob->zCloakO) * a) -
|
||||
(mob->zo + (mob->z - mob->zo) * a);
|
||||
|
||||
float yr = mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a;
|
||||
|
||||
double xa = Mth::sin(yr * PI / 180);
|
||||
double za = -Mth::cos(yr * PI / 180);
|
||||
|
||||
float flap = (float) yd * 10;
|
||||
float flap = (float)yd * 10;
|
||||
if (flap < -6) flap = -6;
|
||||
if (flap > 32) flap = 32;
|
||||
float lean = (float) (xd * xa + zd * za) * 100;
|
||||
float lean2 = (float) (xd * za - zd * xa) * 100;
|
||||
float lean = (float)(xd * xa + zd * za) * 100;
|
||||
float lean2 = (float)(xd * za - zd * xa) * 100;
|
||||
if (lean < 0) lean = 0;
|
||||
|
||||
float pow = mob->oBob + (mob->bob - mob->oBob) * a;
|
||||
|
||||
flap += sin((mob->walkDistO + (mob->walkDist - mob->walkDistO) * a) * 6) * 32 * pow;
|
||||
if (mob->isSneaking())
|
||||
{
|
||||
flap +=
|
||||
sin((mob->walkDistO + (mob->walkDist - mob->walkDistO) * a) * 6) *
|
||||
32 * pow;
|
||||
if (mob->isSneaking()) {
|
||||
flap += 25;
|
||||
}
|
||||
|
||||
// 4J Stu - Fix for sprint-flying causing the cape to rotate up by 180 degrees or more
|
||||
float xRot = 6.0f + lean / 2 + flap;
|
||||
if(xRot > 64.0f) xRot = 64.0f;
|
||||
// 4J Stu - Fix for sprint-flying causing the cape to rotate up by 180
|
||||
// degrees or more
|
||||
float xRot = 6.0f + lean / 2 + flap;
|
||||
if (xRot > 64.0f) xRot = 64.0f;
|
||||
|
||||
glRotatef(xRot, 1, 0, 0);
|
||||
glRotatef(lean2 / 2, 0, 0, 1);
|
||||
glRotatef(-lean2 / 2, 0, 1, 0);
|
||||
glRotatef(180, 0, 1, 0);
|
||||
humanoidModel->renderCloak(1 / 16.0f,true);
|
||||
humanoidModel->renderCloak(1 / 16.0f, true);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ItemInstance> item = mob->inventory->getSelected();
|
||||
|
||||
if (item != NULL)
|
||||
{
|
||||
if (item != NULL) {
|
||||
glPushMatrix();
|
||||
humanoidModel->arm0->translateTo(1 / 16.0f);
|
||||
glTranslatef(-1 / 16.0f, 7 / 16.0f, 1 / 16.0f);
|
||||
|
||||
if (mob->fishing != NULL)
|
||||
{
|
||||
item = std::shared_ptr<ItemInstance>( new ItemInstance(Item::stick) );
|
||||
if (mob->fishing != NULL) {
|
||||
item = std::shared_ptr<ItemInstance>(new ItemInstance(Item::stick));
|
||||
}
|
||||
|
||||
UseAnim anim = UseAnim_none;//null;
|
||||
if (mob->getUseItemDuration() > 0)
|
||||
{
|
||||
anim = item->getUseAnimation();
|
||||
}
|
||||
UseAnim anim = UseAnim_none; // null;
|
||||
if (mob->getUseItemDuration() > 0) {
|
||||
anim = item->getUseAnimation();
|
||||
}
|
||||
|
||||
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape()))
|
||||
{
|
||||
if (item->id < 256 &&
|
||||
TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
||||
float s = 8 / 16.0f;
|
||||
glTranslatef(-0 / 16.0f, 3 / 16.0f, -5 / 16.0f);
|
||||
s *= 0.75f;
|
||||
glRotatef(20, 1, 0, 0);
|
||||
glRotatef(45, 0, 1, 0);
|
||||
glScalef(s, -s, s);
|
||||
}
|
||||
else if (item->id == Item::bow->id)
|
||||
{
|
||||
float s = 10 / 16.0f;
|
||||
glTranslatef(0 / 16.0f, 2 / 16.0f, 5 / 16.0f);
|
||||
glRotatef(-20, 0, 1, 0);
|
||||
glScalef(s, -s, s);
|
||||
glRotatef(-100, 1, 0, 0);
|
||||
glRotatef(45, 0, 1, 0);
|
||||
}
|
||||
else if (Item::items[item->id]->isHandEquipped())
|
||||
{
|
||||
float s = 10 / 16.0f;
|
||||
if (Item::items[item->id]->isMirroredArt())
|
||||
{
|
||||
glRotatef(180, 0, 0, 1);
|
||||
glTranslatef(0, -2 / 16.0f, 0);
|
||||
}
|
||||
if (mob->getUseItemDuration() > 0)
|
||||
{
|
||||
if (anim == UseAnim_block)
|
||||
{
|
||||
glTranslatef(0.05f, 0, -0.1f);
|
||||
glRotatef(-50, 0, 1, 0);
|
||||
glRotatef(-10, 1, 0, 0);
|
||||
glRotatef(-60, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
glTranslatef(0, 3 / 16.0f, 0);
|
||||
glScalef(s, -s, s);
|
||||
glRotatef(-100, 1, 0, 0);
|
||||
glRotatef(45, 0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else if (item->id == Item::bow->id) {
|
||||
float s = 10 / 16.0f;
|
||||
glTranslatef(0 / 16.0f, 2 / 16.0f, 5 / 16.0f);
|
||||
glRotatef(-20, 0, 1, 0);
|
||||
glScalef(s, -s, s);
|
||||
glRotatef(-100, 1, 0, 0);
|
||||
glRotatef(45, 0, 1, 0);
|
||||
} else if (Item::items[item->id]->isHandEquipped()) {
|
||||
float s = 10 / 16.0f;
|
||||
if (Item::items[item->id]->isMirroredArt()) {
|
||||
glRotatef(180, 0, 0, 1);
|
||||
glTranslatef(0, -2 / 16.0f, 0);
|
||||
}
|
||||
if (mob->getUseItemDuration() > 0) {
|
||||
if (anim == UseAnim_block) {
|
||||
glTranslatef(0.05f, 0, -0.1f);
|
||||
glRotatef(-50, 0, 1, 0);
|
||||
glRotatef(-10, 1, 0, 0);
|
||||
glRotatef(-60, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
glTranslatef(0, 3 / 16.0f, 0);
|
||||
glScalef(s, -s, s);
|
||||
glRotatef(-100, 1, 0, 0);
|
||||
glRotatef(45, 0, 1, 0);
|
||||
} else {
|
||||
float s = 6 / 16.0f;
|
||||
glTranslatef(+4 / 16.0f, +3 / 16.0f, -3 / 16.0f);
|
||||
glScalef(s, s, s);
|
||||
@@ -498,88 +483,81 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a)
|
||||
glRotatef(20, 0, 0, 1);
|
||||
}
|
||||
|
||||
if (item->getItem()->hasMultipleSpriteLayers())
|
||||
{
|
||||
for (int layer = 0; layer <= 1; layer++)
|
||||
{
|
||||
int col = item->getItem()->getColor(item,layer);
|
||||
float red = ((col >> 16) & 0xff) / 255.0f;
|
||||
float g = ((col >> 8) & 0xff) / 255.0f;
|
||||
float b = ((col) & 0xff) / 255.0f;
|
||||
if (item->getItem()->hasMultipleSpriteLayers()) {
|
||||
for (int layer = 0; layer <= 1; layer++) {
|
||||
int col = item->getItem()->getColor(item, layer);
|
||||
float red = ((col >> 16) & 0xff) / 255.0f;
|
||||
float g = ((col >> 8) & 0xff) / 255.0f;
|
||||
float b = ((col) & 0xff) / 255.0f;
|
||||
|
||||
glColor4f(red, g, b, 1);
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(mob, item, layer, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(mob, item, 0);
|
||||
}
|
||||
glColor4f(red, g, b, 1);
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(
|
||||
mob, item, layer, false);
|
||||
}
|
||||
} else {
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(
|
||||
mob, item, 0);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlayerRenderer::scale(std::shared_ptr<Mob> player, float a)
|
||||
{
|
||||
void PlayerRenderer::scale(std::shared_ptr<Mob> player, float a) {
|
||||
float s = 15 / 16.0f;
|
||||
glScalef(s, s, s);
|
||||
}
|
||||
|
||||
void PlayerRenderer::renderHand()
|
||||
{
|
||||
humanoidModel->m_uiAnimOverrideBitmask = Minecraft::GetInstance()->player->getAnimOverrideBitmask();
|
||||
armorParts1->eating = armorParts2->eating = humanoidModel->eating = humanoidModel->idle = false;
|
||||
void PlayerRenderer::renderHand() {
|
||||
humanoidModel->m_uiAnimOverrideBitmask =
|
||||
Minecraft::GetInstance()->player->getAnimOverrideBitmask();
|
||||
armorParts1->eating = armorParts2->eating = humanoidModel->eating =
|
||||
humanoidModel->idle = false;
|
||||
humanoidModel->attackTime = 0;
|
||||
humanoidModel->setupAnim(0, 0, 0, 0, 0, 1 / 16.0f);
|
||||
// 4J-PB - does this skin have its arm0 disabled? (Dalek, etc)
|
||||
if((humanoidModel->m_uiAnimOverrideBitmask&(1<<HumanoidModel::eAnim_DisableRenderArm0))==0)
|
||||
{
|
||||
humanoidModel->arm0->render(1 / 16.0f,true);
|
||||
}
|
||||
// 4J-PB - does this skin have its arm0 disabled? (Dalek, etc)
|
||||
if ((humanoidModel->m_uiAnimOverrideBitmask &
|
||||
(1 << HumanoidModel::eAnim_DisableRenderArm0)) == 0) {
|
||||
humanoidModel->arm0->render(1 / 16.0f, true);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::setupPosition(std::shared_ptr<Mob> _mob, double x, double y, double z)
|
||||
{
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
void PlayerRenderer::setupPosition(std::shared_ptr<Mob> _mob, double x,
|
||||
double y, double z) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
|
||||
if (mob->isAlive() && mob->isSleeping())
|
||||
{
|
||||
MobRenderer::setupPosition(mob, x + mob->bedOffsetX, y + mob->bedOffsetY, z + mob->bedOffsetZ);
|
||||
if (mob->isAlive() && mob->isSleeping()) {
|
||||
MobRenderer::setupPosition(mob, x + mob->bedOffsetX,
|
||||
y + mob->bedOffsetY, z + mob->bedOffsetZ);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
MobRenderer::setupPosition(mob, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::setupRotations(std::shared_ptr<Mob> _mob, float bob, float bodyRot, float a)
|
||||
{
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
void PlayerRenderer::setupRotations(std::shared_ptr<Mob> _mob, float bob,
|
||||
float bodyRot, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
|
||||
if (mob->isAlive() && mob->isSleeping())
|
||||
{
|
||||
if (mob->isAlive() && mob->isSleeping()) {
|
||||
glRotatef(mob->getSleepRotation(), 0, 1, 0);
|
||||
glRotatef(getFlipDegrees(mob), 0, 0, 1);
|
||||
glRotatef(270, 0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
MobRenderer::setupRotations(mob, bob, bodyRot, a);
|
||||
}
|
||||
}
|
||||
|
||||
// 4J Added override to stop rendering shadow if player is invisible
|
||||
void PlayerRenderer::renderShadow(std::shared_ptr<Entity> e, double x, double y, double z, float pow, float a)
|
||||
{
|
||||
if(app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) > 0)
|
||||
{
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(e);
|
||||
if(player != NULL && player->hasInvisiblePrivilege()) return;
|
||||
}
|
||||
EntityRenderer::renderShadow(e,x,y,z,pow,a);
|
||||
void PlayerRenderer::renderShadow(std::shared_ptr<Entity> e, double x, double y,
|
||||
double z, float pow, float a) {
|
||||
if (app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) > 0) {
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(e);
|
||||
if (player != NULL && player->hasInvisiblePrivilege()) return;
|
||||
}
|
||||
EntityRenderer::renderShadow(e, x, y, z, pow, a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user